diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 1b45ecb..50ab4a8 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -4,7 +4,6 @@ about: Report a bug with Super Labeler title: '' labels: bug assignees: '' - --- **Describe the bug** @@ -12,6 +11,7 @@ A clear and concise description of what the bug is. **To Reproduce** Steps to reproduce the behavior: + 1. Go to '...' 2. Click on '....' 3. Scroll down to '....' @@ -32,6 +32,7 @@ Add your `labels.json` config and Github Actions workflow: ```yaml insert workflow here ``` + **Github Actions Output** Please [set the `ACTIONS_RUNNER_DEBUG` secret to `true` to enable debug logging](https://help.github.com/en/actions/configuring-and-managing-workflows/managing-a-workflow-run#enabling-debug-logging), rerun the labeler workflow, and paste the output below: diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index f025ed2..e86411b 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -4,7 +4,6 @@ about: Suggest an idea for this project title: '' labels: enhancement, proposal assignees: '' - --- **Is your feature request related to a problem? Please describe.** @@ -17,7 +16,7 @@ If you're proposing a new condition, please include an example of the JSON confi ```json { - name: "example", + "name": "example", "foo": "bar" } ``` diff --git a/.github/labels.json b/.github/labels.json index 13547ad..63b33bf 100644 --- a/.github/labels.json +++ b/.github/labels.json @@ -465,7 +465,7 @@ ] }, "optimisation": { - "requires": 2, + "requires": 1, "conditions": [ { "type": "titleMatches", @@ -490,7 +490,7 @@ ] }, "style": { - "requires": 2, + "requires": 1, "conditions": [ { "type": "titleMatches", @@ -511,7 +511,7 @@ ] }, "refactor": { - "requires": 2, + "requires": 1, "conditions": [ { "type": "titleMatches", @@ -536,7 +536,7 @@ ] }, "revert": { - "requires": 2, + "requires": 1, "conditions": [ { "type": "titleMatches", @@ -557,7 +557,7 @@ ] }, "deprecated": { - "requires": 2, + "requires": 1, "conditions": [ { "type": "titleMatches", @@ -582,7 +582,7 @@ ] }, "removal": { - "requires": 2, + "requires": 1, "conditions": [ { "type": "titleMatches", @@ -655,7 +655,7 @@ ] }, "closed": { - "requires": 2, + "requires": 1, "conditions": [ { "type": "isLocked", @@ -926,7 +926,7 @@ ] }, "optimisation": { - "requires": 2, + "requires": 1, "conditions": [ { "type": "titleMatches", @@ -947,7 +947,7 @@ ] }, "style": { - "requires": 2, + "requires": 1, "conditions": [ { "type": "titleMatches", @@ -964,7 +964,7 @@ ] }, "refactor": { - "requires": 2, + "requires": 1, "conditions": [ { "type": "titleMatches", @@ -985,7 +985,7 @@ ] }, "revert": { - "requires": 2, + "requires": 1, "conditions": [ { "type": "titleMatches", @@ -1002,7 +1002,7 @@ ] }, "deprecated": { - "requires": 2, + "requires": 1, "conditions": [ { "type": "titleMatches", @@ -1023,7 +1023,7 @@ ] }, "removal": { - "requires": 2, + "requires": 1, "conditions": [ { "type": "titleMatches", @@ -1083,7 +1083,7 @@ ] }, "closed": { - "requires": 2, + "requires": 1, "conditions": [ { "type": "isLocked", diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8bf699c..053a3ad 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -34,4 +34,4 @@ jobs: id: labeller uses: ./ with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..769947e --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +registry=https://npm.pkg.github.com/videndum \ No newline at end of file diff --git a/.nvmrc b/.nvmrc deleted file mode 100644 index 48082f7..0000000 --- a/.nvmrc +++ /dev/null @@ -1 +0,0 @@ -12 diff --git a/.prettier.json b/.prettier.json new file mode 100644 index 0000000..1aa12ba --- /dev/null +++ b/.prettier.json @@ -0,0 +1,13 @@ +{ + "arrowParens": "avoid", + "bracketSpacing": true, + "jsxBracketSameLine": true, + "jsxSingleQuote": false, + "printWidth": 80, + "quoteProps": "as-needed", + "semi": false, + "singleQuote": true, + "tabWidth": 2, + "trailingComma": "none", + "useTabs": false +} diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index e87eb52..2f7c298 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -14,22 +14,22 @@ appearance, race, religion, or sexual identity and orientation. Examples of behavior that contributes to creating a positive environment include: -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members +- Using welcoming and inclusive language +- Being respectful of differing viewpoints and experiences +- Gracefully accepting constructive criticism +- Focusing on what is best for the community +- Showing empathy towards other community members Examples of unacceptable behavior by participants include: -* The use of sexualized language or imagery and unwelcome sexual attention or - advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic - address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting +- The use of sexualized language or imagery and unwelcome sexual attention or + advances +- Trolling, insulting/derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or electronic + address, without explicit permission +- Other conduct which could reasonably be considered inappropriate in a + professional setting ## Our Responsibilities diff --git a/__tests__/.env.example b/__tests__/.env.example index 8f2b0a6..4a49343 100644 --- a/__tests__/.env.example +++ b/__tests__/.env.example @@ -5,6 +5,10 @@ export INPUT_GITHUB_TOKEN=your-personal-token export GITHUB_REPOSITORY=owner/repo-name +# Choose one +GITHUB_EVENT_PATH=__tests__/event.pr.json +# GITHUB_EVENT_PATH=__tests__/event.issue.json + # Optional export INPUT_CONFIG=labels.local.json diff --git a/__tests__/Utils.test.ts b/__tests__/Utils.test.ts index d1ffbfc..8f6e966 100644 --- a/__tests__/Utils.test.ts +++ b/__tests__/Utils.test.ts @@ -1,11 +1,11 @@ -import * as utils from '../src/utils' +import { utils } from '../src/utils' const settings = { labels: { test: { name: 'test', color: 'CFD3D7', - description: 'This issue / pull request has been abandon', - }, + description: 'This issue / pull request has been abandon' + } }, issue: { bug: { @@ -13,14 +13,14 @@ const settings = { conditions: [ { type: 'titleMatches', - pattern: '/^bug(\\(.*\\))?:/i', + pattern: '/^bug(\\(.*\\))?:/i' }, { type: 'descriptionMatches', - pattern: '/(created|new|opened|made)( an| a)? bug/i', - }, - ], - }, + pattern: '/(created|new|opened|made)( an| a)? bug/i' + } + ] + } }, pr: { bug: { @@ -28,21 +28,26 @@ const settings = { conditions: [ { type: 'titleMatches', - pattern: '/^bug(\\(.*\\))?:/i', + pattern: '/^bug(\\(.*\\))?:/i' }, { type: 'descriptionMatches', - pattern: '/(created|new|opened|made)( an| a)? bug/i', - }, - ], - }, - }, + pattern: '/(created|new|opened|made)( an| a)? bug/i' + } + ] + } + } } test('test colour format', async () => { await expect(utils.formatColor(settings.labels.test.color)).toBe('CFD3D7') }) test('test colour format', async () => { await expect(utils.formatColor(`#${settings.labels.test.color}`)).toBe( - 'CFD3D7', + 'CFD3D7' ) }) +// test('Run entire script', async () => { +// await expect(utils.formatColor(`#${settings.labels.test.color}`)).toBe( +// 'CFD3D7' +// ) +// }) diff --git a/__tests__/event.pr.example.json b/__tests__/event.pr.example.json deleted file mode 100644 index 853302d..0000000 --- a/__tests__/event.pr.example.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "pull_request": { - "head": { - "ref": "example branch name" - }, - "base": { - "ref": "example base branch name" - }, - "number": 18, - "user": { - "login": "GitHub Login" - }, - "title": "Example pr title" - } -} diff --git a/action.yml b/action.yml index f6f2387..99fb72e 100644 --- a/action.yml +++ b/action.yml @@ -1,6 +1,6 @@ name: 'Everything Labeler' description: 'A superpowered issue and pull request labeler for Github Actions.' -author: ['IvanFon', 'videndum', 'jbinda', 'jayu'] +author: 'Videndum' inputs: GITHUB_TOKEN: description: 'The GITHUB_TOKEN secret' diff --git a/dist/__tests__/Utils.test.js b/dist/__tests__/Utils.test.js index 434a6d0..436311b 100644 --- a/dist/__tests__/Utils.test.js +++ b/dist/__tests__/Utils.test.js @@ -1,56 +1,82 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } +'use strict' +var __awaiter = + (this && this.__awaiter) || + function (thisArg, _arguments, P, generator) { + function adopt(value) { + return value instanceof P + ? value + : new P(function (resolve) { + resolve(value) + }) + } return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -Object.defineProperty(exports, "__esModule", { value: true }); + function fulfilled(value) { + try { + step(generator.next(value)) + } catch (e) { + reject(e) + } + } + function rejected(value) { + try { + step(generator['throw'](value)) + } catch (e) { + reject(e) + } + } + function step(result) { + result.done + ? resolve(result.value) + : adopt(result.value).then(fulfilled, rejected) + } + step((generator = generator.apply(thisArg, _arguments || [])).next()) + }) + } +Object.defineProperty(exports, '__esModule', { value: true }) const settings = { - labels: { - test: { - name: 'test', - color: 'CFD3D7', - description: 'This issue / pull request has been abandon', + labels: { + test: { + name: 'test', + color: 'CFD3D7', + description: 'This issue / pull request has been abandon' + } + }, + issue: { + bug: { + requires: 1, + conditions: [ + { + type: 'titleMatches', + pattern: '/^bug(\\(.*\\))?:/i' }, - }, - issue: { - bug: { - requires: 1, - conditions: [ - { - type: 'titleMatches', - pattern: '/^bug(\\(.*\\))?:/i', - }, - { - type: 'descriptionMatches', - pattern: '/(created|new|opened|made)( an| a)? bug/i', - }, - ], + { + type: 'descriptionMatches', + pattern: '/(created|new|opened|made)( an| a)? bug/i' + } + ] + } + }, + pr: { + bug: { + requires: 1, + conditions: [ + { + type: 'titleMatches', + pattern: '/^bug(\\(.*\\))?:/i' }, - }, - pr: { - bug: { - requires: 1, - conditions: [ - { - type: 'titleMatches', - pattern: '/^bug(\\(.*\\))?:/i', - }, - { - type: 'descriptionMatches', - pattern: '/(created|new|opened|made)( an| a)? bug/i', - }, - ], - }, - }, -}; -test('test colour format', () => __awaiter(void 0, void 0, void 0, function* () { - yield expect(formatColour(settings.labels.test.color)).toBe('CFD3D7'); -})); -test('test colour format', () => __awaiter(void 0, void 0, void 0, function* () { - yield expect(formatColour(`#${settings.labels.test.color}`)).toBe('CFD3D7'); -})); + { + type: 'descriptionMatches', + pattern: '/(created|new|opened|made)( an| a)? bug/i' + } + ] + } + } +} +test('test colour format', () => + __awaiter(void 0, void 0, void 0, function* () { + yield expect(formatColour(settings.labels.test.color)).toBe('CFD3D7') + })) +test('test colour format', () => + __awaiter(void 0, void 0, void 0, function* () { + yield expect(formatColour(`#${settings.labels.test.color}`)).toBe('CFD3D7') + })) diff --git a/dist/iam_service.json b/dist/iam_service.json new file mode 100644 index 0000000..06e2465 --- /dev/null +++ b/dist/iam_service.json @@ -0,0 +1,1301 @@ +{ + "nested": { + "google": { + "nested": { + "iam": { + "nested": { + "v1": { + "options": { + "cc_enable_arenas": true, + "csharp_namespace": "Google.Cloud.Iam.V1", + "go_package": "google.golang.org/genproto/googleapis/iam/v1;iam", + "java_multiple_files": true, + "java_outer_classname": "PolicyProto", + "java_package": "com.google.iam.v1", + "php_namespace": "Google\\Cloud\\Iam\\V1" + }, + "nested": { + "IAMPolicy": { + "options": { + "(google.api.default_host)": "iam-meta-api.googleapis.com" + }, + "methods": { + "SetIamPolicy": { + "requestType": "SetIamPolicyRequest", + "responseType": "Policy", + "options": { + "(google.api.http).post": "/v1/{resource=**}:setIamPolicy", + "(google.api.http).body": "*" + } + }, + "GetIamPolicy": { + "requestType": "GetIamPolicyRequest", + "responseType": "Policy", + "options": { + "(google.api.http).post": "/v1/{resource=**}:getIamPolicy", + "(google.api.http).body": "*" + } + }, + "TestIamPermissions": { + "requestType": "TestIamPermissionsRequest", + "responseType": "TestIamPermissionsResponse", + "options": { + "(google.api.http).post": "/v1/{resource=**}:testIamPermissions", + "(google.api.http).body": "*" + } + } + } + }, + "SetIamPolicyRequest": { + "fields": { + "resource": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "*" + } + }, + "policy": { + "type": "Policy", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "GetIamPolicyRequest": { + "fields": { + "resource": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "*" + } + }, + "options": { + "type": "GetPolicyOptions", + "id": 2 + } + } + }, + "TestIamPermissionsRequest": { + "fields": { + "resource": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "*" + } + }, + "permissions": { + "rule": "repeated", + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "TestIamPermissionsResponse": { + "fields": { + "permissions": { + "rule": "repeated", + "type": "string", + "id": 1 + } + } + }, + "GetPolicyOptions": { + "fields": { + "requestedPolicyVersion": { + "type": "int32", + "id": 1 + } + } + }, + "Policy": { + "fields": { + "version": { + "type": "int32", + "id": 1 + }, + "bindings": { + "rule": "repeated", + "type": "Binding", + "id": 4 + }, + "etag": { + "type": "bytes", + "id": 3 + } + } + }, + "Binding": { + "fields": { + "role": { + "type": "string", + "id": 1 + }, + "members": { + "rule": "repeated", + "type": "string", + "id": 2 + }, + "condition": { + "type": "google.type.Expr", + "id": 3 + } + } + }, + "PolicyDelta": { + "fields": { + "bindingDeltas": { + "rule": "repeated", + "type": "BindingDelta", + "id": 1 + }, + "auditConfigDeltas": { + "rule": "repeated", + "type": "AuditConfigDelta", + "id": 2 + } + } + }, + "BindingDelta": { + "fields": { + "action": { + "type": "Action", + "id": 1 + }, + "role": { + "type": "string", + "id": 2 + }, + "member": { + "type": "string", + "id": 3 + }, + "condition": { + "type": "google.type.Expr", + "id": 4 + } + }, + "nested": { + "Action": { + "values": { + "ACTION_UNSPECIFIED": 0, + "ADD": 1, + "REMOVE": 2 + } + } + } + }, + "AuditConfigDelta": { + "fields": { + "action": { + "type": "Action", + "id": 1 + }, + "service": { + "type": "string", + "id": 2 + }, + "exemptedMember": { + "type": "string", + "id": 3 + }, + "logType": { + "type": "string", + "id": 4 + } + }, + "nested": { + "Action": { + "values": { + "ACTION_UNSPECIFIED": 0, + "ADD": 1, + "REMOVE": 2 + } + } + } + }, + "logging": { + "options": { + "csharp_namespace": "Google.Cloud.Iam.V1.Logging", + "go_package": "google.golang.org/genproto/googleapis/iam/v1/logging;logging", + "java_multiple_files": true, + "java_outer_classname": "AuditDataProto", + "java_package": "com.google.iam.v1.logging" + }, + "nested": { + "AuditData": { + "fields": { + "policyDelta": { + "type": "google.iam.v1.PolicyDelta", + "id": 2 + } + } + } + } + } + } + } + } + }, + "api": { + "options": { + "go_package": "google.golang.org/genproto/googleapis/api/annotations;annotations", + "java_multiple_files": true, + "java_outer_classname": "ResourceProto", + "java_package": "com.google.api", + "objc_class_prefix": "GAPI", + "cc_enable_arenas": true + }, + "nested": { + "http": { + "type": "HttpRule", + "id": 72295728, + "extend": "google.protobuf.MethodOptions" + }, + "Http": { + "fields": { + "rules": { + "rule": "repeated", + "type": "HttpRule", + "id": 1 + }, + "fullyDecodeReservedExpansion": { + "type": "bool", + "id": 2 + } + } + }, + "HttpRule": { + "oneofs": { + "pattern": { + "oneof": ["get", "put", "post", "delete", "patch", "custom"] + } + }, + "fields": { + "selector": { + "type": "string", + "id": 1 + }, + "get": { + "type": "string", + "id": 2 + }, + "put": { + "type": "string", + "id": 3 + }, + "post": { + "type": "string", + "id": 4 + }, + "delete": { + "type": "string", + "id": 5 + }, + "patch": { + "type": "string", + "id": 6 + }, + "custom": { + "type": "CustomHttpPattern", + "id": 8 + }, + "body": { + "type": "string", + "id": 7 + }, + "responseBody": { + "type": "string", + "id": 12 + }, + "additionalBindings": { + "rule": "repeated", + "type": "HttpRule", + "id": 11 + } + } + }, + "CustomHttpPattern": { + "fields": { + "kind": { + "type": "string", + "id": 1 + }, + "path": { + "type": "string", + "id": 2 + } + } + }, + "methodSignature": { + "rule": "repeated", + "type": "string", + "id": 1051, + "extend": "google.protobuf.MethodOptions" + }, + "defaultHost": { + "type": "string", + "id": 1049, + "extend": "google.protobuf.ServiceOptions" + }, + "oauthScopes": { + "type": "string", + "id": 1050, + "extend": "google.protobuf.ServiceOptions" + }, + "fieldBehavior": { + "rule": "repeated", + "type": "google.api.FieldBehavior", + "id": 1052, + "extend": "google.protobuf.FieldOptions" + }, + "FieldBehavior": { + "values": { + "FIELD_BEHAVIOR_UNSPECIFIED": 0, + "OPTIONAL": 1, + "REQUIRED": 2, + "OUTPUT_ONLY": 3, + "INPUT_ONLY": 4, + "IMMUTABLE": 5 + } + }, + "resourceReference": { + "type": "google.api.ResourceReference", + "id": 1055, + "extend": "google.protobuf.FieldOptions" + }, + "resourceDefinition": { + "rule": "repeated", + "type": "google.api.ResourceDescriptor", + "id": 1053, + "extend": "google.protobuf.FileOptions" + }, + "resource": { + "type": "google.api.ResourceDescriptor", + "id": 1053, + "extend": "google.protobuf.MessageOptions" + }, + "ResourceDescriptor": { + "fields": { + "type": { + "type": "string", + "id": 1 + }, + "pattern": { + "rule": "repeated", + "type": "string", + "id": 2 + }, + "nameField": { + "type": "string", + "id": 3 + }, + "history": { + "type": "History", + "id": 4 + }, + "plural": { + "type": "string", + "id": 5 + }, + "singular": { + "type": "string", + "id": 6 + } + }, + "nested": { + "History": { + "values": { + "HISTORY_UNSPECIFIED": 0, + "ORIGINALLY_SINGLE_PATTERN": 1, + "FUTURE_MULTI_PATTERN": 2 + } + } + } + }, + "ResourceReference": { + "fields": { + "type": { + "type": "string", + "id": 1 + }, + "childType": { + "type": "string", + "id": 2 + } + } + } + } + }, + "protobuf": { + "options": { + "go_package": "github.com/golang/protobuf/protoc-gen-go/descriptor;descriptor", + "java_package": "com.google.protobuf", + "java_outer_classname": "DescriptorProtos", + "csharp_namespace": "Google.Protobuf.Reflection", + "objc_class_prefix": "GPB", + "cc_enable_arenas": true, + "optimize_for": "SPEED" + }, + "nested": { + "FileDescriptorSet": { + "fields": { + "file": { + "rule": "repeated", + "type": "FileDescriptorProto", + "id": 1 + } + } + }, + "FileDescriptorProto": { + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "package": { + "type": "string", + "id": 2 + }, + "dependency": { + "rule": "repeated", + "type": "string", + "id": 3 + }, + "publicDependency": { + "rule": "repeated", + "type": "int32", + "id": 10, + "options": { + "packed": false + } + }, + "weakDependency": { + "rule": "repeated", + "type": "int32", + "id": 11, + "options": { + "packed": false + } + }, + "messageType": { + "rule": "repeated", + "type": "DescriptorProto", + "id": 4 + }, + "enumType": { + "rule": "repeated", + "type": "EnumDescriptorProto", + "id": 5 + }, + "service": { + "rule": "repeated", + "type": "ServiceDescriptorProto", + "id": 6 + }, + "extension": { + "rule": "repeated", + "type": "FieldDescriptorProto", + "id": 7 + }, + "options": { + "type": "FileOptions", + "id": 8 + }, + "sourceCodeInfo": { + "type": "SourceCodeInfo", + "id": 9 + }, + "syntax": { + "type": "string", + "id": 12 + } + } + }, + "DescriptorProto": { + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "field": { + "rule": "repeated", + "type": "FieldDescriptorProto", + "id": 2 + }, + "extension": { + "rule": "repeated", + "type": "FieldDescriptorProto", + "id": 6 + }, + "nestedType": { + "rule": "repeated", + "type": "DescriptorProto", + "id": 3 + }, + "enumType": { + "rule": "repeated", + "type": "EnumDescriptorProto", + "id": 4 + }, + "extensionRange": { + "rule": "repeated", + "type": "ExtensionRange", + "id": 5 + }, + "oneofDecl": { + "rule": "repeated", + "type": "OneofDescriptorProto", + "id": 8 + }, + "options": { + "type": "MessageOptions", + "id": 7 + }, + "reservedRange": { + "rule": "repeated", + "type": "ReservedRange", + "id": 9 + }, + "reservedName": { + "rule": "repeated", + "type": "string", + "id": 10 + } + }, + "nested": { + "ExtensionRange": { + "fields": { + "start": { + "type": "int32", + "id": 1 + }, + "end": { + "type": "int32", + "id": 2 + }, + "options": { + "type": "ExtensionRangeOptions", + "id": 3 + } + } + }, + "ReservedRange": { + "fields": { + "start": { + "type": "int32", + "id": 1 + }, + "end": { + "type": "int32", + "id": 2 + } + } + } + } + }, + "ExtensionRangeOptions": { + "fields": { + "uninterpretedOption": { + "rule": "repeated", + "type": "UninterpretedOption", + "id": 999 + } + }, + "extensions": [[1000, 536870911]] + }, + "FieldDescriptorProto": { + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "number": { + "type": "int32", + "id": 3 + }, + "label": { + "type": "Label", + "id": 4 + }, + "type": { + "type": "Type", + "id": 5 + }, + "typeName": { + "type": "string", + "id": 6 + }, + "extendee": { + "type": "string", + "id": 2 + }, + "defaultValue": { + "type": "string", + "id": 7 + }, + "oneofIndex": { + "type": "int32", + "id": 9 + }, + "jsonName": { + "type": "string", + "id": 10 + }, + "options": { + "type": "FieldOptions", + "id": 8 + } + }, + "nested": { + "Type": { + "values": { + "TYPE_DOUBLE": 1, + "TYPE_FLOAT": 2, + "TYPE_INT64": 3, + "TYPE_UINT64": 4, + "TYPE_INT32": 5, + "TYPE_FIXED64": 6, + "TYPE_FIXED32": 7, + "TYPE_BOOL": 8, + "TYPE_STRING": 9, + "TYPE_GROUP": 10, + "TYPE_MESSAGE": 11, + "TYPE_BYTES": 12, + "TYPE_UINT32": 13, + "TYPE_ENUM": 14, + "TYPE_SFIXED32": 15, + "TYPE_SFIXED64": 16, + "TYPE_SINT32": 17, + "TYPE_SINT64": 18 + } + }, + "Label": { + "values": { + "LABEL_OPTIONAL": 1, + "LABEL_REQUIRED": 2, + "LABEL_REPEATED": 3 + } + } + } + }, + "OneofDescriptorProto": { + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "options": { + "type": "OneofOptions", + "id": 2 + } + } + }, + "EnumDescriptorProto": { + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "value": { + "rule": "repeated", + "type": "EnumValueDescriptorProto", + "id": 2 + }, + "options": { + "type": "EnumOptions", + "id": 3 + }, + "reservedRange": { + "rule": "repeated", + "type": "EnumReservedRange", + "id": 4 + }, + "reservedName": { + "rule": "repeated", + "type": "string", + "id": 5 + } + }, + "nested": { + "EnumReservedRange": { + "fields": { + "start": { + "type": "int32", + "id": 1 + }, + "end": { + "type": "int32", + "id": 2 + } + } + } + } + }, + "EnumValueDescriptorProto": { + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "number": { + "type": "int32", + "id": 2 + }, + "options": { + "type": "EnumValueOptions", + "id": 3 + } + } + }, + "ServiceDescriptorProto": { + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "method": { + "rule": "repeated", + "type": "MethodDescriptorProto", + "id": 2 + }, + "options": { + "type": "ServiceOptions", + "id": 3 + } + } + }, + "MethodDescriptorProto": { + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "inputType": { + "type": "string", + "id": 2 + }, + "outputType": { + "type": "string", + "id": 3 + }, + "options": { + "type": "MethodOptions", + "id": 4 + }, + "clientStreaming": { + "type": "bool", + "id": 5, + "options": { + "default": false + } + }, + "serverStreaming": { + "type": "bool", + "id": 6, + "options": { + "default": false + } + } + } + }, + "FileOptions": { + "fields": { + "javaPackage": { + "type": "string", + "id": 1 + }, + "javaOuterClassname": { + "type": "string", + "id": 8 + }, + "javaMultipleFiles": { + "type": "bool", + "id": 10, + "options": { + "default": false + } + }, + "javaGenerateEqualsAndHash": { + "type": "bool", + "id": 20, + "options": { + "deprecated": true + } + }, + "javaStringCheckUtf8": { + "type": "bool", + "id": 27, + "options": { + "default": false + } + }, + "optimizeFor": { + "type": "OptimizeMode", + "id": 9, + "options": { + "default": "SPEED" + } + }, + "goPackage": { + "type": "string", + "id": 11 + }, + "ccGenericServices": { + "type": "bool", + "id": 16, + "options": { + "default": false + } + }, + "javaGenericServices": { + "type": "bool", + "id": 17, + "options": { + "default": false + } + }, + "pyGenericServices": { + "type": "bool", + "id": 18, + "options": { + "default": false + } + }, + "phpGenericServices": { + "type": "bool", + "id": 42, + "options": { + "default": false + } + }, + "deprecated": { + "type": "bool", + "id": 23, + "options": { + "default": false + } + }, + "ccEnableArenas": { + "type": "bool", + "id": 31, + "options": { + "default": false + } + }, + "objcClassPrefix": { + "type": "string", + "id": 36 + }, + "csharpNamespace": { + "type": "string", + "id": 37 + }, + "swiftPrefix": { + "type": "string", + "id": 39 + }, + "phpClassPrefix": { + "type": "string", + "id": 40 + }, + "phpNamespace": { + "type": "string", + "id": 41 + }, + "phpMetadataNamespace": { + "type": "string", + "id": 44 + }, + "rubyPackage": { + "type": "string", + "id": 45 + }, + "uninterpretedOption": { + "rule": "repeated", + "type": "UninterpretedOption", + "id": 999 + } + }, + "extensions": [[1000, 536870911]], + "reserved": [[38, 38]], + "nested": { + "OptimizeMode": { + "values": { + "SPEED": 1, + "CODE_SIZE": 2, + "LITE_RUNTIME": 3 + } + } + } + }, + "MessageOptions": { + "fields": { + "messageSetWireFormat": { + "type": "bool", + "id": 1, + "options": { + "default": false + } + }, + "noStandardDescriptorAccessor": { + "type": "bool", + "id": 2, + "options": { + "default": false + } + }, + "deprecated": { + "type": "bool", + "id": 3, + "options": { + "default": false + } + }, + "mapEntry": { + "type": "bool", + "id": 7 + }, + "uninterpretedOption": { + "rule": "repeated", + "type": "UninterpretedOption", + "id": 999 + } + }, + "extensions": [[1000, 536870911]], + "reserved": [ + [8, 8], + [9, 9] + ] + }, + "FieldOptions": { + "fields": { + "ctype": { + "type": "CType", + "id": 1, + "options": { + "default": "STRING" + } + }, + "packed": { + "type": "bool", + "id": 2 + }, + "jstype": { + "type": "JSType", + "id": 6, + "options": { + "default": "JS_NORMAL" + } + }, + "lazy": { + "type": "bool", + "id": 5, + "options": { + "default": false + } + }, + "deprecated": { + "type": "bool", + "id": 3, + "options": { + "default": false + } + }, + "weak": { + "type": "bool", + "id": 10, + "options": { + "default": false + } + }, + "uninterpretedOption": { + "rule": "repeated", + "type": "UninterpretedOption", + "id": 999 + } + }, + "extensions": [[1000, 536870911]], + "reserved": [[4, 4]], + "nested": { + "CType": { + "values": { + "STRING": 0, + "CORD": 1, + "STRING_PIECE": 2 + } + }, + "JSType": { + "values": { + "JS_NORMAL": 0, + "JS_STRING": 1, + "JS_NUMBER": 2 + } + } + } + }, + "OneofOptions": { + "fields": { + "uninterpretedOption": { + "rule": "repeated", + "type": "UninterpretedOption", + "id": 999 + } + }, + "extensions": [[1000, 536870911]] + }, + "EnumOptions": { + "fields": { + "allowAlias": { + "type": "bool", + "id": 2 + }, + "deprecated": { + "type": "bool", + "id": 3, + "options": { + "default": false + } + }, + "uninterpretedOption": { + "rule": "repeated", + "type": "UninterpretedOption", + "id": 999 + } + }, + "extensions": [[1000, 536870911]], + "reserved": [[5, 5]] + }, + "EnumValueOptions": { + "fields": { + "deprecated": { + "type": "bool", + "id": 1, + "options": { + "default": false + } + }, + "uninterpretedOption": { + "rule": "repeated", + "type": "UninterpretedOption", + "id": 999 + } + }, + "extensions": [[1000, 536870911]] + }, + "ServiceOptions": { + "fields": { + "deprecated": { + "type": "bool", + "id": 33, + "options": { + "default": false + } + }, + "uninterpretedOption": { + "rule": "repeated", + "type": "UninterpretedOption", + "id": 999 + } + }, + "extensions": [[1000, 536870911]] + }, + "MethodOptions": { + "fields": { + "deprecated": { + "type": "bool", + "id": 33, + "options": { + "default": false + } + }, + "idempotencyLevel": { + "type": "IdempotencyLevel", + "id": 34, + "options": { + "default": "IDEMPOTENCY_UNKNOWN" + } + }, + "uninterpretedOption": { + "rule": "repeated", + "type": "UninterpretedOption", + "id": 999 + } + }, + "extensions": [[1000, 536870911]], + "nested": { + "IdempotencyLevel": { + "values": { + "IDEMPOTENCY_UNKNOWN": 0, + "NO_SIDE_EFFECTS": 1, + "IDEMPOTENT": 2 + } + } + } + }, + "UninterpretedOption": { + "fields": { + "name": { + "rule": "repeated", + "type": "NamePart", + "id": 2 + }, + "identifierValue": { + "type": "string", + "id": 3 + }, + "positiveIntValue": { + "type": "uint64", + "id": 4 + }, + "negativeIntValue": { + "type": "int64", + "id": 5 + }, + "doubleValue": { + "type": "double", + "id": 6 + }, + "stringValue": { + "type": "bytes", + "id": 7 + }, + "aggregateValue": { + "type": "string", + "id": 8 + } + }, + "nested": { + "NamePart": { + "fields": { + "namePart": { + "rule": "required", + "type": "string", + "id": 1 + }, + "isExtension": { + "rule": "required", + "type": "bool", + "id": 2 + } + } + } + } + }, + "SourceCodeInfo": { + "fields": { + "location": { + "rule": "repeated", + "type": "Location", + "id": 1 + } + }, + "nested": { + "Location": { + "fields": { + "path": { + "rule": "repeated", + "type": "int32", + "id": 1 + }, + "span": { + "rule": "repeated", + "type": "int32", + "id": 2 + }, + "leadingComments": { + "type": "string", + "id": 3 + }, + "trailingComments": { + "type": "string", + "id": 4 + }, + "leadingDetachedComments": { + "rule": "repeated", + "type": "string", + "id": 6 + } + } + } + } + }, + "GeneratedCodeInfo": { + "fields": { + "annotation": { + "rule": "repeated", + "type": "Annotation", + "id": 1 + } + }, + "nested": { + "Annotation": { + "fields": { + "path": { + "rule": "repeated", + "type": "int32", + "id": 1 + }, + "sourceFile": { + "type": "string", + "id": 2 + }, + "begin": { + "type": "int32", + "id": 3 + }, + "end": { + "type": "int32", + "id": 4 + } + } + } + } + } + } + }, + "type": { + "options": { + "go_package": "google.golang.org/genproto/googleapis/type/expr;expr", + "java_multiple_files": true, + "java_outer_classname": "ExprProto", + "java_package": "com.google.type", + "objc_class_prefix": "GTP" + }, + "nested": { + "Expr": { + "fields": { + "expression": { + "type": "string", + "id": 1 + }, + "title": { + "type": "string", + "id": 2 + }, + "description": { + "type": "string", + "id": 3 + }, + "location": { + "type": "string", + "id": 4 + } + } + } + } + } + } + } + } +} diff --git a/dist/index.js b/dist/index.js index 39260df..370f057 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,27559 +1,263520 @@ -require('./sourcemap-register.js');module.exports = -/******/ (() => { // webpackBootstrap -/******/ var __webpack_modules__ = ({ - -/***/ 9674: -/***/ ((module) => { - -"use strict"; -module.exports = JSON.parse("{\"name\":\"@octokit/rest\",\"version\":\"16.43.1\",\"publishConfig\":{\"access\":\"public\"},\"description\":\"GitHub REST API client for Node.js\",\"keywords\":[\"octokit\",\"github\",\"rest\",\"api-client\"],\"author\":\"Gregor Martynus (https://github.com/gr2m)\",\"contributors\":[{\"name\":\"Mike de Boer\",\"email\":\"info@mikedeboer.nl\"},{\"name\":\"Fabian Jakobs\",\"email\":\"fabian@c9.io\"},{\"name\":\"Joe Gallo\",\"email\":\"joe@brassafrax.com\"},{\"name\":\"Gregor Martynus\",\"url\":\"https://github.com/gr2m\"}],\"repository\":\"https://github.com/octokit/rest.js\",\"dependencies\":{\"@octokit/auth-token\":\"^2.4.0\",\"@octokit/plugin-paginate-rest\":\"^1.1.1\",\"@octokit/plugin-request-log\":\"^1.0.0\",\"@octokit/plugin-rest-endpoint-methods\":\"2.4.0\",\"@octokit/request\":\"^5.2.0\",\"@octokit/request-error\":\"^1.0.2\",\"atob-lite\":\"^2.0.0\",\"before-after-hook\":\"^2.0.0\",\"btoa-lite\":\"^1.0.0\",\"deprecation\":\"^2.0.0\",\"lodash.get\":\"^4.4.2\",\"lodash.set\":\"^4.3.2\",\"lodash.uniq\":\"^4.5.0\",\"octokit-pagination-methods\":\"^1.1.0\",\"once\":\"^1.4.0\",\"universal-user-agent\":\"^4.0.0\"},\"devDependencies\":{\"@gimenete/type-writer\":\"^0.1.3\",\"@octokit/auth\":\"^1.1.1\",\"@octokit/fixtures-server\":\"^5.0.6\",\"@octokit/graphql\":\"^4.2.0\",\"@types/node\":\"^13.1.0\",\"bundlesize\":\"^0.18.0\",\"chai\":\"^4.1.2\",\"compression-webpack-plugin\":\"^3.1.0\",\"cypress\":\"^3.0.0\",\"glob\":\"^7.1.2\",\"http-proxy-agent\":\"^4.0.0\",\"lodash.camelcase\":\"^4.3.0\",\"lodash.merge\":\"^4.6.1\",\"lodash.upperfirst\":\"^4.3.1\",\"lolex\":\"^5.1.2\",\"mkdirp\":\"^1.0.0\",\"mocha\":\"^7.0.1\",\"mustache\":\"^4.0.0\",\"nock\":\"^11.3.3\",\"npm-run-all\":\"^4.1.2\",\"nyc\":\"^15.0.0\",\"prettier\":\"^1.14.2\",\"proxy\":\"^1.0.0\",\"semantic-release\":\"^17.0.0\",\"sinon\":\"^8.0.0\",\"sinon-chai\":\"^3.0.0\",\"sort-keys\":\"^4.0.0\",\"string-to-arraybuffer\":\"^1.0.0\",\"string-to-jsdoc-comment\":\"^1.0.0\",\"typescript\":\"^3.3.1\",\"webpack\":\"^4.0.0\",\"webpack-bundle-analyzer\":\"^3.0.0\",\"webpack-cli\":\"^3.0.0\"},\"types\":\"index.d.ts\",\"scripts\":{\"coverage\":\"nyc report --reporter=html && open coverage/index.html\",\"lint\":\"prettier --check '{lib,plugins,scripts,test}/**/*.{js,json,ts}' 'docs/*.{js,json}' 'docs/src/**/*' index.js README.md package.json\",\"lint:fix\":\"prettier --write '{lib,plugins,scripts,test}/**/*.{js,json,ts}' 'docs/*.{js,json}' 'docs/src/**/*' index.js README.md package.json\",\"pretest\":\"npm run -s lint\",\"test\":\"nyc mocha test/mocha-node-setup.js \\\"test/*/**/*-test.js\\\"\",\"test:browser\":\"cypress run --browser chrome\",\"build\":\"npm-run-all build:*\",\"build:ts\":\"npm run -s update-endpoints:typescript\",\"prebuild:browser\":\"mkdirp dist/\",\"build:browser\":\"npm-run-all build:browser:*\",\"build:browser:development\":\"webpack --mode development --entry . --output-library=Octokit --output=./dist/octokit-rest.js --profile --json > dist/bundle-stats.json\",\"build:browser:production\":\"webpack --mode production --entry . --plugin=compression-webpack-plugin --output-library=Octokit --output-path=./dist --output-filename=octokit-rest.min.js --devtool source-map\",\"generate-bundle-report\":\"webpack-bundle-analyzer dist/bundle-stats.json --mode=static --no-open --report dist/bundle-report.html\",\"update-endpoints\":\"npm-run-all update-endpoints:*\",\"update-endpoints:fetch-json\":\"node scripts/update-endpoints/fetch-json\",\"update-endpoints:typescript\":\"node scripts/update-endpoints/typescript\",\"prevalidate:ts\":\"npm run -s build:ts\",\"validate:ts\":\"tsc --target es6 --noImplicitAny index.d.ts\",\"postvalidate:ts\":\"tsc --noEmit --target es6 test/typescript-validate.ts\",\"start-fixtures-server\":\"octokit-fixtures-server\"},\"license\":\"MIT\",\"files\":[\"index.js\",\"index.d.ts\",\"lib\",\"plugins\"],\"nyc\":{\"ignore\":[\"test\"]},\"release\":{\"publish\":[\"@semantic-release/npm\",{\"path\":\"@semantic-release/github\",\"assets\":[\"dist/*\",\"!dist/*.map.gz\"]}]},\"bundlesize\":[{\"path\":\"./dist/octokit-rest.min.js.gz\",\"maxSize\":\"33 kB\"}]}"); - -/***/ }), - -/***/ 7351: -/***/ (function(__unused_webpack_module, exports, __webpack_require__) { - -"use strict"; - -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -const os = __importStar(__webpack_require__(2087)); -const utils_1 = __webpack_require__(5278); -/** - * Commands - * - * Command Format: - * ::name key=value,key=value::message - * - * Examples: - * ::warning::This is the message - * ::set-env name=MY_VAR::some value - */ -function issueCommand(command, properties, message) { - const cmd = new Command(command, properties, message); - process.stdout.write(cmd.toString() + os.EOL); -} -exports.issueCommand = issueCommand; -function issue(name, message = '') { - issueCommand(name, {}, message); -} -exports.issue = issue; -const CMD_STRING = '::'; -class Command { - constructor(command, properties, message) { - if (!command) { - command = 'missing.command'; - } - this.command = command; - this.properties = properties; - this.message = message; - } - toString() { - let cmdStr = CMD_STRING + this.command; - if (this.properties && Object.keys(this.properties).length > 0) { - cmdStr += ' '; - let first = true; +require('./sourcemap-register.js') +module.exports = /******/ (() => { + // webpackBootstrap + /******/ var __webpack_modules__ = { + /***/ 54479: /***/ module => { + 'use strict' + module.exports = JSON.parse( + '{"nested":{"google":{"nested":{"logging":{"nested":{"v2":{"options":{"cc_enable_arenas":true,"csharp_namespace":"Google.Cloud.Logging.V2","go_package":"google.golang.org/genproto/googleapis/logging/v2;logging","java_multiple_files":true,"java_outer_classname":"LoggingMetricsProto","java_package":"com.google.logging.v2","php_namespace":"Google\\\\Cloud\\\\Logging\\\\V2","ruby_package":"Google::Cloud::Logging::V2","(google.api.resource_definition).type":"logging.googleapis.com/BillingAccountLocation","(google.api.resource_definition).pattern":"billingAccounts/{billing_account}/locations/{location}"},"nested":{"LogEntry":{"options":{"(google.api.resource).type":"logging.googleapis.com/Log","(google.api.resource).pattern":"billingAccounts/{billing_account}/logs/{log}","(google.api.resource).name_field":"log_name"},"oneofs":{"payload":{"oneof":["protoPayload","textPayload","jsonPayload"]}},"fields":{"logName":{"type":"string","id":12,"options":{"(google.api.field_behavior)":"REQUIRED"}},"resource":{"type":"google.api.MonitoredResource","id":8,"options":{"(google.api.field_behavior)":"REQUIRED"}},"protoPayload":{"type":"google.protobuf.Any","id":2},"textPayload":{"type":"string","id":3},"jsonPayload":{"type":"google.protobuf.Struct","id":6},"timestamp":{"type":"google.protobuf.Timestamp","id":9,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"receiveTimestamp":{"type":"google.protobuf.Timestamp","id":24,"options":{"(google.api.field_behavior)":"OUTPUT_ONLY"}},"severity":{"type":"google.logging.type.LogSeverity","id":10,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"insertId":{"type":"string","id":4,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"httpRequest":{"type":"google.logging.type.HttpRequest","id":7,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"labels":{"keyType":"string","type":"string","id":11,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"operation":{"type":"LogEntryOperation","id":15,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"trace":{"type":"string","id":22,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"spanId":{"type":"string","id":27,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"traceSampled":{"type":"bool","id":30,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"sourceLocation":{"type":"LogEntrySourceLocation","id":23,"options":{"(google.api.field_behavior)":"OPTIONAL"}}}},"LogEntryOperation":{"fields":{"id":{"type":"string","id":1,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"producer":{"type":"string","id":2,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"first":{"type":"bool","id":3,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"last":{"type":"bool","id":4,"options":{"(google.api.field_behavior)":"OPTIONAL"}}}},"LogEntrySourceLocation":{"fields":{"file":{"type":"string","id":1,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"line":{"type":"int64","id":2,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"function":{"type":"string","id":3,"options":{"(google.api.field_behavior)":"OPTIONAL"}}}},"LoggingServiceV2":{"options":{"(google.api.default_host)":"logging.googleapis.com","(google.api.oauth_scopes)":"https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/cloud-platform.read-only,https://www.googleapis.com/auth/logging.admin,https://www.googleapis.com/auth/logging.read,https://www.googleapis.com/auth/logging.write"},"methods":{"DeleteLog":{"requestType":"DeleteLogRequest","responseType":"google.protobuf.Empty","options":{"(google.api.http).delete":"/v2/{log_name=projects/*/logs/*}","(google.api.http).additional_bindings.delete":"/v2/{log_name=billingAccounts/*/logs/*}","(google.api.method_signature)":"log_name"}},"WriteLogEntries":{"requestType":"WriteLogEntriesRequest","responseType":"WriteLogEntriesResponse","options":{"(google.api.http).post":"/v2/entries:write","(google.api.http).body":"*","(google.api.method_signature)":"log_name,resource,labels,entries"}},"ListLogEntries":{"requestType":"ListLogEntriesRequest","responseType":"ListLogEntriesResponse","options":{"(google.api.http).post":"/v2/entries:list","(google.api.http).body":"*","(google.api.method_signature)":"resource_names,filter,order_by"}},"ListMonitoredResourceDescriptors":{"requestType":"ListMonitoredResourceDescriptorsRequest","responseType":"ListMonitoredResourceDescriptorsResponse","options":{"(google.api.http).get":"/v2/monitoredResourceDescriptors"}},"ListLogs":{"requestType":"ListLogsRequest","responseType":"ListLogsResponse","options":{"(google.api.http).get":"/v2/{parent=*/*}/logs","(google.api.http).additional_bindings.get":"/v2/{parent=billingAccounts/*}/logs","(google.api.method_signature)":"parent"}}}},"DeleteLogRequest":{"fields":{"logName":{"type":"string","id":1,"options":{"(google.api.field_behavior)":"REQUIRED","(google.api.resource_reference).type":"logging.googleapis.com/Log"}}}},"WriteLogEntriesRequest":{"fields":{"logName":{"type":"string","id":1,"options":{"(google.api.field_behavior)":"OPTIONAL","(google.api.resource_reference).type":"logging.googleapis.com/Log"}},"resource":{"type":"google.api.MonitoredResource","id":2,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"labels":{"keyType":"string","type":"string","id":3,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"entries":{"rule":"repeated","type":"LogEntry","id":4,"options":{"(google.api.field_behavior)":"REQUIRED"}},"partialSuccess":{"type":"bool","id":5,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"dryRun":{"type":"bool","id":6,"options":{"(google.api.field_behavior)":"OPTIONAL"}}}},"WriteLogEntriesResponse":{"fields":{}},"WriteLogEntriesPartialErrors":{"fields":{"logEntryErrors":{"keyType":"int32","type":"google.rpc.Status","id":1}}},"ListLogEntriesRequest":{"fields":{"resourceNames":{"rule":"repeated","type":"string","id":8,"options":{"(google.api.field_behavior)":"REQUIRED","(google.api.resource_reference).child_type":"logging.googleapis.com/Log"}},"filter":{"type":"string","id":2,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"orderBy":{"type":"string","id":3,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"pageSize":{"type":"int32","id":4,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"pageToken":{"type":"string","id":5,"options":{"(google.api.field_behavior)":"OPTIONAL"}}}},"ListLogEntriesResponse":{"fields":{"entries":{"rule":"repeated","type":"LogEntry","id":1},"nextPageToken":{"type":"string","id":2}}},"ListMonitoredResourceDescriptorsRequest":{"fields":{"pageSize":{"type":"int32","id":1,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"pageToken":{"type":"string","id":2,"options":{"(google.api.field_behavior)":"OPTIONAL"}}}},"ListMonitoredResourceDescriptorsResponse":{"fields":{"resourceDescriptors":{"rule":"repeated","type":"google.api.MonitoredResourceDescriptor","id":1},"nextPageToken":{"type":"string","id":2}}},"ListLogsRequest":{"fields":{"parent":{"type":"string","id":1,"options":{"(google.api.field_behavior)":"REQUIRED","(google.api.resource_reference).child_type":"logging.googleapis.com/Log"}},"pageSize":{"type":"int32","id":2,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"pageToken":{"type":"string","id":3,"options":{"(google.api.field_behavior)":"OPTIONAL"}}}},"ListLogsResponse":{"fields":{"logNames":{"rule":"repeated","type":"string","id":3},"nextPageToken":{"type":"string","id":2}}},"ConfigServiceV2":{"options":{"(google.api.default_host)":"logging.googleapis.com","(google.api.oauth_scopes)":"https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/cloud-platform.read-only,https://www.googleapis.com/auth/logging.admin,https://www.googleapis.com/auth/logging.read"},"methods":{"ListBuckets":{"requestType":"ListBucketsRequest","responseType":"ListBucketsResponse","options":{"(google.api.http).get":"/v2/{parent=*/*/locations/*}/buckets","(google.api.http).additional_bindings.get":"/v2/{parent=billingAccounts/*/locations/*}/buckets","(google.api.method_signature)":"parent"}},"GetBucket":{"requestType":"GetBucketRequest","responseType":"LogBucket","options":{"(google.api.http).get":"/v2/{name=*/*/locations/*/buckets/*}","(google.api.http).additional_bindings.get":"/v2/{name=billingAccounts/*/buckets/*}"}},"UpdateBucket":{"requestType":"UpdateBucketRequest","responseType":"LogBucket","options":{"(google.api.http).patch":"/v2/{name=*/*/locations/*/buckets/*}","(google.api.http).body":"bucket","(google.api.http).additional_bindings.patch":"/v2/{name=billingAccounts/*/locations/*/buckets/*}","(google.api.http).additional_bindings.body":"bucket"}},"ListSinks":{"requestType":"ListSinksRequest","responseType":"ListSinksResponse","options":{"(google.api.http).get":"/v2/{parent=*/*}/sinks","(google.api.http).additional_bindings.get":"/v2/{parent=billingAccounts/*}/sinks","(google.api.method_signature)":"parent"}},"GetSink":{"requestType":"GetSinkRequest","responseType":"LogSink","options":{"(google.api.http).get":"/v2/{sink_name=*/*/sinks/*}","(google.api.http).additional_bindings.get":"/v2/{sink_name=billingAccounts/*/sinks/*}","(google.api.method_signature)":"sink_name"}},"CreateSink":{"requestType":"CreateSinkRequest","responseType":"LogSink","options":{"(google.api.http).post":"/v2/{parent=*/*}/sinks","(google.api.http).body":"sink","(google.api.http).additional_bindings.post":"/v2/{parent=billingAccounts/*}/sinks","(google.api.http).additional_bindings.body":"sink","(google.api.method_signature)":"parent,sink"}},"UpdateSink":{"requestType":"UpdateSinkRequest","responseType":"LogSink","options":{"(google.api.http).put":"/v2/{sink_name=*/*/sinks/*}","(google.api.http).body":"sink","(google.api.http).additional_bindings.put":"/v2/{sink_name=billingAccounts/*/sinks/*}","(google.api.http).additional_bindings.body":"sink","(google.api.http).additional_bindings.patch":"/v2/{sink_name=billingAccounts/*/sinks/*}","(google.api.method_signature)":"sink_name,sink"}},"DeleteSink":{"requestType":"DeleteSinkRequest","responseType":"google.protobuf.Empty","options":{"(google.api.http).delete":"/v2/{sink_name=*/*/sinks/*}","(google.api.http).additional_bindings.delete":"/v2/{sink_name=billingAccounts/*/sinks/*}","(google.api.method_signature)":"sink_name"}},"ListExclusions":{"requestType":"ListExclusionsRequest","responseType":"ListExclusionsResponse","options":{"(google.api.http).get":"/v2/{parent=*/*}/exclusions","(google.api.http).additional_bindings.get":"/v2/{parent=billingAccounts/*}/exclusions","(google.api.method_signature)":"parent"}},"GetExclusion":{"requestType":"GetExclusionRequest","responseType":"LogExclusion","options":{"(google.api.http).get":"/v2/{name=*/*/exclusions/*}","(google.api.http).additional_bindings.get":"/v2/{name=billingAccounts/*/exclusions/*}","(google.api.method_signature)":"name"}},"CreateExclusion":{"requestType":"CreateExclusionRequest","responseType":"LogExclusion","options":{"(google.api.http).post":"/v2/{parent=*/*}/exclusions","(google.api.http).body":"exclusion","(google.api.http).additional_bindings.post":"/v2/{parent=billingAccounts/*}/exclusions","(google.api.http).additional_bindings.body":"exclusion","(google.api.method_signature)":"parent,exclusion"}},"UpdateExclusion":{"requestType":"UpdateExclusionRequest","responseType":"LogExclusion","options":{"(google.api.http).patch":"/v2/{name=*/*/exclusions/*}","(google.api.http).body":"exclusion","(google.api.http).additional_bindings.patch":"/v2/{name=billingAccounts/*/exclusions/*}","(google.api.http).additional_bindings.body":"exclusion","(google.api.method_signature)":"name,exclusion,update_mask"}},"DeleteExclusion":{"requestType":"DeleteExclusionRequest","responseType":"google.protobuf.Empty","options":{"(google.api.http).delete":"/v2/{name=*/*/exclusions/*}","(google.api.http).additional_bindings.delete":"/v2/{name=billingAccounts/*/exclusions/*}","(google.api.method_signature)":"name"}},"GetCmekSettings":{"requestType":"GetCmekSettingsRequest","responseType":"CmekSettings","options":{"(google.api.http).get":"/v2/{name=*/*}/cmekSettings","(google.api.http).additional_bindings.get":"/v2/{name=organizations/*}/cmekSettings"}},"UpdateCmekSettings":{"requestType":"UpdateCmekSettingsRequest","responseType":"CmekSettings","options":{"(google.api.http).patch":"/v2/{name=*/*}/cmekSettings","(google.api.http).body":"cmek_settings","(google.api.http).additional_bindings.patch":"/v2/{name=organizations/*}/cmekSettings","(google.api.http).additional_bindings.body":"cmek_settings"}}}},"LogBucket":{"options":{"(google.api.resource).type":"logging.googleapis.com/LogBucket","(google.api.resource).pattern":"billingAccounts/{billing_account}/locations/{location}/buckets/{bucket}"},"fields":{"name":{"type":"string","id":1},"description":{"type":"string","id":3},"createTime":{"type":"google.protobuf.Timestamp","id":4,"options":{"(google.api.field_behavior)":"OUTPUT_ONLY"}},"updateTime":{"type":"google.protobuf.Timestamp","id":5,"options":{"(google.api.field_behavior)":"OUTPUT_ONLY"}},"retentionDays":{"type":"int32","id":11},"lifecycleState":{"type":"LifecycleState","id":12,"options":{"(google.api.field_behavior)":"OUTPUT_ONLY"}}}},"LogSink":{"options":{"(google.api.resource).type":"logging.googleapis.com/LogSink","(google.api.resource).pattern":"billingAccounts/{billing_account}/sinks/{sink}"},"oneofs":{"options":{"oneof":["bigqueryOptions"]}},"fields":{"name":{"type":"string","id":1,"options":{"(google.api.field_behavior)":"REQUIRED"}},"destination":{"type":"string","id":3,"options":{"(google.api.field_behavior)":"REQUIRED","(google.api.resource_reference).type":"*"}},"filter":{"type":"string","id":5,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"description":{"type":"string","id":18,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"disabled":{"type":"bool","id":19,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"outputVersionFormat":{"type":"VersionFormat","id":6,"options":{"deprecated":true}},"writerIdentity":{"type":"string","id":8,"options":{"(google.api.field_behavior)":"OUTPUT_ONLY"}},"includeChildren":{"type":"bool","id":9,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"bigqueryOptions":{"type":"BigQueryOptions","id":12,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"createTime":{"type":"google.protobuf.Timestamp","id":13,"options":{"(google.api.field_behavior)":"OUTPUT_ONLY"}},"updateTime":{"type":"google.protobuf.Timestamp","id":14,"options":{"(google.api.field_behavior)":"OUTPUT_ONLY"}}},"nested":{"VersionFormat":{"values":{"VERSION_FORMAT_UNSPECIFIED":0,"V2":1,"V1":2}}}},"BigQueryOptions":{"fields":{"usePartitionedTables":{"type":"bool","id":1,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"usesTimestampColumnPartitioning":{"type":"bool","id":3,"options":{"(google.api.field_behavior)":"OUTPUT_ONLY"}}}},"LifecycleState":{"values":{"LIFECYCLE_STATE_UNSPECIFIED":0,"ACTIVE":1,"DELETE_REQUESTED":2}},"ListBucketsRequest":{"fields":{"parent":{"type":"string","id":1,"options":{"(google.api.field_behavior)":"REQUIRED","(google.api.resource_reference).child_type":"logging.googleapis.com/LogBucket"}},"pageToken":{"type":"string","id":2,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"pageSize":{"type":"int32","id":3,"options":{"(google.api.field_behavior)":"OPTIONAL"}}}},"ListBucketsResponse":{"fields":{"buckets":{"rule":"repeated","type":"LogBucket","id":1},"nextPageToken":{"type":"string","id":2}}},"UpdateBucketRequest":{"fields":{"name":{"type":"string","id":1,"options":{"(google.api.field_behavior)":"REQUIRED","(google.api.resource_reference).type":"logging.googleapis.com/LogBucket"}},"bucket":{"type":"LogBucket","id":2,"options":{"(google.api.field_behavior)":"REQUIRED"}},"updateMask":{"type":"google.protobuf.FieldMask","id":4,"options":{"(google.api.field_behavior)":"REQUIRED"}}}},"GetBucketRequest":{"fields":{"name":{"type":"string","id":1,"options":{"(google.api.field_behavior)":"REQUIRED","(google.api.resource_reference).type":"logging.googleapis.com/LogBucket"}}}},"ListSinksRequest":{"fields":{"parent":{"type":"string","id":1,"options":{"(google.api.field_behavior)":"REQUIRED","(google.api.resource_reference).child_type":"logging.googleapis.com/LogSink"}},"pageToken":{"type":"string","id":2,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"pageSize":{"type":"int32","id":3,"options":{"(google.api.field_behavior)":"OPTIONAL"}}}},"ListSinksResponse":{"fields":{"sinks":{"rule":"repeated","type":"LogSink","id":1},"nextPageToken":{"type":"string","id":2}}},"GetSinkRequest":{"fields":{"sinkName":{"type":"string","id":1,"options":{"(google.api.field_behavior)":"REQUIRED","(google.api.resource_reference).type":"logging.googleapis.com/LogSink"}}}},"CreateSinkRequest":{"fields":{"parent":{"type":"string","id":1,"options":{"(google.api.field_behavior)":"REQUIRED","(google.api.resource_reference).child_type":"logging.googleapis.com/LogSink"}},"sink":{"type":"LogSink","id":2,"options":{"(google.api.field_behavior)":"REQUIRED"}},"uniqueWriterIdentity":{"type":"bool","id":3,"options":{"(google.api.field_behavior)":"OPTIONAL"}}}},"UpdateSinkRequest":{"fields":{"sinkName":{"type":"string","id":1,"options":{"(google.api.field_behavior)":"REQUIRED","(google.api.resource_reference).type":"logging.googleapis.com/LogSink"}},"sink":{"type":"LogSink","id":2,"options":{"(google.api.field_behavior)":"REQUIRED"}},"uniqueWriterIdentity":{"type":"bool","id":3,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"updateMask":{"type":"google.protobuf.FieldMask","id":4,"options":{"(google.api.field_behavior)":"OPTIONAL"}}}},"DeleteSinkRequest":{"fields":{"sinkName":{"type":"string","id":1,"options":{"(google.api.field_behavior)":"REQUIRED","(google.api.resource_reference).type":"logging.googleapis.com/LogSink"}}}},"LogExclusion":{"options":{"(google.api.resource).type":"logging.googleapis.com/LogExclusion","(google.api.resource).pattern":"billingAccounts/{billing_account}/exclusions/{exclusion}"},"fields":{"name":{"type":"string","id":1,"options":{"(google.api.field_behavior)":"REQUIRED"}},"description":{"type":"string","id":2,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"filter":{"type":"string","id":3,"options":{"(google.api.field_behavior)":"REQUIRED"}},"disabled":{"type":"bool","id":4,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"createTime":{"type":"google.protobuf.Timestamp","id":5,"options":{"(google.api.field_behavior)":"OUTPUT_ONLY"}},"updateTime":{"type":"google.protobuf.Timestamp","id":6,"options":{"(google.api.field_behavior)":"OUTPUT_ONLY"}}}},"ListExclusionsRequest":{"fields":{"parent":{"type":"string","id":1,"options":{"(google.api.field_behavior)":"REQUIRED","(google.api.resource_reference).child_type":"logging.googleapis.com/LogExclusion"}},"pageToken":{"type":"string","id":2,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"pageSize":{"type":"int32","id":3,"options":{"(google.api.field_behavior)":"OPTIONAL"}}}},"ListExclusionsResponse":{"fields":{"exclusions":{"rule":"repeated","type":"LogExclusion","id":1},"nextPageToken":{"type":"string","id":2}}},"GetExclusionRequest":{"fields":{"name":{"type":"string","id":1,"options":{"(google.api.field_behavior)":"REQUIRED","(google.api.resource_reference).type":"logging.googleapis.com/LogExclusion"}}}},"CreateExclusionRequest":{"fields":{"parent":{"type":"string","id":1,"options":{"(google.api.field_behavior)":"REQUIRED","(google.api.resource_reference).child_type":"logging.googleapis.com/LogExclusion"}},"exclusion":{"type":"LogExclusion","id":2,"options":{"(google.api.field_behavior)":"REQUIRED"}}}},"UpdateExclusionRequest":{"fields":{"name":{"type":"string","id":1,"options":{"(google.api.field_behavior)":"REQUIRED","(google.api.resource_reference).type":"logging.googleapis.com/LogExclusion"}},"exclusion":{"type":"LogExclusion","id":2,"options":{"(google.api.field_behavior)":"REQUIRED"}},"updateMask":{"type":"google.protobuf.FieldMask","id":3,"options":{"(google.api.field_behavior)":"REQUIRED"}}}},"DeleteExclusionRequest":{"fields":{"name":{"type":"string","id":1,"options":{"(google.api.field_behavior)":"REQUIRED","(google.api.resource_reference).type":"logging.googleapis.com/LogExclusion"}}}},"GetCmekSettingsRequest":{"fields":{"name":{"type":"string","id":1,"options":{"(google.api.field_behavior)":"REQUIRED","(google.api.resource_reference).type":"logging.googleapis.com/CmekSettings"}}}},"UpdateCmekSettingsRequest":{"fields":{"name":{"type":"string","id":1,"options":{"(google.api.field_behavior)":"REQUIRED"}},"cmekSettings":{"type":"CmekSettings","id":2,"options":{"(google.api.field_behavior)":"REQUIRED"}},"updateMask":{"type":"google.protobuf.FieldMask","id":3,"options":{"(google.api.field_behavior)":"OPTIONAL"}}}},"CmekSettings":{"options":{"(google.api.resource).type":"logging.googleapis.com/CmekSettings","(google.api.resource).pattern":"billingAccounts/{billing_account}/cmekSettings"},"fields":{"name":{"type":"string","id":1,"options":{"(google.api.field_behavior)":"OUTPUT_ONLY"}},"kmsKeyName":{"type":"string","id":2},"serviceAccountId":{"type":"string","id":3,"options":{"(google.api.field_behavior)":"OUTPUT_ONLY"}}}},"MetricsServiceV2":{"options":{"(google.api.default_host)":"logging.googleapis.com","(google.api.oauth_scopes)":"https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/cloud-platform.read-only,https://www.googleapis.com/auth/logging.admin,https://www.googleapis.com/auth/logging.read,https://www.googleapis.com/auth/logging.write"},"methods":{"ListLogMetrics":{"requestType":"ListLogMetricsRequest","responseType":"ListLogMetricsResponse","options":{"(google.api.http).get":"/v2/{parent=projects/*}/metrics","(google.api.method_signature)":"parent"}},"GetLogMetric":{"requestType":"GetLogMetricRequest","responseType":"LogMetric","options":{"(google.api.http).get":"/v2/{metric_name=projects/*/metrics/*}","(google.api.method_signature)":"metric_name"}},"CreateLogMetric":{"requestType":"CreateLogMetricRequest","responseType":"LogMetric","options":{"(google.api.http).post":"/v2/{parent=projects/*}/metrics","(google.api.http).body":"metric","(google.api.method_signature)":"parent,metric"}},"UpdateLogMetric":{"requestType":"UpdateLogMetricRequest","responseType":"LogMetric","options":{"(google.api.http).put":"/v2/{metric_name=projects/*/metrics/*}","(google.api.http).body":"metric","(google.api.method_signature)":"metric_name,metric"}},"DeleteLogMetric":{"requestType":"DeleteLogMetricRequest","responseType":"google.protobuf.Empty","options":{"(google.api.http).delete":"/v2/{metric_name=projects/*/metrics/*}","(google.api.method_signature)":"metric_name"}}}},"LogMetric":{"options":{"(google.api.resource).type":"logging.googleapis.com/LogMetric","(google.api.resource).pattern":"projects/{project}/metrics/{metric}"},"fields":{"name":{"type":"string","id":1,"options":{"(google.api.field_behavior)":"REQUIRED"}},"description":{"type":"string","id":2,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"filter":{"type":"string","id":3,"options":{"(google.api.field_behavior)":"REQUIRED"}},"metricDescriptor":{"type":"google.api.MetricDescriptor","id":5,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"valueExtractor":{"type":"string","id":6,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"labelExtractors":{"keyType":"string","type":"string","id":7,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"bucketOptions":{"type":"google.api.Distribution.BucketOptions","id":8,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"createTime":{"type":"google.protobuf.Timestamp","id":9,"options":{"(google.api.field_behavior)":"OUTPUT_ONLY"}},"updateTime":{"type":"google.protobuf.Timestamp","id":10,"options":{"(google.api.field_behavior)":"OUTPUT_ONLY"}},"version":{"type":"ApiVersion","id":4,"options":{"deprecated":true}}},"nested":{"ApiVersion":{"values":{"V2":0,"V1":1}}}},"ListLogMetricsRequest":{"fields":{"parent":{"type":"string","id":1,"options":{"(google.api.field_behavior)":"REQUIRED","(google.api.resource_reference).type":"cloudresourcemanager.googleapis.com/Project"}},"pageToken":{"type":"string","id":2,"options":{"(google.api.field_behavior)":"OPTIONAL"}},"pageSize":{"type":"int32","id":3,"options":{"(google.api.field_behavior)":"OPTIONAL"}}}},"ListLogMetricsResponse":{"fields":{"metrics":{"rule":"repeated","type":"LogMetric","id":1},"nextPageToken":{"type":"string","id":2}}},"GetLogMetricRequest":{"fields":{"metricName":{"type":"string","id":1,"options":{"(google.api.field_behavior)":"REQUIRED","(google.api.resource_reference).type":"logging.googleapis.com/LogMetric"}}}},"CreateLogMetricRequest":{"fields":{"parent":{"type":"string","id":1,"options":{"(google.api.field_behavior)":"REQUIRED","(google.api.resource_reference).child_type":"logging.googleapis.com/LogMetric"}},"metric":{"type":"LogMetric","id":2,"options":{"(google.api.field_behavior)":"REQUIRED"}}}},"UpdateLogMetricRequest":{"fields":{"metricName":{"type":"string","id":1,"options":{"(google.api.field_behavior)":"REQUIRED","(google.api.resource_reference).type":"logging.googleapis.com/LogMetric"}},"metric":{"type":"LogMetric","id":2,"options":{"(google.api.field_behavior)":"REQUIRED"}}}},"DeleteLogMetricRequest":{"fields":{"metricName":{"type":"string","id":1,"options":{"(google.api.field_behavior)":"REQUIRED","(google.api.resource_reference).type":"logging.googleapis.com/LogMetric"}}}}}},"type":{"options":{"csharp_namespace":"Google.Cloud.Logging.Type","go_package":"google.golang.org/genproto/googleapis/logging/type;ltype","java_multiple_files":true,"java_outer_classname":"LogSeverityProto","java_package":"com.google.logging.type","php_namespace":"Google\\\\Cloud\\\\Logging\\\\Type","ruby_package":"Google::Cloud::Logging::Type"},"nested":{"HttpRequest":{"fields":{"requestMethod":{"type":"string","id":1},"requestUrl":{"type":"string","id":2},"requestSize":{"type":"int64","id":3},"status":{"type":"int32","id":4},"responseSize":{"type":"int64","id":5},"userAgent":{"type":"string","id":6},"remoteIp":{"type":"string","id":7},"serverIp":{"type":"string","id":13},"referer":{"type":"string","id":8},"latency":{"type":"google.protobuf.Duration","id":14},"cacheLookup":{"type":"bool","id":11},"cacheHit":{"type":"bool","id":9},"cacheValidatedWithOriginServer":{"type":"bool","id":10},"cacheFillBytes":{"type":"int64","id":12},"protocol":{"type":"string","id":15}}},"LogSeverity":{"values":{"DEFAULT":0,"DEBUG":100,"INFO":200,"NOTICE":300,"WARNING":400,"ERROR":500,"CRITICAL":600,"ALERT":700,"EMERGENCY":800}}}}}},"api":{"options":{"go_package":"google.golang.org/genproto/googleapis/api/metric;metric","java_multiple_files":true,"java_outer_classname":"MetricProto","java_package":"com.google.api","objc_class_prefix":"GAPI","cc_enable_arenas":true},"nested":{"fieldBehavior":{"rule":"repeated","type":"google.api.FieldBehavior","id":1052,"extend":"google.protobuf.FieldOptions"},"FieldBehavior":{"values":{"FIELD_BEHAVIOR_UNSPECIFIED":0,"OPTIONAL":1,"REQUIRED":2,"OUTPUT_ONLY":3,"INPUT_ONLY":4,"IMMUTABLE":5}},"MonitoredResourceDescriptor":{"fields":{"name":{"type":"string","id":5},"type":{"type":"string","id":1},"displayName":{"type":"string","id":2},"description":{"type":"string","id":3},"labels":{"rule":"repeated","type":"LabelDescriptor","id":4},"launchStage":{"type":"LaunchStage","id":7}}},"MonitoredResource":{"fields":{"type":{"type":"string","id":1},"labels":{"keyType":"string","type":"string","id":2}}},"MonitoredResourceMetadata":{"fields":{"systemLabels":{"type":"google.protobuf.Struct","id":1},"userLabels":{"keyType":"string","type":"string","id":2}}},"LabelDescriptor":{"fields":{"key":{"type":"string","id":1},"valueType":{"type":"ValueType","id":2},"description":{"type":"string","id":3}},"nested":{"ValueType":{"values":{"STRING":0,"BOOL":1,"INT64":2}}}},"LaunchStage":{"values":{"LAUNCH_STAGE_UNSPECIFIED":0,"UNIMPLEMENTED":6,"PRELAUNCH":7,"EARLY_ACCESS":1,"ALPHA":2,"BETA":3,"GA":4,"DEPRECATED":5}},"resourceReference":{"type":"google.api.ResourceReference","id":1055,"extend":"google.protobuf.FieldOptions"},"resourceDefinition":{"rule":"repeated","type":"google.api.ResourceDescriptor","id":1053,"extend":"google.protobuf.FileOptions"},"resource":{"type":"google.api.ResourceDescriptor","id":1053,"extend":"google.protobuf.MessageOptions"},"ResourceDescriptor":{"fields":{"type":{"type":"string","id":1},"pattern":{"rule":"repeated","type":"string","id":2},"nameField":{"type":"string","id":3},"history":{"type":"History","id":4},"plural":{"type":"string","id":5},"singular":{"type":"string","id":6}},"nested":{"History":{"values":{"HISTORY_UNSPECIFIED":0,"ORIGINALLY_SINGLE_PATTERN":1,"FUTURE_MULTI_PATTERN":2}}}},"ResourceReference":{"fields":{"type":{"type":"string","id":1},"childType":{"type":"string","id":2}}},"http":{"type":"HttpRule","id":72295728,"extend":"google.protobuf.MethodOptions"},"Http":{"fields":{"rules":{"rule":"repeated","type":"HttpRule","id":1},"fullyDecodeReservedExpansion":{"type":"bool","id":2}}},"HttpRule":{"oneofs":{"pattern":{"oneof":["get","put","post","delete","patch","custom"]}},"fields":{"selector":{"type":"string","id":1},"get":{"type":"string","id":2},"put":{"type":"string","id":3},"post":{"type":"string","id":4},"delete":{"type":"string","id":5},"patch":{"type":"string","id":6},"custom":{"type":"CustomHttpPattern","id":8},"body":{"type":"string","id":7},"responseBody":{"type":"string","id":12},"additionalBindings":{"rule":"repeated","type":"HttpRule","id":11}}},"CustomHttpPattern":{"fields":{"kind":{"type":"string","id":1},"path":{"type":"string","id":2}}},"methodSignature":{"rule":"repeated","type":"string","id":1051,"extend":"google.protobuf.MethodOptions"},"defaultHost":{"type":"string","id":1049,"extend":"google.protobuf.ServiceOptions"},"oauthScopes":{"type":"string","id":1050,"extend":"google.protobuf.ServiceOptions"},"Distribution":{"fields":{"count":{"type":"int64","id":1},"mean":{"type":"double","id":2},"sumOfSquaredDeviation":{"type":"double","id":3},"range":{"type":"Range","id":4},"bucketOptions":{"type":"BucketOptions","id":6},"bucketCounts":{"rule":"repeated","type":"int64","id":7},"exemplars":{"rule":"repeated","type":"Exemplar","id":10}},"nested":{"Range":{"fields":{"min":{"type":"double","id":1},"max":{"type":"double","id":2}}},"BucketOptions":{"oneofs":{"options":{"oneof":["linearBuckets","exponentialBuckets","explicitBuckets"]}},"fields":{"linearBuckets":{"type":"Linear","id":1},"exponentialBuckets":{"type":"Exponential","id":2},"explicitBuckets":{"type":"Explicit","id":3}},"nested":{"Linear":{"fields":{"numFiniteBuckets":{"type":"int32","id":1},"width":{"type":"double","id":2},"offset":{"type":"double","id":3}}},"Exponential":{"fields":{"numFiniteBuckets":{"type":"int32","id":1},"growthFactor":{"type":"double","id":2},"scale":{"type":"double","id":3}}},"Explicit":{"fields":{"bounds":{"rule":"repeated","type":"double","id":1}}}}},"Exemplar":{"fields":{"value":{"type":"double","id":1},"timestamp":{"type":"google.protobuf.Timestamp","id":2},"attachments":{"rule":"repeated","type":"google.protobuf.Any","id":3}}}}},"MetricDescriptor":{"fields":{"name":{"type":"string","id":1},"type":{"type":"string","id":8},"labels":{"rule":"repeated","type":"LabelDescriptor","id":2},"metricKind":{"type":"MetricKind","id":3},"valueType":{"type":"ValueType","id":4},"unit":{"type":"string","id":5},"description":{"type":"string","id":6},"displayName":{"type":"string","id":7},"metadata":{"type":"MetricDescriptorMetadata","id":10},"launchStage":{"type":"LaunchStage","id":12},"monitoredResourceTypes":{"rule":"repeated","type":"string","id":13}},"nested":{"MetricDescriptorMetadata":{"fields":{"launchStage":{"type":"LaunchStage","id":1,"options":{"deprecated":true}},"samplePeriod":{"type":"google.protobuf.Duration","id":2},"ingestDelay":{"type":"google.protobuf.Duration","id":3}}},"MetricKind":{"values":{"METRIC_KIND_UNSPECIFIED":0,"GAUGE":1,"DELTA":2,"CUMULATIVE":3}},"ValueType":{"values":{"VALUE_TYPE_UNSPECIFIED":0,"BOOL":1,"INT64":2,"DOUBLE":3,"STRING":4,"DISTRIBUTION":5,"MONEY":6}}}},"Metric":{"fields":{"type":{"type":"string","id":3},"labels":{"keyType":"string","type":"string","id":2}}}}},"protobuf":{"options":{"go_package":"github.com/golang/protobuf/protoc-gen-go/descriptor;descriptor","java_package":"com.google.protobuf","java_outer_classname":"DescriptorProtos","csharp_namespace":"Google.Protobuf.Reflection","objc_class_prefix":"GPB","cc_enable_arenas":true,"optimize_for":"SPEED"},"nested":{"FileDescriptorSet":{"fields":{"file":{"rule":"repeated","type":"FileDescriptorProto","id":1}}},"FileDescriptorProto":{"fields":{"name":{"type":"string","id":1},"package":{"type":"string","id":2},"dependency":{"rule":"repeated","type":"string","id":3},"publicDependency":{"rule":"repeated","type":"int32","id":10,"options":{"packed":false}},"weakDependency":{"rule":"repeated","type":"int32","id":11,"options":{"packed":false}},"messageType":{"rule":"repeated","type":"DescriptorProto","id":4},"enumType":{"rule":"repeated","type":"EnumDescriptorProto","id":5},"service":{"rule":"repeated","type":"ServiceDescriptorProto","id":6},"extension":{"rule":"repeated","type":"FieldDescriptorProto","id":7},"options":{"type":"FileOptions","id":8},"sourceCodeInfo":{"type":"SourceCodeInfo","id":9},"syntax":{"type":"string","id":12}}},"DescriptorProto":{"fields":{"name":{"type":"string","id":1},"field":{"rule":"repeated","type":"FieldDescriptorProto","id":2},"extension":{"rule":"repeated","type":"FieldDescriptorProto","id":6},"nestedType":{"rule":"repeated","type":"DescriptorProto","id":3},"enumType":{"rule":"repeated","type":"EnumDescriptorProto","id":4},"extensionRange":{"rule":"repeated","type":"ExtensionRange","id":5},"oneofDecl":{"rule":"repeated","type":"OneofDescriptorProto","id":8},"options":{"type":"MessageOptions","id":7},"reservedRange":{"rule":"repeated","type":"ReservedRange","id":9},"reservedName":{"rule":"repeated","type":"string","id":10}},"nested":{"ExtensionRange":{"fields":{"start":{"type":"int32","id":1},"end":{"type":"int32","id":2},"options":{"type":"ExtensionRangeOptions","id":3}}},"ReservedRange":{"fields":{"start":{"type":"int32","id":1},"end":{"type":"int32","id":2}}}}},"ExtensionRangeOptions":{"fields":{"uninterpretedOption":{"rule":"repeated","type":"UninterpretedOption","id":999}},"extensions":[[1000,536870911]]},"FieldDescriptorProto":{"fields":{"name":{"type":"string","id":1},"number":{"type":"int32","id":3},"label":{"type":"Label","id":4},"type":{"type":"Type","id":5},"typeName":{"type":"string","id":6},"extendee":{"type":"string","id":2},"defaultValue":{"type":"string","id":7},"oneofIndex":{"type":"int32","id":9},"jsonName":{"type":"string","id":10},"options":{"type":"FieldOptions","id":8},"proto3Optional":{"type":"bool","id":17}},"nested":{"Type":{"values":{"TYPE_DOUBLE":1,"TYPE_FLOAT":2,"TYPE_INT64":3,"TYPE_UINT64":4,"TYPE_INT32":5,"TYPE_FIXED64":6,"TYPE_FIXED32":7,"TYPE_BOOL":8,"TYPE_STRING":9,"TYPE_GROUP":10,"TYPE_MESSAGE":11,"TYPE_BYTES":12,"TYPE_UINT32":13,"TYPE_ENUM":14,"TYPE_SFIXED32":15,"TYPE_SFIXED64":16,"TYPE_SINT32":17,"TYPE_SINT64":18}},"Label":{"values":{"LABEL_OPTIONAL":1,"LABEL_REQUIRED":2,"LABEL_REPEATED":3}}}},"OneofDescriptorProto":{"fields":{"name":{"type":"string","id":1},"options":{"type":"OneofOptions","id":2}}},"EnumDescriptorProto":{"fields":{"name":{"type":"string","id":1},"value":{"rule":"repeated","type":"EnumValueDescriptorProto","id":2},"options":{"type":"EnumOptions","id":3},"reservedRange":{"rule":"repeated","type":"EnumReservedRange","id":4},"reservedName":{"rule":"repeated","type":"string","id":5}},"nested":{"EnumReservedRange":{"fields":{"start":{"type":"int32","id":1},"end":{"type":"int32","id":2}}}}},"EnumValueDescriptorProto":{"fields":{"name":{"type":"string","id":1},"number":{"type":"int32","id":2},"options":{"type":"EnumValueOptions","id":3}}},"ServiceDescriptorProto":{"fields":{"name":{"type":"string","id":1},"method":{"rule":"repeated","type":"MethodDescriptorProto","id":2},"options":{"type":"ServiceOptions","id":3}}},"MethodDescriptorProto":{"fields":{"name":{"type":"string","id":1},"inputType":{"type":"string","id":2},"outputType":{"type":"string","id":3},"options":{"type":"MethodOptions","id":4},"clientStreaming":{"type":"bool","id":5,"options":{"default":false}},"serverStreaming":{"type":"bool","id":6,"options":{"default":false}}}},"FileOptions":{"fields":{"javaPackage":{"type":"string","id":1},"javaOuterClassname":{"type":"string","id":8},"javaMultipleFiles":{"type":"bool","id":10,"options":{"default":false}},"javaGenerateEqualsAndHash":{"type":"bool","id":20,"options":{"deprecated":true}},"javaStringCheckUtf8":{"type":"bool","id":27,"options":{"default":false}},"optimizeFor":{"type":"OptimizeMode","id":9,"options":{"default":"SPEED"}},"goPackage":{"type":"string","id":11},"ccGenericServices":{"type":"bool","id":16,"options":{"default":false}},"javaGenericServices":{"type":"bool","id":17,"options":{"default":false}},"pyGenericServices":{"type":"bool","id":18,"options":{"default":false}},"phpGenericServices":{"type":"bool","id":42,"options":{"default":false}},"deprecated":{"type":"bool","id":23,"options":{"default":false}},"ccEnableArenas":{"type":"bool","id":31,"options":{"default":true}},"objcClassPrefix":{"type":"string","id":36},"csharpNamespace":{"type":"string","id":37},"swiftPrefix":{"type":"string","id":39},"phpClassPrefix":{"type":"string","id":40},"phpNamespace":{"type":"string","id":41},"phpMetadataNamespace":{"type":"string","id":44},"rubyPackage":{"type":"string","id":45},"uninterpretedOption":{"rule":"repeated","type":"UninterpretedOption","id":999}},"extensions":[[1000,536870911]],"reserved":[[38,38]],"nested":{"OptimizeMode":{"values":{"SPEED":1,"CODE_SIZE":2,"LITE_RUNTIME":3}}}},"MessageOptions":{"fields":{"messageSetWireFormat":{"type":"bool","id":1,"options":{"default":false}},"noStandardDescriptorAccessor":{"type":"bool","id":2,"options":{"default":false}},"deprecated":{"type":"bool","id":3,"options":{"default":false}},"mapEntry":{"type":"bool","id":7},"uninterpretedOption":{"rule":"repeated","type":"UninterpretedOption","id":999}},"extensions":[[1000,536870911]],"reserved":[[8,8],[9,9]]},"FieldOptions":{"fields":{"ctype":{"type":"CType","id":1,"options":{"default":"STRING"}},"packed":{"type":"bool","id":2},"jstype":{"type":"JSType","id":6,"options":{"default":"JS_NORMAL"}},"lazy":{"type":"bool","id":5,"options":{"default":false}},"deprecated":{"type":"bool","id":3,"options":{"default":false}},"weak":{"type":"bool","id":10,"options":{"default":false}},"uninterpretedOption":{"rule":"repeated","type":"UninterpretedOption","id":999}},"extensions":[[1000,536870911]],"reserved":[[4,4]],"nested":{"CType":{"values":{"STRING":0,"CORD":1,"STRING_PIECE":2}},"JSType":{"values":{"JS_NORMAL":0,"JS_STRING":1,"JS_NUMBER":2}}}},"OneofOptions":{"fields":{"uninterpretedOption":{"rule":"repeated","type":"UninterpretedOption","id":999}},"extensions":[[1000,536870911]]},"EnumOptions":{"fields":{"allowAlias":{"type":"bool","id":2},"deprecated":{"type":"bool","id":3,"options":{"default":false}},"uninterpretedOption":{"rule":"repeated","type":"UninterpretedOption","id":999}},"extensions":[[1000,536870911]],"reserved":[[5,5]]},"EnumValueOptions":{"fields":{"deprecated":{"type":"bool","id":1,"options":{"default":false}},"uninterpretedOption":{"rule":"repeated","type":"UninterpretedOption","id":999}},"extensions":[[1000,536870911]]},"ServiceOptions":{"fields":{"deprecated":{"type":"bool","id":33,"options":{"default":false}},"uninterpretedOption":{"rule":"repeated","type":"UninterpretedOption","id":999}},"extensions":[[1000,536870911]]},"MethodOptions":{"fields":{"deprecated":{"type":"bool","id":33,"options":{"default":false}},"idempotencyLevel":{"type":"IdempotencyLevel","id":34,"options":{"default":"IDEMPOTENCY_UNKNOWN"}},"uninterpretedOption":{"rule":"repeated","type":"UninterpretedOption","id":999}},"extensions":[[1000,536870911]],"nested":{"IdempotencyLevel":{"values":{"IDEMPOTENCY_UNKNOWN":0,"NO_SIDE_EFFECTS":1,"IDEMPOTENT":2}}}},"UninterpretedOption":{"fields":{"name":{"rule":"repeated","type":"NamePart","id":2},"identifierValue":{"type":"string","id":3},"positiveIntValue":{"type":"uint64","id":4},"negativeIntValue":{"type":"int64","id":5},"doubleValue":{"type":"double","id":6},"stringValue":{"type":"bytes","id":7},"aggregateValue":{"type":"string","id":8}},"nested":{"NamePart":{"fields":{"namePart":{"rule":"required","type":"string","id":1},"isExtension":{"rule":"required","type":"bool","id":2}}}}},"SourceCodeInfo":{"fields":{"location":{"rule":"repeated","type":"Location","id":1}},"nested":{"Location":{"fields":{"path":{"rule":"repeated","type":"int32","id":1},"span":{"rule":"repeated","type":"int32","id":2},"leadingComments":{"type":"string","id":3},"trailingComments":{"type":"string","id":4},"leadingDetachedComments":{"rule":"repeated","type":"string","id":6}}}}},"GeneratedCodeInfo":{"fields":{"annotation":{"rule":"repeated","type":"Annotation","id":1}},"nested":{"Annotation":{"fields":{"path":{"rule":"repeated","type":"int32","id":1},"sourceFile":{"type":"string","id":2},"begin":{"type":"int32","id":3},"end":{"type":"int32","id":4}}}}},"Struct":{"fields":{"fields":{"keyType":"string","type":"Value","id":1}}},"Value":{"oneofs":{"kind":{"oneof":["nullValue","numberValue","stringValue","boolValue","structValue","listValue"]}},"fields":{"nullValue":{"type":"NullValue","id":1},"numberValue":{"type":"double","id":2},"stringValue":{"type":"string","id":3},"boolValue":{"type":"bool","id":4},"structValue":{"type":"Struct","id":5},"listValue":{"type":"ListValue","id":6}}},"NullValue":{"values":{"NULL_VALUE":0}},"ListValue":{"fields":{"values":{"rule":"repeated","type":"Value","id":1}}},"Duration":{"fields":{"seconds":{"type":"int64","id":1},"nanos":{"type":"int32","id":2}}},"Any":{"fields":{"type_url":{"type":"string","id":1},"value":{"type":"bytes","id":2}}},"Timestamp":{"fields":{"seconds":{"type":"int64","id":1},"nanos":{"type":"int32","id":2}}},"Empty":{"fields":{}},"FieldMask":{"fields":{"paths":{"rule":"repeated","type":"string","id":1}}}}},"rpc":{"options":{"cc_enable_arenas":true,"go_package":"google.golang.org/genproto/googleapis/rpc/status;status","java_multiple_files":true,"java_outer_classname":"StatusProto","java_package":"com.google.rpc","objc_class_prefix":"RPC"},"nested":{"Status":{"fields":{"code":{"type":"int32","id":1},"message":{"type":"string","id":2},"details":{"rule":"repeated","type":"google.protobuf.Any","id":3}}}}}}}}}' + ) + + /***/ + }, + + /***/ 75821: /***/ module => { + 'use strict' + module.exports = JSON.parse( + '{"interfaces":{"google.logging.v2.ConfigServiceV2":{"retry_codes":{"non_idempotent":[],"idempotent":["DEADLINE_EXCEEDED","UNAVAILABLE"],"deadline_exceeded_internal_unavailable":["DEADLINE_EXCEEDED","INTERNAL","UNAVAILABLE"]},"retry_params":{"default":{"initial_retry_delay_millis":100,"retry_delay_multiplier":1.3,"max_retry_delay_millis":60000,"initial_rpc_timeout_millis":60000,"rpc_timeout_multiplier":1,"max_rpc_timeout_millis":60000,"total_timeout_millis":600000}},"methods":{"ListBuckets":{"retry_codes_name":"non_idempotent","retry_params_name":"default"},"GetBucket":{"retry_codes_name":"non_idempotent","retry_params_name":"default"},"UpdateBucket":{"retry_codes_name":"non_idempotent","retry_params_name":"default"},"ListSinks":{"timeout_millis":60000,"retry_codes_name":"deadline_exceeded_internal_unavailable","retry_params_name":"default"},"GetSink":{"timeout_millis":60000,"retry_codes_name":"deadline_exceeded_internal_unavailable","retry_params_name":"default"},"CreateSink":{"timeout_millis":120000,"retry_codes_name":"non_idempotent","retry_params_name":"default"},"UpdateSink":{"timeout_millis":60000,"retry_codes_name":"deadline_exceeded_internal_unavailable","retry_params_name":"default"},"DeleteSink":{"timeout_millis":60000,"retry_codes_name":"deadline_exceeded_internal_unavailable","retry_params_name":"default"},"ListExclusions":{"timeout_millis":60000,"retry_codes_name":"deadline_exceeded_internal_unavailable","retry_params_name":"default"},"GetExclusion":{"timeout_millis":60000,"retry_codes_name":"deadline_exceeded_internal_unavailable","retry_params_name":"default"},"CreateExclusion":{"timeout_millis":120000,"retry_codes_name":"non_idempotent","retry_params_name":"default"},"UpdateExclusion":{"timeout_millis":120000,"retry_codes_name":"non_idempotent","retry_params_name":"default"},"DeleteExclusion":{"timeout_millis":60000,"retry_codes_name":"deadline_exceeded_internal_unavailable","retry_params_name":"default"},"GetCmekSettings":{"retry_codes_name":"non_idempotent","retry_params_name":"default"},"UpdateCmekSettings":{"retry_codes_name":"non_idempotent","retry_params_name":"default"}}}}}' + ) + + /***/ + }, + + /***/ 34742: /***/ module => { + 'use strict' + module.exports = JSON.parse( + '{"interfaces":{"google.logging.v2.LoggingServiceV2":{"retry_codes":{"non_idempotent":[],"idempotent":["DEADLINE_EXCEEDED","UNAVAILABLE"],"deadline_exceeded_internal_unavailable":["DEADLINE_EXCEEDED","INTERNAL","UNAVAILABLE"]},"retry_params":{"default":{"initial_retry_delay_millis":100,"retry_delay_multiplier":1.3,"max_retry_delay_millis":60000,"initial_rpc_timeout_millis":60000,"rpc_timeout_multiplier":1,"max_rpc_timeout_millis":60000,"total_timeout_millis":600000}},"methods":{"DeleteLog":{"timeout_millis":60000,"retry_codes_name":"deadline_exceeded_internal_unavailable","retry_params_name":"default"},"WriteLogEntries":{"timeout_millis":60000,"retry_codes_name":"deadline_exceeded_internal_unavailable","retry_params_name":"default","bundling":{"element_count_threshold":1000,"request_byte_threshold":1048576,"delay_threshold_millis":50,"element_count_limit":1000000}},"ListLogEntries":{"timeout_millis":60000,"retry_codes_name":"deadline_exceeded_internal_unavailable","retry_params_name":"default"},"ListMonitoredResourceDescriptors":{"timeout_millis":60000,"retry_codes_name":"deadline_exceeded_internal_unavailable","retry_params_name":"default"},"ListLogs":{"timeout_millis":60000,"retry_codes_name":"deadline_exceeded_internal_unavailable","retry_params_name":"default"}}}}}' + ) + + /***/ + }, + + /***/ 95739: /***/ module => { + 'use strict' + module.exports = JSON.parse( + '{"interfaces":{"google.logging.v2.MetricsServiceV2":{"retry_codes":{"non_idempotent":[],"idempotent":["DEADLINE_EXCEEDED","UNAVAILABLE"],"deadline_exceeded_internal_unavailable":["DEADLINE_EXCEEDED","INTERNAL","UNAVAILABLE"]},"retry_params":{"default":{"initial_retry_delay_millis":100,"retry_delay_multiplier":1.3,"max_retry_delay_millis":60000,"initial_rpc_timeout_millis":60000,"rpc_timeout_multiplier":1,"max_rpc_timeout_millis":60000,"total_timeout_millis":600000}},"methods":{"ListLogMetrics":{"timeout_millis":60000,"retry_codes_name":"deadline_exceeded_internal_unavailable","retry_params_name":"default"},"GetLogMetric":{"timeout_millis":60000,"retry_codes_name":"deadline_exceeded_internal_unavailable","retry_params_name":"default"},"CreateLogMetric":{"timeout_millis":60000,"retry_codes_name":"non_idempotent","retry_params_name":"default"},"UpdateLogMetric":{"timeout_millis":60000,"retry_codes_name":"deadline_exceeded_internal_unavailable","retry_params_name":"default"},"DeleteLogMetric":{"timeout_millis":60000,"retry_codes_name":"deadline_exceeded_internal_unavailable","retry_params_name":"default"}}}}}' + ) + + /***/ + }, + + /***/ 87989: /***/ module => { + 'use strict' + module.exports = { i8: '8.1.0' } + + /***/ + }, + + /***/ 68160: /***/ module => { + 'use strict' + module.exports = JSON.parse( + '{"h$":{"d":"^8.13.0 || >=10.10.0"},"i8":"1.1.8"}' + ) + + /***/ + }, + + /***/ 9674: /***/ module => { + 'use strict' + module.exports = JSON.parse( + '{"_from":"@octokit/rest@16.43.1","_id":"@octokit/rest@16.43.1","_inBundle":false,"_integrity":"sha512-gfFKwRT/wFxq5qlNjnW2dh+qh74XgTQ2B179UX5K1HYCluioWj8Ndbgqw2PVqa1NnVJkGHp2ovMpVn/DImlmkw==","_location":"/@octokit/rest","_phantomChildren":{"@octokit/types":"2.16.2","deprecation":"2.3.1","once":"1.4.0"},"_requested":{"type":"version","registry":true,"raw":"@octokit/rest@16.43.1","name":"@octokit/rest","escapedName":"@octokit%2frest","scope":"@octokit","rawSpec":"16.43.1","saveSpec":null,"fetchSpec":"16.43.1"},"_requiredBy":["/@actions/github"],"_resolved":"https://registry.npmjs.org/@octokit/rest/-/rest-16.43.1.tgz","_shasum":"3b11e7d1b1ac2bbeeb23b08a17df0b20947eda6b","_spec":"@octokit/rest@16.43.1","_where":"D:\\\\Repositories\\\\devspace\\\\Videndum\\\\projects\\\\super-labeler-action\\\\node_modules\\\\@actions\\\\github","author":{"name":"Gregor Martynus","url":"https://github.com/gr2m"},"bugs":{"url":"https://github.com/octokit/rest.js/issues"},"bundleDependencies":false,"bundlesize":[{"path":"./dist/octokit-rest.min.js.gz","maxSize":"33 kB"}],"contributors":[{"name":"Mike de Boer","email":"info@mikedeboer.nl"},{"name":"Fabian Jakobs","email":"fabian@c9.io"},{"name":"Joe Gallo","email":"joe@brassafrax.com"},{"name":"Gregor Martynus","url":"https://github.com/gr2m"}],"dependencies":{"@octokit/auth-token":"^2.4.0","@octokit/plugin-paginate-rest":"^1.1.1","@octokit/plugin-request-log":"^1.0.0","@octokit/plugin-rest-endpoint-methods":"2.4.0","@octokit/request":"^5.2.0","@octokit/request-error":"^1.0.2","atob-lite":"^2.0.0","before-after-hook":"^2.0.0","btoa-lite":"^1.0.0","deprecation":"^2.0.0","lodash.get":"^4.4.2","lodash.set":"^4.3.2","lodash.uniq":"^4.5.0","octokit-pagination-methods":"^1.1.0","once":"^1.4.0","universal-user-agent":"^4.0.0"},"deprecated":false,"description":"GitHub REST API client for Node.js","devDependencies":{"@gimenete/type-writer":"^0.1.3","@octokit/auth":"^1.1.1","@octokit/fixtures-server":"^5.0.6","@octokit/graphql":"^4.2.0","@types/node":"^13.1.0","bundlesize":"^0.18.0","chai":"^4.1.2","compression-webpack-plugin":"^3.1.0","cypress":"^3.0.0","glob":"^7.1.2","http-proxy-agent":"^4.0.0","lodash.camelcase":"^4.3.0","lodash.merge":"^4.6.1","lodash.upperfirst":"^4.3.1","lolex":"^5.1.2","mkdirp":"^1.0.0","mocha":"^7.0.1","mustache":"^4.0.0","nock":"^11.3.3","npm-run-all":"^4.1.2","nyc":"^15.0.0","prettier":"^1.14.2","proxy":"^1.0.0","semantic-release":"^17.0.0","sinon":"^8.0.0","sinon-chai":"^3.0.0","sort-keys":"^4.0.0","string-to-arraybuffer":"^1.0.0","string-to-jsdoc-comment":"^1.0.0","typescript":"^3.3.1","webpack":"^4.0.0","webpack-bundle-analyzer":"^3.0.0","webpack-cli":"^3.0.0"},"files":["index.js","index.d.ts","lib","plugins"],"homepage":"https://github.com/octokit/rest.js#readme","keywords":["octokit","github","rest","api-client"],"license":"MIT","name":"@octokit/rest","nyc":{"ignore":["test"]},"publishConfig":{"access":"public"},"release":{"publish":["@semantic-release/npm",{"path":"@semantic-release/github","assets":["dist/*","!dist/*.map.gz"]}]},"repository":{"type":"git","url":"git+https://github.com/octokit/rest.js.git"},"scripts":{"build":"npm-run-all build:*","build:browser":"npm-run-all build:browser:*","build:browser:development":"webpack --mode development --entry . --output-library=Octokit --output=./dist/octokit-rest.js --profile --json > dist/bundle-stats.json","build:browser:production":"webpack --mode production --entry . --plugin=compression-webpack-plugin --output-library=Octokit --output-path=./dist --output-filename=octokit-rest.min.js --devtool source-map","build:ts":"npm run -s update-endpoints:typescript","coverage":"nyc report --reporter=html && open coverage/index.html","generate-bundle-report":"webpack-bundle-analyzer dist/bundle-stats.json --mode=static --no-open --report dist/bundle-report.html","lint":"prettier --check \'{lib,plugins,scripts,test}/**/*.{js,json,ts}\' \'docs/*.{js,json}\' \'docs/src/**/*\' index.js README.md package.json","lint:fix":"prettier --write \'{lib,plugins,scripts,test}/**/*.{js,json,ts}\' \'docs/*.{js,json}\' \'docs/src/**/*\' index.js README.md package.json","postvalidate:ts":"tsc --noEmit --target es6 test/typescript-validate.ts","prebuild:browser":"mkdirp dist/","pretest":"npm run -s lint","prevalidate:ts":"npm run -s build:ts","start-fixtures-server":"octokit-fixtures-server","test":"nyc mocha test/mocha-node-setup.js \\"test/*/**/*-test.js\\"","test:browser":"cypress run --browser chrome","update-endpoints":"npm-run-all update-endpoints:*","update-endpoints:fetch-json":"node scripts/update-endpoints/fetch-json","update-endpoints:typescript":"node scripts/update-endpoints/typescript","validate:ts":"tsc --target es6 --noImplicitAny index.d.ts"},"types":"index.d.ts","version":"16.43.1"}' + ) + + /***/ + }, + + /***/ 87351: /***/ function ( + __unused_webpack_module, + exports, + __webpack_require__ + ) { + 'use strict' + + var __importStar = + (this && this.__importStar) || + function (mod) { + if (mod && mod.__esModule) return mod + var result = {} + if (mod != null) + for (var k in mod) + if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k] + result['default'] = mod + return result + } + Object.defineProperty(exports, '__esModule', { value: true }) + const os = __importStar(__webpack_require__(12087)) + const utils_1 = __webpack_require__(5278) + /** + * Commands + * + * Command Format: + * ::name key=value,key=value::message + * + * Examples: + * ::warning::This is the message + * ::set-env name=MY_VAR::some value + */ + function issueCommand(command, properties, message) { + const cmd = new Command(command, properties, message) + process.stdout.write(cmd.toString() + os.EOL) + } + exports.issueCommand = issueCommand + function issue(name, message = '') { + issueCommand(name, {}, message) + } + exports.issue = issue + const CMD_STRING = '::' + class Command { + constructor(command, properties, message) { + if (!command) { + command = 'missing.command' + } + this.command = command + this.properties = properties + this.message = message + } + toString() { + let cmdStr = CMD_STRING + this.command + if (this.properties && Object.keys(this.properties).length > 0) { + cmdStr += ' ' + let first = true for (const key in this.properties) { - if (this.properties.hasOwnProperty(key)) { - const val = this.properties[key]; - if (val) { - if (first) { - first = false; - } - else { - cmdStr += ','; - } - cmdStr += `${key}=${escapeProperty(val)}`; - } + if (this.properties.hasOwnProperty(key)) { + const val = this.properties[key] + if (val) { + if (first) { + first = false + } else { + cmdStr += ',' + } + cmdStr += `${key}=${escapeProperty(val)}` } + } } + } + cmdStr += `${CMD_STRING}${escapeData(this.message)}` + return cmdStr } - cmdStr += `${CMD_STRING}${escapeData(this.message)}`; - return cmdStr; - } -} -function escapeData(s) { - return utils_1.toCommandValue(s) - .replace(/%/g, '%25') - .replace(/\r/g, '%0D') - .replace(/\n/g, '%0A'); -} -function escapeProperty(s) { - return utils_1.toCommandValue(s) - .replace(/%/g, '%25') - .replace(/\r/g, '%0D') - .replace(/\n/g, '%0A') - .replace(/:/g, '%3A') - .replace(/,/g, '%2C'); -} -//# sourceMappingURL=command.js.map - -/***/ }), - -/***/ 2186: -/***/ (function(__unused_webpack_module, exports, __webpack_require__) { - -"use strict"; - -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -const command_1 = __webpack_require__(7351); -const file_command_1 = __webpack_require__(717); -const utils_1 = __webpack_require__(5278); -const os = __importStar(__webpack_require__(2087)); -const path = __importStar(__webpack_require__(5622)); -/** - * The code to exit an action - */ -var ExitCode; -(function (ExitCode) { - /** - * A code indicating that the action was successful - */ - ExitCode[ExitCode["Success"] = 0] = "Success"; - /** - * A code indicating that the action was a failure - */ - ExitCode[ExitCode["Failure"] = 1] = "Failure"; -})(ExitCode = exports.ExitCode || (exports.ExitCode = {})); -//----------------------------------------------------------------------- -// Variables -//----------------------------------------------------------------------- -/** - * Sets env variable for this action and future actions in the job - * @param name the name of the variable to set - * @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify - */ -// eslint-disable-next-line @typescript-eslint/no-explicit-any -function exportVariable(name, val) { - const convertedVal = utils_1.toCommandValue(val); - process.env[name] = convertedVal; - const filePath = process.env['GITHUB_ENV'] || ''; - if (filePath) { - const delimiter = '_GitHubActionsFileCommandDelimeter_'; - const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`; - file_command_1.issueCommand('ENV', commandValue); - } - else { - command_1.issueCommand('set-env', { name }, convertedVal); - } -} -exports.exportVariable = exportVariable; -/** - * Registers a secret which will get masked from logs - * @param secret value of the secret - */ -function setSecret(secret) { - command_1.issueCommand('add-mask', {}, secret); -} -exports.setSecret = setSecret; -/** - * Prepends inputPath to the PATH (for this action and future actions) - * @param inputPath - */ -function addPath(inputPath) { - const filePath = process.env['GITHUB_PATH'] || ''; - if (filePath) { - file_command_1.issueCommand('PATH', inputPath); - } - else { - command_1.issueCommand('add-path', {}, inputPath); - } - process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`; -} -exports.addPath = addPath; -/** - * Gets the value of an input. The value is also trimmed. - * - * @param name name of the input to get - * @param options optional. See InputOptions. - * @returns string - */ -function getInput(name, options) { - const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || ''; - if (options && options.required && !val) { - throw new Error(`Input required and not supplied: ${name}`); - } - return val.trim(); -} -exports.getInput = getInput; -/** - * Sets the value of an output. - * - * @param name name of the output to set - * @param value value to store. Non-string values will be converted to a string via JSON.stringify - */ -// eslint-disable-next-line @typescript-eslint/no-explicit-any -function setOutput(name, value) { - command_1.issueCommand('set-output', { name }, value); -} -exports.setOutput = setOutput; -/** - * Enables or disables the echoing of commands into stdout for the rest of the step. - * Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set. - * - */ -function setCommandEcho(enabled) { - command_1.issue('echo', enabled ? 'on' : 'off'); -} -exports.setCommandEcho = setCommandEcho; -//----------------------------------------------------------------------- -// Results -//----------------------------------------------------------------------- -/** - * Sets the action status to failed. - * When the action exits it will be with an exit code of 1 - * @param message add error issue message - */ -function setFailed(message) { - process.exitCode = ExitCode.Failure; - error(message); -} -exports.setFailed = setFailed; -//----------------------------------------------------------------------- -// Logging Commands -//----------------------------------------------------------------------- -/** - * Gets whether Actions Step Debug is on or not - */ -function isDebug() { - return process.env['RUNNER_DEBUG'] === '1'; -} -exports.isDebug = isDebug; -/** - * Writes debug message to user log - * @param message debug message - */ -function debug(message) { - command_1.issueCommand('debug', {}, message); -} -exports.debug = debug; -/** - * Adds an error issue - * @param message error issue message. Errors will be converted to string via toString() - */ -function error(message) { - command_1.issue('error', message instanceof Error ? message.toString() : message); -} -exports.error = error; -/** - * Adds an warning issue - * @param message warning issue message. Errors will be converted to string via toString() - */ -function warning(message) { - command_1.issue('warning', message instanceof Error ? message.toString() : message); -} -exports.warning = warning; -/** - * Writes info to log with console.log. - * @param message info message - */ -function info(message) { - process.stdout.write(message + os.EOL); -} -exports.info = info; -/** - * Begin an output group. - * - * Output until the next `groupEnd` will be foldable in this group - * - * @param name The name of the output group - */ -function startGroup(name) { - command_1.issue('group', name); -} -exports.startGroup = startGroup; -/** - * End an output group. - */ -function endGroup() { - command_1.issue('endgroup'); -} -exports.endGroup = endGroup; -/** - * Wrap an asynchronous function call in a group. - * - * Returns the same type as the function itself. - * - * @param name The name of the group - * @param fn The function to wrap in the group - */ -function group(name, fn) { - return __awaiter(this, void 0, void 0, function* () { - startGroup(name); - let result; - try { - result = yield fn(); - } - finally { - endGroup(); - } - return result; - }); -} -exports.group = group; -//----------------------------------------------------------------------- -// Wrapper action state -//----------------------------------------------------------------------- -/** - * Saves state for current action, the state can only be retrieved by this action's post job execution. - * - * @param name name of the state to store - * @param value value to store. Non-string values will be converted to a string via JSON.stringify - */ -// eslint-disable-next-line @typescript-eslint/no-explicit-any -function saveState(name, value) { - command_1.issueCommand('save-state', { name }, value); -} -exports.saveState = saveState; -/** - * Gets the value of an state set by this action's main execution. - * - * @param name name of the state to get - * @returns string - */ -function getState(name) { - return process.env[`STATE_${name}`] || ''; -} -exports.getState = getState; -//# sourceMappingURL=core.js.map - -/***/ }), - -/***/ 717: -/***/ (function(__unused_webpack_module, exports, __webpack_require__) { - -"use strict"; - -// For internal use, subject to change. -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -// We use any as a valid input type -/* eslint-disable @typescript-eslint/no-explicit-any */ -const fs = __importStar(__webpack_require__(5747)); -const os = __importStar(__webpack_require__(2087)); -const utils_1 = __webpack_require__(5278); -function issueCommand(command, message) { - const filePath = process.env[`GITHUB_${command}`]; - if (!filePath) { - throw new Error(`Unable to find environment variable for file command ${command}`); - } - if (!fs.existsSync(filePath)) { - throw new Error(`Missing file at path: ${filePath}`); - } - fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, { - encoding: 'utf8' - }); -} -exports.issueCommand = issueCommand; -//# sourceMappingURL=file-command.js.map - -/***/ }), - -/***/ 5278: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -// We use any as a valid input type -/* eslint-disable @typescript-eslint/no-explicit-any */ -Object.defineProperty(exports, "__esModule", ({ value: true })); -/** - * Sanitizes an input into a string so it can be passed into issueCommand safely - * @param input input to sanitize into a string - */ -function toCommandValue(input) { - if (input === null || input === undefined) { - return ''; - } - else if (typeof input === 'string' || input instanceof String) { - return input; - } - return JSON.stringify(input); -} -exports.toCommandValue = toCommandValue; -//# sourceMappingURL=utils.js.map - -/***/ }), - -/***/ 4087: -/***/ ((__unused_webpack_module, exports, __webpack_require__) => { - -"use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -const fs_1 = __webpack_require__(5747); -const os_1 = __webpack_require__(2087); -class Context { - /** - * Hydrate the context from the environment - */ - constructor() { - this.payload = {}; - if (process.env.GITHUB_EVENT_PATH) { - if (fs_1.existsSync(process.env.GITHUB_EVENT_PATH)) { - this.payload = JSON.parse(fs_1.readFileSync(process.env.GITHUB_EVENT_PATH, { encoding: 'utf8' })); + } + function escapeData(s) { + return utils_1 + .toCommandValue(s) + .replace(/%/g, '%25') + .replace(/\r/g, '%0D') + .replace(/\n/g, '%0A') + } + function escapeProperty(s) { + return utils_1 + .toCommandValue(s) + .replace(/%/g, '%25') + .replace(/\r/g, '%0D') + .replace(/\n/g, '%0A') + .replace(/:/g, '%3A') + .replace(/,/g, '%2C') + } + //# sourceMappingURL=command.js.map + + /***/ + }, + + /***/ 42186: /***/ function ( + __unused_webpack_module, + exports, + __webpack_require__ + ) { + 'use strict' + + var __awaiter = + (this && this.__awaiter) || + function (thisArg, _arguments, P, generator) { + function adopt(value) { + return value instanceof P + ? value + : new P(function (resolve) { + resolve(value) + }) + } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { + try { + step(generator.next(value)) + } catch (e) { + reject(e) + } } - else { - const path = process.env.GITHUB_EVENT_PATH; - process.stdout.write(`GITHUB_EVENT_PATH ${path} does not exist${os_1.EOL}`); + function rejected(value) { + try { + step(generator['throw'](value)) + } catch (e) { + reject(e) + } } + function step(result) { + result.done + ? resolve(result.value) + : adopt(result.value).then(fulfilled, rejected) + } + step( + (generator = generator.apply(thisArg, _arguments || [])).next() + ) + }) } - this.eventName = process.env.GITHUB_EVENT_NAME; - this.sha = process.env.GITHUB_SHA; - this.ref = process.env.GITHUB_REF; - this.workflow = process.env.GITHUB_WORKFLOW; - this.action = process.env.GITHUB_ACTION; - this.actor = process.env.GITHUB_ACTOR; - } - get issue() { - const payload = this.payload; - return Object.assign(Object.assign({}, this.repo), { number: (payload.issue || payload.pull_request || payload).number }); - } - get repo() { - if (process.env.GITHUB_REPOSITORY) { - const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/'); - return { owner, repo }; + var __importStar = + (this && this.__importStar) || + function (mod) { + if (mod && mod.__esModule) return mod + var result = {} + if (mod != null) + for (var k in mod) + if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k] + result['default'] = mod + return result + } + Object.defineProperty(exports, '__esModule', { value: true }) + const command_1 = __webpack_require__(87351) + const file_command_1 = __webpack_require__(717) + const utils_1 = __webpack_require__(5278) + const os = __importStar(__webpack_require__(12087)) + const path = __importStar(__webpack_require__(85622)) + /** + * The code to exit an action + */ + var ExitCode + ;(function (ExitCode) { + /** + * A code indicating that the action was successful + */ + ExitCode[(ExitCode['Success'] = 0)] = 'Success' + /** + * A code indicating that the action was a failure + */ + ExitCode[(ExitCode['Failure'] = 1)] = 'Failure' + })((ExitCode = exports.ExitCode || (exports.ExitCode = {}))) + //----------------------------------------------------------------------- + // Variables + //----------------------------------------------------------------------- + /** + * Sets env variable for this action and future actions in the job + * @param name the name of the variable to set + * @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function exportVariable(name, val) { + const convertedVal = utils_1.toCommandValue(val) + process.env[name] = convertedVal + const filePath = process.env['GITHUB_ENV'] || '' + if (filePath) { + const delimiter = '_GitHubActionsFileCommandDelimeter_' + const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}` + file_command_1.issueCommand('ENV', commandValue) + } else { + command_1.issueCommand('set-env', { name }, convertedVal) + } + } + exports.exportVariable = exportVariable + /** + * Registers a secret which will get masked from logs + * @param secret value of the secret + */ + function setSecret(secret) { + command_1.issueCommand('add-mask', {}, secret) + } + exports.setSecret = setSecret + /** + * Prepends inputPath to the PATH (for this action and future actions) + * @param inputPath + */ + function addPath(inputPath) { + const filePath = process.env['GITHUB_PATH'] || '' + if (filePath) { + file_command_1.issueCommand('PATH', inputPath) + } else { + command_1.issueCommand('add-path', {}, inputPath) + } + process.env[ + 'PATH' + ] = `${inputPath}${path.delimiter}${process.env['PATH']}` + } + exports.addPath = addPath + /** + * Gets the value of an input. The value is also trimmed. + * + * @param name name of the input to get + * @param options optional. See InputOptions. + * @returns string + */ + function getInput(name, options) { + const val = + process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || '' + if (options && options.required && !val) { + throw new Error(`Input required and not supplied: ${name}`) + } + return val.trim() + } + exports.getInput = getInput + /** + * Sets the value of an output. + * + * @param name name of the output to set + * @param value value to store. Non-string values will be converted to a string via JSON.stringify + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function setOutput(name, value) { + command_1.issueCommand('set-output', { name }, value) + } + exports.setOutput = setOutput + /** + * Enables or disables the echoing of commands into stdout for the rest of the step. + * Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set. + * + */ + function setCommandEcho(enabled) { + command_1.issue('echo', enabled ? 'on' : 'off') + } + exports.setCommandEcho = setCommandEcho + //----------------------------------------------------------------------- + // Results + //----------------------------------------------------------------------- + /** + * Sets the action status to failed. + * When the action exits it will be with an exit code of 1 + * @param message add error issue message + */ + function setFailed(message) { + process.exitCode = ExitCode.Failure + error(message) + } + exports.setFailed = setFailed + //----------------------------------------------------------------------- + // Logging Commands + //----------------------------------------------------------------------- + /** + * Gets whether Actions Step Debug is on or not + */ + function isDebug() { + return process.env['RUNNER_DEBUG'] === '1' + } + exports.isDebug = isDebug + /** + * Writes debug message to user log + * @param message debug message + */ + function debug(message) { + command_1.issueCommand('debug', {}, message) + } + exports.debug = debug + /** + * Adds an error issue + * @param message error issue message. Errors will be converted to string via toString() + */ + function error(message) { + command_1.issue( + 'error', + message instanceof Error ? message.toString() : message + ) + } + exports.error = error + /** + * Adds an warning issue + * @param message warning issue message. Errors will be converted to string via toString() + */ + function warning(message) { + command_1.issue( + 'warning', + message instanceof Error ? message.toString() : message + ) + } + exports.warning = warning + /** + * Writes info to log with console.log. + * @param message info message + */ + function info(message) { + process.stdout.write(message + os.EOL) + } + exports.info = info + /** + * Begin an output group. + * + * Output until the next `groupEnd` will be foldable in this group + * + * @param name The name of the output group + */ + function startGroup(name) { + command_1.issue('group', name) + } + exports.startGroup = startGroup + /** + * End an output group. + */ + function endGroup() { + command_1.issue('endgroup') + } + exports.endGroup = endGroup + /** + * Wrap an asynchronous function call in a group. + * + * Returns the same type as the function itself. + * + * @param name The name of the group + * @param fn The function to wrap in the group + */ + function group(name, fn) { + return __awaiter(this, void 0, void 0, function* () { + startGroup(name) + let result + try { + result = yield fn() + } finally { + endGroup() + } + return result + }) + } + exports.group = group + //----------------------------------------------------------------------- + // Wrapper action state + //----------------------------------------------------------------------- + /** + * Saves state for current action, the state can only be retrieved by this action's post job execution. + * + * @param name name of the state to store + * @param value value to store. Non-string values will be converted to a string via JSON.stringify + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function saveState(name, value) { + command_1.issueCommand('save-state', { name }, value) + } + exports.saveState = saveState + /** + * Gets the value of an state set by this action's main execution. + * + * @param name name of the state to get + * @returns string + */ + function getState(name) { + return process.env[`STATE_${name}`] || '' + } + exports.getState = getState + //# sourceMappingURL=core.js.map + + /***/ + }, + + /***/ 717: /***/ function ( + __unused_webpack_module, + exports, + __webpack_require__ + ) { + 'use strict' + + // For internal use, subject to change. + var __importStar = + (this && this.__importStar) || + function (mod) { + if (mod && mod.__esModule) return mod + var result = {} + if (mod != null) + for (var k in mod) + if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k] + result['default'] = mod + return result } - if (this.payload.repository) { + Object.defineProperty(exports, '__esModule', { value: true }) + // We use any as a valid input type + /* eslint-disable @typescript-eslint/no-explicit-any */ + const fs = __importStar(__webpack_require__(35747)) + const os = __importStar(__webpack_require__(12087)) + const utils_1 = __webpack_require__(5278) + function issueCommand(command, message) { + const filePath = process.env[`GITHUB_${command}`] + if (!filePath) { + throw new Error( + `Unable to find environment variable for file command ${command}` + ) + } + if (!fs.existsSync(filePath)) { + throw new Error(`Missing file at path: ${filePath}`) + } + fs.appendFileSync( + filePath, + `${utils_1.toCommandValue(message)}${os.EOL}`, + { + encoding: 'utf8' + } + ) + } + exports.issueCommand = issueCommand + //# sourceMappingURL=file-command.js.map + + /***/ + }, + + /***/ 5278: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + // We use any as a valid input type + /* eslint-disable @typescript-eslint/no-explicit-any */ + Object.defineProperty(exports, '__esModule', { value: true }) + /** + * Sanitizes an input into a string so it can be passed into issueCommand safely + * @param input input to sanitize into a string + */ + function toCommandValue(input) { + if (input === null || input === undefined) { + return '' + } else if (typeof input === 'string' || input instanceof String) { + return input + } + return JSON.stringify(input) + } + exports.toCommandValue = toCommandValue + //# sourceMappingURL=utils.js.map + + /***/ + }, + + /***/ 74087: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + Object.defineProperty(exports, '__esModule', { value: true }) + const fs_1 = __webpack_require__(35747) + const os_1 = __webpack_require__(12087) + class Context { + /** + * Hydrate the context from the environment + */ + constructor() { + this.payload = {} + if (process.env.GITHUB_EVENT_PATH) { + if (fs_1.existsSync(process.env.GITHUB_EVENT_PATH)) { + this.payload = JSON.parse( + fs_1.readFileSync(process.env.GITHUB_EVENT_PATH, { + encoding: 'utf8' + }) + ) + } else { + const path = process.env.GITHUB_EVENT_PATH + process.stdout.write( + `GITHUB_EVENT_PATH ${path} does not exist${os_1.EOL}` + ) + } + } + this.eventName = process.env.GITHUB_EVENT_NAME + this.sha = process.env.GITHUB_SHA + this.ref = process.env.GITHUB_REF + this.workflow = process.env.GITHUB_WORKFLOW + this.action = process.env.GITHUB_ACTION + this.actor = process.env.GITHUB_ACTOR + } + get issue() { + const payload = this.payload + return Object.assign(Object.assign({}, this.repo), { + number: (payload.issue || payload.pull_request || payload).number + }) + } + get repo() { + if (process.env.GITHUB_REPOSITORY) { + const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/') + return { owner, repo } + } + if (this.payload.repository) { return { - owner: this.payload.repository.owner.login, - repo: this.payload.repository.name - }; + owner: this.payload.repository.owner.login, + repo: this.payload.repository.name + } + } + throw new Error( + "context.repo requires a GITHUB_REPOSITORY environment variable like 'owner/repo'" + ) } - throw new Error("context.repo requires a GITHUB_REPOSITORY environment variable like 'owner/repo'"); - } -} -exports.Context = Context; -//# sourceMappingURL=context.js.map - -/***/ }), - -/***/ 5438: -/***/ (function(__unused_webpack_module, exports, __webpack_require__) { - -"use strict"; - -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -// Originally pulled from https://github.com/JasonEtco/actions-toolkit/blob/master/src/github.ts -const graphql_1 = __webpack_require__(8467); -const rest_1 = __webpack_require__(9351); -const Context = __importStar(__webpack_require__(4087)); -const httpClient = __importStar(__webpack_require__(9925)); -// We need this in order to extend Octokit -rest_1.Octokit.prototype = new rest_1.Octokit(); -exports.context = new Context.Context(); -class GitHub extends rest_1.Octokit { - constructor(token, opts) { - super(GitHub.getOctokitOptions(GitHub.disambiguate(token, opts))); - this.graphql = GitHub.getGraphQL(GitHub.disambiguate(token, opts)); - } - /** - * Disambiguates the constructor overload parameters - */ - static disambiguate(token, opts) { - return [ + } + exports.Context = Context + //# sourceMappingURL=context.js.map + + /***/ + }, + + /***/ 95438: /***/ function ( + __unused_webpack_module, + exports, + __webpack_require__ + ) { + 'use strict' + + var __importStar = + (this && this.__importStar) || + function (mod) { + if (mod && mod.__esModule) return mod + var result = {} + if (mod != null) + for (var k in mod) + if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k] + result['default'] = mod + return result + } + Object.defineProperty(exports, '__esModule', { value: true }) + // Originally pulled from https://github.com/JasonEtco/actions-toolkit/blob/master/src/github.ts + const graphql_1 = __webpack_require__(88467) + const rest_1 = __webpack_require__(29351) + const Context = __importStar(__webpack_require__(74087)) + const httpClient = __importStar(__webpack_require__(39925)) + // We need this in order to extend Octokit + rest_1.Octokit.prototype = new rest_1.Octokit() + exports.context = new Context.Context() + class GitHub extends rest_1.Octokit { + constructor(token, opts) { + super(GitHub.getOctokitOptions(GitHub.disambiguate(token, opts))) + this.graphql = GitHub.getGraphQL(GitHub.disambiguate(token, opts)) + } + /** + * Disambiguates the constructor overload parameters + */ + static disambiguate(token, opts) { + return [ typeof token === 'string' ? token : '', typeof token === 'object' ? token : opts || {} - ]; - } - static getOctokitOptions(args) { - const token = args[0]; - const options = Object.assign({}, args[1]); // Shallow clone - don't mutate the object provided by the caller - // Auth - const auth = GitHub.getAuthString(token, options); - if (auth) { - options.auth = auth; - } - // Proxy - const agent = GitHub.getProxyAgent(options); - if (agent) { + ] + } + static getOctokitOptions(args) { + const token = args[0] + const options = Object.assign({}, args[1]) // Shallow clone - don't mutate the object provided by the caller + // Auth + const auth = GitHub.getAuthString(token, options) + if (auth) { + options.auth = auth + } + // Proxy + const agent = GitHub.getProxyAgent(options) + if (agent) { // Shallow clone - don't mutate the object provided by the caller - options.request = options.request ? Object.assign({}, options.request) : {}; + options.request = options.request + ? Object.assign({}, options.request) + : {} // Set the agent - options.request.agent = agent; + options.request.agent = agent + } + return options } - return options; - } - static getGraphQL(args) { - const defaults = {}; - const token = args[0]; - const options = args[1]; - // Authorization - const auth = this.getAuthString(token, options); - if (auth) { + static getGraphQL(args) { + const defaults = {} + const token = args[0] + const options = args[1] + // Authorization + const auth = this.getAuthString(token, options) + if (auth) { defaults.headers = { - authorization: auth - }; - } - // Proxy - const agent = GitHub.getProxyAgent(options); - if (agent) { - defaults.request = { agent }; - } - return graphql_1.graphql.defaults(defaults); - } - static getAuthString(token, options) { - // Validate args - if (!token && !options.auth) { - throw new Error('Parameter token or opts.auth is required'); + authorization: auth + } + } + // Proxy + const agent = GitHub.getProxyAgent(options) + if (agent) { + defaults.request = { agent } + } + return graphql_1.graphql.defaults(defaults) } - else if (token && options.auth) { - throw new Error('Parameters token and opts.auth may not both be specified'); + static getAuthString(token, options) { + // Validate args + if (!token && !options.auth) { + throw new Error('Parameter token or opts.auth is required') + } else if (token && options.auth) { + throw new Error( + 'Parameters token and opts.auth may not both be specified' + ) + } + return typeof options.auth === 'string' + ? options.auth + : `token ${token}` } - return typeof options.auth === 'string' ? options.auth : `token ${token}`; - } - static getProxyAgent(options) { - var _a; - if (!((_a = options.request) === null || _a === void 0 ? void 0 : _a.agent)) { - const serverUrl = 'https://api.github.com'; + static getProxyAgent(options) { + var _a + if ( + !((_a = options.request) === null || _a === void 0 + ? void 0 + : _a.agent) + ) { + const serverUrl = 'https://api.github.com' if (httpClient.getProxyUrl(serverUrl)) { - const hc = new httpClient.HttpClient(); - return hc.getAgent(serverUrl); + const hc = new httpClient.HttpClient() + return hc.getAgent(serverUrl) } + } + return undefined } - return undefined; - } -} -exports.GitHub = GitHub; -//# sourceMappingURL=github.js.map - -/***/ }), - -/***/ 9925: -/***/ ((__unused_webpack_module, exports, __webpack_require__) => { - -"use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -const url = __webpack_require__(8835); -const http = __webpack_require__(8605); -const https = __webpack_require__(7211); -const pm = __webpack_require__(6443); -let tunnel; -var HttpCodes; -(function (HttpCodes) { - HttpCodes[HttpCodes["OK"] = 200] = "OK"; - HttpCodes[HttpCodes["MultipleChoices"] = 300] = "MultipleChoices"; - HttpCodes[HttpCodes["MovedPermanently"] = 301] = "MovedPermanently"; - HttpCodes[HttpCodes["ResourceMoved"] = 302] = "ResourceMoved"; - HttpCodes[HttpCodes["SeeOther"] = 303] = "SeeOther"; - HttpCodes[HttpCodes["NotModified"] = 304] = "NotModified"; - HttpCodes[HttpCodes["UseProxy"] = 305] = "UseProxy"; - HttpCodes[HttpCodes["SwitchProxy"] = 306] = "SwitchProxy"; - HttpCodes[HttpCodes["TemporaryRedirect"] = 307] = "TemporaryRedirect"; - HttpCodes[HttpCodes["PermanentRedirect"] = 308] = "PermanentRedirect"; - HttpCodes[HttpCodes["BadRequest"] = 400] = "BadRequest"; - HttpCodes[HttpCodes["Unauthorized"] = 401] = "Unauthorized"; - HttpCodes[HttpCodes["PaymentRequired"] = 402] = "PaymentRequired"; - HttpCodes[HttpCodes["Forbidden"] = 403] = "Forbidden"; - HttpCodes[HttpCodes["NotFound"] = 404] = "NotFound"; - HttpCodes[HttpCodes["MethodNotAllowed"] = 405] = "MethodNotAllowed"; - HttpCodes[HttpCodes["NotAcceptable"] = 406] = "NotAcceptable"; - HttpCodes[HttpCodes["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired"; - HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout"; - HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict"; - HttpCodes[HttpCodes["Gone"] = 410] = "Gone"; - HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError"; - HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented"; - HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway"; - HttpCodes[HttpCodes["ServiceUnavailable"] = 503] = "ServiceUnavailable"; - HttpCodes[HttpCodes["GatewayTimeout"] = 504] = "GatewayTimeout"; -})(HttpCodes = exports.HttpCodes || (exports.HttpCodes = {})); -var Headers; -(function (Headers) { - Headers["Accept"] = "accept"; - Headers["ContentType"] = "content-type"; -})(Headers = exports.Headers || (exports.Headers = {})); -var MediaTypes; -(function (MediaTypes) { - MediaTypes["ApplicationJson"] = "application/json"; -})(MediaTypes = exports.MediaTypes || (exports.MediaTypes = {})); -/** - * Returns the proxy URL, depending upon the supplied url and proxy environment variables. - * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com - */ -function getProxyUrl(serverUrl) { - let proxyUrl = pm.getProxyUrl(url.parse(serverUrl)); - return proxyUrl ? proxyUrl.href : ''; -} -exports.getProxyUrl = getProxyUrl; -const HttpRedirectCodes = [HttpCodes.MovedPermanently, HttpCodes.ResourceMoved, HttpCodes.SeeOther, HttpCodes.TemporaryRedirect, HttpCodes.PermanentRedirect]; -const HttpResponseRetryCodes = [HttpCodes.BadGateway, HttpCodes.ServiceUnavailable, HttpCodes.GatewayTimeout]; -const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD']; -const ExponentialBackoffCeiling = 10; -const ExponentialBackoffTimeSlice = 5; -class HttpClientResponse { - constructor(message) { - this.message = message; - } - readBody() { - return new Promise(async (resolve, reject) => { - let output = Buffer.alloc(0); - this.message.on('data', (chunk) => { - output = Buffer.concat([output, chunk]); - }); + } + exports.GitHub = GitHub + //# sourceMappingURL=github.js.map + + /***/ + }, + + /***/ 39925: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + Object.defineProperty(exports, '__esModule', { value: true }) + const url = __webpack_require__(78835) + const http = __webpack_require__(98605) + const https = __webpack_require__(57211) + const pm = __webpack_require__(16443) + let tunnel + var HttpCodes + ;(function (HttpCodes) { + HttpCodes[(HttpCodes['OK'] = 200)] = 'OK' + HttpCodes[(HttpCodes['MultipleChoices'] = 300)] = 'MultipleChoices' + HttpCodes[(HttpCodes['MovedPermanently'] = 301)] = 'MovedPermanently' + HttpCodes[(HttpCodes['ResourceMoved'] = 302)] = 'ResourceMoved' + HttpCodes[(HttpCodes['SeeOther'] = 303)] = 'SeeOther' + HttpCodes[(HttpCodes['NotModified'] = 304)] = 'NotModified' + HttpCodes[(HttpCodes['UseProxy'] = 305)] = 'UseProxy' + HttpCodes[(HttpCodes['SwitchProxy'] = 306)] = 'SwitchProxy' + HttpCodes[(HttpCodes['TemporaryRedirect'] = 307)] = 'TemporaryRedirect' + HttpCodes[(HttpCodes['PermanentRedirect'] = 308)] = 'PermanentRedirect' + HttpCodes[(HttpCodes['BadRequest'] = 400)] = 'BadRequest' + HttpCodes[(HttpCodes['Unauthorized'] = 401)] = 'Unauthorized' + HttpCodes[(HttpCodes['PaymentRequired'] = 402)] = 'PaymentRequired' + HttpCodes[(HttpCodes['Forbidden'] = 403)] = 'Forbidden' + HttpCodes[(HttpCodes['NotFound'] = 404)] = 'NotFound' + HttpCodes[(HttpCodes['MethodNotAllowed'] = 405)] = 'MethodNotAllowed' + HttpCodes[(HttpCodes['NotAcceptable'] = 406)] = 'NotAcceptable' + HttpCodes[(HttpCodes['ProxyAuthenticationRequired'] = 407)] = + 'ProxyAuthenticationRequired' + HttpCodes[(HttpCodes['RequestTimeout'] = 408)] = 'RequestTimeout' + HttpCodes[(HttpCodes['Conflict'] = 409)] = 'Conflict' + HttpCodes[(HttpCodes['Gone'] = 410)] = 'Gone' + HttpCodes[(HttpCodes['InternalServerError'] = 500)] = + 'InternalServerError' + HttpCodes[(HttpCodes['NotImplemented'] = 501)] = 'NotImplemented' + HttpCodes[(HttpCodes['BadGateway'] = 502)] = 'BadGateway' + HttpCodes[(HttpCodes['ServiceUnavailable'] = 503)] = + 'ServiceUnavailable' + HttpCodes[(HttpCodes['GatewayTimeout'] = 504)] = 'GatewayTimeout' + })((HttpCodes = exports.HttpCodes || (exports.HttpCodes = {}))) + var Headers + ;(function (Headers) { + Headers['Accept'] = 'accept' + Headers['ContentType'] = 'content-type' + })((Headers = exports.Headers || (exports.Headers = {}))) + var MediaTypes + ;(function (MediaTypes) { + MediaTypes['ApplicationJson'] = 'application/json' + })((MediaTypes = exports.MediaTypes || (exports.MediaTypes = {}))) + /** + * Returns the proxy URL, depending upon the supplied url and proxy environment variables. + * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com + */ + function getProxyUrl(serverUrl) { + let proxyUrl = pm.getProxyUrl(url.parse(serverUrl)) + return proxyUrl ? proxyUrl.href : '' + } + exports.getProxyUrl = getProxyUrl + const HttpRedirectCodes = [ + HttpCodes.MovedPermanently, + HttpCodes.ResourceMoved, + HttpCodes.SeeOther, + HttpCodes.TemporaryRedirect, + HttpCodes.PermanentRedirect + ] + const HttpResponseRetryCodes = [ + HttpCodes.BadGateway, + HttpCodes.ServiceUnavailable, + HttpCodes.GatewayTimeout + ] + const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD'] + const ExponentialBackoffCeiling = 10 + const ExponentialBackoffTimeSlice = 5 + class HttpClientResponse { + constructor(message) { + this.message = message + } + readBody() { + return new Promise(async (resolve, reject) => { + let output = Buffer.alloc(0) + this.message.on('data', chunk => { + output = Buffer.concat([output, chunk]) + }) this.message.on('end', () => { - resolve(output.toString()); - }); - }); - } -} -exports.HttpClientResponse = HttpClientResponse; -function isHttps(requestUrl) { - let parsedUrl = url.parse(requestUrl); - return parsedUrl.protocol === 'https:'; -} -exports.isHttps = isHttps; -class HttpClient { - constructor(userAgent, handlers, requestOptions) { - this._ignoreSslError = false; - this._allowRedirects = true; - this._allowRedirectDowngrade = false; - this._maxRedirects = 50; - this._allowRetries = false; - this._maxRetries = 1; - this._keepAlive = false; - this._disposed = false; - this.userAgent = userAgent; - this.handlers = handlers || []; - this.requestOptions = requestOptions; - if (requestOptions) { + resolve(output.toString()) + }) + }) + } + } + exports.HttpClientResponse = HttpClientResponse + function isHttps(requestUrl) { + let parsedUrl = url.parse(requestUrl) + return parsedUrl.protocol === 'https:' + } + exports.isHttps = isHttps + class HttpClient { + constructor(userAgent, handlers, requestOptions) { + this._ignoreSslError = false + this._allowRedirects = true + this._allowRedirectDowngrade = false + this._maxRedirects = 50 + this._allowRetries = false + this._maxRetries = 1 + this._keepAlive = false + this._disposed = false + this.userAgent = userAgent + this.handlers = handlers || [] + this.requestOptions = requestOptions + if (requestOptions) { if (requestOptions.ignoreSslError != null) { - this._ignoreSslError = requestOptions.ignoreSslError; + this._ignoreSslError = requestOptions.ignoreSslError } - this._socketTimeout = requestOptions.socketTimeout; + this._socketTimeout = requestOptions.socketTimeout if (requestOptions.allowRedirects != null) { - this._allowRedirects = requestOptions.allowRedirects; + this._allowRedirects = requestOptions.allowRedirects } if (requestOptions.allowRedirectDowngrade != null) { - this._allowRedirectDowngrade = requestOptions.allowRedirectDowngrade; + this._allowRedirectDowngrade = + requestOptions.allowRedirectDowngrade } if (requestOptions.maxRedirects != null) { - this._maxRedirects = Math.max(requestOptions.maxRedirects, 0); + this._maxRedirects = Math.max(requestOptions.maxRedirects, 0) } if (requestOptions.keepAlive != null) { - this._keepAlive = requestOptions.keepAlive; + this._keepAlive = requestOptions.keepAlive } if (requestOptions.allowRetries != null) { - this._allowRetries = requestOptions.allowRetries; + this._allowRetries = requestOptions.allowRetries } if (requestOptions.maxRetries != null) { - this._maxRetries = requestOptions.maxRetries; + this._maxRetries = requestOptions.maxRetries } + } } - } - options(requestUrl, additionalHeaders) { - return this.request('OPTIONS', requestUrl, null, additionalHeaders || {}); - } - get(requestUrl, additionalHeaders) { - return this.request('GET', requestUrl, null, additionalHeaders || {}); - } - del(requestUrl, additionalHeaders) { - return this.request('DELETE', requestUrl, null, additionalHeaders || {}); - } - post(requestUrl, data, additionalHeaders) { - return this.request('POST', requestUrl, data, additionalHeaders || {}); - } - patch(requestUrl, data, additionalHeaders) { - return this.request('PATCH', requestUrl, data, additionalHeaders || {}); - } - put(requestUrl, data, additionalHeaders) { - return this.request('PUT', requestUrl, data, additionalHeaders || {}); - } - head(requestUrl, additionalHeaders) { - return this.request('HEAD', requestUrl, null, additionalHeaders || {}); - } - sendStream(verb, requestUrl, stream, additionalHeaders) { - return this.request(verb, requestUrl, stream, additionalHeaders); - } - /** - * Gets a typed object from an endpoint - * Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise - */ - async getJson(requestUrl, additionalHeaders = {}) { - additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); - let res = await this.get(requestUrl, additionalHeaders); - return this._processResponse(res, this.requestOptions); - } - async postJson(requestUrl, obj, additionalHeaders = {}) { - let data = JSON.stringify(obj, null, 2); - additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); - additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); - let res = await this.post(requestUrl, data, additionalHeaders); - return this._processResponse(res, this.requestOptions); - } - async putJson(requestUrl, obj, additionalHeaders = {}) { - let data = JSON.stringify(obj, null, 2); - additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); - additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); - let res = await this.put(requestUrl, data, additionalHeaders); - return this._processResponse(res, this.requestOptions); - } - async patchJson(requestUrl, obj, additionalHeaders = {}) { - let data = JSON.stringify(obj, null, 2); - additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); - additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); - let res = await this.patch(requestUrl, data, additionalHeaders); - return this._processResponse(res, this.requestOptions); - } - /** - * Makes a raw http request. - * All other methods such as get, post, patch, and request ultimately call this. - * Prefer get, del, post and patch - */ - async request(verb, requestUrl, data, headers) { - if (this._disposed) { - throw new Error("Client has already been disposed."); - } - let parsedUrl = url.parse(requestUrl); - let info = this._prepareRequest(verb, parsedUrl, headers); - // Only perform retries on reads since writes may not be idempotent. - let maxTries = (this._allowRetries && RetryableHttpVerbs.indexOf(verb) != -1) ? this._maxRetries + 1 : 1; - let numTries = 0; - let response; - while (numTries < maxTries) { - response = await this.requestRaw(info, data); + options(requestUrl, additionalHeaders) { + return this.request( + 'OPTIONS', + requestUrl, + null, + additionalHeaders || {} + ) + } + get(requestUrl, additionalHeaders) { + return this.request('GET', requestUrl, null, additionalHeaders || {}) + } + del(requestUrl, additionalHeaders) { + return this.request( + 'DELETE', + requestUrl, + null, + additionalHeaders || {} + ) + } + post(requestUrl, data, additionalHeaders) { + return this.request('POST', requestUrl, data, additionalHeaders || {}) + } + patch(requestUrl, data, additionalHeaders) { + return this.request( + 'PATCH', + requestUrl, + data, + additionalHeaders || {} + ) + } + put(requestUrl, data, additionalHeaders) { + return this.request('PUT', requestUrl, data, additionalHeaders || {}) + } + head(requestUrl, additionalHeaders) { + return this.request('HEAD', requestUrl, null, additionalHeaders || {}) + } + sendStream(verb, requestUrl, stream, additionalHeaders) { + return this.request(verb, requestUrl, stream, additionalHeaders) + } + /** + * Gets a typed object from an endpoint + * Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise + */ + async getJson(requestUrl, additionalHeaders = {}) { + additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader( + additionalHeaders, + Headers.Accept, + MediaTypes.ApplicationJson + ) + let res = await this.get(requestUrl, additionalHeaders) + return this._processResponse(res, this.requestOptions) + } + async postJson(requestUrl, obj, additionalHeaders = {}) { + let data = JSON.stringify(obj, null, 2) + additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader( + additionalHeaders, + Headers.Accept, + MediaTypes.ApplicationJson + ) + additionalHeaders[ + Headers.ContentType + ] = this._getExistingOrDefaultHeader( + additionalHeaders, + Headers.ContentType, + MediaTypes.ApplicationJson + ) + let res = await this.post(requestUrl, data, additionalHeaders) + return this._processResponse(res, this.requestOptions) + } + async putJson(requestUrl, obj, additionalHeaders = {}) { + let data = JSON.stringify(obj, null, 2) + additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader( + additionalHeaders, + Headers.Accept, + MediaTypes.ApplicationJson + ) + additionalHeaders[ + Headers.ContentType + ] = this._getExistingOrDefaultHeader( + additionalHeaders, + Headers.ContentType, + MediaTypes.ApplicationJson + ) + let res = await this.put(requestUrl, data, additionalHeaders) + return this._processResponse(res, this.requestOptions) + } + async patchJson(requestUrl, obj, additionalHeaders = {}) { + let data = JSON.stringify(obj, null, 2) + additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader( + additionalHeaders, + Headers.Accept, + MediaTypes.ApplicationJson + ) + additionalHeaders[ + Headers.ContentType + ] = this._getExistingOrDefaultHeader( + additionalHeaders, + Headers.ContentType, + MediaTypes.ApplicationJson + ) + let res = await this.patch(requestUrl, data, additionalHeaders) + return this._processResponse(res, this.requestOptions) + } + /** + * Makes a raw http request. + * All other methods such as get, post, patch, and request ultimately call this. + * Prefer get, del, post and patch + */ + async request(verb, requestUrl, data, headers) { + if (this._disposed) { + throw new Error('Client has already been disposed.') + } + let parsedUrl = url.parse(requestUrl) + let info = this._prepareRequest(verb, parsedUrl, headers) + // Only perform retries on reads since writes may not be idempotent. + let maxTries = + this._allowRetries && RetryableHttpVerbs.indexOf(verb) != -1 + ? this._maxRetries + 1 + : 1 + let numTries = 0 + let response + while (numTries < maxTries) { + response = await this.requestRaw(info, data) // Check if it's an authentication challenge - if (response && response.message && response.message.statusCode === HttpCodes.Unauthorized) { - let authenticationHandler; - for (let i = 0; i < this.handlers.length; i++) { - if (this.handlers[i].canHandleAuthentication(response)) { - authenticationHandler = this.handlers[i]; - break; - } - } - if (authenticationHandler) { - return authenticationHandler.handleAuthentication(this, info, data); + if ( + response && + response.message && + response.message.statusCode === HttpCodes.Unauthorized + ) { + let authenticationHandler + for (let i = 0; i < this.handlers.length; i++) { + if (this.handlers[i].canHandleAuthentication(response)) { + authenticationHandler = this.handlers[i] + break } - else { - // We have received an unauthorized response but have no handlers to handle it. - // Let the response return to the caller. - return response; - } - } - let redirectsRemaining = this._maxRedirects; - while (HttpRedirectCodes.indexOf(response.message.statusCode) != -1 - && this._allowRedirects - && redirectsRemaining > 0) { - const redirectUrl = response.message.headers["location"]; - if (!redirectUrl) { - // if there's no location to redirect to, we won't - break; - } - let parsedRedirectUrl = url.parse(redirectUrl); - if (parsedUrl.protocol == 'https:' && parsedUrl.protocol != parsedRedirectUrl.protocol && !this._allowRedirectDowngrade) { - throw new Error("Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true."); - } - // we need to finish reading the response before reassigning response - // which will leak the open socket. - await response.readBody(); - // let's make the request with the new redirectUrl - info = this._prepareRequest(verb, parsedRedirectUrl, headers); - response = await this.requestRaw(info, data); - redirectsRemaining--; - } - if (HttpResponseRetryCodes.indexOf(response.message.statusCode) == -1) { - // If not a retry code, return immediately instead of retrying - return response; - } - numTries += 1; + } + if (authenticationHandler) { + return authenticationHandler.handleAuthentication( + this, + info, + data + ) + } else { + // We have received an unauthorized response but have no handlers to handle it. + // Let the response return to the caller. + return response + } + } + let redirectsRemaining = this._maxRedirects + while ( + HttpRedirectCodes.indexOf(response.message.statusCode) != -1 && + this._allowRedirects && + redirectsRemaining > 0 + ) { + const redirectUrl = response.message.headers['location'] + if (!redirectUrl) { + // if there's no location to redirect to, we won't + break + } + let parsedRedirectUrl = url.parse(redirectUrl) + if ( + parsedUrl.protocol == 'https:' && + parsedUrl.protocol != parsedRedirectUrl.protocol && + !this._allowRedirectDowngrade + ) { + throw new Error( + 'Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.' + ) + } + // we need to finish reading the response before reassigning response + // which will leak the open socket. + await response.readBody() + // let's make the request with the new redirectUrl + info = this._prepareRequest(verb, parsedRedirectUrl, headers) + response = await this.requestRaw(info, data) + redirectsRemaining-- + } + if ( + HttpResponseRetryCodes.indexOf(response.message.statusCode) == -1 + ) { + // If not a retry code, return immediately instead of retrying + return response + } + numTries += 1 if (numTries < maxTries) { - await response.readBody(); - await this._performExponentialBackoff(numTries); + await response.readBody() + await this._performExponentialBackoff(numTries) } + } + return response } - return response; - } - /** - * Needs to be called if keepAlive is set to true in request options. - */ - dispose() { - if (this._agent) { - this._agent.destroy(); - } - this._disposed = true; - } - /** - * Raw request. - * @param info - * @param data - */ - requestRaw(info, data) { - return new Promise((resolve, reject) => { + /** + * Needs to be called if keepAlive is set to true in request options. + */ + dispose() { + if (this._agent) { + this._agent.destroy() + } + this._disposed = true + } + /** + * Raw request. + * @param info + * @param data + */ + requestRaw(info, data) { + return new Promise((resolve, reject) => { let callbackForResult = function (err, res) { - if (err) { - reject(err); - } - resolve(res); - }; - this.requestRawWithCallback(info, data, callbackForResult); - }); - } - /** - * Raw request with callback. - * @param info - * @param data - * @param onResult - */ - requestRawWithCallback(info, data, onResult) { - let socket; - if (typeof (data) === 'string') { - info.options.headers["Content-Length"] = Buffer.byteLength(data, 'utf8'); - } - let callbackCalled = false; - let handleResult = (err, res) => { + if (err) { + reject(err) + } + resolve(res) + } + this.requestRawWithCallback(info, data, callbackForResult) + }) + } + /** + * Raw request with callback. + * @param info + * @param data + * @param onResult + */ + requestRawWithCallback(info, data, onResult) { + let socket + if (typeof data === 'string') { + info.options.headers['Content-Length'] = Buffer.byteLength( + data, + 'utf8' + ) + } + let callbackCalled = false + let handleResult = (err, res) => { if (!callbackCalled) { - callbackCalled = true; - onResult(err, res); - } - }; - let req = info.httpModule.request(info.options, (msg) => { - let res = new HttpClientResponse(msg); - handleResult(null, res); - }); - req.on('socket', (sock) => { - socket = sock; - }); - // If we ever get disconnected, we want the socket to timeout eventually - req.setTimeout(this._socketTimeout || 3 * 60000, () => { + callbackCalled = true + onResult(err, res) + } + } + let req = info.httpModule.request(info.options, msg => { + let res = new HttpClientResponse(msg) + handleResult(null, res) + }) + req.on('socket', sock => { + socket = sock + }) + // If we ever get disconnected, we want the socket to timeout eventually + req.setTimeout(this._socketTimeout || 3 * 60000, () => { if (socket) { - socket.end(); + socket.end() } - handleResult(new Error('Request timeout: ' + info.options.path), null); - }); - req.on('error', function (err) { + handleResult( + new Error('Request timeout: ' + info.options.path), + null + ) + }) + req.on('error', function (err) { // err has statusCode property // res should have headers - handleResult(err, null); - }); - if (data && typeof (data) === 'string') { - req.write(data, 'utf8'); - } - if (data && typeof (data) !== 'string') { + handleResult(err, null) + }) + if (data && typeof data === 'string') { + req.write(data, 'utf8') + } + if (data && typeof data !== 'string') { data.on('close', function () { - req.end(); - }); - data.pipe(req); + req.end() + }) + data.pipe(req) + } else { + req.end() + } } - else { - req.end(); + /** + * Gets an http agent. This function is useful when you need an http agent that handles + * routing through a proxy server - depending upon the url and proxy environment variables. + * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com + */ + getAgent(serverUrl) { + let parsedUrl = url.parse(serverUrl) + return this._getAgent(parsedUrl) } - } - /** - * Gets an http agent. This function is useful when you need an http agent that handles - * routing through a proxy server - depending upon the url and proxy environment variables. - * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com - */ - getAgent(serverUrl) { - let parsedUrl = url.parse(serverUrl); - return this._getAgent(parsedUrl); - } - _prepareRequest(method, requestUrl, headers) { - const info = {}; - info.parsedUrl = requestUrl; - const usingSsl = info.parsedUrl.protocol === 'https:'; - info.httpModule = usingSsl ? https : http; - const defaultPort = usingSsl ? 443 : 80; - info.options = {}; - info.options.host = info.parsedUrl.hostname; - info.options.port = info.parsedUrl.port ? parseInt(info.parsedUrl.port) : defaultPort; - info.options.path = (info.parsedUrl.pathname || '') + (info.parsedUrl.search || ''); - info.options.method = method; - info.options.headers = this._mergeHeaders(headers); - if (this.userAgent != null) { - info.options.headers["user-agent"] = this.userAgent; - } - info.options.agent = this._getAgent(info.parsedUrl); - // gives handlers an opportunity to participate - if (this.handlers) { - this.handlers.forEach((handler) => { - handler.prepareRequest(info.options); - }); + _prepareRequest(method, requestUrl, headers) { + const info = {} + info.parsedUrl = requestUrl + const usingSsl = info.parsedUrl.protocol === 'https:' + info.httpModule = usingSsl ? https : http + const defaultPort = usingSsl ? 443 : 80 + info.options = {} + info.options.host = info.parsedUrl.hostname + info.options.port = info.parsedUrl.port + ? parseInt(info.parsedUrl.port) + : defaultPort + info.options.path = + (info.parsedUrl.pathname || '') + (info.parsedUrl.search || '') + info.options.method = method + info.options.headers = this._mergeHeaders(headers) + if (this.userAgent != null) { + info.options.headers['user-agent'] = this.userAgent + } + info.options.agent = this._getAgent(info.parsedUrl) + // gives handlers an opportunity to participate + if (this.handlers) { + this.handlers.forEach(handler => { + handler.prepareRequest(info.options) + }) + } + return info } - return info; - } - _mergeHeaders(headers) { - const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => (c[k.toLowerCase()] = obj[k], c), {}); - if (this.requestOptions && this.requestOptions.headers) { - return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers)); + _mergeHeaders(headers) { + const lowercaseKeys = obj => + Object.keys(obj).reduce( + (c, k) => ((c[k.toLowerCase()] = obj[k]), c), + {} + ) + if (this.requestOptions && this.requestOptions.headers) { + return Object.assign( + {}, + lowercaseKeys(this.requestOptions.headers), + lowercaseKeys(headers) + ) + } + return lowercaseKeys(headers || {}) } - return lowercaseKeys(headers || {}); - } - _getExistingOrDefaultHeader(additionalHeaders, header, _default) { - const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => (c[k.toLowerCase()] = obj[k], c), {}); - let clientHeader; - if (this.requestOptions && this.requestOptions.headers) { - clientHeader = lowercaseKeys(this.requestOptions.headers)[header]; + _getExistingOrDefaultHeader(additionalHeaders, header, _default) { + const lowercaseKeys = obj => + Object.keys(obj).reduce( + (c, k) => ((c[k.toLowerCase()] = obj[k]), c), + {} + ) + let clientHeader + if (this.requestOptions && this.requestOptions.headers) { + clientHeader = lowercaseKeys(this.requestOptions.headers)[header] + } + return additionalHeaders[header] || clientHeader || _default } - return additionalHeaders[header] || clientHeader || _default; - } - _getAgent(parsedUrl) { - let agent; - let proxyUrl = pm.getProxyUrl(parsedUrl); - let useProxy = proxyUrl && proxyUrl.hostname; - if (this._keepAlive && useProxy) { - agent = this._proxyAgent; - } - if (this._keepAlive && !useProxy) { - agent = this._agent; - } - // if agent is already assigned use that agent. - if (!!agent) { - return agent; - } - const usingSsl = parsedUrl.protocol === 'https:'; - let maxSockets = 100; - if (!!this.requestOptions) { - maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets; - } - if (useProxy) { - // If using proxy, need tunnel - if (!tunnel) { - tunnel = __webpack_require__(4294); - } + _getAgent(parsedUrl) { + let agent + let proxyUrl = pm.getProxyUrl(parsedUrl) + let useProxy = proxyUrl && proxyUrl.hostname + if (this._keepAlive && useProxy) { + agent = this._proxyAgent + } + if (this._keepAlive && !useProxy) { + agent = this._agent + } + // if agent is already assigned use that agent. + if (!!agent) { + return agent + } + const usingSsl = parsedUrl.protocol === 'https:' + let maxSockets = 100 + if (!!this.requestOptions) { + maxSockets = + this.requestOptions.maxSockets || http.globalAgent.maxSockets + } + if (useProxy) { + // If using proxy, need tunnel + if (!tunnel) { + tunnel = __webpack_require__(74294) + } const agentOptions = { - maxSockets: maxSockets, - keepAlive: this._keepAlive, - proxy: { - proxyAuth: proxyUrl.auth, - host: proxyUrl.hostname, - port: proxyUrl.port - }, - }; - let tunnelAgent; - const overHttps = proxyUrl.protocol === 'https:'; + maxSockets: maxSockets, + keepAlive: this._keepAlive, + proxy: { + proxyAuth: proxyUrl.auth, + host: proxyUrl.hostname, + port: proxyUrl.port + } + } + let tunnelAgent + const overHttps = proxyUrl.protocol === 'https:' if (usingSsl) { - tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp; + tunnelAgent = overHttps + ? tunnel.httpsOverHttps + : tunnel.httpsOverHttp + } else { + tunnelAgent = overHttps + ? tunnel.httpOverHttps + : tunnel.httpOverHttp } - else { - tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp; + agent = tunnelAgent(agentOptions) + this._proxyAgent = agent + } + // if reusing agent across request and tunneling agent isn't assigned create a new agent + if (this._keepAlive && !agent) { + const options = { + keepAlive: this._keepAlive, + maxSockets: maxSockets } - agent = tunnelAgent(agentOptions); - this._proxyAgent = agent; - } - // if reusing agent across request and tunneling agent isn't assigned create a new agent - if (this._keepAlive && !agent) { - const options = { keepAlive: this._keepAlive, maxSockets: maxSockets }; - agent = usingSsl ? new https.Agent(options) : new http.Agent(options); - this._agent = agent; - } - // if not using private agent and tunnel agent isn't setup then use global agent - if (!agent) { - agent = usingSsl ? https.globalAgent : http.globalAgent; - } - if (usingSsl && this._ignoreSslError) { + agent = usingSsl + ? new https.Agent(options) + : new http.Agent(options) + this._agent = agent + } + // if not using private agent and tunnel agent isn't setup then use global agent + if (!agent) { + agent = usingSsl ? https.globalAgent : http.globalAgent + } + if (usingSsl && this._ignoreSslError) { // we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process // http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options // we have to cast it to any and change it directly - agent.options = Object.assign(agent.options || {}, { rejectUnauthorized: false }); + agent.options = Object.assign(agent.options || {}, { + rejectUnauthorized: false + }) + } + return agent } - return agent; - } - _performExponentialBackoff(retryNumber) { - retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber); - const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber); - return new Promise(resolve => setTimeout(() => resolve(), ms)); - } - static dateTimeDeserializer(key, value) { - if (typeof value === 'string') { - let a = new Date(value); + _performExponentialBackoff(retryNumber) { + retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber) + const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber) + return new Promise(resolve => setTimeout(() => resolve(), ms)) + } + static dateTimeDeserializer(key, value) { + if (typeof value === 'string') { + let a = new Date(value) if (!isNaN(a.valueOf())) { - return a; + return a } + } + return value } - return value; - } - async _processResponse(res, options) { - return new Promise(async (resolve, reject) => { - const statusCode = res.message.statusCode; + async _processResponse(res, options) { + return new Promise(async (resolve, reject) => { + const statusCode = res.message.statusCode const response = { - statusCode: statusCode, - result: null, - headers: {} - }; + statusCode: statusCode, + result: null, + headers: {} + } // not found leads to null obj returned if (statusCode == HttpCodes.NotFound) { - resolve(response); + resolve(response) } - let obj; - let contents; + let obj + let contents // get the result from the body try { - contents = await res.readBody(); - if (contents && contents.length > 0) { - if (options && options.deserializeDates) { - obj = JSON.parse(contents, HttpClient.dateTimeDeserializer); - } - else { - obj = JSON.parse(contents); - } - response.result = obj; + contents = await res.readBody() + if (contents && contents.length > 0) { + if (options && options.deserializeDates) { + obj = JSON.parse(contents, HttpClient.dateTimeDeserializer) + } else { + obj = JSON.parse(contents) } - response.headers = res.message.headers; - } - catch (err) { - // Invalid resource (contents not json); leaving result obj null + response.result = obj + } + response.headers = res.message.headers + } catch (err) { + // Invalid resource (contents not json); leaving result obj null } // note that 3xx redirects are handled by the http layer. if (statusCode > 299) { - let msg; - // if exception/error in body, attempt to get better error - if (obj && obj.message) { - msg = obj.message; - } - else if (contents && contents.length > 0) { - // it may be the case that the exception is in the body message as string - msg = contents; - } - else { - msg = "Failed request: (" + statusCode + ")"; - } - let err = new Error(msg); - // attach statusCode and body obj (if available) to the error object - err['statusCode'] = statusCode; - if (response.result) { - err['result'] = response.result; - } - reject(err); - } - else { - resolve(response); + let msg + // if exception/error in body, attempt to get better error + if (obj && obj.message) { + msg = obj.message + } else if (contents && contents.length > 0) { + // it may be the case that the exception is in the body message as string + msg = contents + } else { + msg = 'Failed request: (' + statusCode + ')' + } + let err = new Error(msg) + // attach statusCode and body obj (if available) to the error object + err['statusCode'] = statusCode + if (response.result) { + err['result'] = response.result + } + reject(err) + } else { + resolve(response) } - }); - } -} -exports.HttpClient = HttpClient; - + }) + } + } + exports.HttpClient = HttpClient -/***/ }), + /***/ + }, -/***/ 6443: -/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + /***/ 16443: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + Object.defineProperty(exports, '__esModule', { value: true }) + const url = __webpack_require__(78835) + function getProxyUrl(reqUrl) { + let usingSsl = reqUrl.protocol === 'https:' + let proxyUrl + if (checkBypass(reqUrl)) { + return proxyUrl + } + let proxyVar + if (usingSsl) { + proxyVar = process.env['https_proxy'] || process.env['HTTPS_PROXY'] + } else { + proxyVar = process.env['http_proxy'] || process.env['HTTP_PROXY'] + } + if (proxyVar) { + proxyUrl = url.parse(proxyVar) + } + return proxyUrl + } + exports.getProxyUrl = getProxyUrl + function checkBypass(reqUrl) { + if (!reqUrl.hostname) { + return false + } + let noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || '' + if (!noProxy) { + return false + } + // Determine the request port + let reqPort + if (reqUrl.port) { + reqPort = Number(reqUrl.port) + } else if (reqUrl.protocol === 'http:') { + reqPort = 80 + } else if (reqUrl.protocol === 'https:') { + reqPort = 443 + } + // Format the request hostname and hostname with port + let upperReqHosts = [reqUrl.hostname.toUpperCase()] + if (typeof reqPort === 'number') { + upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`) + } + // Compare request host against noproxy + for (let upperNoProxyItem of noProxy + .split(',') + .map(x => x.trim().toUpperCase()) + .filter(x => x)) { + if (upperReqHosts.some(x => x === upperNoProxyItem)) { + return true + } + } + return false + } + exports.checkBypass = checkBypass -"use strict"; + /***/ + }, -Object.defineProperty(exports, "__esModule", ({ value: true })); -const url = __webpack_require__(8835); -function getProxyUrl(reqUrl) { - let usingSsl = reqUrl.protocol === 'https:'; - let proxyUrl; - if (checkBypass(reqUrl)) { - return proxyUrl; - } - let proxyVar; - if (usingSsl) { - proxyVar = process.env["https_proxy"] || - process.env["HTTPS_PROXY"]; - } - else { - proxyVar = process.env["http_proxy"] || - process.env["HTTP_PROXY"]; - } - if (proxyVar) { - proxyUrl = url.parse(proxyVar); - } - return proxyUrl; -} -exports.getProxyUrl = getProxyUrl; -function checkBypass(reqUrl) { - if (!reqUrl.hostname) { - return false; - } - let noProxy = process.env["no_proxy"] || process.env["NO_PROXY"] || ''; - if (!noProxy) { - return false; - } - // Determine the request port - let reqPort; - if (reqUrl.port) { - reqPort = Number(reqUrl.port); - } - else if (reqUrl.protocol === 'http:') { - reqPort = 80; - } - else if (reqUrl.protocol === 'https:') { - reqPort = 443; - } - // Format the request hostname and hostname with port - let upperReqHosts = [reqUrl.hostname.toUpperCase()]; - if (typeof reqPort === 'number') { - upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`); - } - // Compare request host against noproxy - for (let upperNoProxyItem of noProxy.split(',').map(x => x.trim().toUpperCase()).filter(x => x)) { - if (upperReqHosts.some(x => x === upperNoProxyItem)) { - return true; + /***/ 53808: /***/ module => { + function _assertThisInitialized(self) { + if (self === void 0) { + throw new ReferenceError( + "this hasn't been initialised - super() hasn't been called" + ) } - } - return false; -} -exports.checkBypass = checkBypass; - -/***/ }), + return self + } -/***/ 334: -/***/ ((__unused_webpack_module, exports) => { + module.exports = _assertThisInitialized -"use strict"; + /***/ + }, + /***/ 49346: /***/ module => { + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError('Cannot call a class as a function') + } + } -Object.defineProperty(exports, "__esModule", ({ value: true })); + module.exports = _classCallCheck -async function auth(token) { - const tokenType = token.split(/\./).length === 3 ? "app" : /^v\d+\./.test(token) ? "installation" : "oauth"; - return { - type: "token", - token: token, - tokenType - }; -} + /***/ + }, -/** - * Prefix token for usage in the Authorization header - * - * @param token OAuth token or JSON Web Token - */ -function withAuthorizationPrefix(token) { - if (token.split(/\./).length === 3) { - return `bearer ${token}`; - } + /***/ 72158: /***/ module => { + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i] + descriptor.enumerable = descriptor.enumerable || false + descriptor.configurable = true + if ('value' in descriptor) descriptor.writable = true + Object.defineProperty(target, descriptor.key, descriptor) + } + } - return `token ${token}`; -} + function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps) + if (staticProps) _defineProperties(Constructor, staticProps) + return Constructor + } -async function hook(token, request, route, parameters) { - const endpoint = request.endpoint.merge(route, parameters); - endpoint.headers.authorization = withAuthorizationPrefix(token); - return request(endpoint); -} + module.exports = _createClass -const createTokenAuth = function createTokenAuth(token) { - if (!token) { - throw new Error("[@octokit/auth-token] No token passed to createTokenAuth"); - } + /***/ + }, - if (typeof token !== "string") { - throw new Error("[@octokit/auth-token] Token passed to createTokenAuth is not a string"); - } + /***/ 23561: /***/ module => { + function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }) + } else { + obj[key] = value + } - token = token.replace(/^(token|bearer) +/i, ""); - return Object.assign(auth.bind(null, token), { - hook: hook.bind(null, token) - }); -}; + return obj + } -exports.createTokenAuth = createTokenAuth; -//# sourceMappingURL=index.js.map + module.exports = _defineProperty + /***/ + }, -/***/ }), + /***/ 2030: /***/ module => { + function _getPrototypeOf(o) { + module.exports = _getPrototypeOf = Object.setPrototypeOf + ? Object.getPrototypeOf + : function _getPrototypeOf(o) { + return o.__proto__ || Object.getPrototypeOf(o) + } + return _getPrototypeOf(o) + } -/***/ 9440: -/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + module.exports = _getPrototypeOf -"use strict"; + /***/ + }, + /***/ 35937: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + var setPrototypeOf = __webpack_require__(60020) + + function _inherits(subClass, superClass) { + if (typeof superClass !== 'function' && superClass !== null) { + throw new TypeError( + 'Super expression must either be null or a function' + ) + } -Object.defineProperty(exports, "__esModule", ({ value: true })); + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + writable: true, + configurable: true + } + }) + if (superClass) setPrototypeOf(subClass, superClass) + } -function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } + module.exports = _inherits -var isPlainObject = _interopDefault(__webpack_require__(4038)); -var universalUserAgent = __webpack_require__(1292); + /***/ + }, -function lowercaseKeys(object) { - if (!object) { - return {}; - } + /***/ 27107: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + var defineProperty = __webpack_require__(23561) + + function _objectSpread(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? Object(arguments[i]) : {} + var ownKeys = Object.keys(source) + + if (typeof Object.getOwnPropertySymbols === 'function') { + ownKeys = ownKeys.concat( + Object.getOwnPropertySymbols(source).filter(function (sym) { + return Object.getOwnPropertyDescriptor(source, sym).enumerable + }) + ) + } - return Object.keys(object).reduce((newObj, key) => { - newObj[key.toLowerCase()] = object[key]; - return newObj; - }, {}); -} - -function mergeDeep(defaults, options) { - const result = Object.assign({}, defaults); - Object.keys(options).forEach(key => { - if (isPlainObject(options[key])) { - if (!(key in defaults)) Object.assign(result, { - [key]: options[key] - });else result[key] = mergeDeep(defaults[key], options[key]); - } else { - Object.assign(result, { - [key]: options[key] - }); - } - }); - return result; -} - -function merge(defaults, route, options) { - if (typeof route === "string") { - let [method, url] = route.split(" "); - options = Object.assign(url ? { - method, - url - } : { - url: method - }, options); - } else { - options = Object.assign({}, route); - } // lowercase header names before merging with defaults to avoid duplicates - - - options.headers = lowercaseKeys(options.headers); - const mergedOptions = mergeDeep(defaults || {}, options); // mediaType.previews arrays are merged, instead of overwritten - - if (defaults && defaults.mediaType.previews.length) { - mergedOptions.mediaType.previews = defaults.mediaType.previews.filter(preview => !mergedOptions.mediaType.previews.includes(preview)).concat(mergedOptions.mediaType.previews); - } + ownKeys.forEach(function (key) { + defineProperty(target, key, source[key]) + }) + } - mergedOptions.mediaType.previews = mergedOptions.mediaType.previews.map(preview => preview.replace(/-preview/, "")); - return mergedOptions; -} + return target + } -function addQueryParameters(url, parameters) { - const separator = /\?/.test(url) ? "&" : "?"; - const names = Object.keys(parameters); + module.exports = _objectSpread - if (names.length === 0) { - return url; - } + /***/ + }, - return url + separator + names.map(name => { - if (name === "q") { - return "q=" + parameters.q.split("+").map(encodeURIComponent).join("+"); - } + /***/ 68104: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + var _typeof = __webpack_require__(31042) + + var assertThisInitialized = __webpack_require__(53808) + + function _possibleConstructorReturn(self, call) { + if ( + call && + (_typeof(call) === 'object' || typeof call === 'function') + ) { + return call + } - return `${name}=${encodeURIComponent(parameters[name])}`; - }).join("&"); -} + return assertThisInitialized(self) + } -const urlVariableRegex = /\{[^}]+\}/g; + module.exports = _possibleConstructorReturn -function removeNonChars(variableName) { - return variableName.replace(/^\W+|\W+$/g, "").split(/,/); -} + /***/ + }, -function extractUrlVariableNames(url) { - const matches = url.match(urlVariableRegex); + /***/ 60020: /***/ module => { + function _setPrototypeOf(o, p) { + module.exports = _setPrototypeOf = + Object.setPrototypeOf || + function _setPrototypeOf(o, p) { + o.__proto__ = p + return o + } - if (!matches) { - return []; - } + return _setPrototypeOf(o, p) + } - return matches.map(removeNonChars).reduce((a, b) => a.concat(b), []); -} - -function omit(object, keysToOmit) { - return Object.keys(object).filter(option => !keysToOmit.includes(option)).reduce((obj, key) => { - obj[key] = object[key]; - return obj; - }, {}); -} - -// Based on https://github.com/bramstein/url-template, licensed under BSD -// TODO: create separate package. -// -// Copyright (c) 2012-2014, Bram Stein -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// 3. The name of the author may not be used to endorse or promote products -// derived from this software without specific prior written permission. -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED -// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO -// EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -/* istanbul ignore file */ -function encodeReserved(str) { - return str.split(/(%[0-9A-Fa-f]{2})/g).map(function (part) { - if (!/%[0-9A-Fa-f]/.test(part)) { - part = encodeURI(part).replace(/%5B/g, "[").replace(/%5D/g, "]"); - } + module.exports = _setPrototypeOf - return part; - }).join(""); -} + /***/ + }, -function encodeUnreserved(str) { - return encodeURIComponent(str).replace(/[!'()*]/g, function (c) { - return "%" + c.charCodeAt(0).toString(16).toUpperCase(); - }); -} + /***/ 31042: /***/ module => { + function _typeof(obj) { + '@babel/helpers - typeof' -function encodeValue(operator, value, key) { - value = operator === "+" || operator === "#" ? encodeReserved(value) : encodeUnreserved(value); + if ( + typeof Symbol === 'function' && + typeof Symbol.iterator === 'symbol' + ) { + module.exports = _typeof = function _typeof(obj) { + return typeof obj + } + } else { + module.exports = _typeof = function _typeof(obj) { + return obj && + typeof Symbol === 'function' && + obj.constructor === Symbol && + obj !== Symbol.prototype + ? 'symbol' + : typeof obj + } + } - if (key) { - return encodeUnreserved(key) + "=" + value; - } else { - return value; - } -} + return _typeof(obj) + } -function isDefined(value) { - return value !== undefined && value !== null; -} + module.exports = _typeof -function isKeyOperator(operator) { - return operator === ";" || operator === "&" || operator === "?"; -} + /***/ + }, -function getValues(context, operator, key, modifier) { - var value = context[key], - result = []; + /***/ 54777: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' - if (isDefined(value) && value !== "") { - if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") { - value = value.toString(); + // Copyright 2016 Google LLC + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + Object.defineProperty(exports, '__esModule', { value: true }) + /** + * @type {module:common/operation} + * @private + */ + var operation_1 = __webpack_require__(37378) + exports.Operation = operation_1.Operation + /** + * @type {module:common/service} + * @private + */ + var service_1 = __webpack_require__(61682) + exports.Service = service_1.Service + /** + * @type {module:common/serviceObject} + * @private + */ + var service_object_1 = __webpack_require__(5674) + exports.ServiceObject = service_object_1.ServiceObject + /** + * @type {module:common/util} + * @private + */ + var util_1 = __webpack_require__(12221) + exports.ApiError = util_1.ApiError + exports.util = util_1.util + //# sourceMappingURL=index.js.map + + /***/ + }, - if (modifier && modifier !== "*") { - value = value.substring(0, parseInt(modifier, 10)); - } + /***/ 37378: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' - result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : "")); - } else { - if (modifier === "*") { - if (Array.isArray(value)) { - value.filter(isDefined).forEach(function (value) { - result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : "")); - }); - } else { - Object.keys(value).forEach(function (k) { - if (isDefined(value[k])) { - result.push(encodeValue(operator, value[k], k)); + // Copyright 2016 Google LLC + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + Object.defineProperty(exports, '__esModule', { value: true }) + /*! + * @module common/operation + */ + const service_object_1 = __webpack_require__(5674) + const util_1 = __webpack_require__(31669) + // eslint-disable-next-line @typescript-eslint/no-explicit-any + class Operation extends service_object_1.ServiceObject { + /** + * An Operation object allows you to interact with APIs that take longer to + * process things. + * + * @constructor + * @alias module:common/operation + * + * @param {object} config - Configuration object. + * @param {module:common/service|module:common/serviceObject|module:common/grpcService|module:common/grpcServiceObject} config.parent - The parent object. + */ + constructor(config) { + const methods = { + /** + * Checks to see if an operation exists. + */ + exists: true, + /** + * Retrieves the operation. + */ + get: true, + /** + * Retrieves metadata for the operation. + */ + getMetadata: { + reqOpts: { + name: config.id + } + } + } + config = Object.assign( + { + baseUrl: '' + }, + config + ) + // eslint-disable-next-line @typescript-eslint/no-explicit-any + config.methods = config.methods || methods + super(config) + this.completeListeners = 0 + this.hasActiveListeners = false + this.listenForEvents_() + } + /** + * Wraps the `complete` and `error` events in a Promise. + * + * @return {Promise} + */ + promise() { + return new Promise((resolve, reject) => { + this.on('error', reject).on('complete', metadata => { + resolve([metadata]) + }) + }) + } + /** + * Begin listening for events on the operation. This method keeps track of how + * many "complete" listeners are registered and removed, making sure polling + * is handled automatically. + * + * As long as there is one active "complete" listener, the connection is open. + * When there are no more listeners, the polling stops. + * + * @private + */ + listenForEvents_() { + this.on('newListener', event => { + if (event === 'complete') { + this.completeListeners++ + if (!this.hasActiveListeners) { + this.hasActiveListeners = true + this.startPolling_() + } } - }); + }) + this.on('removeListener', event => { + if (event === 'complete' && --this.completeListeners === 0) { + this.hasActiveListeners = false + } + }) } - } else { - const tmp = []; - - if (Array.isArray(value)) { - value.filter(isDefined).forEach(function (value) { - tmp.push(encodeValue(operator, value)); - }); - } else { - Object.keys(value).forEach(function (k) { - if (isDefined(value[k])) { - tmp.push(encodeUnreserved(k)); - tmp.push(encodeValue(operator, value[k].toString())); + /** + * Poll for a status update. Returns null for an incomplete + * status, and metadata for a complete status. + * + * @private + */ + poll_(callback) { + this.getMetadata((err, body) => { + if (err || body.error) { + callback(err || body.error) + return + } + if (!body.done) { + callback(null) + return } - }); + callback(null, body) + }) } - - if (isKeyOperator(operator)) { - result.push(encodeUnreserved(key) + "=" + tmp.join(",")); - } else if (tmp.length !== 0) { - result.push(tmp.join(",")); + /** + * Poll `getMetadata` to check the operation's status. This runs a loop to + * ping the API on an interval. + * + * Note: This method is automatically called once a "complete" event handler + * is registered on the operation. + * + * @private + */ + async startPolling_() { + if (!this.hasActiveListeners) { + return + } + try { + const metadata = await util_1.promisify(this.poll_.bind(this))() + if (!metadata) { + setTimeout( + this.startPolling_.bind(this), + this.pollIntervalMs || 500 + ) + return + } + this.emit('complete', metadata) + } catch (err) { + this.emit('error', err) + } } } - } - } else { - if (operator === ";") { - if (isDefined(value)) { - result.push(encodeUnreserved(key)); - } - } else if (value === "" && (operator === "&" || operator === "?")) { - result.push(encodeUnreserved(key) + "="); - } else if (value === "") { - result.push(""); - } - } + exports.Operation = Operation + //# sourceMappingURL=operation.js.map - return result; -} - -function parseUrl(template) { - return { - expand: expand.bind(null, template) - }; -} + /***/ + }, -function expand(template, context) { - var operators = ["+", "#", ".", "/", ";", "?", "&"]; - return template.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g, function (_, expression, literal) { - if (expression) { - let operator = ""; - const values = []; + /***/ 5674: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' - if (operators.indexOf(expression.charAt(0)) !== -1) { - operator = expression.charAt(0); - expression = expression.substr(1); + // Copyright 2015 Google LLC + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + Object.defineProperty(exports, '__esModule', { value: true }) + /*! + * @module common/service-object + */ + const promisify_1 = __webpack_require__(19203) + const arrify = __webpack_require__(61546) + const events_1 = __webpack_require__(28614) + const extend = __webpack_require__(38171) + const util_1 = __webpack_require__(12221) + /** + * ServiceObject is a base class, meant to be inherited from by a "service + * object," like a BigQuery dataset or Storage bucket. + * + * Most of the time, these objects share common functionality; they can be + * created or deleted, and you can get or set their metadata. + * + * By inheriting from this class, a service object will be extended with these + * shared behaviors. Note that any method can be overridden when the service + * object requires specific behavior. + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + class ServiceObject extends events_1.EventEmitter { + /* + * @constructor + * @alias module:common/service-object + * + * @private + * + * @param {object} config - Configuration object. + * @param {string} config.baseUrl - The base URL to make API requests to. + * @param {string} config.createMethod - The method which creates this object. + * @param {string=} config.id - The identifier of the object. For example, the + * name of a Storage bucket or Pub/Sub topic. + * @param {object=} config.methods - A map of each method name that should be inherited. + * @param {object} config.methods[].reqOpts - Default request options for this + * particular method. A common use case is when `setMetadata` requires a + * `PUT` method to override the default `PATCH`. + * @param {object} config.parent - The parent service instance. For example, an + * instance of Storage if the object is Bucket. + */ + constructor(config) { + super() + this.metadata = {} + this.baseUrl = config.baseUrl + this.parent = config.parent // Parent class. + this.id = config.id // Name or ID (e.g. dataset ID, bucket name, etc). + this.createMethod = config.createMethod + this.methods = config.methods || {} + this.interceptors = [] + this.pollIntervalMs = config.pollIntervalMs + if (config.methods) { + // This filters the ServiceObject instance (e.g. a "File") to only have + // the configured methods. We make a couple of exceptions for core- + // functionality ("request()" and "getRequestInterceptors()") + Object.getOwnPropertyNames(ServiceObject.prototype) + .filter(methodName => { + return ( + // All ServiceObjects need `request` and `getRequestInterceptors`. + // clang-format off + !/^request/.test(methodName) && + !/^getRequestInterceptors/.test(methodName) && + // clang-format on + // The ServiceObject didn't redefine the method. + // eslint-disable-next-line @typescript-eslint/no-explicit-any + this[methodName] === + // eslint-disable-next-line @typescript-eslint/no-explicit-any + ServiceObject.prototype[methodName] && + // This method isn't wanted. + !config.methods[methodName] + ) + }) + .forEach(methodName => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + this[methodName] = undefined + }) + } + } + create(optionsOrCallback, callback) { + // eslint-disable-next-line @typescript-eslint/no-this-alias + const self = this + const args = [this.id] + if (typeof optionsOrCallback === 'function') { + callback = optionsOrCallback + } + if (typeof optionsOrCallback === 'object') { + args.push(optionsOrCallback) + } + // Wrap the callback to return *this* instance of the object, not the + // newly-created one. + // tslint: disable-next-line no-any + function onCreate(...args) { + const [err, instance] = args + if (!err) { + self.metadata = instance.metadata + args[1] = self // replace the created `instance` with this one. + } + callback(...args) + } + args.push(onCreate) + // eslint-disable-next-line prefer-spread + this.createMethod.apply(null, args) + } + delete(optionsOrCallback, cb) { + const [options, callback] = util_1.util.maybeOptionsOrCallback( + optionsOrCallback, + cb + ) + const methodConfig = + (typeof this.methods.delete === 'object' && this.methods.delete) || + {} + const reqOpts = extend( + true, + { + method: 'DELETE', + uri: '' + }, + methodConfig.reqOpts, + { + qs: options + } + ) + // The `request` method may have been overridden to hold any special + // behavior. Ensure we call the original `request` method. + ServiceObject.prototype.request.call(this, reqOpts, callback) + } + exists(optionsOrCallback, cb) { + const [options, callback] = util_1.util.maybeOptionsOrCallback( + optionsOrCallback, + cb + ) + this.get(options, err => { + if (err) { + if (err.code === 404) { + callback(null, false) + } else { + callback(err) + } + return + } + callback(null, true) + }) + } + get(optionsOrCallback, cb) { + // eslint-disable-next-line @typescript-eslint/no-this-alias + const self = this + const [opts, callback] = util_1.util.maybeOptionsOrCallback( + optionsOrCallback, + cb + ) + const options = Object.assign({}, opts) + const autoCreate = + options.autoCreate && typeof this.create === 'function' + delete options.autoCreate + function onCreate(err, instance, apiResponse) { + if (err) { + if (err.code === 409) { + self.get(options, callback) + return + } + callback(err, null, apiResponse) + return + } + callback(null, instance, apiResponse) + } + this.getMetadata(options, (err, metadata) => { + if (err) { + if (err.code === 404 && autoCreate) { + const args = [] + if (Object.keys(options).length > 0) { + args.push(options) + } + args.push(onCreate) + self.create(...args) + return + } + callback(err, null, metadata) + return + } + callback(null, self, metadata) + }) + } + getMetadata(optionsOrCallback, cb) { + const [options, callback] = util_1.util.maybeOptionsOrCallback( + optionsOrCallback, + cb + ) + const methodConfig = + (typeof this.methods.getMetadata === 'object' && + this.methods.getMetadata) || + {} + const reqOpts = extend( + true, + { + uri: '' + }, + methodConfig.reqOpts, + { + qs: options + } + ) + // The `request` method may have been overridden to hold any special + // behavior. Ensure we call the original `request` method. + ServiceObject.prototype.request.call( + this, + reqOpts, + (err, body, res) => { + this.metadata = body + callback(err, this.metadata, res) + } + ) + } + /** + * Return the user's custom request interceptors. + */ + getRequestInterceptors() { + // Interceptors should be returned in the order they were assigned. + const localInterceptors = this.interceptors + .filter(interceptor => typeof interceptor.request === 'function') + .map(interceptor => interceptor.request) + return this.parent.getRequestInterceptors().concat(localInterceptors) + } + setMetadata(metadata, optionsOrCallback, cb) { + const [options, callback] = util_1.util.maybeOptionsOrCallback( + optionsOrCallback, + cb + ) + const methodConfig = + (typeof this.methods.setMetadata === 'object' && + this.methods.setMetadata) || + {} + const reqOpts = extend( + true, + {}, + { + method: 'PATCH', + uri: '' + }, + methodConfig.reqOpts, + { + json: metadata, + qs: options + } + ) + // The `request` method may have been overridden to hold any special + // behavior. Ensure we call the original `request` method. + ServiceObject.prototype.request.call( + this, + reqOpts, + (err, body, res) => { + this.metadata = body + callback(err, this.metadata, res) + } + ) + } + request_(reqOpts, callback) { + reqOpts = extend(true, {}, reqOpts) + const isAbsoluteUrl = reqOpts.uri.indexOf('http') === 0 + const uriComponents = [this.baseUrl, this.id || '', reqOpts.uri] + if (isAbsoluteUrl) { + uriComponents.splice(0, uriComponents.indexOf(reqOpts.uri)) + } + reqOpts.uri = uriComponents + .filter(x => x.trim()) // Limit to non-empty strings. + .map(uriComponent => { + const trimSlashesRegex = /^\/*|\/*$/g + return uriComponent.replace(trimSlashesRegex, '') + }) + .join('/') + const childInterceptors = arrify(reqOpts.interceptors_) + const localInterceptors = [].slice.call(this.interceptors) + reqOpts.interceptors_ = childInterceptors.concat(localInterceptors) + if (reqOpts.shouldReturnStream) { + return this.parent.requestStream(reqOpts) + } + this.parent.request(reqOpts, callback) + } + request(reqOpts, callback) { + this.request_(reqOpts, callback) + } + /** + * Make an authenticated API request. + * + * @param {object} reqOpts - Request options that are passed to `request`. + * @param {string} reqOpts.uri - A URI relative to the baseUrl. + */ + requestStream(reqOpts) { + const opts = extend(true, reqOpts, { shouldReturnStream: true }) + return this.request_(opts) + } } + exports.ServiceObject = ServiceObject + promisify_1.promisifyAll(ServiceObject, { + exclude: ['getRequestInterceptors'] + }) + //# sourceMappingURL=service-object.js.map - expression.split(/,/g).forEach(function (variable) { - var tmp = /([^:\*]*)(?::(\d+)|(\*))?/.exec(variable); - values.push(getValues(context, operator, tmp[1], tmp[2] || tmp[3])); - }); + /***/ + }, - if (operator && operator !== "+") { - var separator = ","; + /***/ 61682: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' - if (operator === "?") { - separator = "&"; - } else if (operator !== "#") { - separator = operator; + // Copyright 2015 Google LLC + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + Object.defineProperty(exports, '__esModule', { value: true }) + /*! + * @module common/service + */ + const arrify = __webpack_require__(61546) + const extend = __webpack_require__(38171) + const util_1 = __webpack_require__(12221) + const PROJECT_ID_TOKEN = '{{projectId}}' + class Service { + /** + * Service is a base class, meant to be inherited from by a "service," like + * BigQuery or Storage. + * + * This handles making authenticated requests by exposing a `makeReq_` + * function. + * + * @constructor + * @alias module:common/service + * + * @param {object} config - Configuration object. + * @param {string} config.baseUrl - The base URL to make API requests to. + * @param {string[]} config.scopes - The scopes required for the request. + * @param {object=} options - [Configuration object](#/docs). + */ + constructor(config, options = {}) { + this.baseUrl = config.baseUrl + this.apiEndpoint = config.apiEndpoint + this.timeout = options.timeout + this.globalInterceptors = arrify(options.interceptors_) + this.interceptors = [] + this.packageJson = config.packageJson + this.projectId = options.projectId || PROJECT_ID_TOKEN + this.projectIdRequired = config.projectIdRequired !== false + this.providedUserAgent = options.userAgent + const reqCfg = extend({}, config, { + projectIdRequired: this.projectIdRequired, + projectId: this.projectId, + authClient: options.authClient, + credentials: options.credentials, + keyFile: options.keyFilename, + email: options.email, + token: options.token + }) + this.makeAuthenticatedRequest = util_1.util.makeAuthenticatedRequestFactory( + reqCfg + ) + this.authClient = this.makeAuthenticatedRequest.authClient + this.getCredentials = this.makeAuthenticatedRequest.getCredentials + const isCloudFunctionEnv = !!process.env.FUNCTION_NAME + if (isCloudFunctionEnv) { + this.interceptors.push({ + request(reqOpts) { + reqOpts.forever = false + return reqOpts + } + }) + } + } + /** + * Return the user's custom request interceptors. + */ + getRequestInterceptors() { + // Interceptors should be returned in the order they were assigned. + return [].slice + .call(this.globalInterceptors) + .concat(this.interceptors) + .filter(interceptor => typeof interceptor.request === 'function') + .map(interceptor => interceptor.request) + } + getProjectId(callback) { + if (!callback) { + return this.getProjectIdAsync() + } + this.getProjectIdAsync().then(p => callback(null, p), callback) + } + async getProjectIdAsync() { + const projectId = await this.authClient.getProjectId() + if (this.projectId === PROJECT_ID_TOKEN && projectId) { + this.projectId = projectId + } + return this.projectId + } + request_(reqOpts, callback) { + reqOpts = extend(true, {}, reqOpts, { timeout: this.timeout }) + const isAbsoluteUrl = reqOpts.uri.indexOf('http') === 0 + const uriComponents = [this.baseUrl] + if (this.projectIdRequired) { + uriComponents.push('projects') + uriComponents.push(this.projectId) + } + uriComponents.push(reqOpts.uri) + if (isAbsoluteUrl) { + uriComponents.splice(0, uriComponents.indexOf(reqOpts.uri)) + } + reqOpts.uri = uriComponents + .map(uriComponent => { + const trimSlashesRegex = /^\/*|\/*$/g + return uriComponent.replace(trimSlashesRegex, '') + }) + .join('/') + // Some URIs have colon separators. + // Bad: https://.../projects/:list + // Good: https://.../projects:list + .replace(/\/:/g, ':') + const requestInterceptors = this.getRequestInterceptors() + arrify(reqOpts.interceptors_).forEach(interceptor => { + if (typeof interceptor.request === 'function') { + requestInterceptors.push(interceptor.request) + } + }) + requestInterceptors.forEach(requestInterceptor => { + reqOpts = requestInterceptor(reqOpts) + }) + delete reqOpts.interceptors_ + const pkg = this.packageJson + let userAgent = util_1.util.getUserAgentFromPackageJson(pkg) + if (this.providedUserAgent) { + userAgent = `${this.providedUserAgent} ${userAgent}` + } + reqOpts.headers = extend({}, reqOpts.headers, { + 'User-Agent': userAgent, + 'x-goog-api-client': `gl-node/${process.versions.node} gccl/${pkg.version}` + }) + if (reqOpts.shouldReturnStream) { + return this.makeAuthenticatedRequest(reqOpts) + } else { + this.makeAuthenticatedRequest(reqOpts, callback) + } + } + /** + * Make an authenticated API request. + * + * @param {object} reqOpts - Request options that are passed to `request`. + * @param {string} reqOpts.uri - A URI relative to the baseUrl. + * @param {function} callback - The callback function passed to `request`. + */ + request(reqOpts, callback) { + Service.prototype.request_.call(this, reqOpts, callback) + } + /** + * Make an authenticated API request. + * + * @param {object} reqOpts - Request options that are passed to `request`. + * @param {string} reqOpts.uri - A URI relative to the baseUrl. + */ + requestStream(reqOpts) { + const opts = extend(true, reqOpts, { shouldReturnStream: true }) + return Service.prototype.request_.call(this, opts) } - - return (values.length !== 0 ? operator : "") + values.join(separator); - } else { - return values.join(","); } - } else { - return encodeReserved(literal); - } - }); -} - -function parse(options) { - // https://fetch.spec.whatwg.org/#methods - let method = options.method.toUpperCase(); // replace :varname with {varname} to make it RFC 6570 compatible - - let url = (options.url || "/").replace(/:([a-z]\w+)/g, "{+$1}"); - let headers = Object.assign({}, options.headers); - let body; - let parameters = omit(options, ["method", "baseUrl", "url", "headers", "request", "mediaType"]); // extract variable names from URL to calculate remaining variables later - - const urlVariableNames = extractUrlVariableNames(url); - url = parseUrl(url).expand(parameters); - - if (!/^http/.test(url)) { - url = options.baseUrl + url; - } + exports.Service = Service + //# sourceMappingURL=service.js.map - const omittedParameters = Object.keys(options).filter(option => urlVariableNames.includes(option)).concat("baseUrl"); - const remainingParameters = omit(parameters, omittedParameters); - const isBinaryRequset = /application\/octet-stream/i.test(headers.accept); + /***/ + }, - if (!isBinaryRequset) { - if (options.mediaType.format) { - // e.g. application/vnd.github.v3+json => application/vnd.github.v3.raw - headers.accept = headers.accept.split(/,/).map(preview => preview.replace(/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/, `application/vnd$1$2.${options.mediaType.format}`)).join(","); - } + /***/ 12221: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' - if (options.mediaType.previews.length) { - const previewsFromAcceptHeader = headers.accept.match(/[\w-]+(?=-preview)/g) || []; - headers.accept = previewsFromAcceptHeader.concat(options.mediaType.previews).map(preview => { - const format = options.mediaType.format ? `.${options.mediaType.format}` : "+json"; - return `application/vnd.github.${preview}-preview${format}`; - }).join(","); - } - } // for GET/HEAD requests, set URL query parameters from remaining parameters - // for PATCH/POST/PUT/DELETE requests, set request body from remaining parameters - - - if (["GET", "HEAD"].includes(method)) { - url = addQueryParameters(url, remainingParameters); - } else { - if ("data" in remainingParameters) { - body = remainingParameters.data; - } else { - if (Object.keys(remainingParameters).length) { - body = remainingParameters; - } else { - headers["content-length"] = 0; + // Copyright 2014 Google LLC + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + Object.defineProperty(exports, '__esModule', { value: true }) + /*! + * @module common/util + */ + const projectify_1 = __webpack_require__(3497) + const ent = __webpack_require__(1151) + const extend = __webpack_require__(38171) + const google_auth_library_1 = __webpack_require__(20810) + const retryRequest = __webpack_require__(48679) + const stream_1 = __webpack_require__(92413) + const teeny_request_1 = __webpack_require__(6886) + // eslint-disable-next-line @typescript-eslint/no-var-requires + const duplexify = __webpack_require__(76599) + const requestDefaults = { + timeout: 60000, + gzip: true, + forever: true, + pool: { + maxSockets: Infinity + } } - } - } // default content-type for JSON if body is set - - - if (!headers["content-type"] && typeof body !== "undefined") { - headers["content-type"] = "application/json; charset=utf-8"; - } // GitHub expects 'content-length: 0' header for PUT/PATCH requests without body. - // fetch does not allow to set `content-length` header, but we can set body to an empty string - - - if (["PATCH", "PUT"].includes(method) && typeof body === "undefined") { - body = ""; - } // Only return body/request keys if present - - - return Object.assign({ - method, - url, - headers - }, typeof body !== "undefined" ? { - body - } : null, options.request ? { - request: options.request - } : null); -} - -function endpointWithDefaults(defaults, route, options) { - return parse(merge(defaults, route, options)); -} - -function withDefaults(oldDefaults, newDefaults) { - const DEFAULTS = merge(oldDefaults, newDefaults); - const endpoint = endpointWithDefaults.bind(null, DEFAULTS); - return Object.assign(endpoint, { - DEFAULTS, - defaults: withDefaults.bind(null, DEFAULTS), - merge: merge.bind(null, DEFAULTS), - parse - }); -} - -const VERSION = "5.5.3"; - -const userAgent = `octokit-endpoint.js/${VERSION} ${universalUserAgent.getUserAgent()}`; // DEFAULTS has all properties set that EndpointOptions has, except url. -// So we use RequestParameters and add method as additional required property. - -const DEFAULTS = { - method: "GET", - baseUrl: "https://api.github.com", - headers: { - accept: "application/vnd.github.v3+json", - "user-agent": userAgent - }, - mediaType: { - format: "", - previews: [] - } -}; - -const endpoint = withDefaults(null, DEFAULTS); - -exports.endpoint = endpoint; -//# sourceMappingURL=index.js.map - - -/***/ }), - -/***/ 4038: -/***/ ((module) => { - -"use strict"; - - -/*! - * isobject - * - * Copyright (c) 2014-2017, Jon Schlinkert. - * Released under the MIT License. - */ - -function isObject(val) { - return val != null && typeof val === 'object' && Array.isArray(val) === false; -} - -/*! - * is-plain-object - * - * Copyright (c) 2014-2017, Jon Schlinkert. - * Released under the MIT License. - */ - -function isObjectObject(o) { - return isObject(o) === true - && Object.prototype.toString.call(o) === '[object Object]'; -} - -function isPlainObject(o) { - var ctor,prot; - - if (isObjectObject(o) === false) return false; - - // If has modified constructor - ctor = o.constructor; - if (typeof ctor !== 'function') return false; - - // If has modified prototype - prot = ctor.prototype; - if (isObjectObject(prot) === false) return false; - - // If constructor does not have an Object-specific method - if (prot.hasOwnProperty('isPrototypeOf') === false) { - return false; - } - - // Most likely a plain Object - return true; -} - -module.exports = isPlainObject; - - -/***/ }), - -/***/ 1292: -/***/ ((__unused_webpack_module, exports, __webpack_require__) => { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", ({ value: true })); + /** + * Custom error type for API errors. + * + * @param {object} errorBody - Error object. + */ + class ApiError extends Error { + constructor(errorBodyOrMessage) { + super() + if (typeof errorBodyOrMessage !== 'object') { + this.message = errorBodyOrMessage || '' + return + } + const errorBody = errorBodyOrMessage + this.code = errorBody.code + this.errors = errorBody.errors + this.response = errorBody.response + try { + this.errors = JSON.parse(this.response.body).error.errors + } catch (e) { + this.errors = errorBody.errors + } + this.message = ApiError.createMultiErrorMessage( + errorBody, + this.errors + ) + Error.captureStackTrace(this) + } + /** + * Pieces together an error message by combining all unique error messages + * returned from a single GoogleError + * + * @private + * + * @param {GoogleErrorBody} err The original error. + * @param {GoogleInnerError[]} [errors] Inner errors, if any. + * @returns {string} + */ + static createMultiErrorMessage(err, errors) { + const messages = new Set() + if (err.message) { + messages.add(err.message) + } + if (errors && errors.length) { + errors.forEach(({ message }) => messages.add(message)) + } else if (err.response && err.response.body) { + messages.add(ent.decode(err.response.body.toString())) + } else if (!err.message) { + messages.add('A failure occurred during this request.') + } + let messageArr = Array.from(messages) + if (messageArr.length > 1) { + messageArr = messageArr.map( + (message, i) => ` ${i + 1}. ${message}` + ) + messageArr.unshift( + 'Multiple errors occurred during the request. Please see the `errors` array for complete details.\n' + ) + messageArr.push('\n') + } + return messageArr.join('\n') + } + } + exports.ApiError = ApiError + /** + * Custom error type for partial errors returned from the API. + * + * @param {object} b - Error object. + */ + class PartialFailureError extends Error { + constructor(b) { + super() + const errorObject = b + this.errors = errorObject.errors + this.name = 'PartialFailureError' + this.response = errorObject.response + this.message = ApiError.createMultiErrorMessage( + errorObject, + this.errors + ) + } + } + exports.PartialFailureError = PartialFailureError + class Util { + constructor() { + this.ApiError = ApiError + this.PartialFailureError = PartialFailureError + } + /** + * No op. + * + * @example + * function doSomething(callback) { + * callback = callback || noop; + * } + */ + noop() {} + /** + * Uniformly process an API response. + * + * @param {*} err - Error value. + * @param {*} resp - Response value. + * @param {*} body - Body value. + * @param {function} callback - The callback function. + */ + handleResp(err, resp, body, callback) { + callback = callback || util.noop + const parsedResp = extend( + true, + { err: err || null }, + resp && util.parseHttpRespMessage(resp), + body && util.parseHttpRespBody(body) + ) + // Assign the parsed body to resp.body, even if { json: false } was passed + // as a request option. + // We assume that nobody uses the previously unparsed value of resp.body. + if (!parsedResp.err && resp && typeof parsedResp.body === 'object') { + parsedResp.resp.body = parsedResp.body + } + if (parsedResp.err && resp) { + parsedResp.err.response = resp + } + callback(parsedResp.err, parsedResp.body, parsedResp.resp) + } + /** + * Sniff an incoming HTTP response message for errors. + * + * @param {object} httpRespMessage - An incoming HTTP response message from `request`. + * @return {object} parsedHttpRespMessage - The parsed response. + * @param {?error} parsedHttpRespMessage.err - An error detected. + * @param {object} parsedHttpRespMessage.resp - The original response object. + */ + parseHttpRespMessage(httpRespMessage) { + const parsedHttpRespMessage = { + resp: httpRespMessage + } + if ( + httpRespMessage.statusCode < 200 || + httpRespMessage.statusCode > 299 + ) { + // Unknown error. Format according to ApiError standard. + parsedHttpRespMessage.err = new ApiError({ + errors: new Array(), + code: httpRespMessage.statusCode, + message: httpRespMessage.statusMessage, + response: httpRespMessage + }) + } + return parsedHttpRespMessage + } + /** + * Parse the response body from an HTTP request. + * + * @param {object} body - The response body. + * @return {object} parsedHttpRespMessage - The parsed response. + * @param {?error} parsedHttpRespMessage.err - An error detected. + * @param {object} parsedHttpRespMessage.body - The original body value provided + * will try to be JSON.parse'd. If it's successful, the parsed value will + * be returned here, otherwise the original value and an error will be returned. + */ + parseHttpRespBody(body) { + const parsedHttpRespBody = { + body + } + if (typeof body === 'string') { + try { + parsedHttpRespBody.body = JSON.parse(body) + } catch (err) { + parsedHttpRespBody.body = body + } + } + if (parsedHttpRespBody.body && parsedHttpRespBody.body.error) { + // Error from JSON API. + parsedHttpRespBody.err = new ApiError(parsedHttpRespBody.body.error) + } + return parsedHttpRespBody + } + /** + * Take a Duplexify stream, fetch an authenticated connection header, and + * create an outgoing writable stream. + * + * @param {Duplexify} dup - Duplexify stream. + * @param {object} options - Configuration object. + * @param {module:common/connection} options.connection - A connection instance used to get a token with and send the request through. + * @param {object} options.metadata - Metadata to send at the head of the request. + * @param {object} options.request - Request object, in the format of a standard Node.js http.request() object. + * @param {string=} options.request.method - Default: "POST". + * @param {string=} options.request.qs.uploadType - Default: "multipart". + * @param {string=} options.streamContentType - Default: "application/octet-stream". + * @param {function} onComplete - Callback, executed after the writable Request stream has completed. + */ + makeWritableStream(dup, options, onComplete) { + onComplete = onComplete || util.noop + const writeStream = new ProgressStream() + writeStream.on('progress', evt => dup.emit('progress', evt)) + dup.setWritable(writeStream) + const defaultReqOpts = { + method: 'POST', + qs: { + uploadType: 'multipart' + }, + timeout: 0, + maxRetries: 0 + } + const metadata = options.metadata || {} + const reqOpts = extend(true, defaultReqOpts, options.request, { + multipart: [ + { + 'Content-Type': 'application/json', + body: JSON.stringify(metadata) + }, + { + 'Content-Type': + metadata.contentType || 'application/octet-stream', + body: writeStream + } + ] + }) + options.makeAuthenticatedRequest(reqOpts, { + onAuthenticated(err, authenticatedReqOpts) { + if (err) { + dup.destroy(err) + return + } + const request = teeny_request_1.teenyRequest.defaults( + requestDefaults + ) + request(authenticatedReqOpts, (err, resp, body) => { + util.handleResp(err, resp, body, (err, data) => { + if (err) { + dup.destroy(err) + return + } + dup.emit('response', resp) + onComplete(data) + }) + }) + } + }) + } + /** + * Returns true if the API request should be retried, given the error that was + * given the first time the request was attempted. This is used for rate limit + * related errors as well as intermittent server errors. + * + * @param {error} err - The API error to check if it is appropriate to retry. + * @return {boolean} True if the API request should be retried, false otherwise. + */ + shouldRetryRequest(err) { + if (err) { + if ([408, 429, 500, 502, 503].indexOf(err.code) !== -1) { + return true + } + if (err.errors) { + for (const e of err.errors) { + const reason = e.reason + if (reason === 'rateLimitExceeded') { + return true + } + if (reason === 'userRateLimitExceeded') { + return true + } + if (reason && reason.includes('EAI_AGAIN')) { + return true + } + } + } + } + return false + } + /** + * Get a function for making authenticated requests. + * + * @param {object} config - Configuration object. + * @param {boolean=} config.autoRetry - Automatically retry requests if the + * response is related to rate limits or certain intermittent server + * errors. We will exponentially backoff subsequent requests by default. + * (default: true) + * @param {object=} config.credentials - Credentials object. + * @param {boolean=} config.customEndpoint - If true, just return the provided request options. Default: false. + * @param {string=} config.email - Account email address, required for PEM/P12 usage. + * @param {number=} config.maxRetries - Maximum number of automatic retries attempted before returning the error. (default: 3) + * @param {string=} config.keyFile - Path to a .json, .pem, or .p12 keyfile. + * @param {array} config.scopes - Array of scopes required for the API. + */ + makeAuthenticatedRequestFactory(config) { + const googleAutoAuthConfig = extend({}, config) + if (googleAutoAuthConfig.projectId === '{{projectId}}') { + delete googleAutoAuthConfig.projectId + } + const authClient = + googleAutoAuthConfig.authClient || + new google_auth_library_1.GoogleAuth(googleAutoAuthConfig) + function makeAuthenticatedRequest(reqOpts, optionsOrCallback) { + let stream + const reqConfig = extend({}, config) + let activeRequest_ + if (!optionsOrCallback) { + stream = duplexify() + reqConfig.stream = stream + } + const options = + typeof optionsOrCallback === 'object' + ? optionsOrCallback + : undefined + const callback = + typeof optionsOrCallback === 'function' + ? optionsOrCallback + : undefined + const onAuthenticated = (err, authenticatedReqOpts) => { + const authLibraryError = err + const autoAuthFailed = + err && + err.message.indexOf('Could not load the default credentials') > + -1 + if (autoAuthFailed) { + // Even though authentication failed, the API might not actually + // care. + authenticatedReqOpts = reqOpts + } + if (!err || autoAuthFailed) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + let projectId = authClient._cachedProjectId + if (config.projectId && config.projectId !== '{{projectId}}') { + projectId = config.projectId + } + try { + authenticatedReqOpts = util.decorateRequest( + authenticatedReqOpts, + projectId + ) + err = null + } catch (e) { + // A projectId was required, but we don't have one. + // Re-use the "Could not load the default credentials error" if + // auto auth failed. + err = err || e + } + } + if (err) { + if (stream) { + stream.destroy(err) + } else { + const fn = + options && options.onAuthenticated + ? options.onAuthenticated + : callback + fn(err) + } + return + } + if (options && options.onAuthenticated) { + options.onAuthenticated(null, authenticatedReqOpts) + } else { + activeRequest_ = util.makeRequest( + authenticatedReqOpts, + reqConfig, + (apiResponseError, ...params) => { + if ( + apiResponseError && + apiResponseError.code === 401 && + authLibraryError + ) { + // Re-use the "Could not load the default credentials error" if + // the API request failed due to missing credentials. + apiResponseError = authLibraryError + } + callback(apiResponseError, ...params) + } + ) + } + } + if (reqConfig.customEndpoint) { + // Using a custom API override. Do not use `google-auth-library` for + // authentication. (ex: connecting to a local Datastore server) + onAuthenticated(null, reqOpts) + } else { + authClient.authorizeRequest(reqOpts).then( + res => { + const opts = extend(true, {}, reqOpts, res) + onAuthenticated(null, opts) + }, + err => { + onAuthenticated(err) + } + ) + } + if (stream) { + return stream + } + return { + abort() { + setImmediate(() => { + if (activeRequest_) { + activeRequest_.abort() + activeRequest_ = null + } + }) + } + } + } + const mar = makeAuthenticatedRequest + mar.getCredentials = authClient.getCredentials.bind(authClient) + mar.authClient = authClient + return mar + } + /** + * Make a request through the `retryRequest` module with built-in error + * handling and exponential back off. + * + * @param {object} reqOpts - Request options in the format `request` expects. + * @param {object=} config - Configuration object. + * @param {boolean=} config.autoRetry - Automatically retry requests if the + * response is related to rate limits or certain intermittent server + * errors. We will exponentially backoff subsequent requests by default. + * (default: true) + * @param {number=} config.maxRetries - Maximum number of automatic retries + * attempted before returning the error. (default: 3) + * @param {object=} config.request - HTTP module for request calls. + * @param {function} callback - The callback function. + */ + makeRequest(reqOpts, config, callback) { + const options = { + request: teeny_request_1.teenyRequest.defaults(requestDefaults), + retries: config.autoRetry !== false ? config.maxRetries || 3 : 0, + shouldRetryFn(httpRespMessage) { + const err = util.parseHttpRespMessage(httpRespMessage).err + return err && util.shouldRetryRequest(err) + } + } + if (typeof reqOpts.maxRetries === 'number') { + options.retries = reqOpts.maxRetries + } + if (!config.stream) { + return retryRequest(reqOpts, options, (err, response, body) => { + util.handleResp(err, response, body, callback) + }) + } + const dup = config.stream + // eslint-disable-next-line @typescript-eslint/no-explicit-any + let requestStream + const isGetRequest = (reqOpts.method || 'GET').toUpperCase() === 'GET' + if (isGetRequest) { + requestStream = retryRequest(reqOpts, options) + dup.setReadable(requestStream) + } else { + // Streaming writable HTTP requests cannot be retried. + requestStream = options.request(reqOpts) + dup.setWritable(requestStream) + } + // Replay the Request events back to the stream. + requestStream + .on('error', dup.destroy.bind(dup)) + .on('response', dup.emit.bind(dup, 'response')) + .on('complete', dup.emit.bind(dup, 'complete')) + dup.abort = requestStream.abort + return dup + } + /** + * Decorate the options about to be made in a request. + * + * @param {object} reqOpts - The options to be passed to `request`. + * @param {string} projectId - The project ID. + * @return {object} reqOpts - The decorated reqOpts. + */ + decorateRequest(reqOpts, projectId) { + delete reqOpts.autoPaginate + delete reqOpts.autoPaginateVal + delete reqOpts.objectMode + if (reqOpts.qs !== null && typeof reqOpts.qs === 'object') { + delete reqOpts.qs.autoPaginate + delete reqOpts.qs.autoPaginateVal + reqOpts.qs = projectify_1.replaceProjectIdToken( + reqOpts.qs, + projectId + ) + } + if (Array.isArray(reqOpts.multipart)) { + reqOpts.multipart = reqOpts.multipart.map(part => { + return projectify_1.replaceProjectIdToken(part, projectId) + }) + } + if (reqOpts.json !== null && typeof reqOpts.json === 'object') { + delete reqOpts.json.autoPaginate + delete reqOpts.json.autoPaginateVal + reqOpts.json = projectify_1.replaceProjectIdToken( + reqOpts.json, + projectId + ) + } + reqOpts.uri = projectify_1.replaceProjectIdToken( + reqOpts.uri, + projectId + ) + return reqOpts + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + isCustomType(unknown, module) { + function getConstructorName(obj) { + return obj.constructor && obj.constructor.name.toLowerCase() + } + const moduleNameParts = module.split('/') + const parentModuleName = + moduleNameParts[0] && moduleNameParts[0].toLowerCase() + const subModuleName = + moduleNameParts[1] && moduleNameParts[1].toLowerCase() + if (subModuleName && getConstructorName(unknown) !== subModuleName) { + return false + } + let walkingModule = unknown + // eslint-disable-next-line no-constant-condition + while (true) { + if (getConstructorName(walkingModule) === parentModuleName) { + return true + } + walkingModule = walkingModule.parent + if (!walkingModule) { + return false + } + } + } + /** + * Create a properly-formatted User-Agent string from a package.json file. + * + * @param {object} packageJson - A module's package.json file. + * @return {string} userAgent - The formatted User-Agent string. + */ + getUserAgentFromPackageJson(packageJson) { + const hyphenatedPackageName = packageJson.name + .replace('@google-cloud', 'gcloud-node') // For legacy purposes. + .replace('/', '-') // For UA spec-compliance purposes. + return hyphenatedPackageName + '/' + packageJson.version + } + /** + * Given two parameters, figure out if this is either: + * - Just a callback function + * - An options object, and then a callback function + * @param optionsOrCallback An options object or callback. + * @param cb A potentially undefined callback. + */ + maybeOptionsOrCallback(optionsOrCallback, cb) { + return typeof optionsOrCallback === 'function' + ? [{}, optionsOrCallback] + : [optionsOrCallback, cb] + } + } + exports.Util = Util + /** + * Basic Passthrough Stream that records the number of bytes read + * every time the cursor is moved. + */ + class ProgressStream extends stream_1.Transform { + constructor() { + super(...arguments) + this.bytesRead = 0 + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + _transform(chunk, encoding, callback) { + this.bytesRead += chunk.length + this.emit('progress', { + bytesWritten: this.bytesRead, + contentLength: '*' + }) + this.push(chunk) + callback() + } + } + const util = new Util() + exports.util = util + //# sourceMappingURL=util.js.map -function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } + /***/ + }, -var osName = _interopDefault(__webpack_require__(4824)); + /***/ 86114: /***/ function ( + module, + __unused_webpack_exports, + __webpack_require__ + ) { + /* module decorator */ module = __webpack_require__.nmd(module) + // Copyright 2020 Google LLC + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + + /*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/ + ;(function (global, factory) { + /* global define, require, module */ + + /* AMD */ if (typeof define === 'function' && define.amd) + define(['protobufjs/minimal'], factory) + /* CommonJS */ else if (true && module && module.exports) + module.exports = factory(__webpack_require__(12263).protobufMinimal) + })(this, function ($protobuf) { + 'use strict' + + // Common aliases + var $Reader = $protobuf.Reader, + $Writer = $protobuf.Writer, + $util = $protobuf.util + + // Exported root namespace + var $root = + $protobuf.roots._google_cloud_logging_protos || + ($protobuf.roots._google_cloud_logging_protos = {}) + + $root.google = (function () { + /** + * Namespace google. + * @exports google + * @namespace + */ + var google = {} + + google.logging = (function () { + /** + * Namespace logging. + * @memberof google + * @namespace + */ + var logging = {} + + logging.v2 = (function () { + /** + * Namespace v2. + * @memberof google.logging + * @namespace + */ + var v2 = {} + + v2.LogEntry = (function () { + /** + * Properties of a LogEntry. + * @memberof google.logging.v2 + * @interface ILogEntry + * @property {string|null} [logName] LogEntry logName + * @property {google.api.IMonitoredResource|null} [resource] LogEntry resource + * @property {google.protobuf.IAny|null} [protoPayload] LogEntry protoPayload + * @property {string|null} [textPayload] LogEntry textPayload + * @property {google.protobuf.IStruct|null} [jsonPayload] LogEntry jsonPayload + * @property {google.protobuf.ITimestamp|null} [timestamp] LogEntry timestamp + * @property {google.protobuf.ITimestamp|null} [receiveTimestamp] LogEntry receiveTimestamp + * @property {google.logging.type.LogSeverity|null} [severity] LogEntry severity + * @property {string|null} [insertId] LogEntry insertId + * @property {google.logging.type.IHttpRequest|null} [httpRequest] LogEntry httpRequest + * @property {Object.|null} [labels] LogEntry labels + * @property {google.logging.v2.ILogEntryOperation|null} [operation] LogEntry operation + * @property {string|null} [trace] LogEntry trace + * @property {string|null} [spanId] LogEntry spanId + * @property {boolean|null} [traceSampled] LogEntry traceSampled + * @property {google.logging.v2.ILogEntrySourceLocation|null} [sourceLocation] LogEntry sourceLocation + */ + + /** + * Constructs a new LogEntry. + * @memberof google.logging.v2 + * @classdesc Represents a LogEntry. + * @implements ILogEntry + * @constructor + * @param {google.logging.v2.ILogEntry=} [properties] Properties to set + */ + function LogEntry(properties) { + this.labels = {} + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } -function getUserAgent() { - try { - return `Node.js/${process.version.substr(1)} (${osName()}; ${process.arch})`; - } catch (error) { - if (/wmic os get Caption/.test(error.message)) { - return "Windows "; - } + /** + * LogEntry logName. + * @member {string} logName + * @memberof google.logging.v2.LogEntry + * @instance + */ + LogEntry.prototype.logName = '' + + /** + * LogEntry resource. + * @member {google.api.IMonitoredResource|null|undefined} resource + * @memberof google.logging.v2.LogEntry + * @instance + */ + LogEntry.prototype.resource = null + + /** + * LogEntry protoPayload. + * @member {google.protobuf.IAny|null|undefined} protoPayload + * @memberof google.logging.v2.LogEntry + * @instance + */ + LogEntry.prototype.protoPayload = null + + /** + * LogEntry textPayload. + * @member {string} textPayload + * @memberof google.logging.v2.LogEntry + * @instance + */ + LogEntry.prototype.textPayload = '' + + /** + * LogEntry jsonPayload. + * @member {google.protobuf.IStruct|null|undefined} jsonPayload + * @memberof google.logging.v2.LogEntry + * @instance + */ + LogEntry.prototype.jsonPayload = null + + /** + * LogEntry timestamp. + * @member {google.protobuf.ITimestamp|null|undefined} timestamp + * @memberof google.logging.v2.LogEntry + * @instance + */ + LogEntry.prototype.timestamp = null + + /** + * LogEntry receiveTimestamp. + * @member {google.protobuf.ITimestamp|null|undefined} receiveTimestamp + * @memberof google.logging.v2.LogEntry + * @instance + */ + LogEntry.prototype.receiveTimestamp = null + + /** + * LogEntry severity. + * @member {google.logging.type.LogSeverity} severity + * @memberof google.logging.v2.LogEntry + * @instance + */ + LogEntry.prototype.severity = 0 + + /** + * LogEntry insertId. + * @member {string} insertId + * @memberof google.logging.v2.LogEntry + * @instance + */ + LogEntry.prototype.insertId = '' + + /** + * LogEntry httpRequest. + * @member {google.logging.type.IHttpRequest|null|undefined} httpRequest + * @memberof google.logging.v2.LogEntry + * @instance + */ + LogEntry.prototype.httpRequest = null + + /** + * LogEntry labels. + * @member {Object.} labels + * @memberof google.logging.v2.LogEntry + * @instance + */ + LogEntry.prototype.labels = $util.emptyObject + + /** + * LogEntry operation. + * @member {google.logging.v2.ILogEntryOperation|null|undefined} operation + * @memberof google.logging.v2.LogEntry + * @instance + */ + LogEntry.prototype.operation = null + + /** + * LogEntry trace. + * @member {string} trace + * @memberof google.logging.v2.LogEntry + * @instance + */ + LogEntry.prototype.trace = '' + + /** + * LogEntry spanId. + * @member {string} spanId + * @memberof google.logging.v2.LogEntry + * @instance + */ + LogEntry.prototype.spanId = '' + + /** + * LogEntry traceSampled. + * @member {boolean} traceSampled + * @memberof google.logging.v2.LogEntry + * @instance + */ + LogEntry.prototype.traceSampled = false + + /** + * LogEntry sourceLocation. + * @member {google.logging.v2.ILogEntrySourceLocation|null|undefined} sourceLocation + * @memberof google.logging.v2.LogEntry + * @instance + */ + LogEntry.prototype.sourceLocation = null + + // OneOf field names bound to virtual getters and setters + var $oneOfFields + + /** + * LogEntry payload. + * @member {"protoPayload"|"textPayload"|"jsonPayload"|undefined} payload + * @memberof google.logging.v2.LogEntry + * @instance + */ + Object.defineProperty(LogEntry.prototype, 'payload', { + get: $util.oneOfGetter( + ($oneOfFields = [ + 'protoPayload', + 'textPayload', + 'jsonPayload' + ]) + ), + set: $util.oneOfSetter($oneOfFields) + }) + + /** + * Creates a new LogEntry instance using the specified properties. + * @function create + * @memberof google.logging.v2.LogEntry + * @static + * @param {google.logging.v2.ILogEntry=} [properties] Properties to set + * @returns {google.logging.v2.LogEntry} LogEntry instance + */ + LogEntry.create = function create(properties) { + return new LogEntry(properties) + } - return ""; - } -} + /** + * Encodes the specified LogEntry message. Does not implicitly {@link google.logging.v2.LogEntry.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.LogEntry + * @static + * @param {google.logging.v2.ILogEntry} message LogEntry message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LogEntry.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.protoPayload != null && + Object.hasOwnProperty.call(message, 'protoPayload') + ) + $root.google.protobuf.Any.encode( + message.protoPayload, + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + ).ldelim() + if ( + message.textPayload != null && + Object.hasOwnProperty.call(message, 'textPayload') + ) + writer + .uint32(/* id 3, wireType 2 =*/ 26) + .string(message.textPayload) + if ( + message.insertId != null && + Object.hasOwnProperty.call(message, 'insertId') + ) + writer + .uint32(/* id 4, wireType 2 =*/ 34) + .string(message.insertId) + if ( + message.jsonPayload != null && + Object.hasOwnProperty.call(message, 'jsonPayload') + ) + $root.google.protobuf.Struct.encode( + message.jsonPayload, + writer.uint32(/* id 6, wireType 2 =*/ 50).fork() + ).ldelim() + if ( + message.httpRequest != null && + Object.hasOwnProperty.call(message, 'httpRequest') + ) + $root.google.logging.type.HttpRequest.encode( + message.httpRequest, + writer.uint32(/* id 7, wireType 2 =*/ 58).fork() + ).ldelim() + if ( + message.resource != null && + Object.hasOwnProperty.call(message, 'resource') + ) + $root.google.api.MonitoredResource.encode( + message.resource, + writer.uint32(/* id 8, wireType 2 =*/ 66).fork() + ).ldelim() + if ( + message.timestamp != null && + Object.hasOwnProperty.call(message, 'timestamp') + ) + $root.google.protobuf.Timestamp.encode( + message.timestamp, + writer.uint32(/* id 9, wireType 2 =*/ 74).fork() + ).ldelim() + if ( + message.severity != null && + Object.hasOwnProperty.call(message, 'severity') + ) + writer + .uint32(/* id 10, wireType 0 =*/ 80) + .int32(message.severity) + if ( + message.labels != null && + Object.hasOwnProperty.call(message, 'labels') + ) + for ( + var keys = Object.keys(message.labels), i = 0; + i < keys.length; + ++i + ) + writer + .uint32(/* id 11, wireType 2 =*/ 90) + .fork() + .uint32(/* id 1, wireType 2 =*/ 10) + .string(keys[i]) + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.labels[keys[i]]) + .ldelim() + if ( + message.logName != null && + Object.hasOwnProperty.call(message, 'logName') + ) + writer + .uint32(/* id 12, wireType 2 =*/ 98) + .string(message.logName) + if ( + message.operation != null && + Object.hasOwnProperty.call(message, 'operation') + ) + $root.google.logging.v2.LogEntryOperation.encode( + message.operation, + writer.uint32(/* id 15, wireType 2 =*/ 122).fork() + ).ldelim() + if ( + message.trace != null && + Object.hasOwnProperty.call(message, 'trace') + ) + writer + .uint32(/* id 22, wireType 2 =*/ 178) + .string(message.trace) + if ( + message.sourceLocation != null && + Object.hasOwnProperty.call(message, 'sourceLocation') + ) + $root.google.logging.v2.LogEntrySourceLocation.encode( + message.sourceLocation, + writer.uint32(/* id 23, wireType 2 =*/ 186).fork() + ).ldelim() + if ( + message.receiveTimestamp != null && + Object.hasOwnProperty.call(message, 'receiveTimestamp') + ) + $root.google.protobuf.Timestamp.encode( + message.receiveTimestamp, + writer.uint32(/* id 24, wireType 2 =*/ 194).fork() + ).ldelim() + if ( + message.spanId != null && + Object.hasOwnProperty.call(message, 'spanId') + ) + writer + .uint32(/* id 27, wireType 2 =*/ 218) + .string(message.spanId) + if ( + message.traceSampled != null && + Object.hasOwnProperty.call(message, 'traceSampled') + ) + writer + .uint32(/* id 30, wireType 0 =*/ 240) + .bool(message.traceSampled) + return writer + } -exports.getUserAgent = getUserAgent; -//# sourceMappingURL=index.js.map + /** + * Encodes the specified LogEntry message, length delimited. Does not implicitly {@link google.logging.v2.LogEntry.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.LogEntry + * @static + * @param {google.logging.v2.ILogEntry} message LogEntry message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LogEntry.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + /** + * Decodes a LogEntry message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.LogEntry + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.LogEntry} LogEntry + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LogEntry.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.LogEntry(), + key, + value + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 12: + message.logName = reader.string() + break + case 8: + message.resource = $root.google.api.MonitoredResource.decode( + reader, + reader.uint32() + ) + break + case 2: + message.protoPayload = $root.google.protobuf.Any.decode( + reader, + reader.uint32() + ) + break + case 3: + message.textPayload = reader.string() + break + case 6: + message.jsonPayload = $root.google.protobuf.Struct.decode( + reader, + reader.uint32() + ) + break + case 9: + message.timestamp = $root.google.protobuf.Timestamp.decode( + reader, + reader.uint32() + ) + break + case 24: + message.receiveTimestamp = $root.google.protobuf.Timestamp.decode( + reader, + reader.uint32() + ) + break + case 10: + message.severity = reader.int32() + break + case 4: + message.insertId = reader.string() + break + case 7: + message.httpRequest = $root.google.logging.type.HttpRequest.decode( + reader, + reader.uint32() + ) + break + case 11: + if (message.labels === $util.emptyObject) + message.labels = {} + var end2 = reader.uint32() + reader.pos + key = '' + value = '' + while (reader.pos < end2) { + var tag2 = reader.uint32() + switch (tag2 >>> 3) { + case 1: + key = reader.string() + break + case 2: + value = reader.string() + break + default: + reader.skipType(tag2 & 7) + break + } + } + message.labels[key] = value + break + case 15: + message.operation = $root.google.logging.v2.LogEntryOperation.decode( + reader, + reader.uint32() + ) + break + case 22: + message.trace = reader.string() + break + case 27: + message.spanId = reader.string() + break + case 30: + message.traceSampled = reader.bool() + break + case 23: + message.sourceLocation = $root.google.logging.v2.LogEntrySourceLocation.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } -/***/ }), + /** + * Decodes a LogEntry message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.LogEntry + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.LogEntry} LogEntry + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LogEntry.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } -/***/ 8467: -/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + /** + * Verifies a LogEntry message. + * @function verify + * @memberof google.logging.v2.LogEntry + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + LogEntry.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + var properties = {} + if ( + message.logName != null && + message.hasOwnProperty('logName') + ) + if (!$util.isString(message.logName)) + return 'logName: string expected' + if ( + message.resource != null && + message.hasOwnProperty('resource') + ) { + var error = $root.google.api.MonitoredResource.verify( + message.resource + ) + if (error) return 'resource.' + error + } + if ( + message.protoPayload != null && + message.hasOwnProperty('protoPayload') + ) { + properties.payload = 1 + { + var error = $root.google.protobuf.Any.verify( + message.protoPayload + ) + if (error) return 'protoPayload.' + error + } + } + if ( + message.textPayload != null && + message.hasOwnProperty('textPayload') + ) { + if (properties.payload === 1) + return 'payload: multiple values' + properties.payload = 1 + if (!$util.isString(message.textPayload)) + return 'textPayload: string expected' + } + if ( + message.jsonPayload != null && + message.hasOwnProperty('jsonPayload') + ) { + if (properties.payload === 1) + return 'payload: multiple values' + properties.payload = 1 + { + var error = $root.google.protobuf.Struct.verify( + message.jsonPayload + ) + if (error) return 'jsonPayload.' + error + } + } + if ( + message.timestamp != null && + message.hasOwnProperty('timestamp') + ) { + var error = $root.google.protobuf.Timestamp.verify( + message.timestamp + ) + if (error) return 'timestamp.' + error + } + if ( + message.receiveTimestamp != null && + message.hasOwnProperty('receiveTimestamp') + ) { + var error = $root.google.protobuf.Timestamp.verify( + message.receiveTimestamp + ) + if (error) return 'receiveTimestamp.' + error + } + if ( + message.severity != null && + message.hasOwnProperty('severity') + ) + switch (message.severity) { + default: + return 'severity: enum value expected' + case 0: + case 100: + case 200: + case 300: + case 400: + case 500: + case 600: + case 700: + case 800: + break + } + if ( + message.insertId != null && + message.hasOwnProperty('insertId') + ) + if (!$util.isString(message.insertId)) + return 'insertId: string expected' + if ( + message.httpRequest != null && + message.hasOwnProperty('httpRequest') + ) { + var error = $root.google.logging.type.HttpRequest.verify( + message.httpRequest + ) + if (error) return 'httpRequest.' + error + } + if ( + message.labels != null && + message.hasOwnProperty('labels') + ) { + if (!$util.isObject(message.labels)) + return 'labels: object expected' + var key = Object.keys(message.labels) + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.labels[key[i]])) + return 'labels: string{k:string} expected' + } + if ( + message.operation != null && + message.hasOwnProperty('operation') + ) { + var error = $root.google.logging.v2.LogEntryOperation.verify( + message.operation + ) + if (error) return 'operation.' + error + } + if (message.trace != null && message.hasOwnProperty('trace')) + if (!$util.isString(message.trace)) + return 'trace: string expected' + if ( + message.spanId != null && + message.hasOwnProperty('spanId') + ) + if (!$util.isString(message.spanId)) + return 'spanId: string expected' + if ( + message.traceSampled != null && + message.hasOwnProperty('traceSampled') + ) + if (typeof message.traceSampled !== 'boolean') + return 'traceSampled: boolean expected' + if ( + message.sourceLocation != null && + message.hasOwnProperty('sourceLocation') + ) { + var error = $root.google.logging.v2.LogEntrySourceLocation.verify( + message.sourceLocation + ) + if (error) return 'sourceLocation.' + error + } + return null + } -"use strict"; + /** + * Creates a LogEntry message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.LogEntry + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.LogEntry} LogEntry + */ + LogEntry.fromObject = function fromObject(object) { + if (object instanceof $root.google.logging.v2.LogEntry) + return object + var message = new $root.google.logging.v2.LogEntry() + if (object.logName != null) + message.logName = String(object.logName) + if (object.resource != null) { + if (typeof object.resource !== 'object') + throw TypeError( + '.google.logging.v2.LogEntry.resource: object expected' + ) + message.resource = $root.google.api.MonitoredResource.fromObject( + object.resource + ) + } + if (object.protoPayload != null) { + if (typeof object.protoPayload !== 'object') + throw TypeError( + '.google.logging.v2.LogEntry.protoPayload: object expected' + ) + message.protoPayload = $root.google.protobuf.Any.fromObject( + object.protoPayload + ) + } + if (object.textPayload != null) + message.textPayload = String(object.textPayload) + if (object.jsonPayload != null) { + if (typeof object.jsonPayload !== 'object') + throw TypeError( + '.google.logging.v2.LogEntry.jsonPayload: object expected' + ) + message.jsonPayload = $root.google.protobuf.Struct.fromObject( + object.jsonPayload + ) + } + if (object.timestamp != null) { + if (typeof object.timestamp !== 'object') + throw TypeError( + '.google.logging.v2.LogEntry.timestamp: object expected' + ) + message.timestamp = $root.google.protobuf.Timestamp.fromObject( + object.timestamp + ) + } + if (object.receiveTimestamp != null) { + if (typeof object.receiveTimestamp !== 'object') + throw TypeError( + '.google.logging.v2.LogEntry.receiveTimestamp: object expected' + ) + message.receiveTimestamp = $root.google.protobuf.Timestamp.fromObject( + object.receiveTimestamp + ) + } + switch (object.severity) { + case 'DEFAULT': + case 0: + message.severity = 0 + break + case 'DEBUG': + case 100: + message.severity = 100 + break + case 'INFO': + case 200: + message.severity = 200 + break + case 'NOTICE': + case 300: + message.severity = 300 + break + case 'WARNING': + case 400: + message.severity = 400 + break + case 'ERROR': + case 500: + message.severity = 500 + break + case 'CRITICAL': + case 600: + message.severity = 600 + break + case 'ALERT': + case 700: + message.severity = 700 + break + case 'EMERGENCY': + case 800: + message.severity = 800 + break + } + if (object.insertId != null) + message.insertId = String(object.insertId) + if (object.httpRequest != null) { + if (typeof object.httpRequest !== 'object') + throw TypeError( + '.google.logging.v2.LogEntry.httpRequest: object expected' + ) + message.httpRequest = $root.google.logging.type.HttpRequest.fromObject( + object.httpRequest + ) + } + if (object.labels) { + if (typeof object.labels !== 'object') + throw TypeError( + '.google.logging.v2.LogEntry.labels: object expected' + ) + message.labels = {} + for ( + var keys = Object.keys(object.labels), i = 0; + i < keys.length; + ++i + ) + message.labels[keys[i]] = String(object.labels[keys[i]]) + } + if (object.operation != null) { + if (typeof object.operation !== 'object') + throw TypeError( + '.google.logging.v2.LogEntry.operation: object expected' + ) + message.operation = $root.google.logging.v2.LogEntryOperation.fromObject( + object.operation + ) + } + if (object.trace != null) message.trace = String(object.trace) + if (object.spanId != null) + message.spanId = String(object.spanId) + if (object.traceSampled != null) + message.traceSampled = Boolean(object.traceSampled) + if (object.sourceLocation != null) { + if (typeof object.sourceLocation !== 'object') + throw TypeError( + '.google.logging.v2.LogEntry.sourceLocation: object expected' + ) + message.sourceLocation = $root.google.logging.v2.LogEntrySourceLocation.fromObject( + object.sourceLocation + ) + } + return message + } + /** + * Creates a plain object from a LogEntry message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.LogEntry + * @static + * @param {google.logging.v2.LogEntry} message LogEntry + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + LogEntry.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.objects || options.defaults) object.labels = {} + if (options.defaults) { + object.insertId = '' + object.httpRequest = null + object.resource = null + object.timestamp = null + object.severity = options.enums === String ? 'DEFAULT' : 0 + object.logName = '' + object.operation = null + object.trace = '' + object.sourceLocation = null + object.receiveTimestamp = null + object.spanId = '' + object.traceSampled = false + } + if ( + message.protoPayload != null && + message.hasOwnProperty('protoPayload') + ) { + object.protoPayload = $root.google.protobuf.Any.toObject( + message.protoPayload, + options + ) + if (options.oneofs) object.payload = 'protoPayload' + } + if ( + message.textPayload != null && + message.hasOwnProperty('textPayload') + ) { + object.textPayload = message.textPayload + if (options.oneofs) object.payload = 'textPayload' + } + if ( + message.insertId != null && + message.hasOwnProperty('insertId') + ) + object.insertId = message.insertId + if ( + message.jsonPayload != null && + message.hasOwnProperty('jsonPayload') + ) { + object.jsonPayload = $root.google.protobuf.Struct.toObject( + message.jsonPayload, + options + ) + if (options.oneofs) object.payload = 'jsonPayload' + } + if ( + message.httpRequest != null && + message.hasOwnProperty('httpRequest') + ) + object.httpRequest = $root.google.logging.type.HttpRequest.toObject( + message.httpRequest, + options + ) + if ( + message.resource != null && + message.hasOwnProperty('resource') + ) + object.resource = $root.google.api.MonitoredResource.toObject( + message.resource, + options + ) + if ( + message.timestamp != null && + message.hasOwnProperty('timestamp') + ) + object.timestamp = $root.google.protobuf.Timestamp.toObject( + message.timestamp, + options + ) + if ( + message.severity != null && + message.hasOwnProperty('severity') + ) + object.severity = + options.enums === String + ? $root.google.logging.type.LogSeverity[ + message.severity + ] + : message.severity + var keys2 + if ( + message.labels && + (keys2 = Object.keys(message.labels)).length + ) { + object.labels = {} + for (var j = 0; j < keys2.length; ++j) + object.labels[keys2[j]] = message.labels[keys2[j]] + } + if ( + message.logName != null && + message.hasOwnProperty('logName') + ) + object.logName = message.logName + if ( + message.operation != null && + message.hasOwnProperty('operation') + ) + object.operation = $root.google.logging.v2.LogEntryOperation.toObject( + message.operation, + options + ) + if (message.trace != null && message.hasOwnProperty('trace')) + object.trace = message.trace + if ( + message.sourceLocation != null && + message.hasOwnProperty('sourceLocation') + ) + object.sourceLocation = $root.google.logging.v2.LogEntrySourceLocation.toObject( + message.sourceLocation, + options + ) + if ( + message.receiveTimestamp != null && + message.hasOwnProperty('receiveTimestamp') + ) + object.receiveTimestamp = $root.google.protobuf.Timestamp.toObject( + message.receiveTimestamp, + options + ) + if ( + message.spanId != null && + message.hasOwnProperty('spanId') + ) + object.spanId = message.spanId + if ( + message.traceSampled != null && + message.hasOwnProperty('traceSampled') + ) + object.traceSampled = message.traceSampled + return object + } -Object.defineProperty(exports, "__esModule", ({ value: true })); + /** + * Converts this LogEntry to JSON. + * @function toJSON + * @memberof google.logging.v2.LogEntry + * @instance + * @returns {Object.} JSON object + */ + LogEntry.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } -var request = __webpack_require__(6234); -var universalUserAgent = __webpack_require__(5030); + return LogEntry + })() + + v2.LogEntryOperation = (function () { + /** + * Properties of a LogEntryOperation. + * @memberof google.logging.v2 + * @interface ILogEntryOperation + * @property {string|null} [id] LogEntryOperation id + * @property {string|null} [producer] LogEntryOperation producer + * @property {boolean|null} [first] LogEntryOperation first + * @property {boolean|null} [last] LogEntryOperation last + */ + + /** + * Constructs a new LogEntryOperation. + * @memberof google.logging.v2 + * @classdesc Represents a LogEntryOperation. + * @implements ILogEntryOperation + * @constructor + * @param {google.logging.v2.ILogEntryOperation=} [properties] Properties to set + */ + function LogEntryOperation(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } -const VERSION = "4.3.1"; + /** + * LogEntryOperation id. + * @member {string} id + * @memberof google.logging.v2.LogEntryOperation + * @instance + */ + LogEntryOperation.prototype.id = '' + + /** + * LogEntryOperation producer. + * @member {string} producer + * @memberof google.logging.v2.LogEntryOperation + * @instance + */ + LogEntryOperation.prototype.producer = '' + + /** + * LogEntryOperation first. + * @member {boolean} first + * @memberof google.logging.v2.LogEntryOperation + * @instance + */ + LogEntryOperation.prototype.first = false + + /** + * LogEntryOperation last. + * @member {boolean} last + * @memberof google.logging.v2.LogEntryOperation + * @instance + */ + LogEntryOperation.prototype.last = false + + /** + * Creates a new LogEntryOperation instance using the specified properties. + * @function create + * @memberof google.logging.v2.LogEntryOperation + * @static + * @param {google.logging.v2.ILogEntryOperation=} [properties] Properties to set + * @returns {google.logging.v2.LogEntryOperation} LogEntryOperation instance + */ + LogEntryOperation.create = function create(properties) { + return new LogEntryOperation(properties) + } -class GraphqlError extends Error { - constructor(request, response) { - const message = response.data.errors[0].message; - super(message); - Object.assign(this, response.data); - this.name = "GraphqlError"; - this.request = request; // Maintains proper stack trace (only available on V8) + /** + * Encodes the specified LogEntryOperation message. Does not implicitly {@link google.logging.v2.LogEntryOperation.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.LogEntryOperation + * @static + * @param {google.logging.v2.ILogEntryOperation} message LogEntryOperation message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LogEntryOperation.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.id != null && + Object.hasOwnProperty.call(message, 'id') + ) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.id) + if ( + message.producer != null && + Object.hasOwnProperty.call(message, 'producer') + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.producer) + if ( + message.first != null && + Object.hasOwnProperty.call(message, 'first') + ) + writer + .uint32(/* id 3, wireType 0 =*/ 24) + .bool(message.first) + if ( + message.last != null && + Object.hasOwnProperty.call(message, 'last') + ) + writer.uint32(/* id 4, wireType 0 =*/ 32).bool(message.last) + return writer + } - /* istanbul ignore next */ + /** + * Encodes the specified LogEntryOperation message, length delimited. Does not implicitly {@link google.logging.v2.LogEntryOperation.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.LogEntryOperation + * @static + * @param {google.logging.v2.ILogEntryOperation} message LogEntryOperation message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LogEntryOperation.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } - if (Error.captureStackTrace) { - Error.captureStackTrace(this, this.constructor); - } - } + /** + * Decodes a LogEntryOperation message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.LogEntryOperation + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.LogEntryOperation} LogEntryOperation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LogEntryOperation.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.LogEntryOperation() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.id = reader.string() + break + case 2: + message.producer = reader.string() + break + case 3: + message.first = reader.bool() + break + case 4: + message.last = reader.bool() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } -} - -const NON_VARIABLE_OPTIONS = ["method", "baseUrl", "url", "headers", "request", "query"]; -function graphql(request, query, options) { - options = typeof query === "string" ? options = Object.assign({ - query - }, options) : options = query; - const requestOptions = Object.keys(options).reduce((result, key) => { - if (NON_VARIABLE_OPTIONS.includes(key)) { - result[key] = options[key]; - return result; - } + /** + * Decodes a LogEntryOperation message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.LogEntryOperation + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.LogEntryOperation} LogEntryOperation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LogEntryOperation.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } - if (!result.variables) { - result.variables = {}; - } + /** + * Verifies a LogEntryOperation message. + * @function verify + * @memberof google.logging.v2.LogEntryOperation + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + LogEntryOperation.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.id != null && message.hasOwnProperty('id')) + if (!$util.isString(message.id)) + return 'id: string expected' + if ( + message.producer != null && + message.hasOwnProperty('producer') + ) + if (!$util.isString(message.producer)) + return 'producer: string expected' + if (message.first != null && message.hasOwnProperty('first')) + if (typeof message.first !== 'boolean') + return 'first: boolean expected' + if (message.last != null && message.hasOwnProperty('last')) + if (typeof message.last !== 'boolean') + return 'last: boolean expected' + return null + } - result.variables[key] = options[key]; - return result; - }, {}); - return request(requestOptions).then(response => { - if (response.data.errors) { - throw new GraphqlError(requestOptions, { - data: response.data - }); - } + /** + * Creates a LogEntryOperation message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.LogEntryOperation + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.LogEntryOperation} LogEntryOperation + */ + LogEntryOperation.fromObject = function fromObject(object) { + if ( + object instanceof $root.google.logging.v2.LogEntryOperation + ) + return object + var message = new $root.google.logging.v2.LogEntryOperation() + if (object.id != null) message.id = String(object.id) + if (object.producer != null) + message.producer = String(object.producer) + if (object.first != null) + message.first = Boolean(object.first) + if (object.last != null) message.last = Boolean(object.last) + return message + } - return response.data.data; - }); -} - -function withDefaults(request$1, newDefaults) { - const newRequest = request$1.defaults(newDefaults); - - const newApi = (query, options) => { - return graphql(newRequest, query, options); - }; - - return Object.assign(newApi, { - defaults: withDefaults.bind(null, newRequest), - endpoint: request.request.endpoint - }); -} - -const graphql$1 = withDefaults(request.request, { - headers: { - "user-agent": `octokit-graphql.js/${VERSION} ${universalUserAgent.getUserAgent()}` - }, - method: "POST", - url: "/graphql" -}); -function withCustomRequest(customRequest) { - return withDefaults(customRequest, { - method: "POST", - url: "/graphql" - }); -} - -exports.graphql = graphql$1; -exports.withCustomRequest = withCustomRequest; -//# sourceMappingURL=index.js.map + /** + * Creates a plain object from a LogEntryOperation message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.LogEntryOperation + * @static + * @param {google.logging.v2.LogEntryOperation} message LogEntryOperation + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + LogEntryOperation.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.id = '' + object.producer = '' + object.first = false + object.last = false + } + if (message.id != null && message.hasOwnProperty('id')) + object.id = message.id + if ( + message.producer != null && + message.hasOwnProperty('producer') + ) + object.producer = message.producer + if (message.first != null && message.hasOwnProperty('first')) + object.first = message.first + if (message.last != null && message.hasOwnProperty('last')) + object.last = message.last + return object + } + /** + * Converts this LogEntryOperation to JSON. + * @function toJSON + * @memberof google.logging.v2.LogEntryOperation + * @instance + * @returns {Object.} JSON object + */ + LogEntryOperation.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } -/***/ }), + return LogEntryOperation + })() + + v2.LogEntrySourceLocation = (function () { + /** + * Properties of a LogEntrySourceLocation. + * @memberof google.logging.v2 + * @interface ILogEntrySourceLocation + * @property {string|null} [file] LogEntrySourceLocation file + * @property {number|Long|null} [line] LogEntrySourceLocation line + * @property {string|null} ["function"] LogEntrySourceLocation function + */ + + /** + * Constructs a new LogEntrySourceLocation. + * @memberof google.logging.v2 + * @classdesc Represents a LogEntrySourceLocation. + * @implements ILogEntrySourceLocation + * @constructor + * @param {google.logging.v2.ILogEntrySourceLocation=} [properties] Properties to set + */ + function LogEntrySourceLocation(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } -/***/ 4193: -/***/ ((__unused_webpack_module, exports) => { + /** + * LogEntrySourceLocation file. + * @member {string} file + * @memberof google.logging.v2.LogEntrySourceLocation + * @instance + */ + LogEntrySourceLocation.prototype.file = '' + + /** + * LogEntrySourceLocation line. + * @member {number|Long} line + * @memberof google.logging.v2.LogEntrySourceLocation + * @instance + */ + LogEntrySourceLocation.prototype.line = $util.Long + ? $util.Long.fromBits(0, 0, false) + : 0 + + /** + * LogEntrySourceLocation function. + * @member {string} function + * @memberof google.logging.v2.LogEntrySourceLocation + * @instance + */ + LogEntrySourceLocation.prototype['function'] = '' + + /** + * Creates a new LogEntrySourceLocation instance using the specified properties. + * @function create + * @memberof google.logging.v2.LogEntrySourceLocation + * @static + * @param {google.logging.v2.ILogEntrySourceLocation=} [properties] Properties to set + * @returns {google.logging.v2.LogEntrySourceLocation} LogEntrySourceLocation instance + */ + LogEntrySourceLocation.create = function create(properties) { + return new LogEntrySourceLocation(properties) + } -"use strict"; + /** + * Encodes the specified LogEntrySourceLocation message. Does not implicitly {@link google.logging.v2.LogEntrySourceLocation.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.LogEntrySourceLocation + * @static + * @param {google.logging.v2.ILogEntrySourceLocation} message LogEntrySourceLocation message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LogEntrySourceLocation.encode = function encode( + message, + writer + ) { + if (!writer) writer = $Writer.create() + if ( + message.file != null && + Object.hasOwnProperty.call(message, 'file') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.file) + if ( + message.line != null && + Object.hasOwnProperty.call(message, 'line') + ) + writer + .uint32(/* id 2, wireType 0 =*/ 16) + .int64(message.line) + if ( + message['function'] != null && + Object.hasOwnProperty.call(message, 'function') + ) + writer + .uint32(/* id 3, wireType 2 =*/ 26) + .string(message['function']) + return writer + } + /** + * Encodes the specified LogEntrySourceLocation message, length delimited. Does not implicitly {@link google.logging.v2.LogEntrySourceLocation.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.LogEntrySourceLocation + * @static + * @param {google.logging.v2.ILogEntrySourceLocation} message LogEntrySourceLocation message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LogEntrySourceLocation.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } -Object.defineProperty(exports, "__esModule", ({ value: true })); + /** + * Decodes a LogEntrySourceLocation message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.LogEntrySourceLocation + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.LogEntrySourceLocation} LogEntrySourceLocation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LogEntrySourceLocation.decode = function decode( + reader, + length + ) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.LogEntrySourceLocation() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.file = reader.string() + break + case 2: + message.line = reader.int64() + break + case 3: + message['function'] = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } -const VERSION = "1.1.2"; + /** + * Decodes a LogEntrySourceLocation message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.LogEntrySourceLocation + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.LogEntrySourceLocation} LogEntrySourceLocation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LogEntrySourceLocation.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } -/** - * Some “list” response that can be paginated have a different response structure - * - * They have a `total_count` key in the response (search also has `incomplete_results`, - * /installation/repositories also has `repository_selection`), as well as a key with - * the list of the items which name varies from endpoint to endpoint: - * - * - https://developer.github.com/v3/search/#example (key `items`) - * - https://developer.github.com/v3/checks/runs/#response-3 (key: `check_runs`) - * - https://developer.github.com/v3/checks/suites/#response-1 (key: `check_suites`) - * - https://developer.github.com/v3/apps/installations/#list-repositories (key: `repositories`) - * - https://developer.github.com/v3/apps/installations/#list-installations-for-a-user (key `installations`) - * - * Octokit normalizes these responses so that paginated results are always returned following - * the same structure. One challenge is that if the list response has only one page, no Link - * header is provided, so this header alone is not sufficient to check wether a response is - * paginated or not. For the exceptions with the namespace, a fallback check for the route - * paths has to be added in order to normalize the response. We cannot check for the total_count - * property because it also exists in the response of Get the combined status for a specific ref. - */ -const REGEX = [/^\/search\//, /^\/repos\/[^/]+\/[^/]+\/commits\/[^/]+\/(check-runs|check-suites)([^/]|$)/, /^\/installation\/repositories([^/]|$)/, /^\/user\/installations([^/]|$)/, /^\/repos\/[^/]+\/[^/]+\/actions\/secrets([^/]|$)/, /^\/repos\/[^/]+\/[^/]+\/actions\/workflows(\/[^/]+\/runs)?([^/]|$)/, /^\/repos\/[^/]+\/[^/]+\/actions\/runs(\/[^/]+\/(artifacts|jobs))?([^/]|$)/]; -function normalizePaginatedListResponse(octokit, url, response) { - const path = url.replace(octokit.request.endpoint.DEFAULTS.baseUrl, ""); - const responseNeedsNormalization = REGEX.find(regex => regex.test(path)); - if (!responseNeedsNormalization) return; // keep the additional properties intact as there is currently no other way - // to retrieve the same information. - - const incompleteResults = response.data.incomplete_results; - const repositorySelection = response.data.repository_selection; - const totalCount = response.data.total_count; - delete response.data.incomplete_results; - delete response.data.repository_selection; - delete response.data.total_count; - const namespaceKey = Object.keys(response.data)[0]; - const data = response.data[namespaceKey]; - response.data = data; - - if (typeof incompleteResults !== "undefined") { - response.data.incomplete_results = incompleteResults; - } + /** + * Verifies a LogEntrySourceLocation message. + * @function verify + * @memberof google.logging.v2.LogEntrySourceLocation + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + LogEntrySourceLocation.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.file != null && message.hasOwnProperty('file')) + if (!$util.isString(message.file)) + return 'file: string expected' + if (message.line != null && message.hasOwnProperty('line')) + if ( + !$util.isInteger(message.line) && + !( + message.line && + $util.isInteger(message.line.low) && + $util.isInteger(message.line.high) + ) + ) + return 'line: integer|Long expected' + if ( + message['function'] != null && + message.hasOwnProperty('function') + ) + if (!$util.isString(message['function'])) + return 'function: string expected' + return null + } - if (typeof repositorySelection !== "undefined") { - response.data.repository_selection = repositorySelection; - } + /** + * Creates a LogEntrySourceLocation message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.LogEntrySourceLocation + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.LogEntrySourceLocation} LogEntrySourceLocation + */ + LogEntrySourceLocation.fromObject = function fromObject( + object + ) { + if ( + object instanceof + $root.google.logging.v2.LogEntrySourceLocation + ) + return object + var message = new $root.google.logging.v2.LogEntrySourceLocation() + if (object.file != null) message.file = String(object.file) + if (object.line != null) + if ($util.Long) + (message.line = $util.Long.fromValue( + object.line + )).unsigned = false + else if (typeof object.line === 'string') + message.line = parseInt(object.line, 10) + else if (typeof object.line === 'number') + message.line = object.line + else if (typeof object.line === 'object') + message.line = new $util.LongBits( + object.line.low >>> 0, + object.line.high >>> 0 + ).toNumber() + if (object['function'] != null) + message['function'] = String(object['function']) + return message + } - response.data.total_count = totalCount; - Object.defineProperty(response.data, namespaceKey, { - get() { - octokit.log.warn(`[@octokit/paginate-rest] "response.data.${namespaceKey}" is deprecated for "GET ${path}". Get the results directly from "response.data"`); - return Array.from(data); - } + /** + * Creates a plain object from a LogEntrySourceLocation message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.LogEntrySourceLocation + * @static + * @param {google.logging.v2.LogEntrySourceLocation} message LogEntrySourceLocation + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + LogEntrySourceLocation.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.file = '' + if ($util.Long) { + var long = new $util.Long(0, 0, false) + object.line = + options.longs === String + ? long.toString() + : options.longs === Number + ? long.toNumber() + : long + } else object.line = options.longs === String ? '0' : 0 + object['function'] = '' + } + if (message.file != null && message.hasOwnProperty('file')) + object.file = message.file + if (message.line != null && message.hasOwnProperty('line')) + if (typeof message.line === 'number') + object.line = + options.longs === String + ? String(message.line) + : message.line + else + object.line = + options.longs === String + ? $util.Long.prototype.toString.call(message.line) + : options.longs === Number + ? new $util.LongBits( + message.line.low >>> 0, + message.line.high >>> 0 + ).toNumber() + : message.line + if ( + message['function'] != null && + message.hasOwnProperty('function') + ) + object['function'] = message['function'] + return object + } - }); -} - -function iterator(octokit, route, parameters) { - const options = octokit.request.endpoint(route, parameters); - const method = options.method; - const headers = options.headers; - let url = options.url; - return { - [Symbol.asyncIterator]: () => ({ - next() { - if (!url) { - return Promise.resolve({ - done: true - }); - } + /** + * Converts this LogEntrySourceLocation to JSON. + * @function toJSON + * @memberof google.logging.v2.LogEntrySourceLocation + * @instance + * @returns {Object.} JSON object + */ + LogEntrySourceLocation.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } - return octokit.request({ - method, - url, - headers - }).then(response => { - normalizePaginatedListResponse(octokit, url, response); // `response.headers.link` format: - // '; rel="next", ; rel="last"' - // sets `url` to undefined if "next" URL is not present or `link` header is not set + return LogEntrySourceLocation + })() + + v2.LoggingServiceV2 = (function () { + /** + * Constructs a new LoggingServiceV2 service. + * @memberof google.logging.v2 + * @classdesc Represents a LoggingServiceV2 + * @extends $protobuf.rpc.Service + * @constructor + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + */ + function LoggingServiceV2( + rpcImpl, + requestDelimited, + responseDelimited + ) { + $protobuf.rpc.Service.call( + this, + rpcImpl, + requestDelimited, + responseDelimited + ) + } - url = ((response.headers.link || "").match(/<([^>]+)>;\s*rel="next"/) || [])[1]; - return { - value: response - }; - }); - } + ;(LoggingServiceV2.prototype = Object.create( + $protobuf.rpc.Service.prototype + )).constructor = LoggingServiceV2 + + /** + * Creates new LoggingServiceV2 service using the specified rpc implementation. + * @function create + * @memberof google.logging.v2.LoggingServiceV2 + * @static + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + * @returns {LoggingServiceV2} RPC service. Useful where requests and/or responses are streamed. + */ + LoggingServiceV2.create = function create( + rpcImpl, + requestDelimited, + responseDelimited + ) { + return new this(rpcImpl, requestDelimited, responseDelimited) + } - }) - }; -} + /** + * Callback as used by {@link google.logging.v2.LoggingServiceV2#deleteLog}. + * @memberof google.logging.v2.LoggingServiceV2 + * @typedef DeleteLogCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls DeleteLog. + * @function deleteLog + * @memberof google.logging.v2.LoggingServiceV2 + * @instance + * @param {google.logging.v2.IDeleteLogRequest} request DeleteLogRequest message or plain object + * @param {google.logging.v2.LoggingServiceV2.DeleteLogCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty( + (LoggingServiceV2.prototype.deleteLog = function deleteLog( + request, + callback + ) { + return this.rpcCall( + deleteLog, + $root.google.logging.v2.DeleteLogRequest, + $root.google.protobuf.Empty, + request, + callback + ) + }), + 'name', + { value: 'DeleteLog' } + ) + + /** + * Calls DeleteLog. + * @function deleteLog + * @memberof google.logging.v2.LoggingServiceV2 + * @instance + * @param {google.logging.v2.IDeleteLogRequest} request DeleteLogRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.logging.v2.LoggingServiceV2#writeLogEntries}. + * @memberof google.logging.v2.LoggingServiceV2 + * @typedef WriteLogEntriesCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.logging.v2.WriteLogEntriesResponse} [response] WriteLogEntriesResponse + */ + + /** + * Calls WriteLogEntries. + * @function writeLogEntries + * @memberof google.logging.v2.LoggingServiceV2 + * @instance + * @param {google.logging.v2.IWriteLogEntriesRequest} request WriteLogEntriesRequest message or plain object + * @param {google.logging.v2.LoggingServiceV2.WriteLogEntriesCallback} callback Node-style callback called with the error, if any, and WriteLogEntriesResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty( + (LoggingServiceV2.prototype.writeLogEntries = function writeLogEntries( + request, + callback + ) { + return this.rpcCall( + writeLogEntries, + $root.google.logging.v2.WriteLogEntriesRequest, + $root.google.logging.v2.WriteLogEntriesResponse, + request, + callback + ) + }), + 'name', + { value: 'WriteLogEntries' } + ) + + /** + * Calls WriteLogEntries. + * @function writeLogEntries + * @memberof google.logging.v2.LoggingServiceV2 + * @instance + * @param {google.logging.v2.IWriteLogEntriesRequest} request WriteLogEntriesRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.logging.v2.LoggingServiceV2#listLogEntries}. + * @memberof google.logging.v2.LoggingServiceV2 + * @typedef ListLogEntriesCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.logging.v2.ListLogEntriesResponse} [response] ListLogEntriesResponse + */ + + /** + * Calls ListLogEntries. + * @function listLogEntries + * @memberof google.logging.v2.LoggingServiceV2 + * @instance + * @param {google.logging.v2.IListLogEntriesRequest} request ListLogEntriesRequest message or plain object + * @param {google.logging.v2.LoggingServiceV2.ListLogEntriesCallback} callback Node-style callback called with the error, if any, and ListLogEntriesResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty( + (LoggingServiceV2.prototype.listLogEntries = function listLogEntries( + request, + callback + ) { + return this.rpcCall( + listLogEntries, + $root.google.logging.v2.ListLogEntriesRequest, + $root.google.logging.v2.ListLogEntriesResponse, + request, + callback + ) + }), + 'name', + { value: 'ListLogEntries' } + ) + + /** + * Calls ListLogEntries. + * @function listLogEntries + * @memberof google.logging.v2.LoggingServiceV2 + * @instance + * @param {google.logging.v2.IListLogEntriesRequest} request ListLogEntriesRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.logging.v2.LoggingServiceV2#listMonitoredResourceDescriptors}. + * @memberof google.logging.v2.LoggingServiceV2 + * @typedef ListMonitoredResourceDescriptorsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.logging.v2.ListMonitoredResourceDescriptorsResponse} [response] ListMonitoredResourceDescriptorsResponse + */ + + /** + * Calls ListMonitoredResourceDescriptors. + * @function listMonitoredResourceDescriptors + * @memberof google.logging.v2.LoggingServiceV2 + * @instance + * @param {google.logging.v2.IListMonitoredResourceDescriptorsRequest} request ListMonitoredResourceDescriptorsRequest message or plain object + * @param {google.logging.v2.LoggingServiceV2.ListMonitoredResourceDescriptorsCallback} callback Node-style callback called with the error, if any, and ListMonitoredResourceDescriptorsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty( + (LoggingServiceV2.prototype.listMonitoredResourceDescriptors = function listMonitoredResourceDescriptors( + request, + callback + ) { + return this.rpcCall( + listMonitoredResourceDescriptors, + $root.google.logging.v2 + .ListMonitoredResourceDescriptorsRequest, + $root.google.logging.v2 + .ListMonitoredResourceDescriptorsResponse, + request, + callback + ) + }), + 'name', + { value: 'ListMonitoredResourceDescriptors' } + ) + + /** + * Calls ListMonitoredResourceDescriptors. + * @function listMonitoredResourceDescriptors + * @memberof google.logging.v2.LoggingServiceV2 + * @instance + * @param {google.logging.v2.IListMonitoredResourceDescriptorsRequest} request ListMonitoredResourceDescriptorsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.logging.v2.LoggingServiceV2#listLogs}. + * @memberof google.logging.v2.LoggingServiceV2 + * @typedef ListLogsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.logging.v2.ListLogsResponse} [response] ListLogsResponse + */ + + /** + * Calls ListLogs. + * @function listLogs + * @memberof google.logging.v2.LoggingServiceV2 + * @instance + * @param {google.logging.v2.IListLogsRequest} request ListLogsRequest message or plain object + * @param {google.logging.v2.LoggingServiceV2.ListLogsCallback} callback Node-style callback called with the error, if any, and ListLogsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty( + (LoggingServiceV2.prototype.listLogs = function listLogs( + request, + callback + ) { + return this.rpcCall( + listLogs, + $root.google.logging.v2.ListLogsRequest, + $root.google.logging.v2.ListLogsResponse, + request, + callback + ) + }), + 'name', + { value: 'ListLogs' } + ) + + /** + * Calls ListLogs. + * @function listLogs + * @memberof google.logging.v2.LoggingServiceV2 + * @instance + * @param {google.logging.v2.IListLogsRequest} request ListLogsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return LoggingServiceV2 + })() + + v2.DeleteLogRequest = (function () { + /** + * Properties of a DeleteLogRequest. + * @memberof google.logging.v2 + * @interface IDeleteLogRequest + * @property {string|null} [logName] DeleteLogRequest logName + */ + + /** + * Constructs a new DeleteLogRequest. + * @memberof google.logging.v2 + * @classdesc Represents a DeleteLogRequest. + * @implements IDeleteLogRequest + * @constructor + * @param {google.logging.v2.IDeleteLogRequest=} [properties] Properties to set + */ + function DeleteLogRequest(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } -function paginate(octokit, route, parameters, mapFn) { - if (typeof parameters === "function") { - mapFn = parameters; - parameters = undefined; - } + /** + * DeleteLogRequest logName. + * @member {string} logName + * @memberof google.logging.v2.DeleteLogRequest + * @instance + */ + DeleteLogRequest.prototype.logName = '' + + /** + * Creates a new DeleteLogRequest instance using the specified properties. + * @function create + * @memberof google.logging.v2.DeleteLogRequest + * @static + * @param {google.logging.v2.IDeleteLogRequest=} [properties] Properties to set + * @returns {google.logging.v2.DeleteLogRequest} DeleteLogRequest instance + */ + DeleteLogRequest.create = function create(properties) { + return new DeleteLogRequest(properties) + } - return gather(octokit, [], iterator(octokit, route, parameters)[Symbol.asyncIterator](), mapFn); -} + /** + * Encodes the specified DeleteLogRequest message. Does not implicitly {@link google.logging.v2.DeleteLogRequest.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.DeleteLogRequest + * @static + * @param {google.logging.v2.IDeleteLogRequest} message DeleteLogRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteLogRequest.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.logName != null && + Object.hasOwnProperty.call(message, 'logName') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.logName) + return writer + } -function gather(octokit, results, iterator, mapFn) { - return iterator.next().then(result => { - if (result.done) { - return results; - } + /** + * Encodes the specified DeleteLogRequest message, length delimited. Does not implicitly {@link google.logging.v2.DeleteLogRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.DeleteLogRequest + * @static + * @param {google.logging.v2.IDeleteLogRequest} message DeleteLogRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteLogRequest.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } - let earlyExit = false; + /** + * Decodes a DeleteLogRequest message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.DeleteLogRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.DeleteLogRequest} DeleteLogRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteLogRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.DeleteLogRequest() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.logName = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } - function done() { - earlyExit = true; - } + /** + * Decodes a DeleteLogRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.DeleteLogRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.DeleteLogRequest} DeleteLogRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteLogRequest.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } - results = results.concat(mapFn ? mapFn(result.value, done) : result.value.data); + /** + * Verifies a DeleteLogRequest message. + * @function verify + * @memberof google.logging.v2.DeleteLogRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DeleteLogRequest.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.logName != null && + message.hasOwnProperty('logName') + ) + if (!$util.isString(message.logName)) + return 'logName: string expected' + return null + } - if (earlyExit) { - return results; - } + /** + * Creates a DeleteLogRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.DeleteLogRequest + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.DeleteLogRequest} DeleteLogRequest + */ + DeleteLogRequest.fromObject = function fromObject(object) { + if ( + object instanceof $root.google.logging.v2.DeleteLogRequest + ) + return object + var message = new $root.google.logging.v2.DeleteLogRequest() + if (object.logName != null) + message.logName = String(object.logName) + return message + } - return gather(octokit, results, iterator, mapFn); - }); -} + /** + * Creates a plain object from a DeleteLogRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.DeleteLogRequest + * @static + * @param {google.logging.v2.DeleteLogRequest} message DeleteLogRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeleteLogRequest.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) object.logName = '' + if ( + message.logName != null && + message.hasOwnProperty('logName') + ) + object.logName = message.logName + return object + } -/** - * @param octokit Octokit instance - * @param options Options passed to Octokit constructor - */ + /** + * Converts this DeleteLogRequest to JSON. + * @function toJSON + * @memberof google.logging.v2.DeleteLogRequest + * @instance + * @returns {Object.} JSON object + */ + DeleteLogRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } -function paginateRest(octokit) { - return { - paginate: Object.assign(paginate.bind(null, octokit), { - iterator: iterator.bind(null, octokit) - }) - }; -} -paginateRest.VERSION = VERSION; + return DeleteLogRequest + })() + + v2.WriteLogEntriesRequest = (function () { + /** + * Properties of a WriteLogEntriesRequest. + * @memberof google.logging.v2 + * @interface IWriteLogEntriesRequest + * @property {string|null} [logName] WriteLogEntriesRequest logName + * @property {google.api.IMonitoredResource|null} [resource] WriteLogEntriesRequest resource + * @property {Object.|null} [labels] WriteLogEntriesRequest labels + * @property {Array.|null} [entries] WriteLogEntriesRequest entries + * @property {boolean|null} [partialSuccess] WriteLogEntriesRequest partialSuccess + * @property {boolean|null} [dryRun] WriteLogEntriesRequest dryRun + */ + + /** + * Constructs a new WriteLogEntriesRequest. + * @memberof google.logging.v2 + * @classdesc Represents a WriteLogEntriesRequest. + * @implements IWriteLogEntriesRequest + * @constructor + * @param {google.logging.v2.IWriteLogEntriesRequest=} [properties] Properties to set + */ + function WriteLogEntriesRequest(properties) { + this.labels = {} + this.entries = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } -exports.paginateRest = paginateRest; -//# sourceMappingURL=index.js.map + /** + * WriteLogEntriesRequest logName. + * @member {string} logName + * @memberof google.logging.v2.WriteLogEntriesRequest + * @instance + */ + WriteLogEntriesRequest.prototype.logName = '' + + /** + * WriteLogEntriesRequest resource. + * @member {google.api.IMonitoredResource|null|undefined} resource + * @memberof google.logging.v2.WriteLogEntriesRequest + * @instance + */ + WriteLogEntriesRequest.prototype.resource = null + + /** + * WriteLogEntriesRequest labels. + * @member {Object.} labels + * @memberof google.logging.v2.WriteLogEntriesRequest + * @instance + */ + WriteLogEntriesRequest.prototype.labels = $util.emptyObject + + /** + * WriteLogEntriesRequest entries. + * @member {Array.} entries + * @memberof google.logging.v2.WriteLogEntriesRequest + * @instance + */ + WriteLogEntriesRequest.prototype.entries = $util.emptyArray + + /** + * WriteLogEntriesRequest partialSuccess. + * @member {boolean} partialSuccess + * @memberof google.logging.v2.WriteLogEntriesRequest + * @instance + */ + WriteLogEntriesRequest.prototype.partialSuccess = false + + /** + * WriteLogEntriesRequest dryRun. + * @member {boolean} dryRun + * @memberof google.logging.v2.WriteLogEntriesRequest + * @instance + */ + WriteLogEntriesRequest.prototype.dryRun = false + + /** + * Creates a new WriteLogEntriesRequest instance using the specified properties. + * @function create + * @memberof google.logging.v2.WriteLogEntriesRequest + * @static + * @param {google.logging.v2.IWriteLogEntriesRequest=} [properties] Properties to set + * @returns {google.logging.v2.WriteLogEntriesRequest} WriteLogEntriesRequest instance + */ + WriteLogEntriesRequest.create = function create(properties) { + return new WriteLogEntriesRequest(properties) + } + /** + * Encodes the specified WriteLogEntriesRequest message. Does not implicitly {@link google.logging.v2.WriteLogEntriesRequest.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.WriteLogEntriesRequest + * @static + * @param {google.logging.v2.IWriteLogEntriesRequest} message WriteLogEntriesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WriteLogEntriesRequest.encode = function encode( + message, + writer + ) { + if (!writer) writer = $Writer.create() + if ( + message.logName != null && + Object.hasOwnProperty.call(message, 'logName') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.logName) + if ( + message.resource != null && + Object.hasOwnProperty.call(message, 'resource') + ) + $root.google.api.MonitoredResource.encode( + message.resource, + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + ).ldelim() + if ( + message.labels != null && + Object.hasOwnProperty.call(message, 'labels') + ) + for ( + var keys = Object.keys(message.labels), i = 0; + i < keys.length; + ++i + ) + writer + .uint32(/* id 3, wireType 2 =*/ 26) + .fork() + .uint32(/* id 1, wireType 2 =*/ 10) + .string(keys[i]) + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.labels[keys[i]]) + .ldelim() + if (message.entries != null && message.entries.length) + for (var i = 0; i < message.entries.length; ++i) + $root.google.logging.v2.LogEntry.encode( + message.entries[i], + writer.uint32(/* id 4, wireType 2 =*/ 34).fork() + ).ldelim() + if ( + message.partialSuccess != null && + Object.hasOwnProperty.call(message, 'partialSuccess') + ) + writer + .uint32(/* id 5, wireType 0 =*/ 40) + .bool(message.partialSuccess) + if ( + message.dryRun != null && + Object.hasOwnProperty.call(message, 'dryRun') + ) + writer + .uint32(/* id 6, wireType 0 =*/ 48) + .bool(message.dryRun) + return writer + } -/***/ }), + /** + * Encodes the specified WriteLogEntriesRequest message, length delimited. Does not implicitly {@link google.logging.v2.WriteLogEntriesRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.WriteLogEntriesRequest + * @static + * @param {google.logging.v2.IWriteLogEntriesRequest} message WriteLogEntriesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WriteLogEntriesRequest.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } -/***/ 8883: -/***/ ((__unused_webpack_module, exports) => { + /** + * Decodes a WriteLogEntriesRequest message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.WriteLogEntriesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.WriteLogEntriesRequest} WriteLogEntriesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WriteLogEntriesRequest.decode = function decode( + reader, + length + ) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.WriteLogEntriesRequest(), + key, + value + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.logName = reader.string() + break + case 2: + message.resource = $root.google.api.MonitoredResource.decode( + reader, + reader.uint32() + ) + break + case 3: + if (message.labels === $util.emptyObject) + message.labels = {} + var end2 = reader.uint32() + reader.pos + key = '' + value = '' + while (reader.pos < end2) { + var tag2 = reader.uint32() + switch (tag2 >>> 3) { + case 1: + key = reader.string() + break + case 2: + value = reader.string() + break + default: + reader.skipType(tag2 & 7) + break + } + } + message.labels[key] = value + break + case 4: + if (!(message.entries && message.entries.length)) + message.entries = [] + message.entries.push( + $root.google.logging.v2.LogEntry.decode( + reader, + reader.uint32() + ) + ) + break + case 5: + message.partialSuccess = reader.bool() + break + case 6: + message.dryRun = reader.bool() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } -"use strict"; + /** + * Decodes a WriteLogEntriesRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.WriteLogEntriesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.WriteLogEntriesRequest} WriteLogEntriesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WriteLogEntriesRequest.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + /** + * Verifies a WriteLogEntriesRequest message. + * @function verify + * @memberof google.logging.v2.WriteLogEntriesRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + WriteLogEntriesRequest.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.logName != null && + message.hasOwnProperty('logName') + ) + if (!$util.isString(message.logName)) + return 'logName: string expected' + if ( + message.resource != null && + message.hasOwnProperty('resource') + ) { + var error = $root.google.api.MonitoredResource.verify( + message.resource + ) + if (error) return 'resource.' + error + } + if ( + message.labels != null && + message.hasOwnProperty('labels') + ) { + if (!$util.isObject(message.labels)) + return 'labels: object expected' + var key = Object.keys(message.labels) + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.labels[key[i]])) + return 'labels: string{k:string} expected' + } + if ( + message.entries != null && + message.hasOwnProperty('entries') + ) { + if (!Array.isArray(message.entries)) + return 'entries: array expected' + for (var i = 0; i < message.entries.length; ++i) { + var error = $root.google.logging.v2.LogEntry.verify( + message.entries[i] + ) + if (error) return 'entries.' + error + } + } + if ( + message.partialSuccess != null && + message.hasOwnProperty('partialSuccess') + ) + if (typeof message.partialSuccess !== 'boolean') + return 'partialSuccess: boolean expected' + if ( + message.dryRun != null && + message.hasOwnProperty('dryRun') + ) + if (typeof message.dryRun !== 'boolean') + return 'dryRun: boolean expected' + return null + } -Object.defineProperty(exports, "__esModule", ({ value: true })); + /** + * Creates a WriteLogEntriesRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.WriteLogEntriesRequest + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.WriteLogEntriesRequest} WriteLogEntriesRequest + */ + WriteLogEntriesRequest.fromObject = function fromObject( + object + ) { + if ( + object instanceof + $root.google.logging.v2.WriteLogEntriesRequest + ) + return object + var message = new $root.google.logging.v2.WriteLogEntriesRequest() + if (object.logName != null) + message.logName = String(object.logName) + if (object.resource != null) { + if (typeof object.resource !== 'object') + throw TypeError( + '.google.logging.v2.WriteLogEntriesRequest.resource: object expected' + ) + message.resource = $root.google.api.MonitoredResource.fromObject( + object.resource + ) + } + if (object.labels) { + if (typeof object.labels !== 'object') + throw TypeError( + '.google.logging.v2.WriteLogEntriesRequest.labels: object expected' + ) + message.labels = {} + for ( + var keys = Object.keys(object.labels), i = 0; + i < keys.length; + ++i + ) + message.labels[keys[i]] = String(object.labels[keys[i]]) + } + if (object.entries) { + if (!Array.isArray(object.entries)) + throw TypeError( + '.google.logging.v2.WriteLogEntriesRequest.entries: array expected' + ) + message.entries = [] + for (var i = 0; i < object.entries.length; ++i) { + if (typeof object.entries[i] !== 'object') + throw TypeError( + '.google.logging.v2.WriteLogEntriesRequest.entries: object expected' + ) + message.entries[ + i + ] = $root.google.logging.v2.LogEntry.fromObject( + object.entries[i] + ) + } + } + if (object.partialSuccess != null) + message.partialSuccess = Boolean(object.partialSuccess) + if (object.dryRun != null) + message.dryRun = Boolean(object.dryRun) + return message + } -const VERSION = "1.0.0"; + /** + * Creates a plain object from a WriteLogEntriesRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.WriteLogEntriesRequest + * @static + * @param {google.logging.v2.WriteLogEntriesRequest} message WriteLogEntriesRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + WriteLogEntriesRequest.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) object.entries = [] + if (options.objects || options.defaults) object.labels = {} + if (options.defaults) { + object.logName = '' + object.resource = null + object.partialSuccess = false + object.dryRun = false + } + if ( + message.logName != null && + message.hasOwnProperty('logName') + ) + object.logName = message.logName + if ( + message.resource != null && + message.hasOwnProperty('resource') + ) + object.resource = $root.google.api.MonitoredResource.toObject( + message.resource, + options + ) + var keys2 + if ( + message.labels && + (keys2 = Object.keys(message.labels)).length + ) { + object.labels = {} + for (var j = 0; j < keys2.length; ++j) + object.labels[keys2[j]] = message.labels[keys2[j]] + } + if (message.entries && message.entries.length) { + object.entries = [] + for (var j = 0; j < message.entries.length; ++j) + object.entries[ + j + ] = $root.google.logging.v2.LogEntry.toObject( + message.entries[j], + options + ) + } + if ( + message.partialSuccess != null && + message.hasOwnProperty('partialSuccess') + ) + object.partialSuccess = message.partialSuccess + if ( + message.dryRun != null && + message.hasOwnProperty('dryRun') + ) + object.dryRun = message.dryRun + return object + } -/** - * @param octokit Octokit instance - * @param options Options passed to Octokit constructor - */ + /** + * Converts this WriteLogEntriesRequest to JSON. + * @function toJSON + * @memberof google.logging.v2.WriteLogEntriesRequest + * @instance + * @returns {Object.} JSON object + */ + WriteLogEntriesRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } -function requestLog(octokit) { - octokit.hook.wrap("request", (request, options) => { - octokit.log.debug("request", options); - const start = Date.now(); - const requestOptions = octokit.request.endpoint.parse(options); - const path = requestOptions.url.replace(options.baseUrl, ""); - return request(options).then(response => { - octokit.log.info(`${requestOptions.method} ${path} - ${response.status} in ${Date.now() - start}ms`); - return response; - }).catch(error => { - octokit.log.info(`${requestOptions.method} ${path} - ${error.status} in ${Date.now() - start}ms`); - throw error; - }); - }); -} -requestLog.VERSION = VERSION; - -exports.requestLog = requestLog; -//# sourceMappingURL=index.js.map + return WriteLogEntriesRequest + })() + + v2.WriteLogEntriesResponse = (function () { + /** + * Properties of a WriteLogEntriesResponse. + * @memberof google.logging.v2 + * @interface IWriteLogEntriesResponse + */ + + /** + * Constructs a new WriteLogEntriesResponse. + * @memberof google.logging.v2 + * @classdesc Represents a WriteLogEntriesResponse. + * @implements IWriteLogEntriesResponse + * @constructor + * @param {google.logging.v2.IWriteLogEntriesResponse=} [properties] Properties to set + */ + function WriteLogEntriesResponse(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + /** + * Creates a new WriteLogEntriesResponse instance using the specified properties. + * @function create + * @memberof google.logging.v2.WriteLogEntriesResponse + * @static + * @param {google.logging.v2.IWriteLogEntriesResponse=} [properties] Properties to set + * @returns {google.logging.v2.WriteLogEntriesResponse} WriteLogEntriesResponse instance + */ + WriteLogEntriesResponse.create = function create(properties) { + return new WriteLogEntriesResponse(properties) + } -/***/ }), + /** + * Encodes the specified WriteLogEntriesResponse message. Does not implicitly {@link google.logging.v2.WriteLogEntriesResponse.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.WriteLogEntriesResponse + * @static + * @param {google.logging.v2.IWriteLogEntriesResponse} message WriteLogEntriesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WriteLogEntriesResponse.encode = function encode( + message, + writer + ) { + if (!writer) writer = $Writer.create() + return writer + } -/***/ 3044: -/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + /** + * Encodes the specified WriteLogEntriesResponse message, length delimited. Does not implicitly {@link google.logging.v2.WriteLogEntriesResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.WriteLogEntriesResponse + * @static + * @param {google.logging.v2.IWriteLogEntriesResponse} message WriteLogEntriesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WriteLogEntriesResponse.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } -"use strict"; + /** + * Decodes a WriteLogEntriesResponse message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.WriteLogEntriesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.WriteLogEntriesResponse} WriteLogEntriesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WriteLogEntriesResponse.decode = function decode( + reader, + length + ) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.WriteLogEntriesResponse() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + default: + reader.skipType(tag & 7) + break + } + } + return message + } + /** + * Decodes a WriteLogEntriesResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.WriteLogEntriesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.WriteLogEntriesResponse} WriteLogEntriesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WriteLogEntriesResponse.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } -Object.defineProperty(exports, "__esModule", ({ value: true })); + /** + * Verifies a WriteLogEntriesResponse message. + * @function verify + * @memberof google.logging.v2.WriteLogEntriesResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + WriteLogEntriesResponse.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + return null + } -var deprecation = __webpack_require__(8932); + /** + * Creates a WriteLogEntriesResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.WriteLogEntriesResponse + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.WriteLogEntriesResponse} WriteLogEntriesResponse + */ + WriteLogEntriesResponse.fromObject = function fromObject( + object + ) { + if ( + object instanceof + $root.google.logging.v2.WriteLogEntriesResponse + ) + return object + return new $root.google.logging.v2.WriteLogEntriesResponse() + } -var endpointsByScope = { - actions: { - cancelWorkflowRun: { - method: "POST", - params: { - owner: { - required: true, - type: "string" - }, - repo: { - required: true, - type: "string" - }, - run_id: { - required: true, - type: "integer" - } - }, - url: "/repos/:owner/:repo/actions/runs/:run_id/cancel" - }, - createOrUpdateSecretForRepo: { - method: "PUT", - params: { - encrypted_value: { - type: "string" - }, - key_id: { - type: "string" - }, - name: { - required: true, - type: "string" - }, - owner: { - required: true, - type: "string" - }, - repo: { - required: true, - type: "string" - } - }, - url: "/repos/:owner/:repo/actions/secrets/:name" - }, - createRegistrationToken: { - method: "POST", - params: { - owner: { - required: true, - type: "string" - }, - repo: { - required: true, - type: "string" - } - }, - url: "/repos/:owner/:repo/actions/runners/registration-token" - }, - createRemoveToken: { - method: "POST", - params: { - owner: { - required: true, - type: "string" - }, - repo: { - required: true, - type: "string" - } - }, - url: "/repos/:owner/:repo/actions/runners/remove-token" - }, - deleteArtifact: { - method: "DELETE", - params: { - artifact_id: { - required: true, - type: "integer" - }, - owner: { - required: true, - type: "string" - }, - repo: { - required: true, - type: "string" - } - }, - url: "/repos/:owner/:repo/actions/artifacts/:artifact_id" - }, - deleteSecretFromRepo: { - method: "DELETE", - params: { - name: { - required: true, - type: "string" - }, - owner: { - required: true, - type: "string" - }, - repo: { - required: true, - type: "string" - } - }, - url: "/repos/:owner/:repo/actions/secrets/:name" - }, - downloadArtifact: { - method: "GET", - params: { - archive_format: { - required: true, - type: "string" - }, - artifact_id: { - required: true, - type: "integer" - }, - owner: { - required: true, - type: "string" - }, - repo: { - required: true, - type: "string" - } - }, - url: "/repos/:owner/:repo/actions/artifacts/:artifact_id/:archive_format" - }, - getArtifact: { - method: "GET", - params: { - artifact_id: { - required: true, - type: "integer" - }, - owner: { - required: true, - type: "string" - }, - repo: { - required: true, - type: "string" - } - }, - url: "/repos/:owner/:repo/actions/artifacts/:artifact_id" - }, - getPublicKey: { - method: "GET", - params: { - owner: { - required: true, - type: "string" - }, - repo: { - required: true, - type: "string" - } - }, - url: "/repos/:owner/:repo/actions/secrets/public-key" - }, - getSecret: { - method: "GET", - params: { - name: { - required: true, - type: "string" - }, - owner: { - required: true, - type: "string" - }, - page: { - type: "integer" - }, - per_page: { - type: "integer" - }, - repo: { - required: true, - type: "string" - } - }, - url: "/repos/:owner/:repo/actions/secrets/:name" - }, - getSelfHostedRunner: { - method: "GET", - params: { - owner: { - required: true, - type: "string" - }, - repo: { - required: true, - type: "string" - }, - runner_id: { - required: true, - type: "integer" - } - }, - url: "/repos/:owner/:repo/actions/runners/:runner_id" - }, - getWorkflow: { - method: "GET", - params: { - owner: { - required: true, - type: "string" - }, - repo: { - required: true, - type: "string" - }, - workflow_id: { - required: true, - type: "integer" - } - }, - url: "/repos/:owner/:repo/actions/workflows/:workflow_id" - }, - getWorkflowJob: { - method: "GET", - params: { - job_id: { - required: true, - type: "integer" - }, - owner: { - required: true, - type: "string" - }, - repo: { - required: true, - type: "string" - } - }, - url: "/repos/:owner/:repo/actions/jobs/:job_id" - }, - getWorkflowRun: { - method: "GET", - params: { - owner: { - required: true, - type: "string" - }, - repo: { - required: true, - type: "string" - }, - run_id: { - required: true, - type: "integer" - } - }, - url: "/repos/:owner/:repo/actions/runs/:run_id" - }, - listDownloadsForSelfHostedRunnerApplication: { - method: "GET", - params: { - owner: { - required: true, - type: "string" - }, - repo: { - required: true, - type: "string" - } - }, - url: "/repos/:owner/:repo/actions/runners/downloads" - }, - listJobsForWorkflowRun: { - method: "GET", - params: { - owner: { - required: true, - type: "string" - }, - page: { - type: "integer" - }, - per_page: { - type: "integer" - }, - repo: { - required: true, - type: "string" - }, - run_id: { - required: true, - type: "integer" - } - }, - url: "/repos/:owner/:repo/actions/runs/:run_id/jobs" - }, - listRepoWorkflowRuns: { - method: "GET", - params: { - actor: { - type: "string" - }, - branch: { - type: "string" - }, - event: { - type: "string" - }, - owner: { - required: true, - type: "string" - }, - page: { - type: "integer" - }, - per_page: { - type: "integer" - }, - repo: { - required: true, - type: "string" - }, - status: { - enum: ["completed", "status", "conclusion"], - type: "string" - } - }, - url: "/repos/:owner/:repo/actions/runs" - }, - listRepoWorkflows: { - method: "GET", - params: { - owner: { - required: true, - type: "string" - }, - page: { - type: "integer" - }, - per_page: { - type: "integer" - }, - repo: { - required: true, - type: "string" - } - }, - url: "/repos/:owner/:repo/actions/workflows" - }, - listSecretsForRepo: { - method: "GET", - params: { - owner: { - required: true, - type: "string" - }, - page: { - type: "integer" - }, - per_page: { - type: "integer" - }, - repo: { - required: true, - type: "string" - } - }, - url: "/repos/:owner/:repo/actions/secrets" - }, - listSelfHostedRunnersForRepo: { - method: "GET", - params: { - owner: { - required: true, - type: "string" - }, - page: { - type: "integer" - }, - per_page: { - type: "integer" - }, - repo: { - required: true, - type: "string" - } - }, - url: "/repos/:owner/:repo/actions/runners" - }, - listWorkflowJobLogs: { - method: "GET", - params: { - job_id: { - required: true, - type: "integer" - }, - owner: { - required: true, - type: "string" - }, - page: { - type: "integer" - }, - per_page: { - type: "integer" - }, - repo: { - required: true, - type: "string" - } - }, - url: "/repos/:owner/:repo/actions/jobs/:job_id/logs" - }, - listWorkflowRunArtifacts: { - method: "GET", - params: { - owner: { - required: true, - type: "string" - }, - page: { - type: "integer" - }, - per_page: { - type: "integer" - }, - repo: { - required: true, - type: "string" - }, - run_id: { - required: true, - type: "integer" - } - }, - url: "/repos/:owner/:repo/actions/runs/:run_id/artifacts" - }, - listWorkflowRunLogs: { - method: "GET", - params: { - owner: { - required: true, - type: "string" - }, - page: { - type: "integer" - }, - per_page: { - type: "integer" - }, - repo: { - required: true, - type: "string" - }, - run_id: { - required: true, - type: "integer" - } - }, - url: "/repos/:owner/:repo/actions/runs/:run_id/logs" - }, - listWorkflowRuns: { - method: "GET", - params: { - actor: { - type: "string" - }, - branch: { - type: "string" - }, - event: { - type: "string" - }, - owner: { - required: true, - type: "string" - }, - page: { - type: "integer" - }, - per_page: { - type: "integer" - }, - repo: { - required: true, - type: "string" - }, - status: { - enum: ["completed", "status", "conclusion"], - type: "string" - }, - workflow_id: { - required: true, - type: "integer" - } - }, - url: "/repos/:owner/:repo/actions/workflows/:workflow_id/runs" - }, - reRunWorkflow: { - method: "POST", - params: { - owner: { - required: true, - type: "string" - }, - repo: { - required: true, - type: "string" - }, - run_id: { - required: true, - type: "integer" - } - }, - url: "/repos/:owner/:repo/actions/runs/:run_id/rerun" - }, - removeSelfHostedRunner: { - method: "DELETE", - params: { - owner: { - required: true, - type: "string" - }, - repo: { - required: true, - type: "string" - }, - runner_id: { - required: true, - type: "integer" - } - }, - url: "/repos/:owner/:repo/actions/runners/:runner_id" - } - }, - activity: { - checkStarringRepo: { - method: "GET", - params: { - owner: { - required: true, - type: "string" + /** + * Creates a plain object from a WriteLogEntriesResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.WriteLogEntriesResponse + * @static + * @param {google.logging.v2.WriteLogEntriesResponse} message WriteLogEntriesResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + WriteLogEntriesResponse.toObject = function toObject() { + return {} + } + + /** + * Converts this WriteLogEntriesResponse to JSON. + * @function toJSON + * @memberof google.logging.v2.WriteLogEntriesResponse + * @instance + * @returns {Object.} JSON object + */ + WriteLogEntriesResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return WriteLogEntriesResponse + })() + + v2.WriteLogEntriesPartialErrors = (function () { + /** + * Properties of a WriteLogEntriesPartialErrors. + * @memberof google.logging.v2 + * @interface IWriteLogEntriesPartialErrors + * @property {Object.|null} [logEntryErrors] WriteLogEntriesPartialErrors logEntryErrors + */ + + /** + * Constructs a new WriteLogEntriesPartialErrors. + * @memberof google.logging.v2 + * @classdesc Represents a WriteLogEntriesPartialErrors. + * @implements IWriteLogEntriesPartialErrors + * @constructor + * @param {google.logging.v2.IWriteLogEntriesPartialErrors=} [properties] Properties to set + */ + function WriteLogEntriesPartialErrors(properties) { + this.logEntryErrors = {} + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * WriteLogEntriesPartialErrors logEntryErrors. + * @member {Object.} logEntryErrors + * @memberof google.logging.v2.WriteLogEntriesPartialErrors + * @instance + */ + WriteLogEntriesPartialErrors.prototype.logEntryErrors = + $util.emptyObject + + /** + * Creates a new WriteLogEntriesPartialErrors instance using the specified properties. + * @function create + * @memberof google.logging.v2.WriteLogEntriesPartialErrors + * @static + * @param {google.logging.v2.IWriteLogEntriesPartialErrors=} [properties] Properties to set + * @returns {google.logging.v2.WriteLogEntriesPartialErrors} WriteLogEntriesPartialErrors instance + */ + WriteLogEntriesPartialErrors.create = function create( + properties + ) { + return new WriteLogEntriesPartialErrors(properties) + } + + /** + * Encodes the specified WriteLogEntriesPartialErrors message. Does not implicitly {@link google.logging.v2.WriteLogEntriesPartialErrors.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.WriteLogEntriesPartialErrors + * @static + * @param {google.logging.v2.IWriteLogEntriesPartialErrors} message WriteLogEntriesPartialErrors message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WriteLogEntriesPartialErrors.encode = function encode( + message, + writer + ) { + if (!writer) writer = $Writer.create() + if ( + message.logEntryErrors != null && + Object.hasOwnProperty.call(message, 'logEntryErrors') + ) + for ( + var keys = Object.keys(message.logEntryErrors), i = 0; + i < keys.length; + ++i + ) { + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .fork() + .uint32(/* id 1, wireType 0 =*/ 8) + .int32(keys[i]) + $root.google.rpc.Status.encode( + message.logEntryErrors[keys[i]], + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + ) + .ldelim() + .ldelim() + } + return writer + } + + /** + * Encodes the specified WriteLogEntriesPartialErrors message, length delimited. Does not implicitly {@link google.logging.v2.WriteLogEntriesPartialErrors.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.WriteLogEntriesPartialErrors + * @static + * @param {google.logging.v2.IWriteLogEntriesPartialErrors} message WriteLogEntriesPartialErrors message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WriteLogEntriesPartialErrors.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a WriteLogEntriesPartialErrors message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.WriteLogEntriesPartialErrors + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.WriteLogEntriesPartialErrors} WriteLogEntriesPartialErrors + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WriteLogEntriesPartialErrors.decode = function decode( + reader, + length + ) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.WriteLogEntriesPartialErrors(), + key, + value + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + if (message.logEntryErrors === $util.emptyObject) + message.logEntryErrors = {} + var end2 = reader.uint32() + reader.pos + key = 0 + value = null + while (reader.pos < end2) { + var tag2 = reader.uint32() + switch (tag2 >>> 3) { + case 1: + key = reader.int32() + break + case 2: + value = $root.google.rpc.Status.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag2 & 7) + break + } + } + message.logEntryErrors[key] = value + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a WriteLogEntriesPartialErrors message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.WriteLogEntriesPartialErrors + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.WriteLogEntriesPartialErrors} WriteLogEntriesPartialErrors + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WriteLogEntriesPartialErrors.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a WriteLogEntriesPartialErrors message. + * @function verify + * @memberof google.logging.v2.WriteLogEntriesPartialErrors + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + WriteLogEntriesPartialErrors.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.logEntryErrors != null && + message.hasOwnProperty('logEntryErrors') + ) { + if (!$util.isObject(message.logEntryErrors)) + return 'logEntryErrors: object expected' + var key = Object.keys(message.logEntryErrors) + for (var i = 0; i < key.length; ++i) { + if (!$util.key32Re.test(key[i])) + return 'logEntryErrors: integer key{k:int32} expected' + { + var error = $root.google.rpc.Status.verify( + message.logEntryErrors[key[i]] + ) + if (error) return 'logEntryErrors.' + error + } + } + } + return null + } + + /** + * Creates a WriteLogEntriesPartialErrors message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.WriteLogEntriesPartialErrors + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.WriteLogEntriesPartialErrors} WriteLogEntriesPartialErrors + */ + WriteLogEntriesPartialErrors.fromObject = function fromObject( + object + ) { + if ( + object instanceof + $root.google.logging.v2.WriteLogEntriesPartialErrors + ) + return object + var message = new $root.google.logging.v2.WriteLogEntriesPartialErrors() + if (object.logEntryErrors) { + if (typeof object.logEntryErrors !== 'object') + throw TypeError( + '.google.logging.v2.WriteLogEntriesPartialErrors.logEntryErrors: object expected' + ) + message.logEntryErrors = {} + for ( + var keys = Object.keys(object.logEntryErrors), i = 0; + i < keys.length; + ++i + ) { + if (typeof object.logEntryErrors[keys[i]] !== 'object') + throw TypeError( + '.google.logging.v2.WriteLogEntriesPartialErrors.logEntryErrors: object expected' + ) + message.logEntryErrors[ + keys[i] + ] = $root.google.rpc.Status.fromObject( + object.logEntryErrors[keys[i]] + ) + } + } + return message + } + + /** + * Creates a plain object from a WriteLogEntriesPartialErrors message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.WriteLogEntriesPartialErrors + * @static + * @param {google.logging.v2.WriteLogEntriesPartialErrors} message WriteLogEntriesPartialErrors + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + WriteLogEntriesPartialErrors.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.objects || options.defaults) + object.logEntryErrors = {} + var keys2 + if ( + message.logEntryErrors && + (keys2 = Object.keys(message.logEntryErrors)).length + ) { + object.logEntryErrors = {} + for (var j = 0; j < keys2.length; ++j) + object.logEntryErrors[ + keys2[j] + ] = $root.google.rpc.Status.toObject( + message.logEntryErrors[keys2[j]], + options + ) + } + return object + } + + /** + * Converts this WriteLogEntriesPartialErrors to JSON. + * @function toJSON + * @memberof google.logging.v2.WriteLogEntriesPartialErrors + * @instance + * @returns {Object.} JSON object + */ + WriteLogEntriesPartialErrors.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return WriteLogEntriesPartialErrors + })() + + v2.ListLogEntriesRequest = (function () { + /** + * Properties of a ListLogEntriesRequest. + * @memberof google.logging.v2 + * @interface IListLogEntriesRequest + * @property {Array.|null} [resourceNames] ListLogEntriesRequest resourceNames + * @property {string|null} [filter] ListLogEntriesRequest filter + * @property {string|null} [orderBy] ListLogEntriesRequest orderBy + * @property {number|null} [pageSize] ListLogEntriesRequest pageSize + * @property {string|null} [pageToken] ListLogEntriesRequest pageToken + */ + + /** + * Constructs a new ListLogEntriesRequest. + * @memberof google.logging.v2 + * @classdesc Represents a ListLogEntriesRequest. + * @implements IListLogEntriesRequest + * @constructor + * @param {google.logging.v2.IListLogEntriesRequest=} [properties] Properties to set + */ + function ListLogEntriesRequest(properties) { + this.resourceNames = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * ListLogEntriesRequest resourceNames. + * @member {Array.} resourceNames + * @memberof google.logging.v2.ListLogEntriesRequest + * @instance + */ + ListLogEntriesRequest.prototype.resourceNames = $util.emptyArray + + /** + * ListLogEntriesRequest filter. + * @member {string} filter + * @memberof google.logging.v2.ListLogEntriesRequest + * @instance + */ + ListLogEntriesRequest.prototype.filter = '' + + /** + * ListLogEntriesRequest orderBy. + * @member {string} orderBy + * @memberof google.logging.v2.ListLogEntriesRequest + * @instance + */ + ListLogEntriesRequest.prototype.orderBy = '' + + /** + * ListLogEntriesRequest pageSize. + * @member {number} pageSize + * @memberof google.logging.v2.ListLogEntriesRequest + * @instance + */ + ListLogEntriesRequest.prototype.pageSize = 0 + + /** + * ListLogEntriesRequest pageToken. + * @member {string} pageToken + * @memberof google.logging.v2.ListLogEntriesRequest + * @instance + */ + ListLogEntriesRequest.prototype.pageToken = '' + + /** + * Creates a new ListLogEntriesRequest instance using the specified properties. + * @function create + * @memberof google.logging.v2.ListLogEntriesRequest + * @static + * @param {google.logging.v2.IListLogEntriesRequest=} [properties] Properties to set + * @returns {google.logging.v2.ListLogEntriesRequest} ListLogEntriesRequest instance + */ + ListLogEntriesRequest.create = function create(properties) { + return new ListLogEntriesRequest(properties) + } + + /** + * Encodes the specified ListLogEntriesRequest message. Does not implicitly {@link google.logging.v2.ListLogEntriesRequest.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.ListLogEntriesRequest + * @static + * @param {google.logging.v2.IListLogEntriesRequest} message ListLogEntriesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListLogEntriesRequest.encode = function encode( + message, + writer + ) { + if (!writer) writer = $Writer.create() + if ( + message.filter != null && + Object.hasOwnProperty.call(message, 'filter') + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.filter) + if ( + message.orderBy != null && + Object.hasOwnProperty.call(message, 'orderBy') + ) + writer + .uint32(/* id 3, wireType 2 =*/ 26) + .string(message.orderBy) + if ( + message.pageSize != null && + Object.hasOwnProperty.call(message, 'pageSize') + ) + writer + .uint32(/* id 4, wireType 0 =*/ 32) + .int32(message.pageSize) + if ( + message.pageToken != null && + Object.hasOwnProperty.call(message, 'pageToken') + ) + writer + .uint32(/* id 5, wireType 2 =*/ 42) + .string(message.pageToken) + if ( + message.resourceNames != null && + message.resourceNames.length + ) + for (var i = 0; i < message.resourceNames.length; ++i) + writer + .uint32(/* id 8, wireType 2 =*/ 66) + .string(message.resourceNames[i]) + return writer + } + + /** + * Encodes the specified ListLogEntriesRequest message, length delimited. Does not implicitly {@link google.logging.v2.ListLogEntriesRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.ListLogEntriesRequest + * @static + * @param {google.logging.v2.IListLogEntriesRequest} message ListLogEntriesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListLogEntriesRequest.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a ListLogEntriesRequest message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.ListLogEntriesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.ListLogEntriesRequest} ListLogEntriesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListLogEntriesRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.ListLogEntriesRequest() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 8: + if ( + !( + message.resourceNames && + message.resourceNames.length + ) + ) + message.resourceNames = [] + message.resourceNames.push(reader.string()) + break + case 2: + message.filter = reader.string() + break + case 3: + message.orderBy = reader.string() + break + case 4: + message.pageSize = reader.int32() + break + case 5: + message.pageToken = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a ListLogEntriesRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.ListLogEntriesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.ListLogEntriesRequest} ListLogEntriesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListLogEntriesRequest.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a ListLogEntriesRequest message. + * @function verify + * @memberof google.logging.v2.ListLogEntriesRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListLogEntriesRequest.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.resourceNames != null && + message.hasOwnProperty('resourceNames') + ) { + if (!Array.isArray(message.resourceNames)) + return 'resourceNames: array expected' + for (var i = 0; i < message.resourceNames.length; ++i) + if (!$util.isString(message.resourceNames[i])) + return 'resourceNames: string[] expected' + } + if ( + message.filter != null && + message.hasOwnProperty('filter') + ) + if (!$util.isString(message.filter)) + return 'filter: string expected' + if ( + message.orderBy != null && + message.hasOwnProperty('orderBy') + ) + if (!$util.isString(message.orderBy)) + return 'orderBy: string expected' + if ( + message.pageSize != null && + message.hasOwnProperty('pageSize') + ) + if (!$util.isInteger(message.pageSize)) + return 'pageSize: integer expected' + if ( + message.pageToken != null && + message.hasOwnProperty('pageToken') + ) + if (!$util.isString(message.pageToken)) + return 'pageToken: string expected' + return null + } + + /** + * Creates a ListLogEntriesRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.ListLogEntriesRequest + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.ListLogEntriesRequest} ListLogEntriesRequest + */ + ListLogEntriesRequest.fromObject = function fromObject(object) { + if ( + object instanceof + $root.google.logging.v2.ListLogEntriesRequest + ) + return object + var message = new $root.google.logging.v2.ListLogEntriesRequest() + if (object.resourceNames) { + if (!Array.isArray(object.resourceNames)) + throw TypeError( + '.google.logging.v2.ListLogEntriesRequest.resourceNames: array expected' + ) + message.resourceNames = [] + for (var i = 0; i < object.resourceNames.length; ++i) + message.resourceNames[i] = String(object.resourceNames[i]) + } + if (object.filter != null) + message.filter = String(object.filter) + if (object.orderBy != null) + message.orderBy = String(object.orderBy) + if (object.pageSize != null) + message.pageSize = object.pageSize | 0 + if (object.pageToken != null) + message.pageToken = String(object.pageToken) + return message + } + + /** + * Creates a plain object from a ListLogEntriesRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.ListLogEntriesRequest + * @static + * @param {google.logging.v2.ListLogEntriesRequest} message ListLogEntriesRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListLogEntriesRequest.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) + object.resourceNames = [] + if (options.defaults) { + object.filter = '' + object.orderBy = '' + object.pageSize = 0 + object.pageToken = '' + } + if ( + message.filter != null && + message.hasOwnProperty('filter') + ) + object.filter = message.filter + if ( + message.orderBy != null && + message.hasOwnProperty('orderBy') + ) + object.orderBy = message.orderBy + if ( + message.pageSize != null && + message.hasOwnProperty('pageSize') + ) + object.pageSize = message.pageSize + if ( + message.pageToken != null && + message.hasOwnProperty('pageToken') + ) + object.pageToken = message.pageToken + if (message.resourceNames && message.resourceNames.length) { + object.resourceNames = [] + for (var j = 0; j < message.resourceNames.length; ++j) + object.resourceNames[j] = message.resourceNames[j] + } + return object + } + + /** + * Converts this ListLogEntriesRequest to JSON. + * @function toJSON + * @memberof google.logging.v2.ListLogEntriesRequest + * @instance + * @returns {Object.} JSON object + */ + ListLogEntriesRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return ListLogEntriesRequest + })() + + v2.ListLogEntriesResponse = (function () { + /** + * Properties of a ListLogEntriesResponse. + * @memberof google.logging.v2 + * @interface IListLogEntriesResponse + * @property {Array.|null} [entries] ListLogEntriesResponse entries + * @property {string|null} [nextPageToken] ListLogEntriesResponse nextPageToken + */ + + /** + * Constructs a new ListLogEntriesResponse. + * @memberof google.logging.v2 + * @classdesc Represents a ListLogEntriesResponse. + * @implements IListLogEntriesResponse + * @constructor + * @param {google.logging.v2.IListLogEntriesResponse=} [properties] Properties to set + */ + function ListLogEntriesResponse(properties) { + this.entries = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * ListLogEntriesResponse entries. + * @member {Array.} entries + * @memberof google.logging.v2.ListLogEntriesResponse + * @instance + */ + ListLogEntriesResponse.prototype.entries = $util.emptyArray + + /** + * ListLogEntriesResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.logging.v2.ListLogEntriesResponse + * @instance + */ + ListLogEntriesResponse.prototype.nextPageToken = '' + + /** + * Creates a new ListLogEntriesResponse instance using the specified properties. + * @function create + * @memberof google.logging.v2.ListLogEntriesResponse + * @static + * @param {google.logging.v2.IListLogEntriesResponse=} [properties] Properties to set + * @returns {google.logging.v2.ListLogEntriesResponse} ListLogEntriesResponse instance + */ + ListLogEntriesResponse.create = function create(properties) { + return new ListLogEntriesResponse(properties) + } + + /** + * Encodes the specified ListLogEntriesResponse message. Does not implicitly {@link google.logging.v2.ListLogEntriesResponse.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.ListLogEntriesResponse + * @static + * @param {google.logging.v2.IListLogEntriesResponse} message ListLogEntriesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListLogEntriesResponse.encode = function encode( + message, + writer + ) { + if (!writer) writer = $Writer.create() + if (message.entries != null && message.entries.length) + for (var i = 0; i < message.entries.length; ++i) + $root.google.logging.v2.LogEntry.encode( + message.entries[i], + writer.uint32(/* id 1, wireType 2 =*/ 10).fork() + ).ldelim() + if ( + message.nextPageToken != null && + Object.hasOwnProperty.call(message, 'nextPageToken') + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.nextPageToken) + return writer + } + + /** + * Encodes the specified ListLogEntriesResponse message, length delimited. Does not implicitly {@link google.logging.v2.ListLogEntriesResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.ListLogEntriesResponse + * @static + * @param {google.logging.v2.IListLogEntriesResponse} message ListLogEntriesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListLogEntriesResponse.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a ListLogEntriesResponse message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.ListLogEntriesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.ListLogEntriesResponse} ListLogEntriesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListLogEntriesResponse.decode = function decode( + reader, + length + ) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.ListLogEntriesResponse() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + if (!(message.entries && message.entries.length)) + message.entries = [] + message.entries.push( + $root.google.logging.v2.LogEntry.decode( + reader, + reader.uint32() + ) + ) + break + case 2: + message.nextPageToken = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a ListLogEntriesResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.ListLogEntriesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.ListLogEntriesResponse} ListLogEntriesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListLogEntriesResponse.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a ListLogEntriesResponse message. + * @function verify + * @memberof google.logging.v2.ListLogEntriesResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListLogEntriesResponse.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.entries != null && + message.hasOwnProperty('entries') + ) { + if (!Array.isArray(message.entries)) + return 'entries: array expected' + for (var i = 0; i < message.entries.length; ++i) { + var error = $root.google.logging.v2.LogEntry.verify( + message.entries[i] + ) + if (error) return 'entries.' + error + } + } + if ( + message.nextPageToken != null && + message.hasOwnProperty('nextPageToken') + ) + if (!$util.isString(message.nextPageToken)) + return 'nextPageToken: string expected' + return null + } + + /** + * Creates a ListLogEntriesResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.ListLogEntriesResponse + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.ListLogEntriesResponse} ListLogEntriesResponse + */ + ListLogEntriesResponse.fromObject = function fromObject( + object + ) { + if ( + object instanceof + $root.google.logging.v2.ListLogEntriesResponse + ) + return object + var message = new $root.google.logging.v2.ListLogEntriesResponse() + if (object.entries) { + if (!Array.isArray(object.entries)) + throw TypeError( + '.google.logging.v2.ListLogEntriesResponse.entries: array expected' + ) + message.entries = [] + for (var i = 0; i < object.entries.length; ++i) { + if (typeof object.entries[i] !== 'object') + throw TypeError( + '.google.logging.v2.ListLogEntriesResponse.entries: object expected' + ) + message.entries[ + i + ] = $root.google.logging.v2.LogEntry.fromObject( + object.entries[i] + ) + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken) + return message + } + + /** + * Creates a plain object from a ListLogEntriesResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.ListLogEntriesResponse + * @static + * @param {google.logging.v2.ListLogEntriesResponse} message ListLogEntriesResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListLogEntriesResponse.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) object.entries = [] + if (options.defaults) object.nextPageToken = '' + if (message.entries && message.entries.length) { + object.entries = [] + for (var j = 0; j < message.entries.length; ++j) + object.entries[ + j + ] = $root.google.logging.v2.LogEntry.toObject( + message.entries[j], + options + ) + } + if ( + message.nextPageToken != null && + message.hasOwnProperty('nextPageToken') + ) + object.nextPageToken = message.nextPageToken + return object + } + + /** + * Converts this ListLogEntriesResponse to JSON. + * @function toJSON + * @memberof google.logging.v2.ListLogEntriesResponse + * @instance + * @returns {Object.} JSON object + */ + ListLogEntriesResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return ListLogEntriesResponse + })() + + v2.ListMonitoredResourceDescriptorsRequest = (function () { + /** + * Properties of a ListMonitoredResourceDescriptorsRequest. + * @memberof google.logging.v2 + * @interface IListMonitoredResourceDescriptorsRequest + * @property {number|null} [pageSize] ListMonitoredResourceDescriptorsRequest pageSize + * @property {string|null} [pageToken] ListMonitoredResourceDescriptorsRequest pageToken + */ + + /** + * Constructs a new ListMonitoredResourceDescriptorsRequest. + * @memberof google.logging.v2 + * @classdesc Represents a ListMonitoredResourceDescriptorsRequest. + * @implements IListMonitoredResourceDescriptorsRequest + * @constructor + * @param {google.logging.v2.IListMonitoredResourceDescriptorsRequest=} [properties] Properties to set + */ + function ListMonitoredResourceDescriptorsRequest(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * ListMonitoredResourceDescriptorsRequest pageSize. + * @member {number} pageSize + * @memberof google.logging.v2.ListMonitoredResourceDescriptorsRequest + * @instance + */ + ListMonitoredResourceDescriptorsRequest.prototype.pageSize = 0 + + /** + * ListMonitoredResourceDescriptorsRequest pageToken. + * @member {string} pageToken + * @memberof google.logging.v2.ListMonitoredResourceDescriptorsRequest + * @instance + */ + ListMonitoredResourceDescriptorsRequest.prototype.pageToken = '' + + /** + * Creates a new ListMonitoredResourceDescriptorsRequest instance using the specified properties. + * @function create + * @memberof google.logging.v2.ListMonitoredResourceDescriptorsRequest + * @static + * @param {google.logging.v2.IListMonitoredResourceDescriptorsRequest=} [properties] Properties to set + * @returns {google.logging.v2.ListMonitoredResourceDescriptorsRequest} ListMonitoredResourceDescriptorsRequest instance + */ + ListMonitoredResourceDescriptorsRequest.create = function create( + properties + ) { + return new ListMonitoredResourceDescriptorsRequest(properties) + } + + /** + * Encodes the specified ListMonitoredResourceDescriptorsRequest message. Does not implicitly {@link google.logging.v2.ListMonitoredResourceDescriptorsRequest.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.ListMonitoredResourceDescriptorsRequest + * @static + * @param {google.logging.v2.IListMonitoredResourceDescriptorsRequest} message ListMonitoredResourceDescriptorsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListMonitoredResourceDescriptorsRequest.encode = function encode( + message, + writer + ) { + if (!writer) writer = $Writer.create() + if ( + message.pageSize != null && + Object.hasOwnProperty.call(message, 'pageSize') + ) + writer + .uint32(/* id 1, wireType 0 =*/ 8) + .int32(message.pageSize) + if ( + message.pageToken != null && + Object.hasOwnProperty.call(message, 'pageToken') + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.pageToken) + return writer + } + + /** + * Encodes the specified ListMonitoredResourceDescriptorsRequest message, length delimited. Does not implicitly {@link google.logging.v2.ListMonitoredResourceDescriptorsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.ListMonitoredResourceDescriptorsRequest + * @static + * @param {google.logging.v2.IListMonitoredResourceDescriptorsRequest} message ListMonitoredResourceDescriptorsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListMonitoredResourceDescriptorsRequest.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a ListMonitoredResourceDescriptorsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.ListMonitoredResourceDescriptorsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.ListMonitoredResourceDescriptorsRequest} ListMonitoredResourceDescriptorsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListMonitoredResourceDescriptorsRequest.decode = function decode( + reader, + length + ) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.ListMonitoredResourceDescriptorsRequest() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.pageSize = reader.int32() + break + case 2: + message.pageToken = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a ListMonitoredResourceDescriptorsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.ListMonitoredResourceDescriptorsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.ListMonitoredResourceDescriptorsRequest} ListMonitoredResourceDescriptorsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListMonitoredResourceDescriptorsRequest.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a ListMonitoredResourceDescriptorsRequest message. + * @function verify + * @memberof google.logging.v2.ListMonitoredResourceDescriptorsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListMonitoredResourceDescriptorsRequest.verify = function verify( + message + ) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.pageSize != null && + message.hasOwnProperty('pageSize') + ) + if (!$util.isInteger(message.pageSize)) + return 'pageSize: integer expected' + if ( + message.pageToken != null && + message.hasOwnProperty('pageToken') + ) + if (!$util.isString(message.pageToken)) + return 'pageToken: string expected' + return null + } + + /** + * Creates a ListMonitoredResourceDescriptorsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.ListMonitoredResourceDescriptorsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.ListMonitoredResourceDescriptorsRequest} ListMonitoredResourceDescriptorsRequest + */ + ListMonitoredResourceDescriptorsRequest.fromObject = function fromObject( + object + ) { + if ( + object instanceof + $root.google.logging.v2 + .ListMonitoredResourceDescriptorsRequest + ) + return object + var message = new $root.google.logging.v2.ListMonitoredResourceDescriptorsRequest() + if (object.pageSize != null) + message.pageSize = object.pageSize | 0 + if (object.pageToken != null) + message.pageToken = String(object.pageToken) + return message + } + + /** + * Creates a plain object from a ListMonitoredResourceDescriptorsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.ListMonitoredResourceDescriptorsRequest + * @static + * @param {google.logging.v2.ListMonitoredResourceDescriptorsRequest} message ListMonitoredResourceDescriptorsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListMonitoredResourceDescriptorsRequest.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.pageSize = 0 + object.pageToken = '' + } + if ( + message.pageSize != null && + message.hasOwnProperty('pageSize') + ) + object.pageSize = message.pageSize + if ( + message.pageToken != null && + message.hasOwnProperty('pageToken') + ) + object.pageToken = message.pageToken + return object + } + + /** + * Converts this ListMonitoredResourceDescriptorsRequest to JSON. + * @function toJSON + * @memberof google.logging.v2.ListMonitoredResourceDescriptorsRequest + * @instance + * @returns {Object.} JSON object + */ + ListMonitoredResourceDescriptorsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return ListMonitoredResourceDescriptorsRequest + })() + + v2.ListMonitoredResourceDescriptorsResponse = (function () { + /** + * Properties of a ListMonitoredResourceDescriptorsResponse. + * @memberof google.logging.v2 + * @interface IListMonitoredResourceDescriptorsResponse + * @property {Array.|null} [resourceDescriptors] ListMonitoredResourceDescriptorsResponse resourceDescriptors + * @property {string|null} [nextPageToken] ListMonitoredResourceDescriptorsResponse nextPageToken + */ + + /** + * Constructs a new ListMonitoredResourceDescriptorsResponse. + * @memberof google.logging.v2 + * @classdesc Represents a ListMonitoredResourceDescriptorsResponse. + * @implements IListMonitoredResourceDescriptorsResponse + * @constructor + * @param {google.logging.v2.IListMonitoredResourceDescriptorsResponse=} [properties] Properties to set + */ + function ListMonitoredResourceDescriptorsResponse(properties) { + this.resourceDescriptors = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * ListMonitoredResourceDescriptorsResponse resourceDescriptors. + * @member {Array.} resourceDescriptors + * @memberof google.logging.v2.ListMonitoredResourceDescriptorsResponse + * @instance + */ + ListMonitoredResourceDescriptorsResponse.prototype.resourceDescriptors = + $util.emptyArray + + /** + * ListMonitoredResourceDescriptorsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.logging.v2.ListMonitoredResourceDescriptorsResponse + * @instance + */ + ListMonitoredResourceDescriptorsResponse.prototype.nextPageToken = + '' + + /** + * Creates a new ListMonitoredResourceDescriptorsResponse instance using the specified properties. + * @function create + * @memberof google.logging.v2.ListMonitoredResourceDescriptorsResponse + * @static + * @param {google.logging.v2.IListMonitoredResourceDescriptorsResponse=} [properties] Properties to set + * @returns {google.logging.v2.ListMonitoredResourceDescriptorsResponse} ListMonitoredResourceDescriptorsResponse instance + */ + ListMonitoredResourceDescriptorsResponse.create = function create( + properties + ) { + return new ListMonitoredResourceDescriptorsResponse( + properties + ) + } + + /** + * Encodes the specified ListMonitoredResourceDescriptorsResponse message. Does not implicitly {@link google.logging.v2.ListMonitoredResourceDescriptorsResponse.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.ListMonitoredResourceDescriptorsResponse + * @static + * @param {google.logging.v2.IListMonitoredResourceDescriptorsResponse} message ListMonitoredResourceDescriptorsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListMonitoredResourceDescriptorsResponse.encode = function encode( + message, + writer + ) { + if (!writer) writer = $Writer.create() + if ( + message.resourceDescriptors != null && + message.resourceDescriptors.length + ) + for (var i = 0; i < message.resourceDescriptors.length; ++i) + $root.google.api.MonitoredResourceDescriptor.encode( + message.resourceDescriptors[i], + writer.uint32(/* id 1, wireType 2 =*/ 10).fork() + ).ldelim() + if ( + message.nextPageToken != null && + Object.hasOwnProperty.call(message, 'nextPageToken') + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.nextPageToken) + return writer + } + + /** + * Encodes the specified ListMonitoredResourceDescriptorsResponse message, length delimited. Does not implicitly {@link google.logging.v2.ListMonitoredResourceDescriptorsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.ListMonitoredResourceDescriptorsResponse + * @static + * @param {google.logging.v2.IListMonitoredResourceDescriptorsResponse} message ListMonitoredResourceDescriptorsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListMonitoredResourceDescriptorsResponse.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a ListMonitoredResourceDescriptorsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.ListMonitoredResourceDescriptorsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.ListMonitoredResourceDescriptorsResponse} ListMonitoredResourceDescriptorsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListMonitoredResourceDescriptorsResponse.decode = function decode( + reader, + length + ) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.ListMonitoredResourceDescriptorsResponse() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + if ( + !( + message.resourceDescriptors && + message.resourceDescriptors.length + ) + ) + message.resourceDescriptors = [] + message.resourceDescriptors.push( + $root.google.api.MonitoredResourceDescriptor.decode( + reader, + reader.uint32() + ) + ) + break + case 2: + message.nextPageToken = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a ListMonitoredResourceDescriptorsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.ListMonitoredResourceDescriptorsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.ListMonitoredResourceDescriptorsResponse} ListMonitoredResourceDescriptorsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListMonitoredResourceDescriptorsResponse.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a ListMonitoredResourceDescriptorsResponse message. + * @function verify + * @memberof google.logging.v2.ListMonitoredResourceDescriptorsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListMonitoredResourceDescriptorsResponse.verify = function verify( + message + ) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.resourceDescriptors != null && + message.hasOwnProperty('resourceDescriptors') + ) { + if (!Array.isArray(message.resourceDescriptors)) + return 'resourceDescriptors: array expected' + for ( + var i = 0; + i < message.resourceDescriptors.length; + ++i + ) { + var error = $root.google.api.MonitoredResourceDescriptor.verify( + message.resourceDescriptors[i] + ) + if (error) return 'resourceDescriptors.' + error + } + } + if ( + message.nextPageToken != null && + message.hasOwnProperty('nextPageToken') + ) + if (!$util.isString(message.nextPageToken)) + return 'nextPageToken: string expected' + return null + } + + /** + * Creates a ListMonitoredResourceDescriptorsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.ListMonitoredResourceDescriptorsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.ListMonitoredResourceDescriptorsResponse} ListMonitoredResourceDescriptorsResponse + */ + ListMonitoredResourceDescriptorsResponse.fromObject = function fromObject( + object + ) { + if ( + object instanceof + $root.google.logging.v2 + .ListMonitoredResourceDescriptorsResponse + ) + return object + var message = new $root.google.logging.v2.ListMonitoredResourceDescriptorsResponse() + if (object.resourceDescriptors) { + if (!Array.isArray(object.resourceDescriptors)) + throw TypeError( + '.google.logging.v2.ListMonitoredResourceDescriptorsResponse.resourceDescriptors: array expected' + ) + message.resourceDescriptors = [] + for ( + var i = 0; + i < object.resourceDescriptors.length; + ++i + ) { + if (typeof object.resourceDescriptors[i] !== 'object') + throw TypeError( + '.google.logging.v2.ListMonitoredResourceDescriptorsResponse.resourceDescriptors: object expected' + ) + message.resourceDescriptors[ + i + ] = $root.google.api.MonitoredResourceDescriptor.fromObject( + object.resourceDescriptors[i] + ) + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken) + return message + } + + /** + * Creates a plain object from a ListMonitoredResourceDescriptorsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.ListMonitoredResourceDescriptorsResponse + * @static + * @param {google.logging.v2.ListMonitoredResourceDescriptorsResponse} message ListMonitoredResourceDescriptorsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListMonitoredResourceDescriptorsResponse.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) + object.resourceDescriptors = [] + if (options.defaults) object.nextPageToken = '' + if ( + message.resourceDescriptors && + message.resourceDescriptors.length + ) { + object.resourceDescriptors = [] + for (var j = 0; j < message.resourceDescriptors.length; ++j) + object.resourceDescriptors[ + j + ] = $root.google.api.MonitoredResourceDescriptor.toObject( + message.resourceDescriptors[j], + options + ) + } + if ( + message.nextPageToken != null && + message.hasOwnProperty('nextPageToken') + ) + object.nextPageToken = message.nextPageToken + return object + } + + /** + * Converts this ListMonitoredResourceDescriptorsResponse to JSON. + * @function toJSON + * @memberof google.logging.v2.ListMonitoredResourceDescriptorsResponse + * @instance + * @returns {Object.} JSON object + */ + ListMonitoredResourceDescriptorsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return ListMonitoredResourceDescriptorsResponse + })() + + v2.ListLogsRequest = (function () { + /** + * Properties of a ListLogsRequest. + * @memberof google.logging.v2 + * @interface IListLogsRequest + * @property {string|null} [parent] ListLogsRequest parent + * @property {number|null} [pageSize] ListLogsRequest pageSize + * @property {string|null} [pageToken] ListLogsRequest pageToken + */ + + /** + * Constructs a new ListLogsRequest. + * @memberof google.logging.v2 + * @classdesc Represents a ListLogsRequest. + * @implements IListLogsRequest + * @constructor + * @param {google.logging.v2.IListLogsRequest=} [properties] Properties to set + */ + function ListLogsRequest(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * ListLogsRequest parent. + * @member {string} parent + * @memberof google.logging.v2.ListLogsRequest + * @instance + */ + ListLogsRequest.prototype.parent = '' + + /** + * ListLogsRequest pageSize. + * @member {number} pageSize + * @memberof google.logging.v2.ListLogsRequest + * @instance + */ + ListLogsRequest.prototype.pageSize = 0 + + /** + * ListLogsRequest pageToken. + * @member {string} pageToken + * @memberof google.logging.v2.ListLogsRequest + * @instance + */ + ListLogsRequest.prototype.pageToken = '' + + /** + * Creates a new ListLogsRequest instance using the specified properties. + * @function create + * @memberof google.logging.v2.ListLogsRequest + * @static + * @param {google.logging.v2.IListLogsRequest=} [properties] Properties to set + * @returns {google.logging.v2.ListLogsRequest} ListLogsRequest instance + */ + ListLogsRequest.create = function create(properties) { + return new ListLogsRequest(properties) + } + + /** + * Encodes the specified ListLogsRequest message. Does not implicitly {@link google.logging.v2.ListLogsRequest.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.ListLogsRequest + * @static + * @param {google.logging.v2.IListLogsRequest} message ListLogsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListLogsRequest.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.parent != null && + Object.hasOwnProperty.call(message, 'parent') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.parent) + if ( + message.pageSize != null && + Object.hasOwnProperty.call(message, 'pageSize') + ) + writer + .uint32(/* id 2, wireType 0 =*/ 16) + .int32(message.pageSize) + if ( + message.pageToken != null && + Object.hasOwnProperty.call(message, 'pageToken') + ) + writer + .uint32(/* id 3, wireType 2 =*/ 26) + .string(message.pageToken) + return writer + } + + /** + * Encodes the specified ListLogsRequest message, length delimited. Does not implicitly {@link google.logging.v2.ListLogsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.ListLogsRequest + * @static + * @param {google.logging.v2.IListLogsRequest} message ListLogsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListLogsRequest.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a ListLogsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.ListLogsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.ListLogsRequest} ListLogsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListLogsRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.ListLogsRequest() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.parent = reader.string() + break + case 2: + message.pageSize = reader.int32() + break + case 3: + message.pageToken = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a ListLogsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.ListLogsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.ListLogsRequest} ListLogsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListLogsRequest.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a ListLogsRequest message. + * @function verify + * @memberof google.logging.v2.ListLogsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListLogsRequest.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.parent != null && + message.hasOwnProperty('parent') + ) + if (!$util.isString(message.parent)) + return 'parent: string expected' + if ( + message.pageSize != null && + message.hasOwnProperty('pageSize') + ) + if (!$util.isInteger(message.pageSize)) + return 'pageSize: integer expected' + if ( + message.pageToken != null && + message.hasOwnProperty('pageToken') + ) + if (!$util.isString(message.pageToken)) + return 'pageToken: string expected' + return null + } + + /** + * Creates a ListLogsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.ListLogsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.ListLogsRequest} ListLogsRequest + */ + ListLogsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.logging.v2.ListLogsRequest) + return object + var message = new $root.google.logging.v2.ListLogsRequest() + if (object.parent != null) + message.parent = String(object.parent) + if (object.pageSize != null) + message.pageSize = object.pageSize | 0 + if (object.pageToken != null) + message.pageToken = String(object.pageToken) + return message + } + + /** + * Creates a plain object from a ListLogsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.ListLogsRequest + * @static + * @param {google.logging.v2.ListLogsRequest} message ListLogsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListLogsRequest.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.parent = '' + object.pageSize = 0 + object.pageToken = '' + } + if ( + message.parent != null && + message.hasOwnProperty('parent') + ) + object.parent = message.parent + if ( + message.pageSize != null && + message.hasOwnProperty('pageSize') + ) + object.pageSize = message.pageSize + if ( + message.pageToken != null && + message.hasOwnProperty('pageToken') + ) + object.pageToken = message.pageToken + return object + } + + /** + * Converts this ListLogsRequest to JSON. + * @function toJSON + * @memberof google.logging.v2.ListLogsRequest + * @instance + * @returns {Object.} JSON object + */ + ListLogsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return ListLogsRequest + })() + + v2.ListLogsResponse = (function () { + /** + * Properties of a ListLogsResponse. + * @memberof google.logging.v2 + * @interface IListLogsResponse + * @property {Array.|null} [logNames] ListLogsResponse logNames + * @property {string|null} [nextPageToken] ListLogsResponse nextPageToken + */ + + /** + * Constructs a new ListLogsResponse. + * @memberof google.logging.v2 + * @classdesc Represents a ListLogsResponse. + * @implements IListLogsResponse + * @constructor + * @param {google.logging.v2.IListLogsResponse=} [properties] Properties to set + */ + function ListLogsResponse(properties) { + this.logNames = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * ListLogsResponse logNames. + * @member {Array.} logNames + * @memberof google.logging.v2.ListLogsResponse + * @instance + */ + ListLogsResponse.prototype.logNames = $util.emptyArray + + /** + * ListLogsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.logging.v2.ListLogsResponse + * @instance + */ + ListLogsResponse.prototype.nextPageToken = '' + + /** + * Creates a new ListLogsResponse instance using the specified properties. + * @function create + * @memberof google.logging.v2.ListLogsResponse + * @static + * @param {google.logging.v2.IListLogsResponse=} [properties] Properties to set + * @returns {google.logging.v2.ListLogsResponse} ListLogsResponse instance + */ + ListLogsResponse.create = function create(properties) { + return new ListLogsResponse(properties) + } + + /** + * Encodes the specified ListLogsResponse message. Does not implicitly {@link google.logging.v2.ListLogsResponse.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.ListLogsResponse + * @static + * @param {google.logging.v2.IListLogsResponse} message ListLogsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListLogsResponse.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.nextPageToken != null && + Object.hasOwnProperty.call(message, 'nextPageToken') + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.nextPageToken) + if (message.logNames != null && message.logNames.length) + for (var i = 0; i < message.logNames.length; ++i) + writer + .uint32(/* id 3, wireType 2 =*/ 26) + .string(message.logNames[i]) + return writer + } + + /** + * Encodes the specified ListLogsResponse message, length delimited. Does not implicitly {@link google.logging.v2.ListLogsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.ListLogsResponse + * @static + * @param {google.logging.v2.IListLogsResponse} message ListLogsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListLogsResponse.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a ListLogsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.ListLogsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.ListLogsResponse} ListLogsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListLogsResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.ListLogsResponse() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 3: + if (!(message.logNames && message.logNames.length)) + message.logNames = [] + message.logNames.push(reader.string()) + break + case 2: + message.nextPageToken = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a ListLogsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.ListLogsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.ListLogsResponse} ListLogsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListLogsResponse.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a ListLogsResponse message. + * @function verify + * @memberof google.logging.v2.ListLogsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListLogsResponse.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.logNames != null && + message.hasOwnProperty('logNames') + ) { + if (!Array.isArray(message.logNames)) + return 'logNames: array expected' + for (var i = 0; i < message.logNames.length; ++i) + if (!$util.isString(message.logNames[i])) + return 'logNames: string[] expected' + } + if ( + message.nextPageToken != null && + message.hasOwnProperty('nextPageToken') + ) + if (!$util.isString(message.nextPageToken)) + return 'nextPageToken: string expected' + return null + } + + /** + * Creates a ListLogsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.ListLogsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.ListLogsResponse} ListLogsResponse + */ + ListLogsResponse.fromObject = function fromObject(object) { + if ( + object instanceof $root.google.logging.v2.ListLogsResponse + ) + return object + var message = new $root.google.logging.v2.ListLogsResponse() + if (object.logNames) { + if (!Array.isArray(object.logNames)) + throw TypeError( + '.google.logging.v2.ListLogsResponse.logNames: array expected' + ) + message.logNames = [] + for (var i = 0; i < object.logNames.length; ++i) + message.logNames[i] = String(object.logNames[i]) + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken) + return message + } + + /** + * Creates a plain object from a ListLogsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.ListLogsResponse + * @static + * @param {google.logging.v2.ListLogsResponse} message ListLogsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListLogsResponse.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) object.logNames = [] + if (options.defaults) object.nextPageToken = '' + if ( + message.nextPageToken != null && + message.hasOwnProperty('nextPageToken') + ) + object.nextPageToken = message.nextPageToken + if (message.logNames && message.logNames.length) { + object.logNames = [] + for (var j = 0; j < message.logNames.length; ++j) + object.logNames[j] = message.logNames[j] + } + return object + } + + /** + * Converts this ListLogsResponse to JSON. + * @function toJSON + * @memberof google.logging.v2.ListLogsResponse + * @instance + * @returns {Object.} JSON object + */ + ListLogsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return ListLogsResponse + })() + + v2.ConfigServiceV2 = (function () { + /** + * Constructs a new ConfigServiceV2 service. + * @memberof google.logging.v2 + * @classdesc Represents a ConfigServiceV2 + * @extends $protobuf.rpc.Service + * @constructor + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + */ + function ConfigServiceV2( + rpcImpl, + requestDelimited, + responseDelimited + ) { + $protobuf.rpc.Service.call( + this, + rpcImpl, + requestDelimited, + responseDelimited + ) + } + + ;(ConfigServiceV2.prototype = Object.create( + $protobuf.rpc.Service.prototype + )).constructor = ConfigServiceV2 + + /** + * Creates new ConfigServiceV2 service using the specified rpc implementation. + * @function create + * @memberof google.logging.v2.ConfigServiceV2 + * @static + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + * @returns {ConfigServiceV2} RPC service. Useful where requests and/or responses are streamed. + */ + ConfigServiceV2.create = function create( + rpcImpl, + requestDelimited, + responseDelimited + ) { + return new this(rpcImpl, requestDelimited, responseDelimited) + } + + /** + * Callback as used by {@link google.logging.v2.ConfigServiceV2#listBuckets}. + * @memberof google.logging.v2.ConfigServiceV2 + * @typedef ListBucketsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.logging.v2.ListBucketsResponse} [response] ListBucketsResponse + */ + + /** + * Calls ListBuckets. + * @function listBuckets + * @memberof google.logging.v2.ConfigServiceV2 + * @instance + * @param {google.logging.v2.IListBucketsRequest} request ListBucketsRequest message or plain object + * @param {google.logging.v2.ConfigServiceV2.ListBucketsCallback} callback Node-style callback called with the error, if any, and ListBucketsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty( + (ConfigServiceV2.prototype.listBuckets = function listBuckets( + request, + callback + ) { + return this.rpcCall( + listBuckets, + $root.google.logging.v2.ListBucketsRequest, + $root.google.logging.v2.ListBucketsResponse, + request, + callback + ) + }), + 'name', + { value: 'ListBuckets' } + ) + + /** + * Calls ListBuckets. + * @function listBuckets + * @memberof google.logging.v2.ConfigServiceV2 + * @instance + * @param {google.logging.v2.IListBucketsRequest} request ListBucketsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.logging.v2.ConfigServiceV2#getBucket}. + * @memberof google.logging.v2.ConfigServiceV2 + * @typedef GetBucketCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.logging.v2.LogBucket} [response] LogBucket + */ + + /** + * Calls GetBucket. + * @function getBucket + * @memberof google.logging.v2.ConfigServiceV2 + * @instance + * @param {google.logging.v2.IGetBucketRequest} request GetBucketRequest message or plain object + * @param {google.logging.v2.ConfigServiceV2.GetBucketCallback} callback Node-style callback called with the error, if any, and LogBucket + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty( + (ConfigServiceV2.prototype.getBucket = function getBucket( + request, + callback + ) { + return this.rpcCall( + getBucket, + $root.google.logging.v2.GetBucketRequest, + $root.google.logging.v2.LogBucket, + request, + callback + ) + }), + 'name', + { value: 'GetBucket' } + ) + + /** + * Calls GetBucket. + * @function getBucket + * @memberof google.logging.v2.ConfigServiceV2 + * @instance + * @param {google.logging.v2.IGetBucketRequest} request GetBucketRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.logging.v2.ConfigServiceV2#updateBucket}. + * @memberof google.logging.v2.ConfigServiceV2 + * @typedef UpdateBucketCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.logging.v2.LogBucket} [response] LogBucket + */ + + /** + * Calls UpdateBucket. + * @function updateBucket + * @memberof google.logging.v2.ConfigServiceV2 + * @instance + * @param {google.logging.v2.IUpdateBucketRequest} request UpdateBucketRequest message or plain object + * @param {google.logging.v2.ConfigServiceV2.UpdateBucketCallback} callback Node-style callback called with the error, if any, and LogBucket + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty( + (ConfigServiceV2.prototype.updateBucket = function updateBucket( + request, + callback + ) { + return this.rpcCall( + updateBucket, + $root.google.logging.v2.UpdateBucketRequest, + $root.google.logging.v2.LogBucket, + request, + callback + ) + }), + 'name', + { value: 'UpdateBucket' } + ) + + /** + * Calls UpdateBucket. + * @function updateBucket + * @memberof google.logging.v2.ConfigServiceV2 + * @instance + * @param {google.logging.v2.IUpdateBucketRequest} request UpdateBucketRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.logging.v2.ConfigServiceV2#listSinks}. + * @memberof google.logging.v2.ConfigServiceV2 + * @typedef ListSinksCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.logging.v2.ListSinksResponse} [response] ListSinksResponse + */ + + /** + * Calls ListSinks. + * @function listSinks + * @memberof google.logging.v2.ConfigServiceV2 + * @instance + * @param {google.logging.v2.IListSinksRequest} request ListSinksRequest message or plain object + * @param {google.logging.v2.ConfigServiceV2.ListSinksCallback} callback Node-style callback called with the error, if any, and ListSinksResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty( + (ConfigServiceV2.prototype.listSinks = function listSinks( + request, + callback + ) { + return this.rpcCall( + listSinks, + $root.google.logging.v2.ListSinksRequest, + $root.google.logging.v2.ListSinksResponse, + request, + callback + ) + }), + 'name', + { value: 'ListSinks' } + ) + + /** + * Calls ListSinks. + * @function listSinks + * @memberof google.logging.v2.ConfigServiceV2 + * @instance + * @param {google.logging.v2.IListSinksRequest} request ListSinksRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.logging.v2.ConfigServiceV2#getSink}. + * @memberof google.logging.v2.ConfigServiceV2 + * @typedef GetSinkCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.logging.v2.LogSink} [response] LogSink + */ + + /** + * Calls GetSink. + * @function getSink + * @memberof google.logging.v2.ConfigServiceV2 + * @instance + * @param {google.logging.v2.IGetSinkRequest} request GetSinkRequest message or plain object + * @param {google.logging.v2.ConfigServiceV2.GetSinkCallback} callback Node-style callback called with the error, if any, and LogSink + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty( + (ConfigServiceV2.prototype.getSink = function getSink( + request, + callback + ) { + return this.rpcCall( + getSink, + $root.google.logging.v2.GetSinkRequest, + $root.google.logging.v2.LogSink, + request, + callback + ) + }), + 'name', + { value: 'GetSink' } + ) + + /** + * Calls GetSink. + * @function getSink + * @memberof google.logging.v2.ConfigServiceV2 + * @instance + * @param {google.logging.v2.IGetSinkRequest} request GetSinkRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.logging.v2.ConfigServiceV2#createSink}. + * @memberof google.logging.v2.ConfigServiceV2 + * @typedef CreateSinkCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.logging.v2.LogSink} [response] LogSink + */ + + /** + * Calls CreateSink. + * @function createSink + * @memberof google.logging.v2.ConfigServiceV2 + * @instance + * @param {google.logging.v2.ICreateSinkRequest} request CreateSinkRequest message or plain object + * @param {google.logging.v2.ConfigServiceV2.CreateSinkCallback} callback Node-style callback called with the error, if any, and LogSink + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty( + (ConfigServiceV2.prototype.createSink = function createSink( + request, + callback + ) { + return this.rpcCall( + createSink, + $root.google.logging.v2.CreateSinkRequest, + $root.google.logging.v2.LogSink, + request, + callback + ) + }), + 'name', + { value: 'CreateSink' } + ) + + /** + * Calls CreateSink. + * @function createSink + * @memberof google.logging.v2.ConfigServiceV2 + * @instance + * @param {google.logging.v2.ICreateSinkRequest} request CreateSinkRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.logging.v2.ConfigServiceV2#updateSink}. + * @memberof google.logging.v2.ConfigServiceV2 + * @typedef UpdateSinkCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.logging.v2.LogSink} [response] LogSink + */ + + /** + * Calls UpdateSink. + * @function updateSink + * @memberof google.logging.v2.ConfigServiceV2 + * @instance + * @param {google.logging.v2.IUpdateSinkRequest} request UpdateSinkRequest message or plain object + * @param {google.logging.v2.ConfigServiceV2.UpdateSinkCallback} callback Node-style callback called with the error, if any, and LogSink + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty( + (ConfigServiceV2.prototype.updateSink = function updateSink( + request, + callback + ) { + return this.rpcCall( + updateSink, + $root.google.logging.v2.UpdateSinkRequest, + $root.google.logging.v2.LogSink, + request, + callback + ) + }), + 'name', + { value: 'UpdateSink' } + ) + + /** + * Calls UpdateSink. + * @function updateSink + * @memberof google.logging.v2.ConfigServiceV2 + * @instance + * @param {google.logging.v2.IUpdateSinkRequest} request UpdateSinkRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.logging.v2.ConfigServiceV2#deleteSink}. + * @memberof google.logging.v2.ConfigServiceV2 + * @typedef DeleteSinkCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls DeleteSink. + * @function deleteSink + * @memberof google.logging.v2.ConfigServiceV2 + * @instance + * @param {google.logging.v2.IDeleteSinkRequest} request DeleteSinkRequest message or plain object + * @param {google.logging.v2.ConfigServiceV2.DeleteSinkCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty( + (ConfigServiceV2.prototype.deleteSink = function deleteSink( + request, + callback + ) { + return this.rpcCall( + deleteSink, + $root.google.logging.v2.DeleteSinkRequest, + $root.google.protobuf.Empty, + request, + callback + ) + }), + 'name', + { value: 'DeleteSink' } + ) + + /** + * Calls DeleteSink. + * @function deleteSink + * @memberof google.logging.v2.ConfigServiceV2 + * @instance + * @param {google.logging.v2.IDeleteSinkRequest} request DeleteSinkRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.logging.v2.ConfigServiceV2#listExclusions}. + * @memberof google.logging.v2.ConfigServiceV2 + * @typedef ListExclusionsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.logging.v2.ListExclusionsResponse} [response] ListExclusionsResponse + */ + + /** + * Calls ListExclusions. + * @function listExclusions + * @memberof google.logging.v2.ConfigServiceV2 + * @instance + * @param {google.logging.v2.IListExclusionsRequest} request ListExclusionsRequest message or plain object + * @param {google.logging.v2.ConfigServiceV2.ListExclusionsCallback} callback Node-style callback called with the error, if any, and ListExclusionsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty( + (ConfigServiceV2.prototype.listExclusions = function listExclusions( + request, + callback + ) { + return this.rpcCall( + listExclusions, + $root.google.logging.v2.ListExclusionsRequest, + $root.google.logging.v2.ListExclusionsResponse, + request, + callback + ) + }), + 'name', + { value: 'ListExclusions' } + ) + + /** + * Calls ListExclusions. + * @function listExclusions + * @memberof google.logging.v2.ConfigServiceV2 + * @instance + * @param {google.logging.v2.IListExclusionsRequest} request ListExclusionsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.logging.v2.ConfigServiceV2#getExclusion}. + * @memberof google.logging.v2.ConfigServiceV2 + * @typedef GetExclusionCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.logging.v2.LogExclusion} [response] LogExclusion + */ + + /** + * Calls GetExclusion. + * @function getExclusion + * @memberof google.logging.v2.ConfigServiceV2 + * @instance + * @param {google.logging.v2.IGetExclusionRequest} request GetExclusionRequest message or plain object + * @param {google.logging.v2.ConfigServiceV2.GetExclusionCallback} callback Node-style callback called with the error, if any, and LogExclusion + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty( + (ConfigServiceV2.prototype.getExclusion = function getExclusion( + request, + callback + ) { + return this.rpcCall( + getExclusion, + $root.google.logging.v2.GetExclusionRequest, + $root.google.logging.v2.LogExclusion, + request, + callback + ) + }), + 'name', + { value: 'GetExclusion' } + ) + + /** + * Calls GetExclusion. + * @function getExclusion + * @memberof google.logging.v2.ConfigServiceV2 + * @instance + * @param {google.logging.v2.IGetExclusionRequest} request GetExclusionRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.logging.v2.ConfigServiceV2#createExclusion}. + * @memberof google.logging.v2.ConfigServiceV2 + * @typedef CreateExclusionCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.logging.v2.LogExclusion} [response] LogExclusion + */ + + /** + * Calls CreateExclusion. + * @function createExclusion + * @memberof google.logging.v2.ConfigServiceV2 + * @instance + * @param {google.logging.v2.ICreateExclusionRequest} request CreateExclusionRequest message or plain object + * @param {google.logging.v2.ConfigServiceV2.CreateExclusionCallback} callback Node-style callback called with the error, if any, and LogExclusion + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty( + (ConfigServiceV2.prototype.createExclusion = function createExclusion( + request, + callback + ) { + return this.rpcCall( + createExclusion, + $root.google.logging.v2.CreateExclusionRequest, + $root.google.logging.v2.LogExclusion, + request, + callback + ) + }), + 'name', + { value: 'CreateExclusion' } + ) + + /** + * Calls CreateExclusion. + * @function createExclusion + * @memberof google.logging.v2.ConfigServiceV2 + * @instance + * @param {google.logging.v2.ICreateExclusionRequest} request CreateExclusionRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.logging.v2.ConfigServiceV2#updateExclusion}. + * @memberof google.logging.v2.ConfigServiceV2 + * @typedef UpdateExclusionCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.logging.v2.LogExclusion} [response] LogExclusion + */ + + /** + * Calls UpdateExclusion. + * @function updateExclusion + * @memberof google.logging.v2.ConfigServiceV2 + * @instance + * @param {google.logging.v2.IUpdateExclusionRequest} request UpdateExclusionRequest message or plain object + * @param {google.logging.v2.ConfigServiceV2.UpdateExclusionCallback} callback Node-style callback called with the error, if any, and LogExclusion + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty( + (ConfigServiceV2.prototype.updateExclusion = function updateExclusion( + request, + callback + ) { + return this.rpcCall( + updateExclusion, + $root.google.logging.v2.UpdateExclusionRequest, + $root.google.logging.v2.LogExclusion, + request, + callback + ) + }), + 'name', + { value: 'UpdateExclusion' } + ) + + /** + * Calls UpdateExclusion. + * @function updateExclusion + * @memberof google.logging.v2.ConfigServiceV2 + * @instance + * @param {google.logging.v2.IUpdateExclusionRequest} request UpdateExclusionRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.logging.v2.ConfigServiceV2#deleteExclusion}. + * @memberof google.logging.v2.ConfigServiceV2 + * @typedef DeleteExclusionCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls DeleteExclusion. + * @function deleteExclusion + * @memberof google.logging.v2.ConfigServiceV2 + * @instance + * @param {google.logging.v2.IDeleteExclusionRequest} request DeleteExclusionRequest message or plain object + * @param {google.logging.v2.ConfigServiceV2.DeleteExclusionCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty( + (ConfigServiceV2.prototype.deleteExclusion = function deleteExclusion( + request, + callback + ) { + return this.rpcCall( + deleteExclusion, + $root.google.logging.v2.DeleteExclusionRequest, + $root.google.protobuf.Empty, + request, + callback + ) + }), + 'name', + { value: 'DeleteExclusion' } + ) + + /** + * Calls DeleteExclusion. + * @function deleteExclusion + * @memberof google.logging.v2.ConfigServiceV2 + * @instance + * @param {google.logging.v2.IDeleteExclusionRequest} request DeleteExclusionRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.logging.v2.ConfigServiceV2#getCmekSettings}. + * @memberof google.logging.v2.ConfigServiceV2 + * @typedef GetCmekSettingsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.logging.v2.CmekSettings} [response] CmekSettings + */ + + /** + * Calls GetCmekSettings. + * @function getCmekSettings + * @memberof google.logging.v2.ConfigServiceV2 + * @instance + * @param {google.logging.v2.IGetCmekSettingsRequest} request GetCmekSettingsRequest message or plain object + * @param {google.logging.v2.ConfigServiceV2.GetCmekSettingsCallback} callback Node-style callback called with the error, if any, and CmekSettings + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty( + (ConfigServiceV2.prototype.getCmekSettings = function getCmekSettings( + request, + callback + ) { + return this.rpcCall( + getCmekSettings, + $root.google.logging.v2.GetCmekSettingsRequest, + $root.google.logging.v2.CmekSettings, + request, + callback + ) + }), + 'name', + { value: 'GetCmekSettings' } + ) + + /** + * Calls GetCmekSettings. + * @function getCmekSettings + * @memberof google.logging.v2.ConfigServiceV2 + * @instance + * @param {google.logging.v2.IGetCmekSettingsRequest} request GetCmekSettingsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.logging.v2.ConfigServiceV2#updateCmekSettings}. + * @memberof google.logging.v2.ConfigServiceV2 + * @typedef UpdateCmekSettingsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.logging.v2.CmekSettings} [response] CmekSettings + */ + + /** + * Calls UpdateCmekSettings. + * @function updateCmekSettings + * @memberof google.logging.v2.ConfigServiceV2 + * @instance + * @param {google.logging.v2.IUpdateCmekSettingsRequest} request UpdateCmekSettingsRequest message or plain object + * @param {google.logging.v2.ConfigServiceV2.UpdateCmekSettingsCallback} callback Node-style callback called with the error, if any, and CmekSettings + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty( + (ConfigServiceV2.prototype.updateCmekSettings = function updateCmekSettings( + request, + callback + ) { + return this.rpcCall( + updateCmekSettings, + $root.google.logging.v2.UpdateCmekSettingsRequest, + $root.google.logging.v2.CmekSettings, + request, + callback + ) + }), + 'name', + { value: 'UpdateCmekSettings' } + ) + + /** + * Calls UpdateCmekSettings. + * @function updateCmekSettings + * @memberof google.logging.v2.ConfigServiceV2 + * @instance + * @param {google.logging.v2.IUpdateCmekSettingsRequest} request UpdateCmekSettingsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return ConfigServiceV2 + })() + + v2.LogBucket = (function () { + /** + * Properties of a LogBucket. + * @memberof google.logging.v2 + * @interface ILogBucket + * @property {string|null} [name] LogBucket name + * @property {string|null} [description] LogBucket description + * @property {google.protobuf.ITimestamp|null} [createTime] LogBucket createTime + * @property {google.protobuf.ITimestamp|null} [updateTime] LogBucket updateTime + * @property {number|null} [retentionDays] LogBucket retentionDays + * @property {google.logging.v2.LifecycleState|null} [lifecycleState] LogBucket lifecycleState + */ + + /** + * Constructs a new LogBucket. + * @memberof google.logging.v2 + * @classdesc Represents a LogBucket. + * @implements ILogBucket + * @constructor + * @param {google.logging.v2.ILogBucket=} [properties] Properties to set + */ + function LogBucket(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * LogBucket name. + * @member {string} name + * @memberof google.logging.v2.LogBucket + * @instance + */ + LogBucket.prototype.name = '' + + /** + * LogBucket description. + * @member {string} description + * @memberof google.logging.v2.LogBucket + * @instance + */ + LogBucket.prototype.description = '' + + /** + * LogBucket createTime. + * @member {google.protobuf.ITimestamp|null|undefined} createTime + * @memberof google.logging.v2.LogBucket + * @instance + */ + LogBucket.prototype.createTime = null + + /** + * LogBucket updateTime. + * @member {google.protobuf.ITimestamp|null|undefined} updateTime + * @memberof google.logging.v2.LogBucket + * @instance + */ + LogBucket.prototype.updateTime = null + + /** + * LogBucket retentionDays. + * @member {number} retentionDays + * @memberof google.logging.v2.LogBucket + * @instance + */ + LogBucket.prototype.retentionDays = 0 + + /** + * LogBucket lifecycleState. + * @member {google.logging.v2.LifecycleState} lifecycleState + * @memberof google.logging.v2.LogBucket + * @instance + */ + LogBucket.prototype.lifecycleState = 0 + + /** + * Creates a new LogBucket instance using the specified properties. + * @function create + * @memberof google.logging.v2.LogBucket + * @static + * @param {google.logging.v2.ILogBucket=} [properties] Properties to set + * @returns {google.logging.v2.LogBucket} LogBucket instance + */ + LogBucket.create = function create(properties) { + return new LogBucket(properties) + } + + /** + * Encodes the specified LogBucket message. Does not implicitly {@link google.logging.v2.LogBucket.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.LogBucket + * @static + * @param {google.logging.v2.ILogBucket} message LogBucket message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LogBucket.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.name != null && + Object.hasOwnProperty.call(message, 'name') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.name) + if ( + message.description != null && + Object.hasOwnProperty.call(message, 'description') + ) + writer + .uint32(/* id 3, wireType 2 =*/ 26) + .string(message.description) + if ( + message.createTime != null && + Object.hasOwnProperty.call(message, 'createTime') + ) + $root.google.protobuf.Timestamp.encode( + message.createTime, + writer.uint32(/* id 4, wireType 2 =*/ 34).fork() + ).ldelim() + if ( + message.updateTime != null && + Object.hasOwnProperty.call(message, 'updateTime') + ) + $root.google.protobuf.Timestamp.encode( + message.updateTime, + writer.uint32(/* id 5, wireType 2 =*/ 42).fork() + ).ldelim() + if ( + message.retentionDays != null && + Object.hasOwnProperty.call(message, 'retentionDays') + ) + writer + .uint32(/* id 11, wireType 0 =*/ 88) + .int32(message.retentionDays) + if ( + message.lifecycleState != null && + Object.hasOwnProperty.call(message, 'lifecycleState') + ) + writer + .uint32(/* id 12, wireType 0 =*/ 96) + .int32(message.lifecycleState) + return writer + } + + /** + * Encodes the specified LogBucket message, length delimited. Does not implicitly {@link google.logging.v2.LogBucket.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.LogBucket + * @static + * @param {google.logging.v2.ILogBucket} message LogBucket message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LogBucket.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a LogBucket message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.LogBucket + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.LogBucket} LogBucket + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LogBucket.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.LogBucket() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + case 3: + message.description = reader.string() + break + case 4: + message.createTime = $root.google.protobuf.Timestamp.decode( + reader, + reader.uint32() + ) + break + case 5: + message.updateTime = $root.google.protobuf.Timestamp.decode( + reader, + reader.uint32() + ) + break + case 11: + message.retentionDays = reader.int32() + break + case 12: + message.lifecycleState = reader.int32() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a LogBucket message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.LogBucket + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.LogBucket} LogBucket + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LogBucket.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a LogBucket message. + * @function verify + * @memberof google.logging.v2.LogBucket + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + LogBucket.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + if ( + message.description != null && + message.hasOwnProperty('description') + ) + if (!$util.isString(message.description)) + return 'description: string expected' + if ( + message.createTime != null && + message.hasOwnProperty('createTime') + ) { + var error = $root.google.protobuf.Timestamp.verify( + message.createTime + ) + if (error) return 'createTime.' + error + } + if ( + message.updateTime != null && + message.hasOwnProperty('updateTime') + ) { + var error = $root.google.protobuf.Timestamp.verify( + message.updateTime + ) + if (error) return 'updateTime.' + error + } + if ( + message.retentionDays != null && + message.hasOwnProperty('retentionDays') + ) + if (!$util.isInteger(message.retentionDays)) + return 'retentionDays: integer expected' + if ( + message.lifecycleState != null && + message.hasOwnProperty('lifecycleState') + ) + switch (message.lifecycleState) { + default: + return 'lifecycleState: enum value expected' + case 0: + case 1: + case 2: + break + } + return null + } + + /** + * Creates a LogBucket message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.LogBucket + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.LogBucket} LogBucket + */ + LogBucket.fromObject = function fromObject(object) { + if (object instanceof $root.google.logging.v2.LogBucket) + return object + var message = new $root.google.logging.v2.LogBucket() + if (object.name != null) message.name = String(object.name) + if (object.description != null) + message.description = String(object.description) + if (object.createTime != null) { + if (typeof object.createTime !== 'object') + throw TypeError( + '.google.logging.v2.LogBucket.createTime: object expected' + ) + message.createTime = $root.google.protobuf.Timestamp.fromObject( + object.createTime + ) + } + if (object.updateTime != null) { + if (typeof object.updateTime !== 'object') + throw TypeError( + '.google.logging.v2.LogBucket.updateTime: object expected' + ) + message.updateTime = $root.google.protobuf.Timestamp.fromObject( + object.updateTime + ) + } + if (object.retentionDays != null) + message.retentionDays = object.retentionDays | 0 + switch (object.lifecycleState) { + case 'LIFECYCLE_STATE_UNSPECIFIED': + case 0: + message.lifecycleState = 0 + break + case 'ACTIVE': + case 1: + message.lifecycleState = 1 + break + case 'DELETE_REQUESTED': + case 2: + message.lifecycleState = 2 + break + } + return message + } + + /** + * Creates a plain object from a LogBucket message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.LogBucket + * @static + * @param {google.logging.v2.LogBucket} message LogBucket + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + LogBucket.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.name = '' + object.description = '' + object.createTime = null + object.updateTime = null + object.retentionDays = 0 + object.lifecycleState = + options.enums === String + ? 'LIFECYCLE_STATE_UNSPECIFIED' + : 0 + } + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + if ( + message.description != null && + message.hasOwnProperty('description') + ) + object.description = message.description + if ( + message.createTime != null && + message.hasOwnProperty('createTime') + ) + object.createTime = $root.google.protobuf.Timestamp.toObject( + message.createTime, + options + ) + if ( + message.updateTime != null && + message.hasOwnProperty('updateTime') + ) + object.updateTime = $root.google.protobuf.Timestamp.toObject( + message.updateTime, + options + ) + if ( + message.retentionDays != null && + message.hasOwnProperty('retentionDays') + ) + object.retentionDays = message.retentionDays + if ( + message.lifecycleState != null && + message.hasOwnProperty('lifecycleState') + ) + object.lifecycleState = + options.enums === String + ? $root.google.logging.v2.LifecycleState[ + message.lifecycleState + ] + : message.lifecycleState + return object + } + + /** + * Converts this LogBucket to JSON. + * @function toJSON + * @memberof google.logging.v2.LogBucket + * @instance + * @returns {Object.} JSON object + */ + LogBucket.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return LogBucket + })() + + v2.LogSink = (function () { + /** + * Properties of a LogSink. + * @memberof google.logging.v2 + * @interface ILogSink + * @property {string|null} [name] LogSink name + * @property {string|null} [destination] LogSink destination + * @property {string|null} [filter] LogSink filter + * @property {string|null} [description] LogSink description + * @property {boolean|null} [disabled] LogSink disabled + * @property {google.logging.v2.LogSink.VersionFormat|null} [outputVersionFormat] LogSink outputVersionFormat + * @property {string|null} [writerIdentity] LogSink writerIdentity + * @property {boolean|null} [includeChildren] LogSink includeChildren + * @property {google.logging.v2.IBigQueryOptions|null} [bigqueryOptions] LogSink bigqueryOptions + * @property {google.protobuf.ITimestamp|null} [createTime] LogSink createTime + * @property {google.protobuf.ITimestamp|null} [updateTime] LogSink updateTime + */ + + /** + * Constructs a new LogSink. + * @memberof google.logging.v2 + * @classdesc Represents a LogSink. + * @implements ILogSink + * @constructor + * @param {google.logging.v2.ILogSink=} [properties] Properties to set + */ + function LogSink(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * LogSink name. + * @member {string} name + * @memberof google.logging.v2.LogSink + * @instance + */ + LogSink.prototype.name = '' + + /** + * LogSink destination. + * @member {string} destination + * @memberof google.logging.v2.LogSink + * @instance + */ + LogSink.prototype.destination = '' + + /** + * LogSink filter. + * @member {string} filter + * @memberof google.logging.v2.LogSink + * @instance + */ + LogSink.prototype.filter = '' + + /** + * LogSink description. + * @member {string} description + * @memberof google.logging.v2.LogSink + * @instance + */ + LogSink.prototype.description = '' + + /** + * LogSink disabled. + * @member {boolean} disabled + * @memberof google.logging.v2.LogSink + * @instance + */ + LogSink.prototype.disabled = false + + /** + * LogSink outputVersionFormat. + * @member {google.logging.v2.LogSink.VersionFormat} outputVersionFormat + * @memberof google.logging.v2.LogSink + * @instance + */ + LogSink.prototype.outputVersionFormat = 0 + + /** + * LogSink writerIdentity. + * @member {string} writerIdentity + * @memberof google.logging.v2.LogSink + * @instance + */ + LogSink.prototype.writerIdentity = '' + + /** + * LogSink includeChildren. + * @member {boolean} includeChildren + * @memberof google.logging.v2.LogSink + * @instance + */ + LogSink.prototype.includeChildren = false + + /** + * LogSink bigqueryOptions. + * @member {google.logging.v2.IBigQueryOptions|null|undefined} bigqueryOptions + * @memberof google.logging.v2.LogSink + * @instance + */ + LogSink.prototype.bigqueryOptions = null + + /** + * LogSink createTime. + * @member {google.protobuf.ITimestamp|null|undefined} createTime + * @memberof google.logging.v2.LogSink + * @instance + */ + LogSink.prototype.createTime = null + + /** + * LogSink updateTime. + * @member {google.protobuf.ITimestamp|null|undefined} updateTime + * @memberof google.logging.v2.LogSink + * @instance + */ + LogSink.prototype.updateTime = null + + // OneOf field names bound to virtual getters and setters + var $oneOfFields + + /** + * LogSink options. + * @member {"bigqueryOptions"|undefined} options + * @memberof google.logging.v2.LogSink + * @instance + */ + Object.defineProperty(LogSink.prototype, 'options', { + get: $util.oneOfGetter(($oneOfFields = ['bigqueryOptions'])), + set: $util.oneOfSetter($oneOfFields) + }) + + /** + * Creates a new LogSink instance using the specified properties. + * @function create + * @memberof google.logging.v2.LogSink + * @static + * @param {google.logging.v2.ILogSink=} [properties] Properties to set + * @returns {google.logging.v2.LogSink} LogSink instance + */ + LogSink.create = function create(properties) { + return new LogSink(properties) + } + + /** + * Encodes the specified LogSink message. Does not implicitly {@link google.logging.v2.LogSink.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.LogSink + * @static + * @param {google.logging.v2.ILogSink} message LogSink message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LogSink.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.name != null && + Object.hasOwnProperty.call(message, 'name') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.name) + if ( + message.destination != null && + Object.hasOwnProperty.call(message, 'destination') + ) + writer + .uint32(/* id 3, wireType 2 =*/ 26) + .string(message.destination) + if ( + message.filter != null && + Object.hasOwnProperty.call(message, 'filter') + ) + writer + .uint32(/* id 5, wireType 2 =*/ 42) + .string(message.filter) + if ( + message.outputVersionFormat != null && + Object.hasOwnProperty.call(message, 'outputVersionFormat') + ) + writer + .uint32(/* id 6, wireType 0 =*/ 48) + .int32(message.outputVersionFormat) + if ( + message.writerIdentity != null && + Object.hasOwnProperty.call(message, 'writerIdentity') + ) + writer + .uint32(/* id 8, wireType 2 =*/ 66) + .string(message.writerIdentity) + if ( + message.includeChildren != null && + Object.hasOwnProperty.call(message, 'includeChildren') + ) + writer + .uint32(/* id 9, wireType 0 =*/ 72) + .bool(message.includeChildren) + if ( + message.bigqueryOptions != null && + Object.hasOwnProperty.call(message, 'bigqueryOptions') + ) + $root.google.logging.v2.BigQueryOptions.encode( + message.bigqueryOptions, + writer.uint32(/* id 12, wireType 2 =*/ 98).fork() + ).ldelim() + if ( + message.createTime != null && + Object.hasOwnProperty.call(message, 'createTime') + ) + $root.google.protobuf.Timestamp.encode( + message.createTime, + writer.uint32(/* id 13, wireType 2 =*/ 106).fork() + ).ldelim() + if ( + message.updateTime != null && + Object.hasOwnProperty.call(message, 'updateTime') + ) + $root.google.protobuf.Timestamp.encode( + message.updateTime, + writer.uint32(/* id 14, wireType 2 =*/ 114).fork() + ).ldelim() + if ( + message.description != null && + Object.hasOwnProperty.call(message, 'description') + ) + writer + .uint32(/* id 18, wireType 2 =*/ 146) + .string(message.description) + if ( + message.disabled != null && + Object.hasOwnProperty.call(message, 'disabled') + ) + writer + .uint32(/* id 19, wireType 0 =*/ 152) + .bool(message.disabled) + return writer + } + + /** + * Encodes the specified LogSink message, length delimited. Does not implicitly {@link google.logging.v2.LogSink.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.LogSink + * @static + * @param {google.logging.v2.ILogSink} message LogSink message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LogSink.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a LogSink message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.LogSink + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.LogSink} LogSink + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LogSink.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.LogSink() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + case 3: + message.destination = reader.string() + break + case 5: + message.filter = reader.string() + break + case 18: + message.description = reader.string() + break + case 19: + message.disabled = reader.bool() + break + case 6: + message.outputVersionFormat = reader.int32() + break + case 8: + message.writerIdentity = reader.string() + break + case 9: + message.includeChildren = reader.bool() + break + case 12: + message.bigqueryOptions = $root.google.logging.v2.BigQueryOptions.decode( + reader, + reader.uint32() + ) + break + case 13: + message.createTime = $root.google.protobuf.Timestamp.decode( + reader, + reader.uint32() + ) + break + case 14: + message.updateTime = $root.google.protobuf.Timestamp.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a LogSink message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.LogSink + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.LogSink} LogSink + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LogSink.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a LogSink message. + * @function verify + * @memberof google.logging.v2.LogSink + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + LogSink.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + var properties = {} + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + if ( + message.destination != null && + message.hasOwnProperty('destination') + ) + if (!$util.isString(message.destination)) + return 'destination: string expected' + if ( + message.filter != null && + message.hasOwnProperty('filter') + ) + if (!$util.isString(message.filter)) + return 'filter: string expected' + if ( + message.description != null && + message.hasOwnProperty('description') + ) + if (!$util.isString(message.description)) + return 'description: string expected' + if ( + message.disabled != null && + message.hasOwnProperty('disabled') + ) + if (typeof message.disabled !== 'boolean') + return 'disabled: boolean expected' + if ( + message.outputVersionFormat != null && + message.hasOwnProperty('outputVersionFormat') + ) + switch (message.outputVersionFormat) { + default: + return 'outputVersionFormat: enum value expected' + case 0: + case 1: + case 2: + break + } + if ( + message.writerIdentity != null && + message.hasOwnProperty('writerIdentity') + ) + if (!$util.isString(message.writerIdentity)) + return 'writerIdentity: string expected' + if ( + message.includeChildren != null && + message.hasOwnProperty('includeChildren') + ) + if (typeof message.includeChildren !== 'boolean') + return 'includeChildren: boolean expected' + if ( + message.bigqueryOptions != null && + message.hasOwnProperty('bigqueryOptions') + ) { + properties.options = 1 + { + var error = $root.google.logging.v2.BigQueryOptions.verify( + message.bigqueryOptions + ) + if (error) return 'bigqueryOptions.' + error + } + } + if ( + message.createTime != null && + message.hasOwnProperty('createTime') + ) { + var error = $root.google.protobuf.Timestamp.verify( + message.createTime + ) + if (error) return 'createTime.' + error + } + if ( + message.updateTime != null && + message.hasOwnProperty('updateTime') + ) { + var error = $root.google.protobuf.Timestamp.verify( + message.updateTime + ) + if (error) return 'updateTime.' + error + } + return null + } + + /** + * Creates a LogSink message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.LogSink + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.LogSink} LogSink + */ + LogSink.fromObject = function fromObject(object) { + if (object instanceof $root.google.logging.v2.LogSink) + return object + var message = new $root.google.logging.v2.LogSink() + if (object.name != null) message.name = String(object.name) + if (object.destination != null) + message.destination = String(object.destination) + if (object.filter != null) + message.filter = String(object.filter) + if (object.description != null) + message.description = String(object.description) + if (object.disabled != null) + message.disabled = Boolean(object.disabled) + switch (object.outputVersionFormat) { + case 'VERSION_FORMAT_UNSPECIFIED': + case 0: + message.outputVersionFormat = 0 + break + case 'V2': + case 1: + message.outputVersionFormat = 1 + break + case 'V1': + case 2: + message.outputVersionFormat = 2 + break + } + if (object.writerIdentity != null) + message.writerIdentity = String(object.writerIdentity) + if (object.includeChildren != null) + message.includeChildren = Boolean(object.includeChildren) + if (object.bigqueryOptions != null) { + if (typeof object.bigqueryOptions !== 'object') + throw TypeError( + '.google.logging.v2.LogSink.bigqueryOptions: object expected' + ) + message.bigqueryOptions = $root.google.logging.v2.BigQueryOptions.fromObject( + object.bigqueryOptions + ) + } + if (object.createTime != null) { + if (typeof object.createTime !== 'object') + throw TypeError( + '.google.logging.v2.LogSink.createTime: object expected' + ) + message.createTime = $root.google.protobuf.Timestamp.fromObject( + object.createTime + ) + } + if (object.updateTime != null) { + if (typeof object.updateTime !== 'object') + throw TypeError( + '.google.logging.v2.LogSink.updateTime: object expected' + ) + message.updateTime = $root.google.protobuf.Timestamp.fromObject( + object.updateTime + ) + } + return message + } + + /** + * Creates a plain object from a LogSink message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.LogSink + * @static + * @param {google.logging.v2.LogSink} message LogSink + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + LogSink.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.name = '' + object.destination = '' + object.filter = '' + object.outputVersionFormat = + options.enums === String + ? 'VERSION_FORMAT_UNSPECIFIED' + : 0 + object.writerIdentity = '' + object.includeChildren = false + object.createTime = null + object.updateTime = null + object.description = '' + object.disabled = false + } + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + if ( + message.destination != null && + message.hasOwnProperty('destination') + ) + object.destination = message.destination + if ( + message.filter != null && + message.hasOwnProperty('filter') + ) + object.filter = message.filter + if ( + message.outputVersionFormat != null && + message.hasOwnProperty('outputVersionFormat') + ) + object.outputVersionFormat = + options.enums === String + ? $root.google.logging.v2.LogSink.VersionFormat[ + message.outputVersionFormat + ] + : message.outputVersionFormat + if ( + message.writerIdentity != null && + message.hasOwnProperty('writerIdentity') + ) + object.writerIdentity = message.writerIdentity + if ( + message.includeChildren != null && + message.hasOwnProperty('includeChildren') + ) + object.includeChildren = message.includeChildren + if ( + message.bigqueryOptions != null && + message.hasOwnProperty('bigqueryOptions') + ) { + object.bigqueryOptions = $root.google.logging.v2.BigQueryOptions.toObject( + message.bigqueryOptions, + options + ) + if (options.oneofs) object.options = 'bigqueryOptions' + } + if ( + message.createTime != null && + message.hasOwnProperty('createTime') + ) + object.createTime = $root.google.protobuf.Timestamp.toObject( + message.createTime, + options + ) + if ( + message.updateTime != null && + message.hasOwnProperty('updateTime') + ) + object.updateTime = $root.google.protobuf.Timestamp.toObject( + message.updateTime, + options + ) + if ( + message.description != null && + message.hasOwnProperty('description') + ) + object.description = message.description + if ( + message.disabled != null && + message.hasOwnProperty('disabled') + ) + object.disabled = message.disabled + return object + } + + /** + * Converts this LogSink to JSON. + * @function toJSON + * @memberof google.logging.v2.LogSink + * @instance + * @returns {Object.} JSON object + */ + LogSink.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + /** + * VersionFormat enum. + * @name google.logging.v2.LogSink.VersionFormat + * @enum {number} + * @property {number} VERSION_FORMAT_UNSPECIFIED=0 VERSION_FORMAT_UNSPECIFIED value + * @property {number} V2=1 V2 value + * @property {number} V1=2 V1 value + */ + LogSink.VersionFormat = (function () { + var valuesById = {}, + values = Object.create(valuesById) + values[(valuesById[0] = 'VERSION_FORMAT_UNSPECIFIED')] = 0 + values[(valuesById[1] = 'V2')] = 1 + values[(valuesById[2] = 'V1')] = 2 + return values + })() + + return LogSink + })() + + v2.BigQueryOptions = (function () { + /** + * Properties of a BigQueryOptions. + * @memberof google.logging.v2 + * @interface IBigQueryOptions + * @property {boolean|null} [usePartitionedTables] BigQueryOptions usePartitionedTables + * @property {boolean|null} [usesTimestampColumnPartitioning] BigQueryOptions usesTimestampColumnPartitioning + */ + + /** + * Constructs a new BigQueryOptions. + * @memberof google.logging.v2 + * @classdesc Represents a BigQueryOptions. + * @implements IBigQueryOptions + * @constructor + * @param {google.logging.v2.IBigQueryOptions=} [properties] Properties to set + */ + function BigQueryOptions(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * BigQueryOptions usePartitionedTables. + * @member {boolean} usePartitionedTables + * @memberof google.logging.v2.BigQueryOptions + * @instance + */ + BigQueryOptions.prototype.usePartitionedTables = false + + /** + * BigQueryOptions usesTimestampColumnPartitioning. + * @member {boolean} usesTimestampColumnPartitioning + * @memberof google.logging.v2.BigQueryOptions + * @instance + */ + BigQueryOptions.prototype.usesTimestampColumnPartitioning = false + + /** + * Creates a new BigQueryOptions instance using the specified properties. + * @function create + * @memberof google.logging.v2.BigQueryOptions + * @static + * @param {google.logging.v2.IBigQueryOptions=} [properties] Properties to set + * @returns {google.logging.v2.BigQueryOptions} BigQueryOptions instance + */ + BigQueryOptions.create = function create(properties) { + return new BigQueryOptions(properties) + } + + /** + * Encodes the specified BigQueryOptions message. Does not implicitly {@link google.logging.v2.BigQueryOptions.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.BigQueryOptions + * @static + * @param {google.logging.v2.IBigQueryOptions} message BigQueryOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BigQueryOptions.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.usePartitionedTables != null && + Object.hasOwnProperty.call(message, 'usePartitionedTables') + ) + writer + .uint32(/* id 1, wireType 0 =*/ 8) + .bool(message.usePartitionedTables) + if ( + message.usesTimestampColumnPartitioning != null && + Object.hasOwnProperty.call( + message, + 'usesTimestampColumnPartitioning' + ) + ) + writer + .uint32(/* id 3, wireType 0 =*/ 24) + .bool(message.usesTimestampColumnPartitioning) + return writer + } + + /** + * Encodes the specified BigQueryOptions message, length delimited. Does not implicitly {@link google.logging.v2.BigQueryOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.BigQueryOptions + * @static + * @param {google.logging.v2.IBigQueryOptions} message BigQueryOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BigQueryOptions.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a BigQueryOptions message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.BigQueryOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.BigQueryOptions} BigQueryOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BigQueryOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.BigQueryOptions() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.usePartitionedTables = reader.bool() + break + case 3: + message.usesTimestampColumnPartitioning = reader.bool() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a BigQueryOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.BigQueryOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.BigQueryOptions} BigQueryOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BigQueryOptions.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a BigQueryOptions message. + * @function verify + * @memberof google.logging.v2.BigQueryOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BigQueryOptions.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.usePartitionedTables != null && + message.hasOwnProperty('usePartitionedTables') + ) + if (typeof message.usePartitionedTables !== 'boolean') + return 'usePartitionedTables: boolean expected' + if ( + message.usesTimestampColumnPartitioning != null && + message.hasOwnProperty('usesTimestampColumnPartitioning') + ) + if ( + typeof message.usesTimestampColumnPartitioning !== + 'boolean' + ) + return 'usesTimestampColumnPartitioning: boolean expected' + return null + } + + /** + * Creates a BigQueryOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.BigQueryOptions + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.BigQueryOptions} BigQueryOptions + */ + BigQueryOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.logging.v2.BigQueryOptions) + return object + var message = new $root.google.logging.v2.BigQueryOptions() + if (object.usePartitionedTables != null) + message.usePartitionedTables = Boolean( + object.usePartitionedTables + ) + if (object.usesTimestampColumnPartitioning != null) + message.usesTimestampColumnPartitioning = Boolean( + object.usesTimestampColumnPartitioning + ) + return message + } + + /** + * Creates a plain object from a BigQueryOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.BigQueryOptions + * @static + * @param {google.logging.v2.BigQueryOptions} message BigQueryOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BigQueryOptions.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.usePartitionedTables = false + object.usesTimestampColumnPartitioning = false + } + if ( + message.usePartitionedTables != null && + message.hasOwnProperty('usePartitionedTables') + ) + object.usePartitionedTables = message.usePartitionedTables + if ( + message.usesTimestampColumnPartitioning != null && + message.hasOwnProperty('usesTimestampColumnPartitioning') + ) + object.usesTimestampColumnPartitioning = + message.usesTimestampColumnPartitioning + return object + } + + /** + * Converts this BigQueryOptions to JSON. + * @function toJSON + * @memberof google.logging.v2.BigQueryOptions + * @instance + * @returns {Object.} JSON object + */ + BigQueryOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return BigQueryOptions + })() + + /** + * LifecycleState enum. + * @name google.logging.v2.LifecycleState + * @enum {number} + * @property {number} LIFECYCLE_STATE_UNSPECIFIED=0 LIFECYCLE_STATE_UNSPECIFIED value + * @property {number} ACTIVE=1 ACTIVE value + * @property {number} DELETE_REQUESTED=2 DELETE_REQUESTED value + */ + v2.LifecycleState = (function () { + var valuesById = {}, + values = Object.create(valuesById) + values[(valuesById[0] = 'LIFECYCLE_STATE_UNSPECIFIED')] = 0 + values[(valuesById[1] = 'ACTIVE')] = 1 + values[(valuesById[2] = 'DELETE_REQUESTED')] = 2 + return values + })() + + v2.ListBucketsRequest = (function () { + /** + * Properties of a ListBucketsRequest. + * @memberof google.logging.v2 + * @interface IListBucketsRequest + * @property {string|null} [parent] ListBucketsRequest parent + * @property {string|null} [pageToken] ListBucketsRequest pageToken + * @property {number|null} [pageSize] ListBucketsRequest pageSize + */ + + /** + * Constructs a new ListBucketsRequest. + * @memberof google.logging.v2 + * @classdesc Represents a ListBucketsRequest. + * @implements IListBucketsRequest + * @constructor + * @param {google.logging.v2.IListBucketsRequest=} [properties] Properties to set + */ + function ListBucketsRequest(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * ListBucketsRequest parent. + * @member {string} parent + * @memberof google.logging.v2.ListBucketsRequest + * @instance + */ + ListBucketsRequest.prototype.parent = '' + + /** + * ListBucketsRequest pageToken. + * @member {string} pageToken + * @memberof google.logging.v2.ListBucketsRequest + * @instance + */ + ListBucketsRequest.prototype.pageToken = '' + + /** + * ListBucketsRequest pageSize. + * @member {number} pageSize + * @memberof google.logging.v2.ListBucketsRequest + * @instance + */ + ListBucketsRequest.prototype.pageSize = 0 + + /** + * Creates a new ListBucketsRequest instance using the specified properties. + * @function create + * @memberof google.logging.v2.ListBucketsRequest + * @static + * @param {google.logging.v2.IListBucketsRequest=} [properties] Properties to set + * @returns {google.logging.v2.ListBucketsRequest} ListBucketsRequest instance + */ + ListBucketsRequest.create = function create(properties) { + return new ListBucketsRequest(properties) + } + + /** + * Encodes the specified ListBucketsRequest message. Does not implicitly {@link google.logging.v2.ListBucketsRequest.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.ListBucketsRequest + * @static + * @param {google.logging.v2.IListBucketsRequest} message ListBucketsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListBucketsRequest.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.parent != null && + Object.hasOwnProperty.call(message, 'parent') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.parent) + if ( + message.pageToken != null && + Object.hasOwnProperty.call(message, 'pageToken') + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.pageToken) + if ( + message.pageSize != null && + Object.hasOwnProperty.call(message, 'pageSize') + ) + writer + .uint32(/* id 3, wireType 0 =*/ 24) + .int32(message.pageSize) + return writer + } + + /** + * Encodes the specified ListBucketsRequest message, length delimited. Does not implicitly {@link google.logging.v2.ListBucketsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.ListBucketsRequest + * @static + * @param {google.logging.v2.IListBucketsRequest} message ListBucketsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListBucketsRequest.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a ListBucketsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.ListBucketsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.ListBucketsRequest} ListBucketsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListBucketsRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.ListBucketsRequest() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.parent = reader.string() + break + case 2: + message.pageToken = reader.string() + break + case 3: + message.pageSize = reader.int32() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a ListBucketsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.ListBucketsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.ListBucketsRequest} ListBucketsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListBucketsRequest.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a ListBucketsRequest message. + * @function verify + * @memberof google.logging.v2.ListBucketsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListBucketsRequest.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.parent != null && + message.hasOwnProperty('parent') + ) + if (!$util.isString(message.parent)) + return 'parent: string expected' + if ( + message.pageToken != null && + message.hasOwnProperty('pageToken') + ) + if (!$util.isString(message.pageToken)) + return 'pageToken: string expected' + if ( + message.pageSize != null && + message.hasOwnProperty('pageSize') + ) + if (!$util.isInteger(message.pageSize)) + return 'pageSize: integer expected' + return null + } + + /** + * Creates a ListBucketsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.ListBucketsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.ListBucketsRequest} ListBucketsRequest + */ + ListBucketsRequest.fromObject = function fromObject(object) { + if ( + object instanceof $root.google.logging.v2.ListBucketsRequest + ) + return object + var message = new $root.google.logging.v2.ListBucketsRequest() + if (object.parent != null) + message.parent = String(object.parent) + if (object.pageToken != null) + message.pageToken = String(object.pageToken) + if (object.pageSize != null) + message.pageSize = object.pageSize | 0 + return message + } + + /** + * Creates a plain object from a ListBucketsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.ListBucketsRequest + * @static + * @param {google.logging.v2.ListBucketsRequest} message ListBucketsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListBucketsRequest.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.parent = '' + object.pageToken = '' + object.pageSize = 0 + } + if ( + message.parent != null && + message.hasOwnProperty('parent') + ) + object.parent = message.parent + if ( + message.pageToken != null && + message.hasOwnProperty('pageToken') + ) + object.pageToken = message.pageToken + if ( + message.pageSize != null && + message.hasOwnProperty('pageSize') + ) + object.pageSize = message.pageSize + return object + } + + /** + * Converts this ListBucketsRequest to JSON. + * @function toJSON + * @memberof google.logging.v2.ListBucketsRequest + * @instance + * @returns {Object.} JSON object + */ + ListBucketsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return ListBucketsRequest + })() + + v2.ListBucketsResponse = (function () { + /** + * Properties of a ListBucketsResponse. + * @memberof google.logging.v2 + * @interface IListBucketsResponse + * @property {Array.|null} [buckets] ListBucketsResponse buckets + * @property {string|null} [nextPageToken] ListBucketsResponse nextPageToken + */ + + /** + * Constructs a new ListBucketsResponse. + * @memberof google.logging.v2 + * @classdesc Represents a ListBucketsResponse. + * @implements IListBucketsResponse + * @constructor + * @param {google.logging.v2.IListBucketsResponse=} [properties] Properties to set + */ + function ListBucketsResponse(properties) { + this.buckets = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * ListBucketsResponse buckets. + * @member {Array.} buckets + * @memberof google.logging.v2.ListBucketsResponse + * @instance + */ + ListBucketsResponse.prototype.buckets = $util.emptyArray + + /** + * ListBucketsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.logging.v2.ListBucketsResponse + * @instance + */ + ListBucketsResponse.prototype.nextPageToken = '' + + /** + * Creates a new ListBucketsResponse instance using the specified properties. + * @function create + * @memberof google.logging.v2.ListBucketsResponse + * @static + * @param {google.logging.v2.IListBucketsResponse=} [properties] Properties to set + * @returns {google.logging.v2.ListBucketsResponse} ListBucketsResponse instance + */ + ListBucketsResponse.create = function create(properties) { + return new ListBucketsResponse(properties) + } + + /** + * Encodes the specified ListBucketsResponse message. Does not implicitly {@link google.logging.v2.ListBucketsResponse.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.ListBucketsResponse + * @static + * @param {google.logging.v2.IListBucketsResponse} message ListBucketsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListBucketsResponse.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.buckets != null && message.buckets.length) + for (var i = 0; i < message.buckets.length; ++i) + $root.google.logging.v2.LogBucket.encode( + message.buckets[i], + writer.uint32(/* id 1, wireType 2 =*/ 10).fork() + ).ldelim() + if ( + message.nextPageToken != null && + Object.hasOwnProperty.call(message, 'nextPageToken') + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.nextPageToken) + return writer + } + + /** + * Encodes the specified ListBucketsResponse message, length delimited. Does not implicitly {@link google.logging.v2.ListBucketsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.ListBucketsResponse + * @static + * @param {google.logging.v2.IListBucketsResponse} message ListBucketsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListBucketsResponse.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a ListBucketsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.ListBucketsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.ListBucketsResponse} ListBucketsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListBucketsResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.ListBucketsResponse() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + if (!(message.buckets && message.buckets.length)) + message.buckets = [] + message.buckets.push( + $root.google.logging.v2.LogBucket.decode( + reader, + reader.uint32() + ) + ) + break + case 2: + message.nextPageToken = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a ListBucketsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.ListBucketsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.ListBucketsResponse} ListBucketsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListBucketsResponse.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a ListBucketsResponse message. + * @function verify + * @memberof google.logging.v2.ListBucketsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListBucketsResponse.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.buckets != null && + message.hasOwnProperty('buckets') + ) { + if (!Array.isArray(message.buckets)) + return 'buckets: array expected' + for (var i = 0; i < message.buckets.length; ++i) { + var error = $root.google.logging.v2.LogBucket.verify( + message.buckets[i] + ) + if (error) return 'buckets.' + error + } + } + if ( + message.nextPageToken != null && + message.hasOwnProperty('nextPageToken') + ) + if (!$util.isString(message.nextPageToken)) + return 'nextPageToken: string expected' + return null + } + + /** + * Creates a ListBucketsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.ListBucketsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.ListBucketsResponse} ListBucketsResponse + */ + ListBucketsResponse.fromObject = function fromObject(object) { + if ( + object instanceof + $root.google.logging.v2.ListBucketsResponse + ) + return object + var message = new $root.google.logging.v2.ListBucketsResponse() + if (object.buckets) { + if (!Array.isArray(object.buckets)) + throw TypeError( + '.google.logging.v2.ListBucketsResponse.buckets: array expected' + ) + message.buckets = [] + for (var i = 0; i < object.buckets.length; ++i) { + if (typeof object.buckets[i] !== 'object') + throw TypeError( + '.google.logging.v2.ListBucketsResponse.buckets: object expected' + ) + message.buckets[ + i + ] = $root.google.logging.v2.LogBucket.fromObject( + object.buckets[i] + ) + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken) + return message + } + + /** + * Creates a plain object from a ListBucketsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.ListBucketsResponse + * @static + * @param {google.logging.v2.ListBucketsResponse} message ListBucketsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListBucketsResponse.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) object.buckets = [] + if (options.defaults) object.nextPageToken = '' + if (message.buckets && message.buckets.length) { + object.buckets = [] + for (var j = 0; j < message.buckets.length; ++j) + object.buckets[ + j + ] = $root.google.logging.v2.LogBucket.toObject( + message.buckets[j], + options + ) + } + if ( + message.nextPageToken != null && + message.hasOwnProperty('nextPageToken') + ) + object.nextPageToken = message.nextPageToken + return object + } + + /** + * Converts this ListBucketsResponse to JSON. + * @function toJSON + * @memberof google.logging.v2.ListBucketsResponse + * @instance + * @returns {Object.} JSON object + */ + ListBucketsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return ListBucketsResponse + })() + + v2.UpdateBucketRequest = (function () { + /** + * Properties of an UpdateBucketRequest. + * @memberof google.logging.v2 + * @interface IUpdateBucketRequest + * @property {string|null} [name] UpdateBucketRequest name + * @property {google.logging.v2.ILogBucket|null} [bucket] UpdateBucketRequest bucket + * @property {google.protobuf.IFieldMask|null} [updateMask] UpdateBucketRequest updateMask + */ + + /** + * Constructs a new UpdateBucketRequest. + * @memberof google.logging.v2 + * @classdesc Represents an UpdateBucketRequest. + * @implements IUpdateBucketRequest + * @constructor + * @param {google.logging.v2.IUpdateBucketRequest=} [properties] Properties to set + */ + function UpdateBucketRequest(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * UpdateBucketRequest name. + * @member {string} name + * @memberof google.logging.v2.UpdateBucketRequest + * @instance + */ + UpdateBucketRequest.prototype.name = '' + + /** + * UpdateBucketRequest bucket. + * @member {google.logging.v2.ILogBucket|null|undefined} bucket + * @memberof google.logging.v2.UpdateBucketRequest + * @instance + */ + UpdateBucketRequest.prototype.bucket = null + + /** + * UpdateBucketRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.logging.v2.UpdateBucketRequest + * @instance + */ + UpdateBucketRequest.prototype.updateMask = null + + /** + * Creates a new UpdateBucketRequest instance using the specified properties. + * @function create + * @memberof google.logging.v2.UpdateBucketRequest + * @static + * @param {google.logging.v2.IUpdateBucketRequest=} [properties] Properties to set + * @returns {google.logging.v2.UpdateBucketRequest} UpdateBucketRequest instance + */ + UpdateBucketRequest.create = function create(properties) { + return new UpdateBucketRequest(properties) + } + + /** + * Encodes the specified UpdateBucketRequest message. Does not implicitly {@link google.logging.v2.UpdateBucketRequest.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.UpdateBucketRequest + * @static + * @param {google.logging.v2.IUpdateBucketRequest} message UpdateBucketRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateBucketRequest.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.name != null && + Object.hasOwnProperty.call(message, 'name') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.name) + if ( + message.bucket != null && + Object.hasOwnProperty.call(message, 'bucket') + ) + $root.google.logging.v2.LogBucket.encode( + message.bucket, + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + ).ldelim() + if ( + message.updateMask != null && + Object.hasOwnProperty.call(message, 'updateMask') + ) + $root.google.protobuf.FieldMask.encode( + message.updateMask, + writer.uint32(/* id 4, wireType 2 =*/ 34).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified UpdateBucketRequest message, length delimited. Does not implicitly {@link google.logging.v2.UpdateBucketRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.UpdateBucketRequest + * @static + * @param {google.logging.v2.IUpdateBucketRequest} message UpdateBucketRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateBucketRequest.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an UpdateBucketRequest message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.UpdateBucketRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.UpdateBucketRequest} UpdateBucketRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateBucketRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.UpdateBucketRequest() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + case 2: + message.bucket = $root.google.logging.v2.LogBucket.decode( + reader, + reader.uint32() + ) + break + case 4: + message.updateMask = $root.google.protobuf.FieldMask.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an UpdateBucketRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.UpdateBucketRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.UpdateBucketRequest} UpdateBucketRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateBucketRequest.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an UpdateBucketRequest message. + * @function verify + * @memberof google.logging.v2.UpdateBucketRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UpdateBucketRequest.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + if ( + message.bucket != null && + message.hasOwnProperty('bucket') + ) { + var error = $root.google.logging.v2.LogBucket.verify( + message.bucket + ) + if (error) return 'bucket.' + error + } + if ( + message.updateMask != null && + message.hasOwnProperty('updateMask') + ) { + var error = $root.google.protobuf.FieldMask.verify( + message.updateMask + ) + if (error) return 'updateMask.' + error + } + return null + } + + /** + * Creates an UpdateBucketRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.UpdateBucketRequest + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.UpdateBucketRequest} UpdateBucketRequest + */ + UpdateBucketRequest.fromObject = function fromObject(object) { + if ( + object instanceof + $root.google.logging.v2.UpdateBucketRequest + ) + return object + var message = new $root.google.logging.v2.UpdateBucketRequest() + if (object.name != null) message.name = String(object.name) + if (object.bucket != null) { + if (typeof object.bucket !== 'object') + throw TypeError( + '.google.logging.v2.UpdateBucketRequest.bucket: object expected' + ) + message.bucket = $root.google.logging.v2.LogBucket.fromObject( + object.bucket + ) + } + if (object.updateMask != null) { + if (typeof object.updateMask !== 'object') + throw TypeError( + '.google.logging.v2.UpdateBucketRequest.updateMask: object expected' + ) + message.updateMask = $root.google.protobuf.FieldMask.fromObject( + object.updateMask + ) + } + return message + } + + /** + * Creates a plain object from an UpdateBucketRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.UpdateBucketRequest + * @static + * @param {google.logging.v2.UpdateBucketRequest} message UpdateBucketRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UpdateBucketRequest.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.name = '' + object.bucket = null + object.updateMask = null + } + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + if ( + message.bucket != null && + message.hasOwnProperty('bucket') + ) + object.bucket = $root.google.logging.v2.LogBucket.toObject( + message.bucket, + options + ) + if ( + message.updateMask != null && + message.hasOwnProperty('updateMask') + ) + object.updateMask = $root.google.protobuf.FieldMask.toObject( + message.updateMask, + options + ) + return object + } + + /** + * Converts this UpdateBucketRequest to JSON. + * @function toJSON + * @memberof google.logging.v2.UpdateBucketRequest + * @instance + * @returns {Object.} JSON object + */ + UpdateBucketRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return UpdateBucketRequest + })() + + v2.GetBucketRequest = (function () { + /** + * Properties of a GetBucketRequest. + * @memberof google.logging.v2 + * @interface IGetBucketRequest + * @property {string|null} [name] GetBucketRequest name + */ + + /** + * Constructs a new GetBucketRequest. + * @memberof google.logging.v2 + * @classdesc Represents a GetBucketRequest. + * @implements IGetBucketRequest + * @constructor + * @param {google.logging.v2.IGetBucketRequest=} [properties] Properties to set + */ + function GetBucketRequest(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * GetBucketRequest name. + * @member {string} name + * @memberof google.logging.v2.GetBucketRequest + * @instance + */ + GetBucketRequest.prototype.name = '' + + /** + * Creates a new GetBucketRequest instance using the specified properties. + * @function create + * @memberof google.logging.v2.GetBucketRequest + * @static + * @param {google.logging.v2.IGetBucketRequest=} [properties] Properties to set + * @returns {google.logging.v2.GetBucketRequest} GetBucketRequest instance + */ + GetBucketRequest.create = function create(properties) { + return new GetBucketRequest(properties) + } + + /** + * Encodes the specified GetBucketRequest message. Does not implicitly {@link google.logging.v2.GetBucketRequest.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.GetBucketRequest + * @static + * @param {google.logging.v2.IGetBucketRequest} message GetBucketRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetBucketRequest.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.name != null && + Object.hasOwnProperty.call(message, 'name') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.name) + return writer + } + + /** + * Encodes the specified GetBucketRequest message, length delimited. Does not implicitly {@link google.logging.v2.GetBucketRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.GetBucketRequest + * @static + * @param {google.logging.v2.IGetBucketRequest} message GetBucketRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetBucketRequest.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a GetBucketRequest message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.GetBucketRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.GetBucketRequest} GetBucketRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetBucketRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.GetBucketRequest() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a GetBucketRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.GetBucketRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.GetBucketRequest} GetBucketRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetBucketRequest.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a GetBucketRequest message. + * @function verify + * @memberof google.logging.v2.GetBucketRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetBucketRequest.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + return null + } + + /** + * Creates a GetBucketRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.GetBucketRequest + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.GetBucketRequest} GetBucketRequest + */ + GetBucketRequest.fromObject = function fromObject(object) { + if ( + object instanceof $root.google.logging.v2.GetBucketRequest + ) + return object + var message = new $root.google.logging.v2.GetBucketRequest() + if (object.name != null) message.name = String(object.name) + return message + } + + /** + * Creates a plain object from a GetBucketRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.GetBucketRequest + * @static + * @param {google.logging.v2.GetBucketRequest} message GetBucketRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetBucketRequest.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) object.name = '' + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + return object + } + + /** + * Converts this GetBucketRequest to JSON. + * @function toJSON + * @memberof google.logging.v2.GetBucketRequest + * @instance + * @returns {Object.} JSON object + */ + GetBucketRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return GetBucketRequest + })() + + v2.ListSinksRequest = (function () { + /** + * Properties of a ListSinksRequest. + * @memberof google.logging.v2 + * @interface IListSinksRequest + * @property {string|null} [parent] ListSinksRequest parent + * @property {string|null} [pageToken] ListSinksRequest pageToken + * @property {number|null} [pageSize] ListSinksRequest pageSize + */ + + /** + * Constructs a new ListSinksRequest. + * @memberof google.logging.v2 + * @classdesc Represents a ListSinksRequest. + * @implements IListSinksRequest + * @constructor + * @param {google.logging.v2.IListSinksRequest=} [properties] Properties to set + */ + function ListSinksRequest(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * ListSinksRequest parent. + * @member {string} parent + * @memberof google.logging.v2.ListSinksRequest + * @instance + */ + ListSinksRequest.prototype.parent = '' + + /** + * ListSinksRequest pageToken. + * @member {string} pageToken + * @memberof google.logging.v2.ListSinksRequest + * @instance + */ + ListSinksRequest.prototype.pageToken = '' + + /** + * ListSinksRequest pageSize. + * @member {number} pageSize + * @memberof google.logging.v2.ListSinksRequest + * @instance + */ + ListSinksRequest.prototype.pageSize = 0 + + /** + * Creates a new ListSinksRequest instance using the specified properties. + * @function create + * @memberof google.logging.v2.ListSinksRequest + * @static + * @param {google.logging.v2.IListSinksRequest=} [properties] Properties to set + * @returns {google.logging.v2.ListSinksRequest} ListSinksRequest instance + */ + ListSinksRequest.create = function create(properties) { + return new ListSinksRequest(properties) + } + + /** + * Encodes the specified ListSinksRequest message. Does not implicitly {@link google.logging.v2.ListSinksRequest.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.ListSinksRequest + * @static + * @param {google.logging.v2.IListSinksRequest} message ListSinksRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListSinksRequest.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.parent != null && + Object.hasOwnProperty.call(message, 'parent') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.parent) + if ( + message.pageToken != null && + Object.hasOwnProperty.call(message, 'pageToken') + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.pageToken) + if ( + message.pageSize != null && + Object.hasOwnProperty.call(message, 'pageSize') + ) + writer + .uint32(/* id 3, wireType 0 =*/ 24) + .int32(message.pageSize) + return writer + } + + /** + * Encodes the specified ListSinksRequest message, length delimited. Does not implicitly {@link google.logging.v2.ListSinksRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.ListSinksRequest + * @static + * @param {google.logging.v2.IListSinksRequest} message ListSinksRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListSinksRequest.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a ListSinksRequest message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.ListSinksRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.ListSinksRequest} ListSinksRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListSinksRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.ListSinksRequest() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.parent = reader.string() + break + case 2: + message.pageToken = reader.string() + break + case 3: + message.pageSize = reader.int32() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a ListSinksRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.ListSinksRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.ListSinksRequest} ListSinksRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListSinksRequest.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a ListSinksRequest message. + * @function verify + * @memberof google.logging.v2.ListSinksRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListSinksRequest.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.parent != null && + message.hasOwnProperty('parent') + ) + if (!$util.isString(message.parent)) + return 'parent: string expected' + if ( + message.pageToken != null && + message.hasOwnProperty('pageToken') + ) + if (!$util.isString(message.pageToken)) + return 'pageToken: string expected' + if ( + message.pageSize != null && + message.hasOwnProperty('pageSize') + ) + if (!$util.isInteger(message.pageSize)) + return 'pageSize: integer expected' + return null + } + + /** + * Creates a ListSinksRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.ListSinksRequest + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.ListSinksRequest} ListSinksRequest + */ + ListSinksRequest.fromObject = function fromObject(object) { + if ( + object instanceof $root.google.logging.v2.ListSinksRequest + ) + return object + var message = new $root.google.logging.v2.ListSinksRequest() + if (object.parent != null) + message.parent = String(object.parent) + if (object.pageToken != null) + message.pageToken = String(object.pageToken) + if (object.pageSize != null) + message.pageSize = object.pageSize | 0 + return message + } + + /** + * Creates a plain object from a ListSinksRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.ListSinksRequest + * @static + * @param {google.logging.v2.ListSinksRequest} message ListSinksRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListSinksRequest.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.parent = '' + object.pageToken = '' + object.pageSize = 0 + } + if ( + message.parent != null && + message.hasOwnProperty('parent') + ) + object.parent = message.parent + if ( + message.pageToken != null && + message.hasOwnProperty('pageToken') + ) + object.pageToken = message.pageToken + if ( + message.pageSize != null && + message.hasOwnProperty('pageSize') + ) + object.pageSize = message.pageSize + return object + } + + /** + * Converts this ListSinksRequest to JSON. + * @function toJSON + * @memberof google.logging.v2.ListSinksRequest + * @instance + * @returns {Object.} JSON object + */ + ListSinksRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return ListSinksRequest + })() + + v2.ListSinksResponse = (function () { + /** + * Properties of a ListSinksResponse. + * @memberof google.logging.v2 + * @interface IListSinksResponse + * @property {Array.|null} [sinks] ListSinksResponse sinks + * @property {string|null} [nextPageToken] ListSinksResponse nextPageToken + */ + + /** + * Constructs a new ListSinksResponse. + * @memberof google.logging.v2 + * @classdesc Represents a ListSinksResponse. + * @implements IListSinksResponse + * @constructor + * @param {google.logging.v2.IListSinksResponse=} [properties] Properties to set + */ + function ListSinksResponse(properties) { + this.sinks = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * ListSinksResponse sinks. + * @member {Array.} sinks + * @memberof google.logging.v2.ListSinksResponse + * @instance + */ + ListSinksResponse.prototype.sinks = $util.emptyArray + + /** + * ListSinksResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.logging.v2.ListSinksResponse + * @instance + */ + ListSinksResponse.prototype.nextPageToken = '' + + /** + * Creates a new ListSinksResponse instance using the specified properties. + * @function create + * @memberof google.logging.v2.ListSinksResponse + * @static + * @param {google.logging.v2.IListSinksResponse=} [properties] Properties to set + * @returns {google.logging.v2.ListSinksResponse} ListSinksResponse instance + */ + ListSinksResponse.create = function create(properties) { + return new ListSinksResponse(properties) + } + + /** + * Encodes the specified ListSinksResponse message. Does not implicitly {@link google.logging.v2.ListSinksResponse.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.ListSinksResponse + * @static + * @param {google.logging.v2.IListSinksResponse} message ListSinksResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListSinksResponse.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.sinks != null && message.sinks.length) + for (var i = 0; i < message.sinks.length; ++i) + $root.google.logging.v2.LogSink.encode( + message.sinks[i], + writer.uint32(/* id 1, wireType 2 =*/ 10).fork() + ).ldelim() + if ( + message.nextPageToken != null && + Object.hasOwnProperty.call(message, 'nextPageToken') + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.nextPageToken) + return writer + } + + /** + * Encodes the specified ListSinksResponse message, length delimited. Does not implicitly {@link google.logging.v2.ListSinksResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.ListSinksResponse + * @static + * @param {google.logging.v2.IListSinksResponse} message ListSinksResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListSinksResponse.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a ListSinksResponse message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.ListSinksResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.ListSinksResponse} ListSinksResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListSinksResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.ListSinksResponse() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + if (!(message.sinks && message.sinks.length)) + message.sinks = [] + message.sinks.push( + $root.google.logging.v2.LogSink.decode( + reader, + reader.uint32() + ) + ) + break + case 2: + message.nextPageToken = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a ListSinksResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.ListSinksResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.ListSinksResponse} ListSinksResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListSinksResponse.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a ListSinksResponse message. + * @function verify + * @memberof google.logging.v2.ListSinksResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListSinksResponse.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.sinks != null && + message.hasOwnProperty('sinks') + ) { + if (!Array.isArray(message.sinks)) + return 'sinks: array expected' + for (var i = 0; i < message.sinks.length; ++i) { + var error = $root.google.logging.v2.LogSink.verify( + message.sinks[i] + ) + if (error) return 'sinks.' + error + } + } + if ( + message.nextPageToken != null && + message.hasOwnProperty('nextPageToken') + ) + if (!$util.isString(message.nextPageToken)) + return 'nextPageToken: string expected' + return null + } + + /** + * Creates a ListSinksResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.ListSinksResponse + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.ListSinksResponse} ListSinksResponse + */ + ListSinksResponse.fromObject = function fromObject(object) { + if ( + object instanceof $root.google.logging.v2.ListSinksResponse + ) + return object + var message = new $root.google.logging.v2.ListSinksResponse() + if (object.sinks) { + if (!Array.isArray(object.sinks)) + throw TypeError( + '.google.logging.v2.ListSinksResponse.sinks: array expected' + ) + message.sinks = [] + for (var i = 0; i < object.sinks.length; ++i) { + if (typeof object.sinks[i] !== 'object') + throw TypeError( + '.google.logging.v2.ListSinksResponse.sinks: object expected' + ) + message.sinks[ + i + ] = $root.google.logging.v2.LogSink.fromObject( + object.sinks[i] + ) + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken) + return message + } + + /** + * Creates a plain object from a ListSinksResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.ListSinksResponse + * @static + * @param {google.logging.v2.ListSinksResponse} message ListSinksResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListSinksResponse.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) object.sinks = [] + if (options.defaults) object.nextPageToken = '' + if (message.sinks && message.sinks.length) { + object.sinks = [] + for (var j = 0; j < message.sinks.length; ++j) + object.sinks[ + j + ] = $root.google.logging.v2.LogSink.toObject( + message.sinks[j], + options + ) + } + if ( + message.nextPageToken != null && + message.hasOwnProperty('nextPageToken') + ) + object.nextPageToken = message.nextPageToken + return object + } + + /** + * Converts this ListSinksResponse to JSON. + * @function toJSON + * @memberof google.logging.v2.ListSinksResponse + * @instance + * @returns {Object.} JSON object + */ + ListSinksResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return ListSinksResponse + })() + + v2.GetSinkRequest = (function () { + /** + * Properties of a GetSinkRequest. + * @memberof google.logging.v2 + * @interface IGetSinkRequest + * @property {string|null} [sinkName] GetSinkRequest sinkName + */ + + /** + * Constructs a new GetSinkRequest. + * @memberof google.logging.v2 + * @classdesc Represents a GetSinkRequest. + * @implements IGetSinkRequest + * @constructor + * @param {google.logging.v2.IGetSinkRequest=} [properties] Properties to set + */ + function GetSinkRequest(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * GetSinkRequest sinkName. + * @member {string} sinkName + * @memberof google.logging.v2.GetSinkRequest + * @instance + */ + GetSinkRequest.prototype.sinkName = '' + + /** + * Creates a new GetSinkRequest instance using the specified properties. + * @function create + * @memberof google.logging.v2.GetSinkRequest + * @static + * @param {google.logging.v2.IGetSinkRequest=} [properties] Properties to set + * @returns {google.logging.v2.GetSinkRequest} GetSinkRequest instance + */ + GetSinkRequest.create = function create(properties) { + return new GetSinkRequest(properties) + } + + /** + * Encodes the specified GetSinkRequest message. Does not implicitly {@link google.logging.v2.GetSinkRequest.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.GetSinkRequest + * @static + * @param {google.logging.v2.IGetSinkRequest} message GetSinkRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetSinkRequest.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.sinkName != null && + Object.hasOwnProperty.call(message, 'sinkName') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.sinkName) + return writer + } + + /** + * Encodes the specified GetSinkRequest message, length delimited. Does not implicitly {@link google.logging.v2.GetSinkRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.GetSinkRequest + * @static + * @param {google.logging.v2.IGetSinkRequest} message GetSinkRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetSinkRequest.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a GetSinkRequest message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.GetSinkRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.GetSinkRequest} GetSinkRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetSinkRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.GetSinkRequest() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.sinkName = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a GetSinkRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.GetSinkRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.GetSinkRequest} GetSinkRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetSinkRequest.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a GetSinkRequest message. + * @function verify + * @memberof google.logging.v2.GetSinkRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetSinkRequest.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.sinkName != null && + message.hasOwnProperty('sinkName') + ) + if (!$util.isString(message.sinkName)) + return 'sinkName: string expected' + return null + } + + /** + * Creates a GetSinkRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.GetSinkRequest + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.GetSinkRequest} GetSinkRequest + */ + GetSinkRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.logging.v2.GetSinkRequest) + return object + var message = new $root.google.logging.v2.GetSinkRequest() + if (object.sinkName != null) + message.sinkName = String(object.sinkName) + return message + } + + /** + * Creates a plain object from a GetSinkRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.GetSinkRequest + * @static + * @param {google.logging.v2.GetSinkRequest} message GetSinkRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetSinkRequest.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.defaults) object.sinkName = '' + if ( + message.sinkName != null && + message.hasOwnProperty('sinkName') + ) + object.sinkName = message.sinkName + return object + } + + /** + * Converts this GetSinkRequest to JSON. + * @function toJSON + * @memberof google.logging.v2.GetSinkRequest + * @instance + * @returns {Object.} JSON object + */ + GetSinkRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return GetSinkRequest + })() + + v2.CreateSinkRequest = (function () { + /** + * Properties of a CreateSinkRequest. + * @memberof google.logging.v2 + * @interface ICreateSinkRequest + * @property {string|null} [parent] CreateSinkRequest parent + * @property {google.logging.v2.ILogSink|null} [sink] CreateSinkRequest sink + * @property {boolean|null} [uniqueWriterIdentity] CreateSinkRequest uniqueWriterIdentity + */ + + /** + * Constructs a new CreateSinkRequest. + * @memberof google.logging.v2 + * @classdesc Represents a CreateSinkRequest. + * @implements ICreateSinkRequest + * @constructor + * @param {google.logging.v2.ICreateSinkRequest=} [properties] Properties to set + */ + function CreateSinkRequest(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * CreateSinkRequest parent. + * @member {string} parent + * @memberof google.logging.v2.CreateSinkRequest + * @instance + */ + CreateSinkRequest.prototype.parent = '' + + /** + * CreateSinkRequest sink. + * @member {google.logging.v2.ILogSink|null|undefined} sink + * @memberof google.logging.v2.CreateSinkRequest + * @instance + */ + CreateSinkRequest.prototype.sink = null + + /** + * CreateSinkRequest uniqueWriterIdentity. + * @member {boolean} uniqueWriterIdentity + * @memberof google.logging.v2.CreateSinkRequest + * @instance + */ + CreateSinkRequest.prototype.uniqueWriterIdentity = false + + /** + * Creates a new CreateSinkRequest instance using the specified properties. + * @function create + * @memberof google.logging.v2.CreateSinkRequest + * @static + * @param {google.logging.v2.ICreateSinkRequest=} [properties] Properties to set + * @returns {google.logging.v2.CreateSinkRequest} CreateSinkRequest instance + */ + CreateSinkRequest.create = function create(properties) { + return new CreateSinkRequest(properties) + } + + /** + * Encodes the specified CreateSinkRequest message. Does not implicitly {@link google.logging.v2.CreateSinkRequest.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.CreateSinkRequest + * @static + * @param {google.logging.v2.ICreateSinkRequest} message CreateSinkRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateSinkRequest.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.parent != null && + Object.hasOwnProperty.call(message, 'parent') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.parent) + if ( + message.sink != null && + Object.hasOwnProperty.call(message, 'sink') + ) + $root.google.logging.v2.LogSink.encode( + message.sink, + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + ).ldelim() + if ( + message.uniqueWriterIdentity != null && + Object.hasOwnProperty.call(message, 'uniqueWriterIdentity') + ) + writer + .uint32(/* id 3, wireType 0 =*/ 24) + .bool(message.uniqueWriterIdentity) + return writer + } + + /** + * Encodes the specified CreateSinkRequest message, length delimited. Does not implicitly {@link google.logging.v2.CreateSinkRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.CreateSinkRequest + * @static + * @param {google.logging.v2.ICreateSinkRequest} message CreateSinkRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateSinkRequest.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a CreateSinkRequest message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.CreateSinkRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.CreateSinkRequest} CreateSinkRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateSinkRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.CreateSinkRequest() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.parent = reader.string() + break + case 2: + message.sink = $root.google.logging.v2.LogSink.decode( + reader, + reader.uint32() + ) + break + case 3: + message.uniqueWriterIdentity = reader.bool() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a CreateSinkRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.CreateSinkRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.CreateSinkRequest} CreateSinkRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateSinkRequest.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a CreateSinkRequest message. + * @function verify + * @memberof google.logging.v2.CreateSinkRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CreateSinkRequest.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.parent != null && + message.hasOwnProperty('parent') + ) + if (!$util.isString(message.parent)) + return 'parent: string expected' + if (message.sink != null && message.hasOwnProperty('sink')) { + var error = $root.google.logging.v2.LogSink.verify( + message.sink + ) + if (error) return 'sink.' + error + } + if ( + message.uniqueWriterIdentity != null && + message.hasOwnProperty('uniqueWriterIdentity') + ) + if (typeof message.uniqueWriterIdentity !== 'boolean') + return 'uniqueWriterIdentity: boolean expected' + return null + } + + /** + * Creates a CreateSinkRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.CreateSinkRequest + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.CreateSinkRequest} CreateSinkRequest + */ + CreateSinkRequest.fromObject = function fromObject(object) { + if ( + object instanceof $root.google.logging.v2.CreateSinkRequest + ) + return object + var message = new $root.google.logging.v2.CreateSinkRequest() + if (object.parent != null) + message.parent = String(object.parent) + if (object.sink != null) { + if (typeof object.sink !== 'object') + throw TypeError( + '.google.logging.v2.CreateSinkRequest.sink: object expected' + ) + message.sink = $root.google.logging.v2.LogSink.fromObject( + object.sink + ) + } + if (object.uniqueWriterIdentity != null) + message.uniqueWriterIdentity = Boolean( + object.uniqueWriterIdentity + ) + return message + } + + /** + * Creates a plain object from a CreateSinkRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.CreateSinkRequest + * @static + * @param {google.logging.v2.CreateSinkRequest} message CreateSinkRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CreateSinkRequest.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.parent = '' + object.sink = null + object.uniqueWriterIdentity = false + } + if ( + message.parent != null && + message.hasOwnProperty('parent') + ) + object.parent = message.parent + if (message.sink != null && message.hasOwnProperty('sink')) + object.sink = $root.google.logging.v2.LogSink.toObject( + message.sink, + options + ) + if ( + message.uniqueWriterIdentity != null && + message.hasOwnProperty('uniqueWriterIdentity') + ) + object.uniqueWriterIdentity = message.uniqueWriterIdentity + return object + } + + /** + * Converts this CreateSinkRequest to JSON. + * @function toJSON + * @memberof google.logging.v2.CreateSinkRequest + * @instance + * @returns {Object.} JSON object + */ + CreateSinkRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return CreateSinkRequest + })() + + v2.UpdateSinkRequest = (function () { + /** + * Properties of an UpdateSinkRequest. + * @memberof google.logging.v2 + * @interface IUpdateSinkRequest + * @property {string|null} [sinkName] UpdateSinkRequest sinkName + * @property {google.logging.v2.ILogSink|null} [sink] UpdateSinkRequest sink + * @property {boolean|null} [uniqueWriterIdentity] UpdateSinkRequest uniqueWriterIdentity + * @property {google.protobuf.IFieldMask|null} [updateMask] UpdateSinkRequest updateMask + */ + + /** + * Constructs a new UpdateSinkRequest. + * @memberof google.logging.v2 + * @classdesc Represents an UpdateSinkRequest. + * @implements IUpdateSinkRequest + * @constructor + * @param {google.logging.v2.IUpdateSinkRequest=} [properties] Properties to set + */ + function UpdateSinkRequest(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * UpdateSinkRequest sinkName. + * @member {string} sinkName + * @memberof google.logging.v2.UpdateSinkRequest + * @instance + */ + UpdateSinkRequest.prototype.sinkName = '' + + /** + * UpdateSinkRequest sink. + * @member {google.logging.v2.ILogSink|null|undefined} sink + * @memberof google.logging.v2.UpdateSinkRequest + * @instance + */ + UpdateSinkRequest.prototype.sink = null + + /** + * UpdateSinkRequest uniqueWriterIdentity. + * @member {boolean} uniqueWriterIdentity + * @memberof google.logging.v2.UpdateSinkRequest + * @instance + */ + UpdateSinkRequest.prototype.uniqueWriterIdentity = false + + /** + * UpdateSinkRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.logging.v2.UpdateSinkRequest + * @instance + */ + UpdateSinkRequest.prototype.updateMask = null + + /** + * Creates a new UpdateSinkRequest instance using the specified properties. + * @function create + * @memberof google.logging.v2.UpdateSinkRequest + * @static + * @param {google.logging.v2.IUpdateSinkRequest=} [properties] Properties to set + * @returns {google.logging.v2.UpdateSinkRequest} UpdateSinkRequest instance + */ + UpdateSinkRequest.create = function create(properties) { + return new UpdateSinkRequest(properties) + } + + /** + * Encodes the specified UpdateSinkRequest message. Does not implicitly {@link google.logging.v2.UpdateSinkRequest.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.UpdateSinkRequest + * @static + * @param {google.logging.v2.IUpdateSinkRequest} message UpdateSinkRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateSinkRequest.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.sinkName != null && + Object.hasOwnProperty.call(message, 'sinkName') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.sinkName) + if ( + message.sink != null && + Object.hasOwnProperty.call(message, 'sink') + ) + $root.google.logging.v2.LogSink.encode( + message.sink, + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + ).ldelim() + if ( + message.uniqueWriterIdentity != null && + Object.hasOwnProperty.call(message, 'uniqueWriterIdentity') + ) + writer + .uint32(/* id 3, wireType 0 =*/ 24) + .bool(message.uniqueWriterIdentity) + if ( + message.updateMask != null && + Object.hasOwnProperty.call(message, 'updateMask') + ) + $root.google.protobuf.FieldMask.encode( + message.updateMask, + writer.uint32(/* id 4, wireType 2 =*/ 34).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified UpdateSinkRequest message, length delimited. Does not implicitly {@link google.logging.v2.UpdateSinkRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.UpdateSinkRequest + * @static + * @param {google.logging.v2.IUpdateSinkRequest} message UpdateSinkRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateSinkRequest.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an UpdateSinkRequest message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.UpdateSinkRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.UpdateSinkRequest} UpdateSinkRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateSinkRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.UpdateSinkRequest() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.sinkName = reader.string() + break + case 2: + message.sink = $root.google.logging.v2.LogSink.decode( + reader, + reader.uint32() + ) + break + case 3: + message.uniqueWriterIdentity = reader.bool() + break + case 4: + message.updateMask = $root.google.protobuf.FieldMask.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an UpdateSinkRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.UpdateSinkRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.UpdateSinkRequest} UpdateSinkRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateSinkRequest.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an UpdateSinkRequest message. + * @function verify + * @memberof google.logging.v2.UpdateSinkRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UpdateSinkRequest.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.sinkName != null && + message.hasOwnProperty('sinkName') + ) + if (!$util.isString(message.sinkName)) + return 'sinkName: string expected' + if (message.sink != null && message.hasOwnProperty('sink')) { + var error = $root.google.logging.v2.LogSink.verify( + message.sink + ) + if (error) return 'sink.' + error + } + if ( + message.uniqueWriterIdentity != null && + message.hasOwnProperty('uniqueWriterIdentity') + ) + if (typeof message.uniqueWriterIdentity !== 'boolean') + return 'uniqueWriterIdentity: boolean expected' + if ( + message.updateMask != null && + message.hasOwnProperty('updateMask') + ) { + var error = $root.google.protobuf.FieldMask.verify( + message.updateMask + ) + if (error) return 'updateMask.' + error + } + return null + } + + /** + * Creates an UpdateSinkRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.UpdateSinkRequest + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.UpdateSinkRequest} UpdateSinkRequest + */ + UpdateSinkRequest.fromObject = function fromObject(object) { + if ( + object instanceof $root.google.logging.v2.UpdateSinkRequest + ) + return object + var message = new $root.google.logging.v2.UpdateSinkRequest() + if (object.sinkName != null) + message.sinkName = String(object.sinkName) + if (object.sink != null) { + if (typeof object.sink !== 'object') + throw TypeError( + '.google.logging.v2.UpdateSinkRequest.sink: object expected' + ) + message.sink = $root.google.logging.v2.LogSink.fromObject( + object.sink + ) + } + if (object.uniqueWriterIdentity != null) + message.uniqueWriterIdentity = Boolean( + object.uniqueWriterIdentity + ) + if (object.updateMask != null) { + if (typeof object.updateMask !== 'object') + throw TypeError( + '.google.logging.v2.UpdateSinkRequest.updateMask: object expected' + ) + message.updateMask = $root.google.protobuf.FieldMask.fromObject( + object.updateMask + ) + } + return message + } + + /** + * Creates a plain object from an UpdateSinkRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.UpdateSinkRequest + * @static + * @param {google.logging.v2.UpdateSinkRequest} message UpdateSinkRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UpdateSinkRequest.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.sinkName = '' + object.sink = null + object.uniqueWriterIdentity = false + object.updateMask = null + } + if ( + message.sinkName != null && + message.hasOwnProperty('sinkName') + ) + object.sinkName = message.sinkName + if (message.sink != null && message.hasOwnProperty('sink')) + object.sink = $root.google.logging.v2.LogSink.toObject( + message.sink, + options + ) + if ( + message.uniqueWriterIdentity != null && + message.hasOwnProperty('uniqueWriterIdentity') + ) + object.uniqueWriterIdentity = message.uniqueWriterIdentity + if ( + message.updateMask != null && + message.hasOwnProperty('updateMask') + ) + object.updateMask = $root.google.protobuf.FieldMask.toObject( + message.updateMask, + options + ) + return object + } + + /** + * Converts this UpdateSinkRequest to JSON. + * @function toJSON + * @memberof google.logging.v2.UpdateSinkRequest + * @instance + * @returns {Object.} JSON object + */ + UpdateSinkRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return UpdateSinkRequest + })() + + v2.DeleteSinkRequest = (function () { + /** + * Properties of a DeleteSinkRequest. + * @memberof google.logging.v2 + * @interface IDeleteSinkRequest + * @property {string|null} [sinkName] DeleteSinkRequest sinkName + */ + + /** + * Constructs a new DeleteSinkRequest. + * @memberof google.logging.v2 + * @classdesc Represents a DeleteSinkRequest. + * @implements IDeleteSinkRequest + * @constructor + * @param {google.logging.v2.IDeleteSinkRequest=} [properties] Properties to set + */ + function DeleteSinkRequest(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * DeleteSinkRequest sinkName. + * @member {string} sinkName + * @memberof google.logging.v2.DeleteSinkRequest + * @instance + */ + DeleteSinkRequest.prototype.sinkName = '' + + /** + * Creates a new DeleteSinkRequest instance using the specified properties. + * @function create + * @memberof google.logging.v2.DeleteSinkRequest + * @static + * @param {google.logging.v2.IDeleteSinkRequest=} [properties] Properties to set + * @returns {google.logging.v2.DeleteSinkRequest} DeleteSinkRequest instance + */ + DeleteSinkRequest.create = function create(properties) { + return new DeleteSinkRequest(properties) + } + + /** + * Encodes the specified DeleteSinkRequest message. Does not implicitly {@link google.logging.v2.DeleteSinkRequest.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.DeleteSinkRequest + * @static + * @param {google.logging.v2.IDeleteSinkRequest} message DeleteSinkRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteSinkRequest.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.sinkName != null && + Object.hasOwnProperty.call(message, 'sinkName') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.sinkName) + return writer + } + + /** + * Encodes the specified DeleteSinkRequest message, length delimited. Does not implicitly {@link google.logging.v2.DeleteSinkRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.DeleteSinkRequest + * @static + * @param {google.logging.v2.IDeleteSinkRequest} message DeleteSinkRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteSinkRequest.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a DeleteSinkRequest message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.DeleteSinkRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.DeleteSinkRequest} DeleteSinkRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteSinkRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.DeleteSinkRequest() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.sinkName = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a DeleteSinkRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.DeleteSinkRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.DeleteSinkRequest} DeleteSinkRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteSinkRequest.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a DeleteSinkRequest message. + * @function verify + * @memberof google.logging.v2.DeleteSinkRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DeleteSinkRequest.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.sinkName != null && + message.hasOwnProperty('sinkName') + ) + if (!$util.isString(message.sinkName)) + return 'sinkName: string expected' + return null + } + + /** + * Creates a DeleteSinkRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.DeleteSinkRequest + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.DeleteSinkRequest} DeleteSinkRequest + */ + DeleteSinkRequest.fromObject = function fromObject(object) { + if ( + object instanceof $root.google.logging.v2.DeleteSinkRequest + ) + return object + var message = new $root.google.logging.v2.DeleteSinkRequest() + if (object.sinkName != null) + message.sinkName = String(object.sinkName) + return message + } + + /** + * Creates a plain object from a DeleteSinkRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.DeleteSinkRequest + * @static + * @param {google.logging.v2.DeleteSinkRequest} message DeleteSinkRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeleteSinkRequest.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) object.sinkName = '' + if ( + message.sinkName != null && + message.hasOwnProperty('sinkName') + ) + object.sinkName = message.sinkName + return object + } + + /** + * Converts this DeleteSinkRequest to JSON. + * @function toJSON + * @memberof google.logging.v2.DeleteSinkRequest + * @instance + * @returns {Object.} JSON object + */ + DeleteSinkRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return DeleteSinkRequest + })() + + v2.LogExclusion = (function () { + /** + * Properties of a LogExclusion. + * @memberof google.logging.v2 + * @interface ILogExclusion + * @property {string|null} [name] LogExclusion name + * @property {string|null} [description] LogExclusion description + * @property {string|null} [filter] LogExclusion filter + * @property {boolean|null} [disabled] LogExclusion disabled + * @property {google.protobuf.ITimestamp|null} [createTime] LogExclusion createTime + * @property {google.protobuf.ITimestamp|null} [updateTime] LogExclusion updateTime + */ + + /** + * Constructs a new LogExclusion. + * @memberof google.logging.v2 + * @classdesc Represents a LogExclusion. + * @implements ILogExclusion + * @constructor + * @param {google.logging.v2.ILogExclusion=} [properties] Properties to set + */ + function LogExclusion(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * LogExclusion name. + * @member {string} name + * @memberof google.logging.v2.LogExclusion + * @instance + */ + LogExclusion.prototype.name = '' + + /** + * LogExclusion description. + * @member {string} description + * @memberof google.logging.v2.LogExclusion + * @instance + */ + LogExclusion.prototype.description = '' + + /** + * LogExclusion filter. + * @member {string} filter + * @memberof google.logging.v2.LogExclusion + * @instance + */ + LogExclusion.prototype.filter = '' + + /** + * LogExclusion disabled. + * @member {boolean} disabled + * @memberof google.logging.v2.LogExclusion + * @instance + */ + LogExclusion.prototype.disabled = false + + /** + * LogExclusion createTime. + * @member {google.protobuf.ITimestamp|null|undefined} createTime + * @memberof google.logging.v2.LogExclusion + * @instance + */ + LogExclusion.prototype.createTime = null + + /** + * LogExclusion updateTime. + * @member {google.protobuf.ITimestamp|null|undefined} updateTime + * @memberof google.logging.v2.LogExclusion + * @instance + */ + LogExclusion.prototype.updateTime = null + + /** + * Creates a new LogExclusion instance using the specified properties. + * @function create + * @memberof google.logging.v2.LogExclusion + * @static + * @param {google.logging.v2.ILogExclusion=} [properties] Properties to set + * @returns {google.logging.v2.LogExclusion} LogExclusion instance + */ + LogExclusion.create = function create(properties) { + return new LogExclusion(properties) + } + + /** + * Encodes the specified LogExclusion message. Does not implicitly {@link google.logging.v2.LogExclusion.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.LogExclusion + * @static + * @param {google.logging.v2.ILogExclusion} message LogExclusion message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LogExclusion.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.name != null && + Object.hasOwnProperty.call(message, 'name') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.name) + if ( + message.description != null && + Object.hasOwnProperty.call(message, 'description') + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.description) + if ( + message.filter != null && + Object.hasOwnProperty.call(message, 'filter') + ) + writer + .uint32(/* id 3, wireType 2 =*/ 26) + .string(message.filter) + if ( + message.disabled != null && + Object.hasOwnProperty.call(message, 'disabled') + ) + writer + .uint32(/* id 4, wireType 0 =*/ 32) + .bool(message.disabled) + if ( + message.createTime != null && + Object.hasOwnProperty.call(message, 'createTime') + ) + $root.google.protobuf.Timestamp.encode( + message.createTime, + writer.uint32(/* id 5, wireType 2 =*/ 42).fork() + ).ldelim() + if ( + message.updateTime != null && + Object.hasOwnProperty.call(message, 'updateTime') + ) + $root.google.protobuf.Timestamp.encode( + message.updateTime, + writer.uint32(/* id 6, wireType 2 =*/ 50).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified LogExclusion message, length delimited. Does not implicitly {@link google.logging.v2.LogExclusion.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.LogExclusion + * @static + * @param {google.logging.v2.ILogExclusion} message LogExclusion message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LogExclusion.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a LogExclusion message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.LogExclusion + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.LogExclusion} LogExclusion + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LogExclusion.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.LogExclusion() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + case 2: + message.description = reader.string() + break + case 3: + message.filter = reader.string() + break + case 4: + message.disabled = reader.bool() + break + case 5: + message.createTime = $root.google.protobuf.Timestamp.decode( + reader, + reader.uint32() + ) + break + case 6: + message.updateTime = $root.google.protobuf.Timestamp.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a LogExclusion message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.LogExclusion + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.LogExclusion} LogExclusion + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LogExclusion.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a LogExclusion message. + * @function verify + * @memberof google.logging.v2.LogExclusion + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + LogExclusion.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + if ( + message.description != null && + message.hasOwnProperty('description') + ) + if (!$util.isString(message.description)) + return 'description: string expected' + if ( + message.filter != null && + message.hasOwnProperty('filter') + ) + if (!$util.isString(message.filter)) + return 'filter: string expected' + if ( + message.disabled != null && + message.hasOwnProperty('disabled') + ) + if (typeof message.disabled !== 'boolean') + return 'disabled: boolean expected' + if ( + message.createTime != null && + message.hasOwnProperty('createTime') + ) { + var error = $root.google.protobuf.Timestamp.verify( + message.createTime + ) + if (error) return 'createTime.' + error + } + if ( + message.updateTime != null && + message.hasOwnProperty('updateTime') + ) { + var error = $root.google.protobuf.Timestamp.verify( + message.updateTime + ) + if (error) return 'updateTime.' + error + } + return null + } + + /** + * Creates a LogExclusion message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.LogExclusion + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.LogExclusion} LogExclusion + */ + LogExclusion.fromObject = function fromObject(object) { + if (object instanceof $root.google.logging.v2.LogExclusion) + return object + var message = new $root.google.logging.v2.LogExclusion() + if (object.name != null) message.name = String(object.name) + if (object.description != null) + message.description = String(object.description) + if (object.filter != null) + message.filter = String(object.filter) + if (object.disabled != null) + message.disabled = Boolean(object.disabled) + if (object.createTime != null) { + if (typeof object.createTime !== 'object') + throw TypeError( + '.google.logging.v2.LogExclusion.createTime: object expected' + ) + message.createTime = $root.google.protobuf.Timestamp.fromObject( + object.createTime + ) + } + if (object.updateTime != null) { + if (typeof object.updateTime !== 'object') + throw TypeError( + '.google.logging.v2.LogExclusion.updateTime: object expected' + ) + message.updateTime = $root.google.protobuf.Timestamp.fromObject( + object.updateTime + ) + } + return message + } + + /** + * Creates a plain object from a LogExclusion message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.LogExclusion + * @static + * @param {google.logging.v2.LogExclusion} message LogExclusion + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + LogExclusion.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.name = '' + object.description = '' + object.filter = '' + object.disabled = false + object.createTime = null + object.updateTime = null + } + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + if ( + message.description != null && + message.hasOwnProperty('description') + ) + object.description = message.description + if ( + message.filter != null && + message.hasOwnProperty('filter') + ) + object.filter = message.filter + if ( + message.disabled != null && + message.hasOwnProperty('disabled') + ) + object.disabled = message.disabled + if ( + message.createTime != null && + message.hasOwnProperty('createTime') + ) + object.createTime = $root.google.protobuf.Timestamp.toObject( + message.createTime, + options + ) + if ( + message.updateTime != null && + message.hasOwnProperty('updateTime') + ) + object.updateTime = $root.google.protobuf.Timestamp.toObject( + message.updateTime, + options + ) + return object + } + + /** + * Converts this LogExclusion to JSON. + * @function toJSON + * @memberof google.logging.v2.LogExclusion + * @instance + * @returns {Object.} JSON object + */ + LogExclusion.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return LogExclusion + })() + + v2.ListExclusionsRequest = (function () { + /** + * Properties of a ListExclusionsRequest. + * @memberof google.logging.v2 + * @interface IListExclusionsRequest + * @property {string|null} [parent] ListExclusionsRequest parent + * @property {string|null} [pageToken] ListExclusionsRequest pageToken + * @property {number|null} [pageSize] ListExclusionsRequest pageSize + */ + + /** + * Constructs a new ListExclusionsRequest. + * @memberof google.logging.v2 + * @classdesc Represents a ListExclusionsRequest. + * @implements IListExclusionsRequest + * @constructor + * @param {google.logging.v2.IListExclusionsRequest=} [properties] Properties to set + */ + function ListExclusionsRequest(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * ListExclusionsRequest parent. + * @member {string} parent + * @memberof google.logging.v2.ListExclusionsRequest + * @instance + */ + ListExclusionsRequest.prototype.parent = '' + + /** + * ListExclusionsRequest pageToken. + * @member {string} pageToken + * @memberof google.logging.v2.ListExclusionsRequest + * @instance + */ + ListExclusionsRequest.prototype.pageToken = '' + + /** + * ListExclusionsRequest pageSize. + * @member {number} pageSize + * @memberof google.logging.v2.ListExclusionsRequest + * @instance + */ + ListExclusionsRequest.prototype.pageSize = 0 + + /** + * Creates a new ListExclusionsRequest instance using the specified properties. + * @function create + * @memberof google.logging.v2.ListExclusionsRequest + * @static + * @param {google.logging.v2.IListExclusionsRequest=} [properties] Properties to set + * @returns {google.logging.v2.ListExclusionsRequest} ListExclusionsRequest instance + */ + ListExclusionsRequest.create = function create(properties) { + return new ListExclusionsRequest(properties) + } + + /** + * Encodes the specified ListExclusionsRequest message. Does not implicitly {@link google.logging.v2.ListExclusionsRequest.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.ListExclusionsRequest + * @static + * @param {google.logging.v2.IListExclusionsRequest} message ListExclusionsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListExclusionsRequest.encode = function encode( + message, + writer + ) { + if (!writer) writer = $Writer.create() + if ( + message.parent != null && + Object.hasOwnProperty.call(message, 'parent') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.parent) + if ( + message.pageToken != null && + Object.hasOwnProperty.call(message, 'pageToken') + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.pageToken) + if ( + message.pageSize != null && + Object.hasOwnProperty.call(message, 'pageSize') + ) + writer + .uint32(/* id 3, wireType 0 =*/ 24) + .int32(message.pageSize) + return writer + } + + /** + * Encodes the specified ListExclusionsRequest message, length delimited. Does not implicitly {@link google.logging.v2.ListExclusionsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.ListExclusionsRequest + * @static + * @param {google.logging.v2.IListExclusionsRequest} message ListExclusionsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListExclusionsRequest.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a ListExclusionsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.ListExclusionsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.ListExclusionsRequest} ListExclusionsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListExclusionsRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.ListExclusionsRequest() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.parent = reader.string() + break + case 2: + message.pageToken = reader.string() + break + case 3: + message.pageSize = reader.int32() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a ListExclusionsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.ListExclusionsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.ListExclusionsRequest} ListExclusionsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListExclusionsRequest.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a ListExclusionsRequest message. + * @function verify + * @memberof google.logging.v2.ListExclusionsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListExclusionsRequest.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.parent != null && + message.hasOwnProperty('parent') + ) + if (!$util.isString(message.parent)) + return 'parent: string expected' + if ( + message.pageToken != null && + message.hasOwnProperty('pageToken') + ) + if (!$util.isString(message.pageToken)) + return 'pageToken: string expected' + if ( + message.pageSize != null && + message.hasOwnProperty('pageSize') + ) + if (!$util.isInteger(message.pageSize)) + return 'pageSize: integer expected' + return null + } + + /** + * Creates a ListExclusionsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.ListExclusionsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.ListExclusionsRequest} ListExclusionsRequest + */ + ListExclusionsRequest.fromObject = function fromObject(object) { + if ( + object instanceof + $root.google.logging.v2.ListExclusionsRequest + ) + return object + var message = new $root.google.logging.v2.ListExclusionsRequest() + if (object.parent != null) + message.parent = String(object.parent) + if (object.pageToken != null) + message.pageToken = String(object.pageToken) + if (object.pageSize != null) + message.pageSize = object.pageSize | 0 + return message + } + + /** + * Creates a plain object from a ListExclusionsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.ListExclusionsRequest + * @static + * @param {google.logging.v2.ListExclusionsRequest} message ListExclusionsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListExclusionsRequest.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.parent = '' + object.pageToken = '' + object.pageSize = 0 + } + if ( + message.parent != null && + message.hasOwnProperty('parent') + ) + object.parent = message.parent + if ( + message.pageToken != null && + message.hasOwnProperty('pageToken') + ) + object.pageToken = message.pageToken + if ( + message.pageSize != null && + message.hasOwnProperty('pageSize') + ) + object.pageSize = message.pageSize + return object + } + + /** + * Converts this ListExclusionsRequest to JSON. + * @function toJSON + * @memberof google.logging.v2.ListExclusionsRequest + * @instance + * @returns {Object.} JSON object + */ + ListExclusionsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return ListExclusionsRequest + })() + + v2.ListExclusionsResponse = (function () { + /** + * Properties of a ListExclusionsResponse. + * @memberof google.logging.v2 + * @interface IListExclusionsResponse + * @property {Array.|null} [exclusions] ListExclusionsResponse exclusions + * @property {string|null} [nextPageToken] ListExclusionsResponse nextPageToken + */ + + /** + * Constructs a new ListExclusionsResponse. + * @memberof google.logging.v2 + * @classdesc Represents a ListExclusionsResponse. + * @implements IListExclusionsResponse + * @constructor + * @param {google.logging.v2.IListExclusionsResponse=} [properties] Properties to set + */ + function ListExclusionsResponse(properties) { + this.exclusions = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * ListExclusionsResponse exclusions. + * @member {Array.} exclusions + * @memberof google.logging.v2.ListExclusionsResponse + * @instance + */ + ListExclusionsResponse.prototype.exclusions = $util.emptyArray + + /** + * ListExclusionsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.logging.v2.ListExclusionsResponse + * @instance + */ + ListExclusionsResponse.prototype.nextPageToken = '' + + /** + * Creates a new ListExclusionsResponse instance using the specified properties. + * @function create + * @memberof google.logging.v2.ListExclusionsResponse + * @static + * @param {google.logging.v2.IListExclusionsResponse=} [properties] Properties to set + * @returns {google.logging.v2.ListExclusionsResponse} ListExclusionsResponse instance + */ + ListExclusionsResponse.create = function create(properties) { + return new ListExclusionsResponse(properties) + } + + /** + * Encodes the specified ListExclusionsResponse message. Does not implicitly {@link google.logging.v2.ListExclusionsResponse.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.ListExclusionsResponse + * @static + * @param {google.logging.v2.IListExclusionsResponse} message ListExclusionsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListExclusionsResponse.encode = function encode( + message, + writer + ) { + if (!writer) writer = $Writer.create() + if (message.exclusions != null && message.exclusions.length) + for (var i = 0; i < message.exclusions.length; ++i) + $root.google.logging.v2.LogExclusion.encode( + message.exclusions[i], + writer.uint32(/* id 1, wireType 2 =*/ 10).fork() + ).ldelim() + if ( + message.nextPageToken != null && + Object.hasOwnProperty.call(message, 'nextPageToken') + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.nextPageToken) + return writer + } + + /** + * Encodes the specified ListExclusionsResponse message, length delimited. Does not implicitly {@link google.logging.v2.ListExclusionsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.ListExclusionsResponse + * @static + * @param {google.logging.v2.IListExclusionsResponse} message ListExclusionsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListExclusionsResponse.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a ListExclusionsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.ListExclusionsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.ListExclusionsResponse} ListExclusionsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListExclusionsResponse.decode = function decode( + reader, + length + ) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.ListExclusionsResponse() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + if (!(message.exclusions && message.exclusions.length)) + message.exclusions = [] + message.exclusions.push( + $root.google.logging.v2.LogExclusion.decode( + reader, + reader.uint32() + ) + ) + break + case 2: + message.nextPageToken = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a ListExclusionsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.ListExclusionsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.ListExclusionsResponse} ListExclusionsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListExclusionsResponse.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a ListExclusionsResponse message. + * @function verify + * @memberof google.logging.v2.ListExclusionsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListExclusionsResponse.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.exclusions != null && + message.hasOwnProperty('exclusions') + ) { + if (!Array.isArray(message.exclusions)) + return 'exclusions: array expected' + for (var i = 0; i < message.exclusions.length; ++i) { + var error = $root.google.logging.v2.LogExclusion.verify( + message.exclusions[i] + ) + if (error) return 'exclusions.' + error + } + } + if ( + message.nextPageToken != null && + message.hasOwnProperty('nextPageToken') + ) + if (!$util.isString(message.nextPageToken)) + return 'nextPageToken: string expected' + return null + } + + /** + * Creates a ListExclusionsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.ListExclusionsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.ListExclusionsResponse} ListExclusionsResponse + */ + ListExclusionsResponse.fromObject = function fromObject( + object + ) { + if ( + object instanceof + $root.google.logging.v2.ListExclusionsResponse + ) + return object + var message = new $root.google.logging.v2.ListExclusionsResponse() + if (object.exclusions) { + if (!Array.isArray(object.exclusions)) + throw TypeError( + '.google.logging.v2.ListExclusionsResponse.exclusions: array expected' + ) + message.exclusions = [] + for (var i = 0; i < object.exclusions.length; ++i) { + if (typeof object.exclusions[i] !== 'object') + throw TypeError( + '.google.logging.v2.ListExclusionsResponse.exclusions: object expected' + ) + message.exclusions[ + i + ] = $root.google.logging.v2.LogExclusion.fromObject( + object.exclusions[i] + ) + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken) + return message + } + + /** + * Creates a plain object from a ListExclusionsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.ListExclusionsResponse + * @static + * @param {google.logging.v2.ListExclusionsResponse} message ListExclusionsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListExclusionsResponse.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) object.exclusions = [] + if (options.defaults) object.nextPageToken = '' + if (message.exclusions && message.exclusions.length) { + object.exclusions = [] + for (var j = 0; j < message.exclusions.length; ++j) + object.exclusions[ + j + ] = $root.google.logging.v2.LogExclusion.toObject( + message.exclusions[j], + options + ) + } + if ( + message.nextPageToken != null && + message.hasOwnProperty('nextPageToken') + ) + object.nextPageToken = message.nextPageToken + return object + } + + /** + * Converts this ListExclusionsResponse to JSON. + * @function toJSON + * @memberof google.logging.v2.ListExclusionsResponse + * @instance + * @returns {Object.} JSON object + */ + ListExclusionsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return ListExclusionsResponse + })() + + v2.GetExclusionRequest = (function () { + /** + * Properties of a GetExclusionRequest. + * @memberof google.logging.v2 + * @interface IGetExclusionRequest + * @property {string|null} [name] GetExclusionRequest name + */ + + /** + * Constructs a new GetExclusionRequest. + * @memberof google.logging.v2 + * @classdesc Represents a GetExclusionRequest. + * @implements IGetExclusionRequest + * @constructor + * @param {google.logging.v2.IGetExclusionRequest=} [properties] Properties to set + */ + function GetExclusionRequest(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * GetExclusionRequest name. + * @member {string} name + * @memberof google.logging.v2.GetExclusionRequest + * @instance + */ + GetExclusionRequest.prototype.name = '' + + /** + * Creates a new GetExclusionRequest instance using the specified properties. + * @function create + * @memberof google.logging.v2.GetExclusionRequest + * @static + * @param {google.logging.v2.IGetExclusionRequest=} [properties] Properties to set + * @returns {google.logging.v2.GetExclusionRequest} GetExclusionRequest instance + */ + GetExclusionRequest.create = function create(properties) { + return new GetExclusionRequest(properties) + } + + /** + * Encodes the specified GetExclusionRequest message. Does not implicitly {@link google.logging.v2.GetExclusionRequest.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.GetExclusionRequest + * @static + * @param {google.logging.v2.IGetExclusionRequest} message GetExclusionRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetExclusionRequest.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.name != null && + Object.hasOwnProperty.call(message, 'name') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.name) + return writer + } + + /** + * Encodes the specified GetExclusionRequest message, length delimited. Does not implicitly {@link google.logging.v2.GetExclusionRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.GetExclusionRequest + * @static + * @param {google.logging.v2.IGetExclusionRequest} message GetExclusionRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetExclusionRequest.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a GetExclusionRequest message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.GetExclusionRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.GetExclusionRequest} GetExclusionRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetExclusionRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.GetExclusionRequest() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a GetExclusionRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.GetExclusionRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.GetExclusionRequest} GetExclusionRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetExclusionRequest.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a GetExclusionRequest message. + * @function verify + * @memberof google.logging.v2.GetExclusionRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetExclusionRequest.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + return null + } + + /** + * Creates a GetExclusionRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.GetExclusionRequest + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.GetExclusionRequest} GetExclusionRequest + */ + GetExclusionRequest.fromObject = function fromObject(object) { + if ( + object instanceof + $root.google.logging.v2.GetExclusionRequest + ) + return object + var message = new $root.google.logging.v2.GetExclusionRequest() + if (object.name != null) message.name = String(object.name) + return message + } + + /** + * Creates a plain object from a GetExclusionRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.GetExclusionRequest + * @static + * @param {google.logging.v2.GetExclusionRequest} message GetExclusionRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetExclusionRequest.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) object.name = '' + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + return object + } + + /** + * Converts this GetExclusionRequest to JSON. + * @function toJSON + * @memberof google.logging.v2.GetExclusionRequest + * @instance + * @returns {Object.} JSON object + */ + GetExclusionRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return GetExclusionRequest + })() + + v2.CreateExclusionRequest = (function () { + /** + * Properties of a CreateExclusionRequest. + * @memberof google.logging.v2 + * @interface ICreateExclusionRequest + * @property {string|null} [parent] CreateExclusionRequest parent + * @property {google.logging.v2.ILogExclusion|null} [exclusion] CreateExclusionRequest exclusion + */ + + /** + * Constructs a new CreateExclusionRequest. + * @memberof google.logging.v2 + * @classdesc Represents a CreateExclusionRequest. + * @implements ICreateExclusionRequest + * @constructor + * @param {google.logging.v2.ICreateExclusionRequest=} [properties] Properties to set + */ + function CreateExclusionRequest(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * CreateExclusionRequest parent. + * @member {string} parent + * @memberof google.logging.v2.CreateExclusionRequest + * @instance + */ + CreateExclusionRequest.prototype.parent = '' + + /** + * CreateExclusionRequest exclusion. + * @member {google.logging.v2.ILogExclusion|null|undefined} exclusion + * @memberof google.logging.v2.CreateExclusionRequest + * @instance + */ + CreateExclusionRequest.prototype.exclusion = null + + /** + * Creates a new CreateExclusionRequest instance using the specified properties. + * @function create + * @memberof google.logging.v2.CreateExclusionRequest + * @static + * @param {google.logging.v2.ICreateExclusionRequest=} [properties] Properties to set + * @returns {google.logging.v2.CreateExclusionRequest} CreateExclusionRequest instance + */ + CreateExclusionRequest.create = function create(properties) { + return new CreateExclusionRequest(properties) + } + + /** + * Encodes the specified CreateExclusionRequest message. Does not implicitly {@link google.logging.v2.CreateExclusionRequest.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.CreateExclusionRequest + * @static + * @param {google.logging.v2.ICreateExclusionRequest} message CreateExclusionRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateExclusionRequest.encode = function encode( + message, + writer + ) { + if (!writer) writer = $Writer.create() + if ( + message.parent != null && + Object.hasOwnProperty.call(message, 'parent') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.parent) + if ( + message.exclusion != null && + Object.hasOwnProperty.call(message, 'exclusion') + ) + $root.google.logging.v2.LogExclusion.encode( + message.exclusion, + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified CreateExclusionRequest message, length delimited. Does not implicitly {@link google.logging.v2.CreateExclusionRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.CreateExclusionRequest + * @static + * @param {google.logging.v2.ICreateExclusionRequest} message CreateExclusionRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateExclusionRequest.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a CreateExclusionRequest message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.CreateExclusionRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.CreateExclusionRequest} CreateExclusionRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateExclusionRequest.decode = function decode( + reader, + length + ) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.CreateExclusionRequest() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.parent = reader.string() + break + case 2: + message.exclusion = $root.google.logging.v2.LogExclusion.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a CreateExclusionRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.CreateExclusionRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.CreateExclusionRequest} CreateExclusionRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateExclusionRequest.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a CreateExclusionRequest message. + * @function verify + * @memberof google.logging.v2.CreateExclusionRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CreateExclusionRequest.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.parent != null && + message.hasOwnProperty('parent') + ) + if (!$util.isString(message.parent)) + return 'parent: string expected' + if ( + message.exclusion != null && + message.hasOwnProperty('exclusion') + ) { + var error = $root.google.logging.v2.LogExclusion.verify( + message.exclusion + ) + if (error) return 'exclusion.' + error + } + return null + } + + /** + * Creates a CreateExclusionRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.CreateExclusionRequest + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.CreateExclusionRequest} CreateExclusionRequest + */ + CreateExclusionRequest.fromObject = function fromObject( + object + ) { + if ( + object instanceof + $root.google.logging.v2.CreateExclusionRequest + ) + return object + var message = new $root.google.logging.v2.CreateExclusionRequest() + if (object.parent != null) + message.parent = String(object.parent) + if (object.exclusion != null) { + if (typeof object.exclusion !== 'object') + throw TypeError( + '.google.logging.v2.CreateExclusionRequest.exclusion: object expected' + ) + message.exclusion = $root.google.logging.v2.LogExclusion.fromObject( + object.exclusion + ) + } + return message + } + + /** + * Creates a plain object from a CreateExclusionRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.CreateExclusionRequest + * @static + * @param {google.logging.v2.CreateExclusionRequest} message CreateExclusionRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CreateExclusionRequest.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.parent = '' + object.exclusion = null + } + if ( + message.parent != null && + message.hasOwnProperty('parent') + ) + object.parent = message.parent + if ( + message.exclusion != null && + message.hasOwnProperty('exclusion') + ) + object.exclusion = $root.google.logging.v2.LogExclusion.toObject( + message.exclusion, + options + ) + return object + } + + /** + * Converts this CreateExclusionRequest to JSON. + * @function toJSON + * @memberof google.logging.v2.CreateExclusionRequest + * @instance + * @returns {Object.} JSON object + */ + CreateExclusionRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return CreateExclusionRequest + })() + + v2.UpdateExclusionRequest = (function () { + /** + * Properties of an UpdateExclusionRequest. + * @memberof google.logging.v2 + * @interface IUpdateExclusionRequest + * @property {string|null} [name] UpdateExclusionRequest name + * @property {google.logging.v2.ILogExclusion|null} [exclusion] UpdateExclusionRequest exclusion + * @property {google.protobuf.IFieldMask|null} [updateMask] UpdateExclusionRequest updateMask + */ + + /** + * Constructs a new UpdateExclusionRequest. + * @memberof google.logging.v2 + * @classdesc Represents an UpdateExclusionRequest. + * @implements IUpdateExclusionRequest + * @constructor + * @param {google.logging.v2.IUpdateExclusionRequest=} [properties] Properties to set + */ + function UpdateExclusionRequest(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * UpdateExclusionRequest name. + * @member {string} name + * @memberof google.logging.v2.UpdateExclusionRequest + * @instance + */ + UpdateExclusionRequest.prototype.name = '' + + /** + * UpdateExclusionRequest exclusion. + * @member {google.logging.v2.ILogExclusion|null|undefined} exclusion + * @memberof google.logging.v2.UpdateExclusionRequest + * @instance + */ + UpdateExclusionRequest.prototype.exclusion = null + + /** + * UpdateExclusionRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.logging.v2.UpdateExclusionRequest + * @instance + */ + UpdateExclusionRequest.prototype.updateMask = null + + /** + * Creates a new UpdateExclusionRequest instance using the specified properties. + * @function create + * @memberof google.logging.v2.UpdateExclusionRequest + * @static + * @param {google.logging.v2.IUpdateExclusionRequest=} [properties] Properties to set + * @returns {google.logging.v2.UpdateExclusionRequest} UpdateExclusionRequest instance + */ + UpdateExclusionRequest.create = function create(properties) { + return new UpdateExclusionRequest(properties) + } + + /** + * Encodes the specified UpdateExclusionRequest message. Does not implicitly {@link google.logging.v2.UpdateExclusionRequest.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.UpdateExclusionRequest + * @static + * @param {google.logging.v2.IUpdateExclusionRequest} message UpdateExclusionRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateExclusionRequest.encode = function encode( + message, + writer + ) { + if (!writer) writer = $Writer.create() + if ( + message.name != null && + Object.hasOwnProperty.call(message, 'name') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.name) + if ( + message.exclusion != null && + Object.hasOwnProperty.call(message, 'exclusion') + ) + $root.google.logging.v2.LogExclusion.encode( + message.exclusion, + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + ).ldelim() + if ( + message.updateMask != null && + Object.hasOwnProperty.call(message, 'updateMask') + ) + $root.google.protobuf.FieldMask.encode( + message.updateMask, + writer.uint32(/* id 3, wireType 2 =*/ 26).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified UpdateExclusionRequest message, length delimited. Does not implicitly {@link google.logging.v2.UpdateExclusionRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.UpdateExclusionRequest + * @static + * @param {google.logging.v2.IUpdateExclusionRequest} message UpdateExclusionRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateExclusionRequest.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an UpdateExclusionRequest message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.UpdateExclusionRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.UpdateExclusionRequest} UpdateExclusionRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateExclusionRequest.decode = function decode( + reader, + length + ) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.UpdateExclusionRequest() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + case 2: + message.exclusion = $root.google.logging.v2.LogExclusion.decode( + reader, + reader.uint32() + ) + break + case 3: + message.updateMask = $root.google.protobuf.FieldMask.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an UpdateExclusionRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.UpdateExclusionRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.UpdateExclusionRequest} UpdateExclusionRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateExclusionRequest.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an UpdateExclusionRequest message. + * @function verify + * @memberof google.logging.v2.UpdateExclusionRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UpdateExclusionRequest.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + if ( + message.exclusion != null && + message.hasOwnProperty('exclusion') + ) { + var error = $root.google.logging.v2.LogExclusion.verify( + message.exclusion + ) + if (error) return 'exclusion.' + error + } + if ( + message.updateMask != null && + message.hasOwnProperty('updateMask') + ) { + var error = $root.google.protobuf.FieldMask.verify( + message.updateMask + ) + if (error) return 'updateMask.' + error + } + return null + } + + /** + * Creates an UpdateExclusionRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.UpdateExclusionRequest + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.UpdateExclusionRequest} UpdateExclusionRequest + */ + UpdateExclusionRequest.fromObject = function fromObject( + object + ) { + if ( + object instanceof + $root.google.logging.v2.UpdateExclusionRequest + ) + return object + var message = new $root.google.logging.v2.UpdateExclusionRequest() + if (object.name != null) message.name = String(object.name) + if (object.exclusion != null) { + if (typeof object.exclusion !== 'object') + throw TypeError( + '.google.logging.v2.UpdateExclusionRequest.exclusion: object expected' + ) + message.exclusion = $root.google.logging.v2.LogExclusion.fromObject( + object.exclusion + ) + } + if (object.updateMask != null) { + if (typeof object.updateMask !== 'object') + throw TypeError( + '.google.logging.v2.UpdateExclusionRequest.updateMask: object expected' + ) + message.updateMask = $root.google.protobuf.FieldMask.fromObject( + object.updateMask + ) + } + return message + } + + /** + * Creates a plain object from an UpdateExclusionRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.UpdateExclusionRequest + * @static + * @param {google.logging.v2.UpdateExclusionRequest} message UpdateExclusionRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UpdateExclusionRequest.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.name = '' + object.exclusion = null + object.updateMask = null + } + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + if ( + message.exclusion != null && + message.hasOwnProperty('exclusion') + ) + object.exclusion = $root.google.logging.v2.LogExclusion.toObject( + message.exclusion, + options + ) + if ( + message.updateMask != null && + message.hasOwnProperty('updateMask') + ) + object.updateMask = $root.google.protobuf.FieldMask.toObject( + message.updateMask, + options + ) + return object + } + + /** + * Converts this UpdateExclusionRequest to JSON. + * @function toJSON + * @memberof google.logging.v2.UpdateExclusionRequest + * @instance + * @returns {Object.} JSON object + */ + UpdateExclusionRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return UpdateExclusionRequest + })() + + v2.DeleteExclusionRequest = (function () { + /** + * Properties of a DeleteExclusionRequest. + * @memberof google.logging.v2 + * @interface IDeleteExclusionRequest + * @property {string|null} [name] DeleteExclusionRequest name + */ + + /** + * Constructs a new DeleteExclusionRequest. + * @memberof google.logging.v2 + * @classdesc Represents a DeleteExclusionRequest. + * @implements IDeleteExclusionRequest + * @constructor + * @param {google.logging.v2.IDeleteExclusionRequest=} [properties] Properties to set + */ + function DeleteExclusionRequest(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * DeleteExclusionRequest name. + * @member {string} name + * @memberof google.logging.v2.DeleteExclusionRequest + * @instance + */ + DeleteExclusionRequest.prototype.name = '' + + /** + * Creates a new DeleteExclusionRequest instance using the specified properties. + * @function create + * @memberof google.logging.v2.DeleteExclusionRequest + * @static + * @param {google.logging.v2.IDeleteExclusionRequest=} [properties] Properties to set + * @returns {google.logging.v2.DeleteExclusionRequest} DeleteExclusionRequest instance + */ + DeleteExclusionRequest.create = function create(properties) { + return new DeleteExclusionRequest(properties) + } + + /** + * Encodes the specified DeleteExclusionRequest message. Does not implicitly {@link google.logging.v2.DeleteExclusionRequest.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.DeleteExclusionRequest + * @static + * @param {google.logging.v2.IDeleteExclusionRequest} message DeleteExclusionRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteExclusionRequest.encode = function encode( + message, + writer + ) { + if (!writer) writer = $Writer.create() + if ( + message.name != null && + Object.hasOwnProperty.call(message, 'name') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.name) + return writer + } + + /** + * Encodes the specified DeleteExclusionRequest message, length delimited. Does not implicitly {@link google.logging.v2.DeleteExclusionRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.DeleteExclusionRequest + * @static + * @param {google.logging.v2.IDeleteExclusionRequest} message DeleteExclusionRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteExclusionRequest.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a DeleteExclusionRequest message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.DeleteExclusionRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.DeleteExclusionRequest} DeleteExclusionRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteExclusionRequest.decode = function decode( + reader, + length + ) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.DeleteExclusionRequest() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a DeleteExclusionRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.DeleteExclusionRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.DeleteExclusionRequest} DeleteExclusionRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteExclusionRequest.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a DeleteExclusionRequest message. + * @function verify + * @memberof google.logging.v2.DeleteExclusionRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DeleteExclusionRequest.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + return null + } + + /** + * Creates a DeleteExclusionRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.DeleteExclusionRequest + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.DeleteExclusionRequest} DeleteExclusionRequest + */ + DeleteExclusionRequest.fromObject = function fromObject( + object + ) { + if ( + object instanceof + $root.google.logging.v2.DeleteExclusionRequest + ) + return object + var message = new $root.google.logging.v2.DeleteExclusionRequest() + if (object.name != null) message.name = String(object.name) + return message + } + + /** + * Creates a plain object from a DeleteExclusionRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.DeleteExclusionRequest + * @static + * @param {google.logging.v2.DeleteExclusionRequest} message DeleteExclusionRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeleteExclusionRequest.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) object.name = '' + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + return object + } + + /** + * Converts this DeleteExclusionRequest to JSON. + * @function toJSON + * @memberof google.logging.v2.DeleteExclusionRequest + * @instance + * @returns {Object.} JSON object + */ + DeleteExclusionRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return DeleteExclusionRequest + })() + + v2.GetCmekSettingsRequest = (function () { + /** + * Properties of a GetCmekSettingsRequest. + * @memberof google.logging.v2 + * @interface IGetCmekSettingsRequest + * @property {string|null} [name] GetCmekSettingsRequest name + */ + + /** + * Constructs a new GetCmekSettingsRequest. + * @memberof google.logging.v2 + * @classdesc Represents a GetCmekSettingsRequest. + * @implements IGetCmekSettingsRequest + * @constructor + * @param {google.logging.v2.IGetCmekSettingsRequest=} [properties] Properties to set + */ + function GetCmekSettingsRequest(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * GetCmekSettingsRequest name. + * @member {string} name + * @memberof google.logging.v2.GetCmekSettingsRequest + * @instance + */ + GetCmekSettingsRequest.prototype.name = '' + + /** + * Creates a new GetCmekSettingsRequest instance using the specified properties. + * @function create + * @memberof google.logging.v2.GetCmekSettingsRequest + * @static + * @param {google.logging.v2.IGetCmekSettingsRequest=} [properties] Properties to set + * @returns {google.logging.v2.GetCmekSettingsRequest} GetCmekSettingsRequest instance + */ + GetCmekSettingsRequest.create = function create(properties) { + return new GetCmekSettingsRequest(properties) + } + + /** + * Encodes the specified GetCmekSettingsRequest message. Does not implicitly {@link google.logging.v2.GetCmekSettingsRequest.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.GetCmekSettingsRequest + * @static + * @param {google.logging.v2.IGetCmekSettingsRequest} message GetCmekSettingsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetCmekSettingsRequest.encode = function encode( + message, + writer + ) { + if (!writer) writer = $Writer.create() + if ( + message.name != null && + Object.hasOwnProperty.call(message, 'name') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.name) + return writer + } + + /** + * Encodes the specified GetCmekSettingsRequest message, length delimited. Does not implicitly {@link google.logging.v2.GetCmekSettingsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.GetCmekSettingsRequest + * @static + * @param {google.logging.v2.IGetCmekSettingsRequest} message GetCmekSettingsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetCmekSettingsRequest.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a GetCmekSettingsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.GetCmekSettingsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.GetCmekSettingsRequest} GetCmekSettingsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetCmekSettingsRequest.decode = function decode( + reader, + length + ) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.GetCmekSettingsRequest() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a GetCmekSettingsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.GetCmekSettingsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.GetCmekSettingsRequest} GetCmekSettingsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetCmekSettingsRequest.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a GetCmekSettingsRequest message. + * @function verify + * @memberof google.logging.v2.GetCmekSettingsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetCmekSettingsRequest.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + return null + } + + /** + * Creates a GetCmekSettingsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.GetCmekSettingsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.GetCmekSettingsRequest} GetCmekSettingsRequest + */ + GetCmekSettingsRequest.fromObject = function fromObject( + object + ) { + if ( + object instanceof + $root.google.logging.v2.GetCmekSettingsRequest + ) + return object + var message = new $root.google.logging.v2.GetCmekSettingsRequest() + if (object.name != null) message.name = String(object.name) + return message + } + + /** + * Creates a plain object from a GetCmekSettingsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.GetCmekSettingsRequest + * @static + * @param {google.logging.v2.GetCmekSettingsRequest} message GetCmekSettingsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetCmekSettingsRequest.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) object.name = '' + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + return object + } + + /** + * Converts this GetCmekSettingsRequest to JSON. + * @function toJSON + * @memberof google.logging.v2.GetCmekSettingsRequest + * @instance + * @returns {Object.} JSON object + */ + GetCmekSettingsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return GetCmekSettingsRequest + })() + + v2.UpdateCmekSettingsRequest = (function () { + /** + * Properties of an UpdateCmekSettingsRequest. + * @memberof google.logging.v2 + * @interface IUpdateCmekSettingsRequest + * @property {string|null} [name] UpdateCmekSettingsRequest name + * @property {google.logging.v2.ICmekSettings|null} [cmekSettings] UpdateCmekSettingsRequest cmekSettings + * @property {google.protobuf.IFieldMask|null} [updateMask] UpdateCmekSettingsRequest updateMask + */ + + /** + * Constructs a new UpdateCmekSettingsRequest. + * @memberof google.logging.v2 + * @classdesc Represents an UpdateCmekSettingsRequest. + * @implements IUpdateCmekSettingsRequest + * @constructor + * @param {google.logging.v2.IUpdateCmekSettingsRequest=} [properties] Properties to set + */ + function UpdateCmekSettingsRequest(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * UpdateCmekSettingsRequest name. + * @member {string} name + * @memberof google.logging.v2.UpdateCmekSettingsRequest + * @instance + */ + UpdateCmekSettingsRequest.prototype.name = '' + + /** + * UpdateCmekSettingsRequest cmekSettings. + * @member {google.logging.v2.ICmekSettings|null|undefined} cmekSettings + * @memberof google.logging.v2.UpdateCmekSettingsRequest + * @instance + */ + UpdateCmekSettingsRequest.prototype.cmekSettings = null + + /** + * UpdateCmekSettingsRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.logging.v2.UpdateCmekSettingsRequest + * @instance + */ + UpdateCmekSettingsRequest.prototype.updateMask = null + + /** + * Creates a new UpdateCmekSettingsRequest instance using the specified properties. + * @function create + * @memberof google.logging.v2.UpdateCmekSettingsRequest + * @static + * @param {google.logging.v2.IUpdateCmekSettingsRequest=} [properties] Properties to set + * @returns {google.logging.v2.UpdateCmekSettingsRequest} UpdateCmekSettingsRequest instance + */ + UpdateCmekSettingsRequest.create = function create(properties) { + return new UpdateCmekSettingsRequest(properties) + } + + /** + * Encodes the specified UpdateCmekSettingsRequest message. Does not implicitly {@link google.logging.v2.UpdateCmekSettingsRequest.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.UpdateCmekSettingsRequest + * @static + * @param {google.logging.v2.IUpdateCmekSettingsRequest} message UpdateCmekSettingsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateCmekSettingsRequest.encode = function encode( + message, + writer + ) { + if (!writer) writer = $Writer.create() + if ( + message.name != null && + Object.hasOwnProperty.call(message, 'name') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.name) + if ( + message.cmekSettings != null && + Object.hasOwnProperty.call(message, 'cmekSettings') + ) + $root.google.logging.v2.CmekSettings.encode( + message.cmekSettings, + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + ).ldelim() + if ( + message.updateMask != null && + Object.hasOwnProperty.call(message, 'updateMask') + ) + $root.google.protobuf.FieldMask.encode( + message.updateMask, + writer.uint32(/* id 3, wireType 2 =*/ 26).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified UpdateCmekSettingsRequest message, length delimited. Does not implicitly {@link google.logging.v2.UpdateCmekSettingsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.UpdateCmekSettingsRequest + * @static + * @param {google.logging.v2.IUpdateCmekSettingsRequest} message UpdateCmekSettingsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateCmekSettingsRequest.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an UpdateCmekSettingsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.UpdateCmekSettingsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.UpdateCmekSettingsRequest} UpdateCmekSettingsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateCmekSettingsRequest.decode = function decode( + reader, + length + ) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.UpdateCmekSettingsRequest() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + case 2: + message.cmekSettings = $root.google.logging.v2.CmekSettings.decode( + reader, + reader.uint32() + ) + break + case 3: + message.updateMask = $root.google.protobuf.FieldMask.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an UpdateCmekSettingsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.UpdateCmekSettingsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.UpdateCmekSettingsRequest} UpdateCmekSettingsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateCmekSettingsRequest.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an UpdateCmekSettingsRequest message. + * @function verify + * @memberof google.logging.v2.UpdateCmekSettingsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UpdateCmekSettingsRequest.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + if ( + message.cmekSettings != null && + message.hasOwnProperty('cmekSettings') + ) { + var error = $root.google.logging.v2.CmekSettings.verify( + message.cmekSettings + ) + if (error) return 'cmekSettings.' + error + } + if ( + message.updateMask != null && + message.hasOwnProperty('updateMask') + ) { + var error = $root.google.protobuf.FieldMask.verify( + message.updateMask + ) + if (error) return 'updateMask.' + error + } + return null + } + + /** + * Creates an UpdateCmekSettingsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.UpdateCmekSettingsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.UpdateCmekSettingsRequest} UpdateCmekSettingsRequest + */ + UpdateCmekSettingsRequest.fromObject = function fromObject( + object + ) { + if ( + object instanceof + $root.google.logging.v2.UpdateCmekSettingsRequest + ) + return object + var message = new $root.google.logging.v2.UpdateCmekSettingsRequest() + if (object.name != null) message.name = String(object.name) + if (object.cmekSettings != null) { + if (typeof object.cmekSettings !== 'object') + throw TypeError( + '.google.logging.v2.UpdateCmekSettingsRequest.cmekSettings: object expected' + ) + message.cmekSettings = $root.google.logging.v2.CmekSettings.fromObject( + object.cmekSettings + ) + } + if (object.updateMask != null) { + if (typeof object.updateMask !== 'object') + throw TypeError( + '.google.logging.v2.UpdateCmekSettingsRequest.updateMask: object expected' + ) + message.updateMask = $root.google.protobuf.FieldMask.fromObject( + object.updateMask + ) + } + return message + } + + /** + * Creates a plain object from an UpdateCmekSettingsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.UpdateCmekSettingsRequest + * @static + * @param {google.logging.v2.UpdateCmekSettingsRequest} message UpdateCmekSettingsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UpdateCmekSettingsRequest.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.name = '' + object.cmekSettings = null + object.updateMask = null + } + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + if ( + message.cmekSettings != null && + message.hasOwnProperty('cmekSettings') + ) + object.cmekSettings = $root.google.logging.v2.CmekSettings.toObject( + message.cmekSettings, + options + ) + if ( + message.updateMask != null && + message.hasOwnProperty('updateMask') + ) + object.updateMask = $root.google.protobuf.FieldMask.toObject( + message.updateMask, + options + ) + return object + } + + /** + * Converts this UpdateCmekSettingsRequest to JSON. + * @function toJSON + * @memberof google.logging.v2.UpdateCmekSettingsRequest + * @instance + * @returns {Object.} JSON object + */ + UpdateCmekSettingsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return UpdateCmekSettingsRequest + })() + + v2.CmekSettings = (function () { + /** + * Properties of a CmekSettings. + * @memberof google.logging.v2 + * @interface ICmekSettings + * @property {string|null} [name] CmekSettings name + * @property {string|null} [kmsKeyName] CmekSettings kmsKeyName + * @property {string|null} [serviceAccountId] CmekSettings serviceAccountId + */ + + /** + * Constructs a new CmekSettings. + * @memberof google.logging.v2 + * @classdesc Represents a CmekSettings. + * @implements ICmekSettings + * @constructor + * @param {google.logging.v2.ICmekSettings=} [properties] Properties to set + */ + function CmekSettings(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * CmekSettings name. + * @member {string} name + * @memberof google.logging.v2.CmekSettings + * @instance + */ + CmekSettings.prototype.name = '' + + /** + * CmekSettings kmsKeyName. + * @member {string} kmsKeyName + * @memberof google.logging.v2.CmekSettings + * @instance + */ + CmekSettings.prototype.kmsKeyName = '' + + /** + * CmekSettings serviceAccountId. + * @member {string} serviceAccountId + * @memberof google.logging.v2.CmekSettings + * @instance + */ + CmekSettings.prototype.serviceAccountId = '' + + /** + * Creates a new CmekSettings instance using the specified properties. + * @function create + * @memberof google.logging.v2.CmekSettings + * @static + * @param {google.logging.v2.ICmekSettings=} [properties] Properties to set + * @returns {google.logging.v2.CmekSettings} CmekSettings instance + */ + CmekSettings.create = function create(properties) { + return new CmekSettings(properties) + } + + /** + * Encodes the specified CmekSettings message. Does not implicitly {@link google.logging.v2.CmekSettings.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.CmekSettings + * @static + * @param {google.logging.v2.ICmekSettings} message CmekSettings message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CmekSettings.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.name != null && + Object.hasOwnProperty.call(message, 'name') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.name) + if ( + message.kmsKeyName != null && + Object.hasOwnProperty.call(message, 'kmsKeyName') + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.kmsKeyName) + if ( + message.serviceAccountId != null && + Object.hasOwnProperty.call(message, 'serviceAccountId') + ) + writer + .uint32(/* id 3, wireType 2 =*/ 26) + .string(message.serviceAccountId) + return writer + } + + /** + * Encodes the specified CmekSettings message, length delimited. Does not implicitly {@link google.logging.v2.CmekSettings.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.CmekSettings + * @static + * @param {google.logging.v2.ICmekSettings} message CmekSettings message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CmekSettings.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a CmekSettings message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.CmekSettings + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.CmekSettings} CmekSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CmekSettings.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.CmekSettings() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + case 2: + message.kmsKeyName = reader.string() + break + case 3: + message.serviceAccountId = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a CmekSettings message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.CmekSettings + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.CmekSettings} CmekSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CmekSettings.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a CmekSettings message. + * @function verify + * @memberof google.logging.v2.CmekSettings + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CmekSettings.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + if ( + message.kmsKeyName != null && + message.hasOwnProperty('kmsKeyName') + ) + if (!$util.isString(message.kmsKeyName)) + return 'kmsKeyName: string expected' + if ( + message.serviceAccountId != null && + message.hasOwnProperty('serviceAccountId') + ) + if (!$util.isString(message.serviceAccountId)) + return 'serviceAccountId: string expected' + return null + } + + /** + * Creates a CmekSettings message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.CmekSettings + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.CmekSettings} CmekSettings + */ + CmekSettings.fromObject = function fromObject(object) { + if (object instanceof $root.google.logging.v2.CmekSettings) + return object + var message = new $root.google.logging.v2.CmekSettings() + if (object.name != null) message.name = String(object.name) + if (object.kmsKeyName != null) + message.kmsKeyName = String(object.kmsKeyName) + if (object.serviceAccountId != null) + message.serviceAccountId = String(object.serviceAccountId) + return message + } + + /** + * Creates a plain object from a CmekSettings message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.CmekSettings + * @static + * @param {google.logging.v2.CmekSettings} message CmekSettings + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CmekSettings.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.name = '' + object.kmsKeyName = '' + object.serviceAccountId = '' + } + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + if ( + message.kmsKeyName != null && + message.hasOwnProperty('kmsKeyName') + ) + object.kmsKeyName = message.kmsKeyName + if ( + message.serviceAccountId != null && + message.hasOwnProperty('serviceAccountId') + ) + object.serviceAccountId = message.serviceAccountId + return object + } + + /** + * Converts this CmekSettings to JSON. + * @function toJSON + * @memberof google.logging.v2.CmekSettings + * @instance + * @returns {Object.} JSON object + */ + CmekSettings.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return CmekSettings + })() + + v2.MetricsServiceV2 = (function () { + /** + * Constructs a new MetricsServiceV2 service. + * @memberof google.logging.v2 + * @classdesc Represents a MetricsServiceV2 + * @extends $protobuf.rpc.Service + * @constructor + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + */ + function MetricsServiceV2( + rpcImpl, + requestDelimited, + responseDelimited + ) { + $protobuf.rpc.Service.call( + this, + rpcImpl, + requestDelimited, + responseDelimited + ) + } + + ;(MetricsServiceV2.prototype = Object.create( + $protobuf.rpc.Service.prototype + )).constructor = MetricsServiceV2 + + /** + * Creates new MetricsServiceV2 service using the specified rpc implementation. + * @function create + * @memberof google.logging.v2.MetricsServiceV2 + * @static + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + * @returns {MetricsServiceV2} RPC service. Useful where requests and/or responses are streamed. + */ + MetricsServiceV2.create = function create( + rpcImpl, + requestDelimited, + responseDelimited + ) { + return new this(rpcImpl, requestDelimited, responseDelimited) + } + + /** + * Callback as used by {@link google.logging.v2.MetricsServiceV2#listLogMetrics}. + * @memberof google.logging.v2.MetricsServiceV2 + * @typedef ListLogMetricsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.logging.v2.ListLogMetricsResponse} [response] ListLogMetricsResponse + */ + + /** + * Calls ListLogMetrics. + * @function listLogMetrics + * @memberof google.logging.v2.MetricsServiceV2 + * @instance + * @param {google.logging.v2.IListLogMetricsRequest} request ListLogMetricsRequest message or plain object + * @param {google.logging.v2.MetricsServiceV2.ListLogMetricsCallback} callback Node-style callback called with the error, if any, and ListLogMetricsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty( + (MetricsServiceV2.prototype.listLogMetrics = function listLogMetrics( + request, + callback + ) { + return this.rpcCall( + listLogMetrics, + $root.google.logging.v2.ListLogMetricsRequest, + $root.google.logging.v2.ListLogMetricsResponse, + request, + callback + ) + }), + 'name', + { value: 'ListLogMetrics' } + ) + + /** + * Calls ListLogMetrics. + * @function listLogMetrics + * @memberof google.logging.v2.MetricsServiceV2 + * @instance + * @param {google.logging.v2.IListLogMetricsRequest} request ListLogMetricsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.logging.v2.MetricsServiceV2#getLogMetric}. + * @memberof google.logging.v2.MetricsServiceV2 + * @typedef GetLogMetricCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.logging.v2.LogMetric} [response] LogMetric + */ + + /** + * Calls GetLogMetric. + * @function getLogMetric + * @memberof google.logging.v2.MetricsServiceV2 + * @instance + * @param {google.logging.v2.IGetLogMetricRequest} request GetLogMetricRequest message or plain object + * @param {google.logging.v2.MetricsServiceV2.GetLogMetricCallback} callback Node-style callback called with the error, if any, and LogMetric + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty( + (MetricsServiceV2.prototype.getLogMetric = function getLogMetric( + request, + callback + ) { + return this.rpcCall( + getLogMetric, + $root.google.logging.v2.GetLogMetricRequest, + $root.google.logging.v2.LogMetric, + request, + callback + ) + }), + 'name', + { value: 'GetLogMetric' } + ) + + /** + * Calls GetLogMetric. + * @function getLogMetric + * @memberof google.logging.v2.MetricsServiceV2 + * @instance + * @param {google.logging.v2.IGetLogMetricRequest} request GetLogMetricRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.logging.v2.MetricsServiceV2#createLogMetric}. + * @memberof google.logging.v2.MetricsServiceV2 + * @typedef CreateLogMetricCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.logging.v2.LogMetric} [response] LogMetric + */ + + /** + * Calls CreateLogMetric. + * @function createLogMetric + * @memberof google.logging.v2.MetricsServiceV2 + * @instance + * @param {google.logging.v2.ICreateLogMetricRequest} request CreateLogMetricRequest message or plain object + * @param {google.logging.v2.MetricsServiceV2.CreateLogMetricCallback} callback Node-style callback called with the error, if any, and LogMetric + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty( + (MetricsServiceV2.prototype.createLogMetric = function createLogMetric( + request, + callback + ) { + return this.rpcCall( + createLogMetric, + $root.google.logging.v2.CreateLogMetricRequest, + $root.google.logging.v2.LogMetric, + request, + callback + ) + }), + 'name', + { value: 'CreateLogMetric' } + ) + + /** + * Calls CreateLogMetric. + * @function createLogMetric + * @memberof google.logging.v2.MetricsServiceV2 + * @instance + * @param {google.logging.v2.ICreateLogMetricRequest} request CreateLogMetricRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.logging.v2.MetricsServiceV2#updateLogMetric}. + * @memberof google.logging.v2.MetricsServiceV2 + * @typedef UpdateLogMetricCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.logging.v2.LogMetric} [response] LogMetric + */ + + /** + * Calls UpdateLogMetric. + * @function updateLogMetric + * @memberof google.logging.v2.MetricsServiceV2 + * @instance + * @param {google.logging.v2.IUpdateLogMetricRequest} request UpdateLogMetricRequest message or plain object + * @param {google.logging.v2.MetricsServiceV2.UpdateLogMetricCallback} callback Node-style callback called with the error, if any, and LogMetric + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty( + (MetricsServiceV2.prototype.updateLogMetric = function updateLogMetric( + request, + callback + ) { + return this.rpcCall( + updateLogMetric, + $root.google.logging.v2.UpdateLogMetricRequest, + $root.google.logging.v2.LogMetric, + request, + callback + ) + }), + 'name', + { value: 'UpdateLogMetric' } + ) + + /** + * Calls UpdateLogMetric. + * @function updateLogMetric + * @memberof google.logging.v2.MetricsServiceV2 + * @instance + * @param {google.logging.v2.IUpdateLogMetricRequest} request UpdateLogMetricRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.logging.v2.MetricsServiceV2#deleteLogMetric}. + * @memberof google.logging.v2.MetricsServiceV2 + * @typedef DeleteLogMetricCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls DeleteLogMetric. + * @function deleteLogMetric + * @memberof google.logging.v2.MetricsServiceV2 + * @instance + * @param {google.logging.v2.IDeleteLogMetricRequest} request DeleteLogMetricRequest message or plain object + * @param {google.logging.v2.MetricsServiceV2.DeleteLogMetricCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty( + (MetricsServiceV2.prototype.deleteLogMetric = function deleteLogMetric( + request, + callback + ) { + return this.rpcCall( + deleteLogMetric, + $root.google.logging.v2.DeleteLogMetricRequest, + $root.google.protobuf.Empty, + request, + callback + ) + }), + 'name', + { value: 'DeleteLogMetric' } + ) + + /** + * Calls DeleteLogMetric. + * @function deleteLogMetric + * @memberof google.logging.v2.MetricsServiceV2 + * @instance + * @param {google.logging.v2.IDeleteLogMetricRequest} request DeleteLogMetricRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return MetricsServiceV2 + })() + + v2.LogMetric = (function () { + /** + * Properties of a LogMetric. + * @memberof google.logging.v2 + * @interface ILogMetric + * @property {string|null} [name] LogMetric name + * @property {string|null} [description] LogMetric description + * @property {string|null} [filter] LogMetric filter + * @property {google.api.IMetricDescriptor|null} [metricDescriptor] LogMetric metricDescriptor + * @property {string|null} [valueExtractor] LogMetric valueExtractor + * @property {Object.|null} [labelExtractors] LogMetric labelExtractors + * @property {google.api.Distribution.IBucketOptions|null} [bucketOptions] LogMetric bucketOptions + * @property {google.protobuf.ITimestamp|null} [createTime] LogMetric createTime + * @property {google.protobuf.ITimestamp|null} [updateTime] LogMetric updateTime + * @property {google.logging.v2.LogMetric.ApiVersion|null} [version] LogMetric version + */ + + /** + * Constructs a new LogMetric. + * @memberof google.logging.v2 + * @classdesc Represents a LogMetric. + * @implements ILogMetric + * @constructor + * @param {google.logging.v2.ILogMetric=} [properties] Properties to set + */ + function LogMetric(properties) { + this.labelExtractors = {} + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * LogMetric name. + * @member {string} name + * @memberof google.logging.v2.LogMetric + * @instance + */ + LogMetric.prototype.name = '' + + /** + * LogMetric description. + * @member {string} description + * @memberof google.logging.v2.LogMetric + * @instance + */ + LogMetric.prototype.description = '' + + /** + * LogMetric filter. + * @member {string} filter + * @memberof google.logging.v2.LogMetric + * @instance + */ + LogMetric.prototype.filter = '' + + /** + * LogMetric metricDescriptor. + * @member {google.api.IMetricDescriptor|null|undefined} metricDescriptor + * @memberof google.logging.v2.LogMetric + * @instance + */ + LogMetric.prototype.metricDescriptor = null + + /** + * LogMetric valueExtractor. + * @member {string} valueExtractor + * @memberof google.logging.v2.LogMetric + * @instance + */ + LogMetric.prototype.valueExtractor = '' + + /** + * LogMetric labelExtractors. + * @member {Object.} labelExtractors + * @memberof google.logging.v2.LogMetric + * @instance + */ + LogMetric.prototype.labelExtractors = $util.emptyObject + + /** + * LogMetric bucketOptions. + * @member {google.api.Distribution.IBucketOptions|null|undefined} bucketOptions + * @memberof google.logging.v2.LogMetric + * @instance + */ + LogMetric.prototype.bucketOptions = null + + /** + * LogMetric createTime. + * @member {google.protobuf.ITimestamp|null|undefined} createTime + * @memberof google.logging.v2.LogMetric + * @instance + */ + LogMetric.prototype.createTime = null + + /** + * LogMetric updateTime. + * @member {google.protobuf.ITimestamp|null|undefined} updateTime + * @memberof google.logging.v2.LogMetric + * @instance + */ + LogMetric.prototype.updateTime = null + + /** + * LogMetric version. + * @member {google.logging.v2.LogMetric.ApiVersion} version + * @memberof google.logging.v2.LogMetric + * @instance + */ + LogMetric.prototype.version = 0 + + /** + * Creates a new LogMetric instance using the specified properties. + * @function create + * @memberof google.logging.v2.LogMetric + * @static + * @param {google.logging.v2.ILogMetric=} [properties] Properties to set + * @returns {google.logging.v2.LogMetric} LogMetric instance + */ + LogMetric.create = function create(properties) { + return new LogMetric(properties) + } + + /** + * Encodes the specified LogMetric message. Does not implicitly {@link google.logging.v2.LogMetric.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.LogMetric + * @static + * @param {google.logging.v2.ILogMetric} message LogMetric message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LogMetric.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.name != null && + Object.hasOwnProperty.call(message, 'name') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.name) + if ( + message.description != null && + Object.hasOwnProperty.call(message, 'description') + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.description) + if ( + message.filter != null && + Object.hasOwnProperty.call(message, 'filter') + ) + writer + .uint32(/* id 3, wireType 2 =*/ 26) + .string(message.filter) + if ( + message.version != null && + Object.hasOwnProperty.call(message, 'version') + ) + writer + .uint32(/* id 4, wireType 0 =*/ 32) + .int32(message.version) + if ( + message.metricDescriptor != null && + Object.hasOwnProperty.call(message, 'metricDescriptor') + ) + $root.google.api.MetricDescriptor.encode( + message.metricDescriptor, + writer.uint32(/* id 5, wireType 2 =*/ 42).fork() + ).ldelim() + if ( + message.valueExtractor != null && + Object.hasOwnProperty.call(message, 'valueExtractor') + ) + writer + .uint32(/* id 6, wireType 2 =*/ 50) + .string(message.valueExtractor) + if ( + message.labelExtractors != null && + Object.hasOwnProperty.call(message, 'labelExtractors') + ) + for ( + var keys = Object.keys(message.labelExtractors), i = 0; + i < keys.length; + ++i + ) + writer + .uint32(/* id 7, wireType 2 =*/ 58) + .fork() + .uint32(/* id 1, wireType 2 =*/ 10) + .string(keys[i]) + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.labelExtractors[keys[i]]) + .ldelim() + if ( + message.bucketOptions != null && + Object.hasOwnProperty.call(message, 'bucketOptions') + ) + $root.google.api.Distribution.BucketOptions.encode( + message.bucketOptions, + writer.uint32(/* id 8, wireType 2 =*/ 66).fork() + ).ldelim() + if ( + message.createTime != null && + Object.hasOwnProperty.call(message, 'createTime') + ) + $root.google.protobuf.Timestamp.encode( + message.createTime, + writer.uint32(/* id 9, wireType 2 =*/ 74).fork() + ).ldelim() + if ( + message.updateTime != null && + Object.hasOwnProperty.call(message, 'updateTime') + ) + $root.google.protobuf.Timestamp.encode( + message.updateTime, + writer.uint32(/* id 10, wireType 2 =*/ 82).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified LogMetric message, length delimited. Does not implicitly {@link google.logging.v2.LogMetric.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.LogMetric + * @static + * @param {google.logging.v2.ILogMetric} message LogMetric message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LogMetric.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a LogMetric message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.LogMetric + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.LogMetric} LogMetric + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LogMetric.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.LogMetric(), + key, + value + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + case 2: + message.description = reader.string() + break + case 3: + message.filter = reader.string() + break + case 5: + message.metricDescriptor = $root.google.api.MetricDescriptor.decode( + reader, + reader.uint32() + ) + break + case 6: + message.valueExtractor = reader.string() + break + case 7: + if (message.labelExtractors === $util.emptyObject) + message.labelExtractors = {} + var end2 = reader.uint32() + reader.pos + key = '' + value = '' + while (reader.pos < end2) { + var tag2 = reader.uint32() + switch (tag2 >>> 3) { + case 1: + key = reader.string() + break + case 2: + value = reader.string() + break + default: + reader.skipType(tag2 & 7) + break + } + } + message.labelExtractors[key] = value + break + case 8: + message.bucketOptions = $root.google.api.Distribution.BucketOptions.decode( + reader, + reader.uint32() + ) + break + case 9: + message.createTime = $root.google.protobuf.Timestamp.decode( + reader, + reader.uint32() + ) + break + case 10: + message.updateTime = $root.google.protobuf.Timestamp.decode( + reader, + reader.uint32() + ) + break + case 4: + message.version = reader.int32() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a LogMetric message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.LogMetric + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.LogMetric} LogMetric + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LogMetric.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a LogMetric message. + * @function verify + * @memberof google.logging.v2.LogMetric + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + LogMetric.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + if ( + message.description != null && + message.hasOwnProperty('description') + ) + if (!$util.isString(message.description)) + return 'description: string expected' + if ( + message.filter != null && + message.hasOwnProperty('filter') + ) + if (!$util.isString(message.filter)) + return 'filter: string expected' + if ( + message.metricDescriptor != null && + message.hasOwnProperty('metricDescriptor') + ) { + var error = $root.google.api.MetricDescriptor.verify( + message.metricDescriptor + ) + if (error) return 'metricDescriptor.' + error + } + if ( + message.valueExtractor != null && + message.hasOwnProperty('valueExtractor') + ) + if (!$util.isString(message.valueExtractor)) + return 'valueExtractor: string expected' + if ( + message.labelExtractors != null && + message.hasOwnProperty('labelExtractors') + ) { + if (!$util.isObject(message.labelExtractors)) + return 'labelExtractors: object expected' + var key = Object.keys(message.labelExtractors) + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.labelExtractors[key[i]])) + return 'labelExtractors: string{k:string} expected' + } + if ( + message.bucketOptions != null && + message.hasOwnProperty('bucketOptions') + ) { + var error = $root.google.api.Distribution.BucketOptions.verify( + message.bucketOptions + ) + if (error) return 'bucketOptions.' + error + } + if ( + message.createTime != null && + message.hasOwnProperty('createTime') + ) { + var error = $root.google.protobuf.Timestamp.verify( + message.createTime + ) + if (error) return 'createTime.' + error + } + if ( + message.updateTime != null && + message.hasOwnProperty('updateTime') + ) { + var error = $root.google.protobuf.Timestamp.verify( + message.updateTime + ) + if (error) return 'updateTime.' + error + } + if ( + message.version != null && + message.hasOwnProperty('version') + ) + switch (message.version) { + default: + return 'version: enum value expected' + case 0: + case 1: + break + } + return null + } + + /** + * Creates a LogMetric message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.LogMetric + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.LogMetric} LogMetric + */ + LogMetric.fromObject = function fromObject(object) { + if (object instanceof $root.google.logging.v2.LogMetric) + return object + var message = new $root.google.logging.v2.LogMetric() + if (object.name != null) message.name = String(object.name) + if (object.description != null) + message.description = String(object.description) + if (object.filter != null) + message.filter = String(object.filter) + if (object.metricDescriptor != null) { + if (typeof object.metricDescriptor !== 'object') + throw TypeError( + '.google.logging.v2.LogMetric.metricDescriptor: object expected' + ) + message.metricDescriptor = $root.google.api.MetricDescriptor.fromObject( + object.metricDescriptor + ) + } + if (object.valueExtractor != null) + message.valueExtractor = String(object.valueExtractor) + if (object.labelExtractors) { + if (typeof object.labelExtractors !== 'object') + throw TypeError( + '.google.logging.v2.LogMetric.labelExtractors: object expected' + ) + message.labelExtractors = {} + for ( + var keys = Object.keys(object.labelExtractors), i = 0; + i < keys.length; + ++i + ) + message.labelExtractors[keys[i]] = String( + object.labelExtractors[keys[i]] + ) + } + if (object.bucketOptions != null) { + if (typeof object.bucketOptions !== 'object') + throw TypeError( + '.google.logging.v2.LogMetric.bucketOptions: object expected' + ) + message.bucketOptions = $root.google.api.Distribution.BucketOptions.fromObject( + object.bucketOptions + ) + } + if (object.createTime != null) { + if (typeof object.createTime !== 'object') + throw TypeError( + '.google.logging.v2.LogMetric.createTime: object expected' + ) + message.createTime = $root.google.protobuf.Timestamp.fromObject( + object.createTime + ) + } + if (object.updateTime != null) { + if (typeof object.updateTime !== 'object') + throw TypeError( + '.google.logging.v2.LogMetric.updateTime: object expected' + ) + message.updateTime = $root.google.protobuf.Timestamp.fromObject( + object.updateTime + ) + } + switch (object.version) { + case 'V2': + case 0: + message.version = 0 + break + case 'V1': + case 1: + message.version = 1 + break + } + return message + } + + /** + * Creates a plain object from a LogMetric message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.LogMetric + * @static + * @param {google.logging.v2.LogMetric} message LogMetric + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + LogMetric.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.objects || options.defaults) + object.labelExtractors = {} + if (options.defaults) { + object.name = '' + object.description = '' + object.filter = '' + object.version = options.enums === String ? 'V2' : 0 + object.metricDescriptor = null + object.valueExtractor = '' + object.bucketOptions = null + object.createTime = null + object.updateTime = null + } + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + if ( + message.description != null && + message.hasOwnProperty('description') + ) + object.description = message.description + if ( + message.filter != null && + message.hasOwnProperty('filter') + ) + object.filter = message.filter + if ( + message.version != null && + message.hasOwnProperty('version') + ) + object.version = + options.enums === String + ? $root.google.logging.v2.LogMetric.ApiVersion[ + message.version + ] + : message.version + if ( + message.metricDescriptor != null && + message.hasOwnProperty('metricDescriptor') + ) + object.metricDescriptor = $root.google.api.MetricDescriptor.toObject( + message.metricDescriptor, + options + ) + if ( + message.valueExtractor != null && + message.hasOwnProperty('valueExtractor') + ) + object.valueExtractor = message.valueExtractor + var keys2 + if ( + message.labelExtractors && + (keys2 = Object.keys(message.labelExtractors)).length + ) { + object.labelExtractors = {} + for (var j = 0; j < keys2.length; ++j) + object.labelExtractors[keys2[j]] = + message.labelExtractors[keys2[j]] + } + if ( + message.bucketOptions != null && + message.hasOwnProperty('bucketOptions') + ) + object.bucketOptions = $root.google.api.Distribution.BucketOptions.toObject( + message.bucketOptions, + options + ) + if ( + message.createTime != null && + message.hasOwnProperty('createTime') + ) + object.createTime = $root.google.protobuf.Timestamp.toObject( + message.createTime, + options + ) + if ( + message.updateTime != null && + message.hasOwnProperty('updateTime') + ) + object.updateTime = $root.google.protobuf.Timestamp.toObject( + message.updateTime, + options + ) + return object + } + + /** + * Converts this LogMetric to JSON. + * @function toJSON + * @memberof google.logging.v2.LogMetric + * @instance + * @returns {Object.} JSON object + */ + LogMetric.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + /** + * ApiVersion enum. + * @name google.logging.v2.LogMetric.ApiVersion + * @enum {number} + * @property {number} V2=0 V2 value + * @property {number} V1=1 V1 value + */ + LogMetric.ApiVersion = (function () { + var valuesById = {}, + values = Object.create(valuesById) + values[(valuesById[0] = 'V2')] = 0 + values[(valuesById[1] = 'V1')] = 1 + return values + })() + + return LogMetric + })() + + v2.ListLogMetricsRequest = (function () { + /** + * Properties of a ListLogMetricsRequest. + * @memberof google.logging.v2 + * @interface IListLogMetricsRequest + * @property {string|null} [parent] ListLogMetricsRequest parent + * @property {string|null} [pageToken] ListLogMetricsRequest pageToken + * @property {number|null} [pageSize] ListLogMetricsRequest pageSize + */ + + /** + * Constructs a new ListLogMetricsRequest. + * @memberof google.logging.v2 + * @classdesc Represents a ListLogMetricsRequest. + * @implements IListLogMetricsRequest + * @constructor + * @param {google.logging.v2.IListLogMetricsRequest=} [properties] Properties to set + */ + function ListLogMetricsRequest(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * ListLogMetricsRequest parent. + * @member {string} parent + * @memberof google.logging.v2.ListLogMetricsRequest + * @instance + */ + ListLogMetricsRequest.prototype.parent = '' + + /** + * ListLogMetricsRequest pageToken. + * @member {string} pageToken + * @memberof google.logging.v2.ListLogMetricsRequest + * @instance + */ + ListLogMetricsRequest.prototype.pageToken = '' + + /** + * ListLogMetricsRequest pageSize. + * @member {number} pageSize + * @memberof google.logging.v2.ListLogMetricsRequest + * @instance + */ + ListLogMetricsRequest.prototype.pageSize = 0 + + /** + * Creates a new ListLogMetricsRequest instance using the specified properties. + * @function create + * @memberof google.logging.v2.ListLogMetricsRequest + * @static + * @param {google.logging.v2.IListLogMetricsRequest=} [properties] Properties to set + * @returns {google.logging.v2.ListLogMetricsRequest} ListLogMetricsRequest instance + */ + ListLogMetricsRequest.create = function create(properties) { + return new ListLogMetricsRequest(properties) + } + + /** + * Encodes the specified ListLogMetricsRequest message. Does not implicitly {@link google.logging.v2.ListLogMetricsRequest.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.ListLogMetricsRequest + * @static + * @param {google.logging.v2.IListLogMetricsRequest} message ListLogMetricsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListLogMetricsRequest.encode = function encode( + message, + writer + ) { + if (!writer) writer = $Writer.create() + if ( + message.parent != null && + Object.hasOwnProperty.call(message, 'parent') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.parent) + if ( + message.pageToken != null && + Object.hasOwnProperty.call(message, 'pageToken') + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.pageToken) + if ( + message.pageSize != null && + Object.hasOwnProperty.call(message, 'pageSize') + ) + writer + .uint32(/* id 3, wireType 0 =*/ 24) + .int32(message.pageSize) + return writer + } + + /** + * Encodes the specified ListLogMetricsRequest message, length delimited. Does not implicitly {@link google.logging.v2.ListLogMetricsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.ListLogMetricsRequest + * @static + * @param {google.logging.v2.IListLogMetricsRequest} message ListLogMetricsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListLogMetricsRequest.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a ListLogMetricsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.ListLogMetricsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.ListLogMetricsRequest} ListLogMetricsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListLogMetricsRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.ListLogMetricsRequest() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.parent = reader.string() + break + case 2: + message.pageToken = reader.string() + break + case 3: + message.pageSize = reader.int32() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a ListLogMetricsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.ListLogMetricsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.ListLogMetricsRequest} ListLogMetricsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListLogMetricsRequest.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a ListLogMetricsRequest message. + * @function verify + * @memberof google.logging.v2.ListLogMetricsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListLogMetricsRequest.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.parent != null && + message.hasOwnProperty('parent') + ) + if (!$util.isString(message.parent)) + return 'parent: string expected' + if ( + message.pageToken != null && + message.hasOwnProperty('pageToken') + ) + if (!$util.isString(message.pageToken)) + return 'pageToken: string expected' + if ( + message.pageSize != null && + message.hasOwnProperty('pageSize') + ) + if (!$util.isInteger(message.pageSize)) + return 'pageSize: integer expected' + return null + } + + /** + * Creates a ListLogMetricsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.ListLogMetricsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.ListLogMetricsRequest} ListLogMetricsRequest + */ + ListLogMetricsRequest.fromObject = function fromObject(object) { + if ( + object instanceof + $root.google.logging.v2.ListLogMetricsRequest + ) + return object + var message = new $root.google.logging.v2.ListLogMetricsRequest() + if (object.parent != null) + message.parent = String(object.parent) + if (object.pageToken != null) + message.pageToken = String(object.pageToken) + if (object.pageSize != null) + message.pageSize = object.pageSize | 0 + return message + } + + /** + * Creates a plain object from a ListLogMetricsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.ListLogMetricsRequest + * @static + * @param {google.logging.v2.ListLogMetricsRequest} message ListLogMetricsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListLogMetricsRequest.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.parent = '' + object.pageToken = '' + object.pageSize = 0 + } + if ( + message.parent != null && + message.hasOwnProperty('parent') + ) + object.parent = message.parent + if ( + message.pageToken != null && + message.hasOwnProperty('pageToken') + ) + object.pageToken = message.pageToken + if ( + message.pageSize != null && + message.hasOwnProperty('pageSize') + ) + object.pageSize = message.pageSize + return object + } + + /** + * Converts this ListLogMetricsRequest to JSON. + * @function toJSON + * @memberof google.logging.v2.ListLogMetricsRequest + * @instance + * @returns {Object.} JSON object + */ + ListLogMetricsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return ListLogMetricsRequest + })() + + v2.ListLogMetricsResponse = (function () { + /** + * Properties of a ListLogMetricsResponse. + * @memberof google.logging.v2 + * @interface IListLogMetricsResponse + * @property {Array.|null} [metrics] ListLogMetricsResponse metrics + * @property {string|null} [nextPageToken] ListLogMetricsResponse nextPageToken + */ + + /** + * Constructs a new ListLogMetricsResponse. + * @memberof google.logging.v2 + * @classdesc Represents a ListLogMetricsResponse. + * @implements IListLogMetricsResponse + * @constructor + * @param {google.logging.v2.IListLogMetricsResponse=} [properties] Properties to set + */ + function ListLogMetricsResponse(properties) { + this.metrics = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * ListLogMetricsResponse metrics. + * @member {Array.} metrics + * @memberof google.logging.v2.ListLogMetricsResponse + * @instance + */ + ListLogMetricsResponse.prototype.metrics = $util.emptyArray + + /** + * ListLogMetricsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.logging.v2.ListLogMetricsResponse + * @instance + */ + ListLogMetricsResponse.prototype.nextPageToken = '' + + /** + * Creates a new ListLogMetricsResponse instance using the specified properties. + * @function create + * @memberof google.logging.v2.ListLogMetricsResponse + * @static + * @param {google.logging.v2.IListLogMetricsResponse=} [properties] Properties to set + * @returns {google.logging.v2.ListLogMetricsResponse} ListLogMetricsResponse instance + */ + ListLogMetricsResponse.create = function create(properties) { + return new ListLogMetricsResponse(properties) + } + + /** + * Encodes the specified ListLogMetricsResponse message. Does not implicitly {@link google.logging.v2.ListLogMetricsResponse.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.ListLogMetricsResponse + * @static + * @param {google.logging.v2.IListLogMetricsResponse} message ListLogMetricsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListLogMetricsResponse.encode = function encode( + message, + writer + ) { + if (!writer) writer = $Writer.create() + if (message.metrics != null && message.metrics.length) + for (var i = 0; i < message.metrics.length; ++i) + $root.google.logging.v2.LogMetric.encode( + message.metrics[i], + writer.uint32(/* id 1, wireType 2 =*/ 10).fork() + ).ldelim() + if ( + message.nextPageToken != null && + Object.hasOwnProperty.call(message, 'nextPageToken') + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.nextPageToken) + return writer + } + + /** + * Encodes the specified ListLogMetricsResponse message, length delimited. Does not implicitly {@link google.logging.v2.ListLogMetricsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.ListLogMetricsResponse + * @static + * @param {google.logging.v2.IListLogMetricsResponse} message ListLogMetricsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListLogMetricsResponse.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a ListLogMetricsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.ListLogMetricsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.ListLogMetricsResponse} ListLogMetricsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListLogMetricsResponse.decode = function decode( + reader, + length + ) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.ListLogMetricsResponse() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + if (!(message.metrics && message.metrics.length)) + message.metrics = [] + message.metrics.push( + $root.google.logging.v2.LogMetric.decode( + reader, + reader.uint32() + ) + ) + break + case 2: + message.nextPageToken = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a ListLogMetricsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.ListLogMetricsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.ListLogMetricsResponse} ListLogMetricsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListLogMetricsResponse.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a ListLogMetricsResponse message. + * @function verify + * @memberof google.logging.v2.ListLogMetricsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListLogMetricsResponse.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.metrics != null && + message.hasOwnProperty('metrics') + ) { + if (!Array.isArray(message.metrics)) + return 'metrics: array expected' + for (var i = 0; i < message.metrics.length; ++i) { + var error = $root.google.logging.v2.LogMetric.verify( + message.metrics[i] + ) + if (error) return 'metrics.' + error + } + } + if ( + message.nextPageToken != null && + message.hasOwnProperty('nextPageToken') + ) + if (!$util.isString(message.nextPageToken)) + return 'nextPageToken: string expected' + return null + } + + /** + * Creates a ListLogMetricsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.ListLogMetricsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.ListLogMetricsResponse} ListLogMetricsResponse + */ + ListLogMetricsResponse.fromObject = function fromObject( + object + ) { + if ( + object instanceof + $root.google.logging.v2.ListLogMetricsResponse + ) + return object + var message = new $root.google.logging.v2.ListLogMetricsResponse() + if (object.metrics) { + if (!Array.isArray(object.metrics)) + throw TypeError( + '.google.logging.v2.ListLogMetricsResponse.metrics: array expected' + ) + message.metrics = [] + for (var i = 0; i < object.metrics.length; ++i) { + if (typeof object.metrics[i] !== 'object') + throw TypeError( + '.google.logging.v2.ListLogMetricsResponse.metrics: object expected' + ) + message.metrics[ + i + ] = $root.google.logging.v2.LogMetric.fromObject( + object.metrics[i] + ) + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken) + return message + } + + /** + * Creates a plain object from a ListLogMetricsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.ListLogMetricsResponse + * @static + * @param {google.logging.v2.ListLogMetricsResponse} message ListLogMetricsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListLogMetricsResponse.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) object.metrics = [] + if (options.defaults) object.nextPageToken = '' + if (message.metrics && message.metrics.length) { + object.metrics = [] + for (var j = 0; j < message.metrics.length; ++j) + object.metrics[ + j + ] = $root.google.logging.v2.LogMetric.toObject( + message.metrics[j], + options + ) + } + if ( + message.nextPageToken != null && + message.hasOwnProperty('nextPageToken') + ) + object.nextPageToken = message.nextPageToken + return object + } + + /** + * Converts this ListLogMetricsResponse to JSON. + * @function toJSON + * @memberof google.logging.v2.ListLogMetricsResponse + * @instance + * @returns {Object.} JSON object + */ + ListLogMetricsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return ListLogMetricsResponse + })() + + v2.GetLogMetricRequest = (function () { + /** + * Properties of a GetLogMetricRequest. + * @memberof google.logging.v2 + * @interface IGetLogMetricRequest + * @property {string|null} [metricName] GetLogMetricRequest metricName + */ + + /** + * Constructs a new GetLogMetricRequest. + * @memberof google.logging.v2 + * @classdesc Represents a GetLogMetricRequest. + * @implements IGetLogMetricRequest + * @constructor + * @param {google.logging.v2.IGetLogMetricRequest=} [properties] Properties to set + */ + function GetLogMetricRequest(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * GetLogMetricRequest metricName. + * @member {string} metricName + * @memberof google.logging.v2.GetLogMetricRequest + * @instance + */ + GetLogMetricRequest.prototype.metricName = '' + + /** + * Creates a new GetLogMetricRequest instance using the specified properties. + * @function create + * @memberof google.logging.v2.GetLogMetricRequest + * @static + * @param {google.logging.v2.IGetLogMetricRequest=} [properties] Properties to set + * @returns {google.logging.v2.GetLogMetricRequest} GetLogMetricRequest instance + */ + GetLogMetricRequest.create = function create(properties) { + return new GetLogMetricRequest(properties) + } + + /** + * Encodes the specified GetLogMetricRequest message. Does not implicitly {@link google.logging.v2.GetLogMetricRequest.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.GetLogMetricRequest + * @static + * @param {google.logging.v2.IGetLogMetricRequest} message GetLogMetricRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetLogMetricRequest.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.metricName != null && + Object.hasOwnProperty.call(message, 'metricName') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.metricName) + return writer + } + + /** + * Encodes the specified GetLogMetricRequest message, length delimited. Does not implicitly {@link google.logging.v2.GetLogMetricRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.GetLogMetricRequest + * @static + * @param {google.logging.v2.IGetLogMetricRequest} message GetLogMetricRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetLogMetricRequest.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a GetLogMetricRequest message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.GetLogMetricRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.GetLogMetricRequest} GetLogMetricRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetLogMetricRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.GetLogMetricRequest() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.metricName = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a GetLogMetricRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.GetLogMetricRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.GetLogMetricRequest} GetLogMetricRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetLogMetricRequest.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a GetLogMetricRequest message. + * @function verify + * @memberof google.logging.v2.GetLogMetricRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetLogMetricRequest.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.metricName != null && + message.hasOwnProperty('metricName') + ) + if (!$util.isString(message.metricName)) + return 'metricName: string expected' + return null + } + + /** + * Creates a GetLogMetricRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.GetLogMetricRequest + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.GetLogMetricRequest} GetLogMetricRequest + */ + GetLogMetricRequest.fromObject = function fromObject(object) { + if ( + object instanceof + $root.google.logging.v2.GetLogMetricRequest + ) + return object + var message = new $root.google.logging.v2.GetLogMetricRequest() + if (object.metricName != null) + message.metricName = String(object.metricName) + return message + } + + /** + * Creates a plain object from a GetLogMetricRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.GetLogMetricRequest + * @static + * @param {google.logging.v2.GetLogMetricRequest} message GetLogMetricRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetLogMetricRequest.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) object.metricName = '' + if ( + message.metricName != null && + message.hasOwnProperty('metricName') + ) + object.metricName = message.metricName + return object + } + + /** + * Converts this GetLogMetricRequest to JSON. + * @function toJSON + * @memberof google.logging.v2.GetLogMetricRequest + * @instance + * @returns {Object.} JSON object + */ + GetLogMetricRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return GetLogMetricRequest + })() + + v2.CreateLogMetricRequest = (function () { + /** + * Properties of a CreateLogMetricRequest. + * @memberof google.logging.v2 + * @interface ICreateLogMetricRequest + * @property {string|null} [parent] CreateLogMetricRequest parent + * @property {google.logging.v2.ILogMetric|null} [metric] CreateLogMetricRequest metric + */ + + /** + * Constructs a new CreateLogMetricRequest. + * @memberof google.logging.v2 + * @classdesc Represents a CreateLogMetricRequest. + * @implements ICreateLogMetricRequest + * @constructor + * @param {google.logging.v2.ICreateLogMetricRequest=} [properties] Properties to set + */ + function CreateLogMetricRequest(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * CreateLogMetricRequest parent. + * @member {string} parent + * @memberof google.logging.v2.CreateLogMetricRequest + * @instance + */ + CreateLogMetricRequest.prototype.parent = '' + + /** + * CreateLogMetricRequest metric. + * @member {google.logging.v2.ILogMetric|null|undefined} metric + * @memberof google.logging.v2.CreateLogMetricRequest + * @instance + */ + CreateLogMetricRequest.prototype.metric = null + + /** + * Creates a new CreateLogMetricRequest instance using the specified properties. + * @function create + * @memberof google.logging.v2.CreateLogMetricRequest + * @static + * @param {google.logging.v2.ICreateLogMetricRequest=} [properties] Properties to set + * @returns {google.logging.v2.CreateLogMetricRequest} CreateLogMetricRequest instance + */ + CreateLogMetricRequest.create = function create(properties) { + return new CreateLogMetricRequest(properties) + } + + /** + * Encodes the specified CreateLogMetricRequest message. Does not implicitly {@link google.logging.v2.CreateLogMetricRequest.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.CreateLogMetricRequest + * @static + * @param {google.logging.v2.ICreateLogMetricRequest} message CreateLogMetricRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateLogMetricRequest.encode = function encode( + message, + writer + ) { + if (!writer) writer = $Writer.create() + if ( + message.parent != null && + Object.hasOwnProperty.call(message, 'parent') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.parent) + if ( + message.metric != null && + Object.hasOwnProperty.call(message, 'metric') + ) + $root.google.logging.v2.LogMetric.encode( + message.metric, + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified CreateLogMetricRequest message, length delimited. Does not implicitly {@link google.logging.v2.CreateLogMetricRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.CreateLogMetricRequest + * @static + * @param {google.logging.v2.ICreateLogMetricRequest} message CreateLogMetricRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateLogMetricRequest.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a CreateLogMetricRequest message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.CreateLogMetricRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.CreateLogMetricRequest} CreateLogMetricRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateLogMetricRequest.decode = function decode( + reader, + length + ) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.CreateLogMetricRequest() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.parent = reader.string() + break + case 2: + message.metric = $root.google.logging.v2.LogMetric.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a CreateLogMetricRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.CreateLogMetricRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.CreateLogMetricRequest} CreateLogMetricRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateLogMetricRequest.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a CreateLogMetricRequest message. + * @function verify + * @memberof google.logging.v2.CreateLogMetricRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CreateLogMetricRequest.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.parent != null && + message.hasOwnProperty('parent') + ) + if (!$util.isString(message.parent)) + return 'parent: string expected' + if ( + message.metric != null && + message.hasOwnProperty('metric') + ) { + var error = $root.google.logging.v2.LogMetric.verify( + message.metric + ) + if (error) return 'metric.' + error + } + return null + } + + /** + * Creates a CreateLogMetricRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.CreateLogMetricRequest + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.CreateLogMetricRequest} CreateLogMetricRequest + */ + CreateLogMetricRequest.fromObject = function fromObject( + object + ) { + if ( + object instanceof + $root.google.logging.v2.CreateLogMetricRequest + ) + return object + var message = new $root.google.logging.v2.CreateLogMetricRequest() + if (object.parent != null) + message.parent = String(object.parent) + if (object.metric != null) { + if (typeof object.metric !== 'object') + throw TypeError( + '.google.logging.v2.CreateLogMetricRequest.metric: object expected' + ) + message.metric = $root.google.logging.v2.LogMetric.fromObject( + object.metric + ) + } + return message + } + + /** + * Creates a plain object from a CreateLogMetricRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.CreateLogMetricRequest + * @static + * @param {google.logging.v2.CreateLogMetricRequest} message CreateLogMetricRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CreateLogMetricRequest.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.parent = '' + object.metric = null + } + if ( + message.parent != null && + message.hasOwnProperty('parent') + ) + object.parent = message.parent + if ( + message.metric != null && + message.hasOwnProperty('metric') + ) + object.metric = $root.google.logging.v2.LogMetric.toObject( + message.metric, + options + ) + return object + } + + /** + * Converts this CreateLogMetricRequest to JSON. + * @function toJSON + * @memberof google.logging.v2.CreateLogMetricRequest + * @instance + * @returns {Object.} JSON object + */ + CreateLogMetricRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return CreateLogMetricRequest + })() + + v2.UpdateLogMetricRequest = (function () { + /** + * Properties of an UpdateLogMetricRequest. + * @memberof google.logging.v2 + * @interface IUpdateLogMetricRequest + * @property {string|null} [metricName] UpdateLogMetricRequest metricName + * @property {google.logging.v2.ILogMetric|null} [metric] UpdateLogMetricRequest metric + */ + + /** + * Constructs a new UpdateLogMetricRequest. + * @memberof google.logging.v2 + * @classdesc Represents an UpdateLogMetricRequest. + * @implements IUpdateLogMetricRequest + * @constructor + * @param {google.logging.v2.IUpdateLogMetricRequest=} [properties] Properties to set + */ + function UpdateLogMetricRequest(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * UpdateLogMetricRequest metricName. + * @member {string} metricName + * @memberof google.logging.v2.UpdateLogMetricRequest + * @instance + */ + UpdateLogMetricRequest.prototype.metricName = '' + + /** + * UpdateLogMetricRequest metric. + * @member {google.logging.v2.ILogMetric|null|undefined} metric + * @memberof google.logging.v2.UpdateLogMetricRequest + * @instance + */ + UpdateLogMetricRequest.prototype.metric = null + + /** + * Creates a new UpdateLogMetricRequest instance using the specified properties. + * @function create + * @memberof google.logging.v2.UpdateLogMetricRequest + * @static + * @param {google.logging.v2.IUpdateLogMetricRequest=} [properties] Properties to set + * @returns {google.logging.v2.UpdateLogMetricRequest} UpdateLogMetricRequest instance + */ + UpdateLogMetricRequest.create = function create(properties) { + return new UpdateLogMetricRequest(properties) + } + + /** + * Encodes the specified UpdateLogMetricRequest message. Does not implicitly {@link google.logging.v2.UpdateLogMetricRequest.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.UpdateLogMetricRequest + * @static + * @param {google.logging.v2.IUpdateLogMetricRequest} message UpdateLogMetricRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateLogMetricRequest.encode = function encode( + message, + writer + ) { + if (!writer) writer = $Writer.create() + if ( + message.metricName != null && + Object.hasOwnProperty.call(message, 'metricName') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.metricName) + if ( + message.metric != null && + Object.hasOwnProperty.call(message, 'metric') + ) + $root.google.logging.v2.LogMetric.encode( + message.metric, + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified UpdateLogMetricRequest message, length delimited. Does not implicitly {@link google.logging.v2.UpdateLogMetricRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.UpdateLogMetricRequest + * @static + * @param {google.logging.v2.IUpdateLogMetricRequest} message UpdateLogMetricRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateLogMetricRequest.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an UpdateLogMetricRequest message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.UpdateLogMetricRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.UpdateLogMetricRequest} UpdateLogMetricRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateLogMetricRequest.decode = function decode( + reader, + length + ) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.UpdateLogMetricRequest() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.metricName = reader.string() + break + case 2: + message.metric = $root.google.logging.v2.LogMetric.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an UpdateLogMetricRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.UpdateLogMetricRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.UpdateLogMetricRequest} UpdateLogMetricRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateLogMetricRequest.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an UpdateLogMetricRequest message. + * @function verify + * @memberof google.logging.v2.UpdateLogMetricRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UpdateLogMetricRequest.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.metricName != null && + message.hasOwnProperty('metricName') + ) + if (!$util.isString(message.metricName)) + return 'metricName: string expected' + if ( + message.metric != null && + message.hasOwnProperty('metric') + ) { + var error = $root.google.logging.v2.LogMetric.verify( + message.metric + ) + if (error) return 'metric.' + error + } + return null + } + + /** + * Creates an UpdateLogMetricRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.UpdateLogMetricRequest + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.UpdateLogMetricRequest} UpdateLogMetricRequest + */ + UpdateLogMetricRequest.fromObject = function fromObject( + object + ) { + if ( + object instanceof + $root.google.logging.v2.UpdateLogMetricRequest + ) + return object + var message = new $root.google.logging.v2.UpdateLogMetricRequest() + if (object.metricName != null) + message.metricName = String(object.metricName) + if (object.metric != null) { + if (typeof object.metric !== 'object') + throw TypeError( + '.google.logging.v2.UpdateLogMetricRequest.metric: object expected' + ) + message.metric = $root.google.logging.v2.LogMetric.fromObject( + object.metric + ) + } + return message + } + + /** + * Creates a plain object from an UpdateLogMetricRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.UpdateLogMetricRequest + * @static + * @param {google.logging.v2.UpdateLogMetricRequest} message UpdateLogMetricRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UpdateLogMetricRequest.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.metricName = '' + object.metric = null + } + if ( + message.metricName != null && + message.hasOwnProperty('metricName') + ) + object.metricName = message.metricName + if ( + message.metric != null && + message.hasOwnProperty('metric') + ) + object.metric = $root.google.logging.v2.LogMetric.toObject( + message.metric, + options + ) + return object + } + + /** + * Converts this UpdateLogMetricRequest to JSON. + * @function toJSON + * @memberof google.logging.v2.UpdateLogMetricRequest + * @instance + * @returns {Object.} JSON object + */ + UpdateLogMetricRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return UpdateLogMetricRequest + })() + + v2.DeleteLogMetricRequest = (function () { + /** + * Properties of a DeleteLogMetricRequest. + * @memberof google.logging.v2 + * @interface IDeleteLogMetricRequest + * @property {string|null} [metricName] DeleteLogMetricRequest metricName + */ + + /** + * Constructs a new DeleteLogMetricRequest. + * @memberof google.logging.v2 + * @classdesc Represents a DeleteLogMetricRequest. + * @implements IDeleteLogMetricRequest + * @constructor + * @param {google.logging.v2.IDeleteLogMetricRequest=} [properties] Properties to set + */ + function DeleteLogMetricRequest(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * DeleteLogMetricRequest metricName. + * @member {string} metricName + * @memberof google.logging.v2.DeleteLogMetricRequest + * @instance + */ + DeleteLogMetricRequest.prototype.metricName = '' + + /** + * Creates a new DeleteLogMetricRequest instance using the specified properties. + * @function create + * @memberof google.logging.v2.DeleteLogMetricRequest + * @static + * @param {google.logging.v2.IDeleteLogMetricRequest=} [properties] Properties to set + * @returns {google.logging.v2.DeleteLogMetricRequest} DeleteLogMetricRequest instance + */ + DeleteLogMetricRequest.create = function create(properties) { + return new DeleteLogMetricRequest(properties) + } + + /** + * Encodes the specified DeleteLogMetricRequest message. Does not implicitly {@link google.logging.v2.DeleteLogMetricRequest.verify|verify} messages. + * @function encode + * @memberof google.logging.v2.DeleteLogMetricRequest + * @static + * @param {google.logging.v2.IDeleteLogMetricRequest} message DeleteLogMetricRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteLogMetricRequest.encode = function encode( + message, + writer + ) { + if (!writer) writer = $Writer.create() + if ( + message.metricName != null && + Object.hasOwnProperty.call(message, 'metricName') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.metricName) + return writer + } + + /** + * Encodes the specified DeleteLogMetricRequest message, length delimited. Does not implicitly {@link google.logging.v2.DeleteLogMetricRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.v2.DeleteLogMetricRequest + * @static + * @param {google.logging.v2.IDeleteLogMetricRequest} message DeleteLogMetricRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteLogMetricRequest.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a DeleteLogMetricRequest message from the specified reader or buffer. + * @function decode + * @memberof google.logging.v2.DeleteLogMetricRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.v2.DeleteLogMetricRequest} DeleteLogMetricRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteLogMetricRequest.decode = function decode( + reader, + length + ) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.v2.DeleteLogMetricRequest() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.metricName = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a DeleteLogMetricRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.v2.DeleteLogMetricRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.v2.DeleteLogMetricRequest} DeleteLogMetricRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteLogMetricRequest.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a DeleteLogMetricRequest message. + * @function verify + * @memberof google.logging.v2.DeleteLogMetricRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DeleteLogMetricRequest.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.metricName != null && + message.hasOwnProperty('metricName') + ) + if (!$util.isString(message.metricName)) + return 'metricName: string expected' + return null + } + + /** + * Creates a DeleteLogMetricRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.v2.DeleteLogMetricRequest + * @static + * @param {Object.} object Plain object + * @returns {google.logging.v2.DeleteLogMetricRequest} DeleteLogMetricRequest + */ + DeleteLogMetricRequest.fromObject = function fromObject( + object + ) { + if ( + object instanceof + $root.google.logging.v2.DeleteLogMetricRequest + ) + return object + var message = new $root.google.logging.v2.DeleteLogMetricRequest() + if (object.metricName != null) + message.metricName = String(object.metricName) + return message + } + + /** + * Creates a plain object from a DeleteLogMetricRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.v2.DeleteLogMetricRequest + * @static + * @param {google.logging.v2.DeleteLogMetricRequest} message DeleteLogMetricRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeleteLogMetricRequest.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) object.metricName = '' + if ( + message.metricName != null && + message.hasOwnProperty('metricName') + ) + object.metricName = message.metricName + return object + } + + /** + * Converts this DeleteLogMetricRequest to JSON. + * @function toJSON + * @memberof google.logging.v2.DeleteLogMetricRequest + * @instance + * @returns {Object.} JSON object + */ + DeleteLogMetricRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return DeleteLogMetricRequest + })() + + return v2 + })() + + logging.type = (function () { + /** + * Namespace type. + * @memberof google.logging + * @namespace + */ + var type = {} + + type.HttpRequest = (function () { + /** + * Properties of a HttpRequest. + * @memberof google.logging.type + * @interface IHttpRequest + * @property {string|null} [requestMethod] HttpRequest requestMethod + * @property {string|null} [requestUrl] HttpRequest requestUrl + * @property {number|Long|null} [requestSize] HttpRequest requestSize + * @property {number|null} [status] HttpRequest status + * @property {number|Long|null} [responseSize] HttpRequest responseSize + * @property {string|null} [userAgent] HttpRequest userAgent + * @property {string|null} [remoteIp] HttpRequest remoteIp + * @property {string|null} [serverIp] HttpRequest serverIp + * @property {string|null} [referer] HttpRequest referer + * @property {google.protobuf.IDuration|null} [latency] HttpRequest latency + * @property {boolean|null} [cacheLookup] HttpRequest cacheLookup + * @property {boolean|null} [cacheHit] HttpRequest cacheHit + * @property {boolean|null} [cacheValidatedWithOriginServer] HttpRequest cacheValidatedWithOriginServer + * @property {number|Long|null} [cacheFillBytes] HttpRequest cacheFillBytes + * @property {string|null} [protocol] HttpRequest protocol + */ + + /** + * Constructs a new HttpRequest. + * @memberof google.logging.type + * @classdesc Represents a HttpRequest. + * @implements IHttpRequest + * @constructor + * @param {google.logging.type.IHttpRequest=} [properties] Properties to set + */ + function HttpRequest(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * HttpRequest requestMethod. + * @member {string} requestMethod + * @memberof google.logging.type.HttpRequest + * @instance + */ + HttpRequest.prototype.requestMethod = '' + + /** + * HttpRequest requestUrl. + * @member {string} requestUrl + * @memberof google.logging.type.HttpRequest + * @instance + */ + HttpRequest.prototype.requestUrl = '' + + /** + * HttpRequest requestSize. + * @member {number|Long} requestSize + * @memberof google.logging.type.HttpRequest + * @instance + */ + HttpRequest.prototype.requestSize = $util.Long + ? $util.Long.fromBits(0, 0, false) + : 0 + + /** + * HttpRequest status. + * @member {number} status + * @memberof google.logging.type.HttpRequest + * @instance + */ + HttpRequest.prototype.status = 0 + + /** + * HttpRequest responseSize. + * @member {number|Long} responseSize + * @memberof google.logging.type.HttpRequest + * @instance + */ + HttpRequest.prototype.responseSize = $util.Long + ? $util.Long.fromBits(0, 0, false) + : 0 + + /** + * HttpRequest userAgent. + * @member {string} userAgent + * @memberof google.logging.type.HttpRequest + * @instance + */ + HttpRequest.prototype.userAgent = '' + + /** + * HttpRequest remoteIp. + * @member {string} remoteIp + * @memberof google.logging.type.HttpRequest + * @instance + */ + HttpRequest.prototype.remoteIp = '' + + /** + * HttpRequest serverIp. + * @member {string} serverIp + * @memberof google.logging.type.HttpRequest + * @instance + */ + HttpRequest.prototype.serverIp = '' + + /** + * HttpRequest referer. + * @member {string} referer + * @memberof google.logging.type.HttpRequest + * @instance + */ + HttpRequest.prototype.referer = '' + + /** + * HttpRequest latency. + * @member {google.protobuf.IDuration|null|undefined} latency + * @memberof google.logging.type.HttpRequest + * @instance + */ + HttpRequest.prototype.latency = null + + /** + * HttpRequest cacheLookup. + * @member {boolean} cacheLookup + * @memberof google.logging.type.HttpRequest + * @instance + */ + HttpRequest.prototype.cacheLookup = false + + /** + * HttpRequest cacheHit. + * @member {boolean} cacheHit + * @memberof google.logging.type.HttpRequest + * @instance + */ + HttpRequest.prototype.cacheHit = false + + /** + * HttpRequest cacheValidatedWithOriginServer. + * @member {boolean} cacheValidatedWithOriginServer + * @memberof google.logging.type.HttpRequest + * @instance + */ + HttpRequest.prototype.cacheValidatedWithOriginServer = false + + /** + * HttpRequest cacheFillBytes. + * @member {number|Long} cacheFillBytes + * @memberof google.logging.type.HttpRequest + * @instance + */ + HttpRequest.prototype.cacheFillBytes = $util.Long + ? $util.Long.fromBits(0, 0, false) + : 0 + + /** + * HttpRequest protocol. + * @member {string} protocol + * @memberof google.logging.type.HttpRequest + * @instance + */ + HttpRequest.prototype.protocol = '' + + /** + * Creates a new HttpRequest instance using the specified properties. + * @function create + * @memberof google.logging.type.HttpRequest + * @static + * @param {google.logging.type.IHttpRequest=} [properties] Properties to set + * @returns {google.logging.type.HttpRequest} HttpRequest instance + */ + HttpRequest.create = function create(properties) { + return new HttpRequest(properties) + } + + /** + * Encodes the specified HttpRequest message. Does not implicitly {@link google.logging.type.HttpRequest.verify|verify} messages. + * @function encode + * @memberof google.logging.type.HttpRequest + * @static + * @param {google.logging.type.IHttpRequest} message HttpRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + HttpRequest.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.requestMethod != null && + Object.hasOwnProperty.call(message, 'requestMethod') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.requestMethod) + if ( + message.requestUrl != null && + Object.hasOwnProperty.call(message, 'requestUrl') + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.requestUrl) + if ( + message.requestSize != null && + Object.hasOwnProperty.call(message, 'requestSize') + ) + writer + .uint32(/* id 3, wireType 0 =*/ 24) + .int64(message.requestSize) + if ( + message.status != null && + Object.hasOwnProperty.call(message, 'status') + ) + writer + .uint32(/* id 4, wireType 0 =*/ 32) + .int32(message.status) + if ( + message.responseSize != null && + Object.hasOwnProperty.call(message, 'responseSize') + ) + writer + .uint32(/* id 5, wireType 0 =*/ 40) + .int64(message.responseSize) + if ( + message.userAgent != null && + Object.hasOwnProperty.call(message, 'userAgent') + ) + writer + .uint32(/* id 6, wireType 2 =*/ 50) + .string(message.userAgent) + if ( + message.remoteIp != null && + Object.hasOwnProperty.call(message, 'remoteIp') + ) + writer + .uint32(/* id 7, wireType 2 =*/ 58) + .string(message.remoteIp) + if ( + message.referer != null && + Object.hasOwnProperty.call(message, 'referer') + ) + writer + .uint32(/* id 8, wireType 2 =*/ 66) + .string(message.referer) + if ( + message.cacheHit != null && + Object.hasOwnProperty.call(message, 'cacheHit') + ) + writer + .uint32(/* id 9, wireType 0 =*/ 72) + .bool(message.cacheHit) + if ( + message.cacheValidatedWithOriginServer != null && + Object.hasOwnProperty.call( + message, + 'cacheValidatedWithOriginServer' + ) + ) + writer + .uint32(/* id 10, wireType 0 =*/ 80) + .bool(message.cacheValidatedWithOriginServer) + if ( + message.cacheLookup != null && + Object.hasOwnProperty.call(message, 'cacheLookup') + ) + writer + .uint32(/* id 11, wireType 0 =*/ 88) + .bool(message.cacheLookup) + if ( + message.cacheFillBytes != null && + Object.hasOwnProperty.call(message, 'cacheFillBytes') + ) + writer + .uint32(/* id 12, wireType 0 =*/ 96) + .int64(message.cacheFillBytes) + if ( + message.serverIp != null && + Object.hasOwnProperty.call(message, 'serverIp') + ) + writer + .uint32(/* id 13, wireType 2 =*/ 106) + .string(message.serverIp) + if ( + message.latency != null && + Object.hasOwnProperty.call(message, 'latency') + ) + $root.google.protobuf.Duration.encode( + message.latency, + writer.uint32(/* id 14, wireType 2 =*/ 114).fork() + ).ldelim() + if ( + message.protocol != null && + Object.hasOwnProperty.call(message, 'protocol') + ) + writer + .uint32(/* id 15, wireType 2 =*/ 122) + .string(message.protocol) + return writer + } + + /** + * Encodes the specified HttpRequest message, length delimited. Does not implicitly {@link google.logging.type.HttpRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.logging.type.HttpRequest + * @static + * @param {google.logging.type.IHttpRequest} message HttpRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + HttpRequest.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a HttpRequest message from the specified reader or buffer. + * @function decode + * @memberof google.logging.type.HttpRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.logging.type.HttpRequest} HttpRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + HttpRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.logging.type.HttpRequest() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.requestMethod = reader.string() + break + case 2: + message.requestUrl = reader.string() + break + case 3: + message.requestSize = reader.int64() + break + case 4: + message.status = reader.int32() + break + case 5: + message.responseSize = reader.int64() + break + case 6: + message.userAgent = reader.string() + break + case 7: + message.remoteIp = reader.string() + break + case 13: + message.serverIp = reader.string() + break + case 8: + message.referer = reader.string() + break + case 14: + message.latency = $root.google.protobuf.Duration.decode( + reader, + reader.uint32() + ) + break + case 11: + message.cacheLookup = reader.bool() + break + case 9: + message.cacheHit = reader.bool() + break + case 10: + message.cacheValidatedWithOriginServer = reader.bool() + break + case 12: + message.cacheFillBytes = reader.int64() + break + case 15: + message.protocol = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a HttpRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.logging.type.HttpRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.logging.type.HttpRequest} HttpRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + HttpRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a HttpRequest message. + * @function verify + * @memberof google.logging.type.HttpRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + HttpRequest.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.requestMethod != null && + message.hasOwnProperty('requestMethod') + ) + if (!$util.isString(message.requestMethod)) + return 'requestMethod: string expected' + if ( + message.requestUrl != null && + message.hasOwnProperty('requestUrl') + ) + if (!$util.isString(message.requestUrl)) + return 'requestUrl: string expected' + if ( + message.requestSize != null && + message.hasOwnProperty('requestSize') + ) + if ( + !$util.isInteger(message.requestSize) && + !( + message.requestSize && + $util.isInteger(message.requestSize.low) && + $util.isInteger(message.requestSize.high) + ) + ) + return 'requestSize: integer|Long expected' + if ( + message.status != null && + message.hasOwnProperty('status') + ) + if (!$util.isInteger(message.status)) + return 'status: integer expected' + if ( + message.responseSize != null && + message.hasOwnProperty('responseSize') + ) + if ( + !$util.isInteger(message.responseSize) && + !( + message.responseSize && + $util.isInteger(message.responseSize.low) && + $util.isInteger(message.responseSize.high) + ) + ) + return 'responseSize: integer|Long expected' + if ( + message.userAgent != null && + message.hasOwnProperty('userAgent') + ) + if (!$util.isString(message.userAgent)) + return 'userAgent: string expected' + if ( + message.remoteIp != null && + message.hasOwnProperty('remoteIp') + ) + if (!$util.isString(message.remoteIp)) + return 'remoteIp: string expected' + if ( + message.serverIp != null && + message.hasOwnProperty('serverIp') + ) + if (!$util.isString(message.serverIp)) + return 'serverIp: string expected' + if ( + message.referer != null && + message.hasOwnProperty('referer') + ) + if (!$util.isString(message.referer)) + return 'referer: string expected' + if ( + message.latency != null && + message.hasOwnProperty('latency') + ) { + var error = $root.google.protobuf.Duration.verify( + message.latency + ) + if (error) return 'latency.' + error + } + if ( + message.cacheLookup != null && + message.hasOwnProperty('cacheLookup') + ) + if (typeof message.cacheLookup !== 'boolean') + return 'cacheLookup: boolean expected' + if ( + message.cacheHit != null && + message.hasOwnProperty('cacheHit') + ) + if (typeof message.cacheHit !== 'boolean') + return 'cacheHit: boolean expected' + if ( + message.cacheValidatedWithOriginServer != null && + message.hasOwnProperty('cacheValidatedWithOriginServer') + ) + if ( + typeof message.cacheValidatedWithOriginServer !== + 'boolean' + ) + return 'cacheValidatedWithOriginServer: boolean expected' + if ( + message.cacheFillBytes != null && + message.hasOwnProperty('cacheFillBytes') + ) + if ( + !$util.isInteger(message.cacheFillBytes) && + !( + message.cacheFillBytes && + $util.isInteger(message.cacheFillBytes.low) && + $util.isInteger(message.cacheFillBytes.high) + ) + ) + return 'cacheFillBytes: integer|Long expected' + if ( + message.protocol != null && + message.hasOwnProperty('protocol') + ) + if (!$util.isString(message.protocol)) + return 'protocol: string expected' + return null + } + + /** + * Creates a HttpRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.logging.type.HttpRequest + * @static + * @param {Object.} object Plain object + * @returns {google.logging.type.HttpRequest} HttpRequest + */ + HttpRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.logging.type.HttpRequest) + return object + var message = new $root.google.logging.type.HttpRequest() + if (object.requestMethod != null) + message.requestMethod = String(object.requestMethod) + if (object.requestUrl != null) + message.requestUrl = String(object.requestUrl) + if (object.requestSize != null) + if ($util.Long) + (message.requestSize = $util.Long.fromValue( + object.requestSize + )).unsigned = false + else if (typeof object.requestSize === 'string') + message.requestSize = parseInt(object.requestSize, 10) + else if (typeof object.requestSize === 'number') + message.requestSize = object.requestSize + else if (typeof object.requestSize === 'object') + message.requestSize = new $util.LongBits( + object.requestSize.low >>> 0, + object.requestSize.high >>> 0 + ).toNumber() + if (object.status != null) message.status = object.status | 0 + if (object.responseSize != null) + if ($util.Long) + (message.responseSize = $util.Long.fromValue( + object.responseSize + )).unsigned = false + else if (typeof object.responseSize === 'string') + message.responseSize = parseInt(object.responseSize, 10) + else if (typeof object.responseSize === 'number') + message.responseSize = object.responseSize + else if (typeof object.responseSize === 'object') + message.responseSize = new $util.LongBits( + object.responseSize.low >>> 0, + object.responseSize.high >>> 0 + ).toNumber() + if (object.userAgent != null) + message.userAgent = String(object.userAgent) + if (object.remoteIp != null) + message.remoteIp = String(object.remoteIp) + if (object.serverIp != null) + message.serverIp = String(object.serverIp) + if (object.referer != null) + message.referer = String(object.referer) + if (object.latency != null) { + if (typeof object.latency !== 'object') + throw TypeError( + '.google.logging.type.HttpRequest.latency: object expected' + ) + message.latency = $root.google.protobuf.Duration.fromObject( + object.latency + ) + } + if (object.cacheLookup != null) + message.cacheLookup = Boolean(object.cacheLookup) + if (object.cacheHit != null) + message.cacheHit = Boolean(object.cacheHit) + if (object.cacheValidatedWithOriginServer != null) + message.cacheValidatedWithOriginServer = Boolean( + object.cacheValidatedWithOriginServer + ) + if (object.cacheFillBytes != null) + if ($util.Long) + (message.cacheFillBytes = $util.Long.fromValue( + object.cacheFillBytes + )).unsigned = false + else if (typeof object.cacheFillBytes === 'string') + message.cacheFillBytes = parseInt( + object.cacheFillBytes, + 10 + ) + else if (typeof object.cacheFillBytes === 'number') + message.cacheFillBytes = object.cacheFillBytes + else if (typeof object.cacheFillBytes === 'object') + message.cacheFillBytes = new $util.LongBits( + object.cacheFillBytes.low >>> 0, + object.cacheFillBytes.high >>> 0 + ).toNumber() + if (object.protocol != null) + message.protocol = String(object.protocol) + return message + } + + /** + * Creates a plain object from a HttpRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.logging.type.HttpRequest + * @static + * @param {google.logging.type.HttpRequest} message HttpRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + HttpRequest.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.requestMethod = '' + object.requestUrl = '' + if ($util.Long) { + var long = new $util.Long(0, 0, false) + object.requestSize = + options.longs === String + ? long.toString() + : options.longs === Number + ? long.toNumber() + : long + } else + object.requestSize = options.longs === String ? '0' : 0 + object.status = 0 + if ($util.Long) { + var long = new $util.Long(0, 0, false) + object.responseSize = + options.longs === String + ? long.toString() + : options.longs === Number + ? long.toNumber() + : long + } else + object.responseSize = options.longs === String ? '0' : 0 + object.userAgent = '' + object.remoteIp = '' + object.referer = '' + object.cacheHit = false + object.cacheValidatedWithOriginServer = false + object.cacheLookup = false + if ($util.Long) { + var long = new $util.Long(0, 0, false) + object.cacheFillBytes = + options.longs === String + ? long.toString() + : options.longs === Number + ? long.toNumber() + : long + } else + object.cacheFillBytes = options.longs === String ? '0' : 0 + object.serverIp = '' + object.latency = null + object.protocol = '' + } + if ( + message.requestMethod != null && + message.hasOwnProperty('requestMethod') + ) + object.requestMethod = message.requestMethod + if ( + message.requestUrl != null && + message.hasOwnProperty('requestUrl') + ) + object.requestUrl = message.requestUrl + if ( + message.requestSize != null && + message.hasOwnProperty('requestSize') + ) + if (typeof message.requestSize === 'number') + object.requestSize = + options.longs === String + ? String(message.requestSize) + : message.requestSize + else + object.requestSize = + options.longs === String + ? $util.Long.prototype.toString.call( + message.requestSize + ) + : options.longs === Number + ? new $util.LongBits( + message.requestSize.low >>> 0, + message.requestSize.high >>> 0 + ).toNumber() + : message.requestSize + if ( + message.status != null && + message.hasOwnProperty('status') + ) + object.status = message.status + if ( + message.responseSize != null && + message.hasOwnProperty('responseSize') + ) + if (typeof message.responseSize === 'number') + object.responseSize = + options.longs === String + ? String(message.responseSize) + : message.responseSize + else + object.responseSize = + options.longs === String + ? $util.Long.prototype.toString.call( + message.responseSize + ) + : options.longs === Number + ? new $util.LongBits( + message.responseSize.low >>> 0, + message.responseSize.high >>> 0 + ).toNumber() + : message.responseSize + if ( + message.userAgent != null && + message.hasOwnProperty('userAgent') + ) + object.userAgent = message.userAgent + if ( + message.remoteIp != null && + message.hasOwnProperty('remoteIp') + ) + object.remoteIp = message.remoteIp + if ( + message.referer != null && + message.hasOwnProperty('referer') + ) + object.referer = message.referer + if ( + message.cacheHit != null && + message.hasOwnProperty('cacheHit') + ) + object.cacheHit = message.cacheHit + if ( + message.cacheValidatedWithOriginServer != null && + message.hasOwnProperty('cacheValidatedWithOriginServer') + ) + object.cacheValidatedWithOriginServer = + message.cacheValidatedWithOriginServer + if ( + message.cacheLookup != null && + message.hasOwnProperty('cacheLookup') + ) + object.cacheLookup = message.cacheLookup + if ( + message.cacheFillBytes != null && + message.hasOwnProperty('cacheFillBytes') + ) + if (typeof message.cacheFillBytes === 'number') + object.cacheFillBytes = + options.longs === String + ? String(message.cacheFillBytes) + : message.cacheFillBytes + else + object.cacheFillBytes = + options.longs === String + ? $util.Long.prototype.toString.call( + message.cacheFillBytes + ) + : options.longs === Number + ? new $util.LongBits( + message.cacheFillBytes.low >>> 0, + message.cacheFillBytes.high >>> 0 + ).toNumber() + : message.cacheFillBytes + if ( + message.serverIp != null && + message.hasOwnProperty('serverIp') + ) + object.serverIp = message.serverIp + if ( + message.latency != null && + message.hasOwnProperty('latency') + ) + object.latency = $root.google.protobuf.Duration.toObject( + message.latency, + options + ) + if ( + message.protocol != null && + message.hasOwnProperty('protocol') + ) + object.protocol = message.protocol + return object + } + + /** + * Converts this HttpRequest to JSON. + * @function toJSON + * @memberof google.logging.type.HttpRequest + * @instance + * @returns {Object.} JSON object + */ + HttpRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return HttpRequest + })() + + /** + * LogSeverity enum. + * @name google.logging.type.LogSeverity + * @enum {number} + * @property {number} DEFAULT=0 DEFAULT value + * @property {number} DEBUG=100 DEBUG value + * @property {number} INFO=200 INFO value + * @property {number} NOTICE=300 NOTICE value + * @property {number} WARNING=400 WARNING value + * @property {number} ERROR=500 ERROR value + * @property {number} CRITICAL=600 CRITICAL value + * @property {number} ALERT=700 ALERT value + * @property {number} EMERGENCY=800 EMERGENCY value + */ + type.LogSeverity = (function () { + var valuesById = {}, + values = Object.create(valuesById) + values[(valuesById[0] = 'DEFAULT')] = 0 + values[(valuesById[100] = 'DEBUG')] = 100 + values[(valuesById[200] = 'INFO')] = 200 + values[(valuesById[300] = 'NOTICE')] = 300 + values[(valuesById[400] = 'WARNING')] = 400 + values[(valuesById[500] = 'ERROR')] = 500 + values[(valuesById[600] = 'CRITICAL')] = 600 + values[(valuesById[700] = 'ALERT')] = 700 + values[(valuesById[800] = 'EMERGENCY')] = 800 + return values + })() + + return type + })() + + return logging + })() + + google.api = (function () { + /** + * Namespace api. + * @memberof google + * @namespace + */ + var api = {} + + /** + * FieldBehavior enum. + * @name google.api.FieldBehavior + * @enum {number} + * @property {number} FIELD_BEHAVIOR_UNSPECIFIED=0 FIELD_BEHAVIOR_UNSPECIFIED value + * @property {number} OPTIONAL=1 OPTIONAL value + * @property {number} REQUIRED=2 REQUIRED value + * @property {number} OUTPUT_ONLY=3 OUTPUT_ONLY value + * @property {number} INPUT_ONLY=4 INPUT_ONLY value + * @property {number} IMMUTABLE=5 IMMUTABLE value + */ + api.FieldBehavior = (function () { + var valuesById = {}, + values = Object.create(valuesById) + values[(valuesById[0] = 'FIELD_BEHAVIOR_UNSPECIFIED')] = 0 + values[(valuesById[1] = 'OPTIONAL')] = 1 + values[(valuesById[2] = 'REQUIRED')] = 2 + values[(valuesById[3] = 'OUTPUT_ONLY')] = 3 + values[(valuesById[4] = 'INPUT_ONLY')] = 4 + values[(valuesById[5] = 'IMMUTABLE')] = 5 + return values + })() + + api.MonitoredResourceDescriptor = (function () { + /** + * Properties of a MonitoredResourceDescriptor. + * @memberof google.api + * @interface IMonitoredResourceDescriptor + * @property {string|null} [name] MonitoredResourceDescriptor name + * @property {string|null} [type] MonitoredResourceDescriptor type + * @property {string|null} [displayName] MonitoredResourceDescriptor displayName + * @property {string|null} [description] MonitoredResourceDescriptor description + * @property {Array.|null} [labels] MonitoredResourceDescriptor labels + * @property {google.api.LaunchStage|null} [launchStage] MonitoredResourceDescriptor launchStage + */ + + /** + * Constructs a new MonitoredResourceDescriptor. + * @memberof google.api + * @classdesc Represents a MonitoredResourceDescriptor. + * @implements IMonitoredResourceDescriptor + * @constructor + * @param {google.api.IMonitoredResourceDescriptor=} [properties] Properties to set + */ + function MonitoredResourceDescriptor(properties) { + this.labels = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * MonitoredResourceDescriptor name. + * @member {string} name + * @memberof google.api.MonitoredResourceDescriptor + * @instance + */ + MonitoredResourceDescriptor.prototype.name = '' + + /** + * MonitoredResourceDescriptor type. + * @member {string} type + * @memberof google.api.MonitoredResourceDescriptor + * @instance + */ + MonitoredResourceDescriptor.prototype.type = '' + + /** + * MonitoredResourceDescriptor displayName. + * @member {string} displayName + * @memberof google.api.MonitoredResourceDescriptor + * @instance + */ + MonitoredResourceDescriptor.prototype.displayName = '' + + /** + * MonitoredResourceDescriptor description. + * @member {string} description + * @memberof google.api.MonitoredResourceDescriptor + * @instance + */ + MonitoredResourceDescriptor.prototype.description = '' + + /** + * MonitoredResourceDescriptor labels. + * @member {Array.} labels + * @memberof google.api.MonitoredResourceDescriptor + * @instance + */ + MonitoredResourceDescriptor.prototype.labels = $util.emptyArray + + /** + * MonitoredResourceDescriptor launchStage. + * @member {google.api.LaunchStage} launchStage + * @memberof google.api.MonitoredResourceDescriptor + * @instance + */ + MonitoredResourceDescriptor.prototype.launchStage = 0 + + /** + * Creates a new MonitoredResourceDescriptor instance using the specified properties. + * @function create + * @memberof google.api.MonitoredResourceDescriptor + * @static + * @param {google.api.IMonitoredResourceDescriptor=} [properties] Properties to set + * @returns {google.api.MonitoredResourceDescriptor} MonitoredResourceDescriptor instance + */ + MonitoredResourceDescriptor.create = function create(properties) { + return new MonitoredResourceDescriptor(properties) + } + + /** + * Encodes the specified MonitoredResourceDescriptor message. Does not implicitly {@link google.api.MonitoredResourceDescriptor.verify|verify} messages. + * @function encode + * @memberof google.api.MonitoredResourceDescriptor + * @static + * @param {google.api.IMonitoredResourceDescriptor} message MonitoredResourceDescriptor message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MonitoredResourceDescriptor.encode = function encode( + message, + writer + ) { + if (!writer) writer = $Writer.create() + if ( + message.type != null && + Object.hasOwnProperty.call(message, 'type') + ) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.type) + if ( + message.displayName != null && + Object.hasOwnProperty.call(message, 'displayName') + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.displayName) + if ( + message.description != null && + Object.hasOwnProperty.call(message, 'description') + ) + writer + .uint32(/* id 3, wireType 2 =*/ 26) + .string(message.description) + if (message.labels != null && message.labels.length) + for (var i = 0; i < message.labels.length; ++i) + $root.google.api.LabelDescriptor.encode( + message.labels[i], + writer.uint32(/* id 4, wireType 2 =*/ 34).fork() + ).ldelim() + if ( + message.name != null && + Object.hasOwnProperty.call(message, 'name') + ) + writer.uint32(/* id 5, wireType 2 =*/ 42).string(message.name) + if ( + message.launchStage != null && + Object.hasOwnProperty.call(message, 'launchStage') + ) + writer + .uint32(/* id 7, wireType 0 =*/ 56) + .int32(message.launchStage) + return writer + } + + /** + * Encodes the specified MonitoredResourceDescriptor message, length delimited. Does not implicitly {@link google.api.MonitoredResourceDescriptor.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.MonitoredResourceDescriptor + * @static + * @param {google.api.IMonitoredResourceDescriptor} message MonitoredResourceDescriptor message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MonitoredResourceDescriptor.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a MonitoredResourceDescriptor message from the specified reader or buffer. + * @function decode + * @memberof google.api.MonitoredResourceDescriptor + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.MonitoredResourceDescriptor} MonitoredResourceDescriptor + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MonitoredResourceDescriptor.decode = function decode( + reader, + length + ) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.api.MonitoredResourceDescriptor() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 5: + message.name = reader.string() + break + case 1: + message.type = reader.string() + break + case 2: + message.displayName = reader.string() + break + case 3: + message.description = reader.string() + break + case 4: + if (!(message.labels && message.labels.length)) + message.labels = [] + message.labels.push( + $root.google.api.LabelDescriptor.decode( + reader, + reader.uint32() + ) + ) + break + case 7: + message.launchStage = reader.int32() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a MonitoredResourceDescriptor message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.MonitoredResourceDescriptor + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.MonitoredResourceDescriptor} MonitoredResourceDescriptor + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MonitoredResourceDescriptor.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a MonitoredResourceDescriptor message. + * @function verify + * @memberof google.api.MonitoredResourceDescriptor + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + MonitoredResourceDescriptor.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + if (message.type != null && message.hasOwnProperty('type')) + if (!$util.isString(message.type)) + return 'type: string expected' + if ( + message.displayName != null && + message.hasOwnProperty('displayName') + ) + if (!$util.isString(message.displayName)) + return 'displayName: string expected' + if ( + message.description != null && + message.hasOwnProperty('description') + ) + if (!$util.isString(message.description)) + return 'description: string expected' + if ( + message.labels != null && + message.hasOwnProperty('labels') + ) { + if (!Array.isArray(message.labels)) + return 'labels: array expected' + for (var i = 0; i < message.labels.length; ++i) { + var error = $root.google.api.LabelDescriptor.verify( + message.labels[i] + ) + if (error) return 'labels.' + error + } + } + if ( + message.launchStage != null && + message.hasOwnProperty('launchStage') + ) + switch (message.launchStage) { + default: + return 'launchStage: enum value expected' + case 0: + case 6: + case 7: + case 1: + case 2: + case 3: + case 4: + case 5: + break + } + return null + } + + /** + * Creates a MonitoredResourceDescriptor message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.MonitoredResourceDescriptor + * @static + * @param {Object.} object Plain object + * @returns {google.api.MonitoredResourceDescriptor} MonitoredResourceDescriptor + */ + MonitoredResourceDescriptor.fromObject = function fromObject( + object + ) { + if ( + object instanceof $root.google.api.MonitoredResourceDescriptor + ) + return object + var message = new $root.google.api.MonitoredResourceDescriptor() + if (object.name != null) message.name = String(object.name) + if (object.type != null) message.type = String(object.type) + if (object.displayName != null) + message.displayName = String(object.displayName) + if (object.description != null) + message.description = String(object.description) + if (object.labels) { + if (!Array.isArray(object.labels)) + throw TypeError( + '.google.api.MonitoredResourceDescriptor.labels: array expected' + ) + message.labels = [] + for (var i = 0; i < object.labels.length; ++i) { + if (typeof object.labels[i] !== 'object') + throw TypeError( + '.google.api.MonitoredResourceDescriptor.labels: object expected' + ) + message.labels[ + i + ] = $root.google.api.LabelDescriptor.fromObject( + object.labels[i] + ) + } + } + switch (object.launchStage) { + case 'LAUNCH_STAGE_UNSPECIFIED': + case 0: + message.launchStage = 0 + break + case 'UNIMPLEMENTED': + case 6: + message.launchStage = 6 + break + case 'PRELAUNCH': + case 7: + message.launchStage = 7 + break + case 'EARLY_ACCESS': + case 1: + message.launchStage = 1 + break + case 'ALPHA': + case 2: + message.launchStage = 2 + break + case 'BETA': + case 3: + message.launchStage = 3 + break + case 'GA': + case 4: + message.launchStage = 4 + break + case 'DEPRECATED': + case 5: + message.launchStage = 5 + break + } + return message + } + + /** + * Creates a plain object from a MonitoredResourceDescriptor message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.MonitoredResourceDescriptor + * @static + * @param {google.api.MonitoredResourceDescriptor} message MonitoredResourceDescriptor + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MonitoredResourceDescriptor.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) object.labels = [] + if (options.defaults) { + object.type = '' + object.displayName = '' + object.description = '' + object.name = '' + object.launchStage = + options.enums === String ? 'LAUNCH_STAGE_UNSPECIFIED' : 0 + } + if (message.type != null && message.hasOwnProperty('type')) + object.type = message.type + if ( + message.displayName != null && + message.hasOwnProperty('displayName') + ) + object.displayName = message.displayName + if ( + message.description != null && + message.hasOwnProperty('description') + ) + object.description = message.description + if (message.labels && message.labels.length) { + object.labels = [] + for (var j = 0; j < message.labels.length; ++j) + object.labels[ + j + ] = $root.google.api.LabelDescriptor.toObject( + message.labels[j], + options + ) + } + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + if ( + message.launchStage != null && + message.hasOwnProperty('launchStage') + ) + object.launchStage = + options.enums === String + ? $root.google.api.LaunchStage[message.launchStage] + : message.launchStage + return object + } + + /** + * Converts this MonitoredResourceDescriptor to JSON. + * @function toJSON + * @memberof google.api.MonitoredResourceDescriptor + * @instance + * @returns {Object.} JSON object + */ + MonitoredResourceDescriptor.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return MonitoredResourceDescriptor + })() + + api.MonitoredResource = (function () { + /** + * Properties of a MonitoredResource. + * @memberof google.api + * @interface IMonitoredResource + * @property {string|null} [type] MonitoredResource type + * @property {Object.|null} [labels] MonitoredResource labels + */ + + /** + * Constructs a new MonitoredResource. + * @memberof google.api + * @classdesc Represents a MonitoredResource. + * @implements IMonitoredResource + * @constructor + * @param {google.api.IMonitoredResource=} [properties] Properties to set + */ + function MonitoredResource(properties) { + this.labels = {} + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * MonitoredResource type. + * @member {string} type + * @memberof google.api.MonitoredResource + * @instance + */ + MonitoredResource.prototype.type = '' + + /** + * MonitoredResource labels. + * @member {Object.} labels + * @memberof google.api.MonitoredResource + * @instance + */ + MonitoredResource.prototype.labels = $util.emptyObject + + /** + * Creates a new MonitoredResource instance using the specified properties. + * @function create + * @memberof google.api.MonitoredResource + * @static + * @param {google.api.IMonitoredResource=} [properties] Properties to set + * @returns {google.api.MonitoredResource} MonitoredResource instance + */ + MonitoredResource.create = function create(properties) { + return new MonitoredResource(properties) + } + + /** + * Encodes the specified MonitoredResource message. Does not implicitly {@link google.api.MonitoredResource.verify|verify} messages. + * @function encode + * @memberof google.api.MonitoredResource + * @static + * @param {google.api.IMonitoredResource} message MonitoredResource message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MonitoredResource.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.type != null && + Object.hasOwnProperty.call(message, 'type') + ) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.type) + if ( + message.labels != null && + Object.hasOwnProperty.call(message, 'labels') + ) + for ( + var keys = Object.keys(message.labels), i = 0; + i < keys.length; + ++i + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .fork() + .uint32(/* id 1, wireType 2 =*/ 10) + .string(keys[i]) + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.labels[keys[i]]) + .ldelim() + return writer + } + + /** + * Encodes the specified MonitoredResource message, length delimited. Does not implicitly {@link google.api.MonitoredResource.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.MonitoredResource + * @static + * @param {google.api.IMonitoredResource} message MonitoredResource message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MonitoredResource.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a MonitoredResource message from the specified reader or buffer. + * @function decode + * @memberof google.api.MonitoredResource + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.MonitoredResource} MonitoredResource + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MonitoredResource.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.api.MonitoredResource(), + key, + value + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.type = reader.string() + break + case 2: + if (message.labels === $util.emptyObject) + message.labels = {} + var end2 = reader.uint32() + reader.pos + key = '' + value = '' + while (reader.pos < end2) { + var tag2 = reader.uint32() + switch (tag2 >>> 3) { + case 1: + key = reader.string() + break + case 2: + value = reader.string() + break + default: + reader.skipType(tag2 & 7) + break + } + } + message.labels[key] = value + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a MonitoredResource message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.MonitoredResource + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.MonitoredResource} MonitoredResource + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MonitoredResource.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a MonitoredResource message. + * @function verify + * @memberof google.api.MonitoredResource + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + MonitoredResource.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.type != null && message.hasOwnProperty('type')) + if (!$util.isString(message.type)) + return 'type: string expected' + if ( + message.labels != null && + message.hasOwnProperty('labels') + ) { + if (!$util.isObject(message.labels)) + return 'labels: object expected' + var key = Object.keys(message.labels) + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.labels[key[i]])) + return 'labels: string{k:string} expected' + } + return null + } + + /** + * Creates a MonitoredResource message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.MonitoredResource + * @static + * @param {Object.} object Plain object + * @returns {google.api.MonitoredResource} MonitoredResource + */ + MonitoredResource.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.MonitoredResource) + return object + var message = new $root.google.api.MonitoredResource() + if (object.type != null) message.type = String(object.type) + if (object.labels) { + if (typeof object.labels !== 'object') + throw TypeError( + '.google.api.MonitoredResource.labels: object expected' + ) + message.labels = {} + for ( + var keys = Object.keys(object.labels), i = 0; + i < keys.length; + ++i + ) + message.labels[keys[i]] = String(object.labels[keys[i]]) + } + return message + } + + /** + * Creates a plain object from a MonitoredResource message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.MonitoredResource + * @static + * @param {google.api.MonitoredResource} message MonitoredResource + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MonitoredResource.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.objects || options.defaults) object.labels = {} + if (options.defaults) object.type = '' + if (message.type != null && message.hasOwnProperty('type')) + object.type = message.type + var keys2 + if ( + message.labels && + (keys2 = Object.keys(message.labels)).length + ) { + object.labels = {} + for (var j = 0; j < keys2.length; ++j) + object.labels[keys2[j]] = message.labels[keys2[j]] + } + return object + } + + /** + * Converts this MonitoredResource to JSON. + * @function toJSON + * @memberof google.api.MonitoredResource + * @instance + * @returns {Object.} JSON object + */ + MonitoredResource.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return MonitoredResource + })() + + api.MonitoredResourceMetadata = (function () { + /** + * Properties of a MonitoredResourceMetadata. + * @memberof google.api + * @interface IMonitoredResourceMetadata + * @property {google.protobuf.IStruct|null} [systemLabels] MonitoredResourceMetadata systemLabels + * @property {Object.|null} [userLabels] MonitoredResourceMetadata userLabels + */ + + /** + * Constructs a new MonitoredResourceMetadata. + * @memberof google.api + * @classdesc Represents a MonitoredResourceMetadata. + * @implements IMonitoredResourceMetadata + * @constructor + * @param {google.api.IMonitoredResourceMetadata=} [properties] Properties to set + */ + function MonitoredResourceMetadata(properties) { + this.userLabels = {} + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * MonitoredResourceMetadata systemLabels. + * @member {google.protobuf.IStruct|null|undefined} systemLabels + * @memberof google.api.MonitoredResourceMetadata + * @instance + */ + MonitoredResourceMetadata.prototype.systemLabels = null + + /** + * MonitoredResourceMetadata userLabels. + * @member {Object.} userLabels + * @memberof google.api.MonitoredResourceMetadata + * @instance + */ + MonitoredResourceMetadata.prototype.userLabels = $util.emptyObject + + /** + * Creates a new MonitoredResourceMetadata instance using the specified properties. + * @function create + * @memberof google.api.MonitoredResourceMetadata + * @static + * @param {google.api.IMonitoredResourceMetadata=} [properties] Properties to set + * @returns {google.api.MonitoredResourceMetadata} MonitoredResourceMetadata instance + */ + MonitoredResourceMetadata.create = function create(properties) { + return new MonitoredResourceMetadata(properties) + } + + /** + * Encodes the specified MonitoredResourceMetadata message. Does not implicitly {@link google.api.MonitoredResourceMetadata.verify|verify} messages. + * @function encode + * @memberof google.api.MonitoredResourceMetadata + * @static + * @param {google.api.IMonitoredResourceMetadata} message MonitoredResourceMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MonitoredResourceMetadata.encode = function encode( + message, + writer + ) { + if (!writer) writer = $Writer.create() + if ( + message.systemLabels != null && + Object.hasOwnProperty.call(message, 'systemLabels') + ) + $root.google.protobuf.Struct.encode( + message.systemLabels, + writer.uint32(/* id 1, wireType 2 =*/ 10).fork() + ).ldelim() + if ( + message.userLabels != null && + Object.hasOwnProperty.call(message, 'userLabels') + ) + for ( + var keys = Object.keys(message.userLabels), i = 0; + i < keys.length; + ++i + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .fork() + .uint32(/* id 1, wireType 2 =*/ 10) + .string(keys[i]) + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.userLabels[keys[i]]) + .ldelim() + return writer + } + + /** + * Encodes the specified MonitoredResourceMetadata message, length delimited. Does not implicitly {@link google.api.MonitoredResourceMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.MonitoredResourceMetadata + * @static + * @param {google.api.IMonitoredResourceMetadata} message MonitoredResourceMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MonitoredResourceMetadata.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a MonitoredResourceMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.api.MonitoredResourceMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.MonitoredResourceMetadata} MonitoredResourceMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MonitoredResourceMetadata.decode = function decode( + reader, + length + ) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.api.MonitoredResourceMetadata(), + key, + value + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.systemLabels = $root.google.protobuf.Struct.decode( + reader, + reader.uint32() + ) + break + case 2: + if (message.userLabels === $util.emptyObject) + message.userLabels = {} + var end2 = reader.uint32() + reader.pos + key = '' + value = '' + while (reader.pos < end2) { + var tag2 = reader.uint32() + switch (tag2 >>> 3) { + case 1: + key = reader.string() + break + case 2: + value = reader.string() + break + default: + reader.skipType(tag2 & 7) + break + } + } + message.userLabels[key] = value + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a MonitoredResourceMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.MonitoredResourceMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.MonitoredResourceMetadata} MonitoredResourceMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MonitoredResourceMetadata.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a MonitoredResourceMetadata message. + * @function verify + * @memberof google.api.MonitoredResourceMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + MonitoredResourceMetadata.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.systemLabels != null && + message.hasOwnProperty('systemLabels') + ) { + var error = $root.google.protobuf.Struct.verify( + message.systemLabels + ) + if (error) return 'systemLabels.' + error + } + if ( + message.userLabels != null && + message.hasOwnProperty('userLabels') + ) { + if (!$util.isObject(message.userLabels)) + return 'userLabels: object expected' + var key = Object.keys(message.userLabels) + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.userLabels[key[i]])) + return 'userLabels: string{k:string} expected' + } + return null + } + + /** + * Creates a MonitoredResourceMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.MonitoredResourceMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.api.MonitoredResourceMetadata} MonitoredResourceMetadata + */ + MonitoredResourceMetadata.fromObject = function fromObject( + object + ) { + if ( + object instanceof $root.google.api.MonitoredResourceMetadata + ) + return object + var message = new $root.google.api.MonitoredResourceMetadata() + if (object.systemLabels != null) { + if (typeof object.systemLabels !== 'object') + throw TypeError( + '.google.api.MonitoredResourceMetadata.systemLabels: object expected' + ) + message.systemLabels = $root.google.protobuf.Struct.fromObject( + object.systemLabels + ) + } + if (object.userLabels) { + if (typeof object.userLabels !== 'object') + throw TypeError( + '.google.api.MonitoredResourceMetadata.userLabels: object expected' + ) + message.userLabels = {} + for ( + var keys = Object.keys(object.userLabels), i = 0; + i < keys.length; + ++i + ) + message.userLabels[keys[i]] = String( + object.userLabels[keys[i]] + ) + } + return message + } + + /** + * Creates a plain object from a MonitoredResourceMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.MonitoredResourceMetadata + * @static + * @param {google.api.MonitoredResourceMetadata} message MonitoredResourceMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MonitoredResourceMetadata.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.objects || options.defaults) object.userLabels = {} + if (options.defaults) object.systemLabels = null + if ( + message.systemLabels != null && + message.hasOwnProperty('systemLabels') + ) + object.systemLabels = $root.google.protobuf.Struct.toObject( + message.systemLabels, + options + ) + var keys2 + if ( + message.userLabels && + (keys2 = Object.keys(message.userLabels)).length + ) { + object.userLabels = {} + for (var j = 0; j < keys2.length; ++j) + object.userLabels[keys2[j]] = message.userLabels[keys2[j]] + } + return object + } + + /** + * Converts this MonitoredResourceMetadata to JSON. + * @function toJSON + * @memberof google.api.MonitoredResourceMetadata + * @instance + * @returns {Object.} JSON object + */ + MonitoredResourceMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return MonitoredResourceMetadata + })() + + api.LabelDescriptor = (function () { + /** + * Properties of a LabelDescriptor. + * @memberof google.api + * @interface ILabelDescriptor + * @property {string|null} [key] LabelDescriptor key + * @property {google.api.LabelDescriptor.ValueType|null} [valueType] LabelDescriptor valueType + * @property {string|null} [description] LabelDescriptor description + */ + + /** + * Constructs a new LabelDescriptor. + * @memberof google.api + * @classdesc Represents a LabelDescriptor. + * @implements ILabelDescriptor + * @constructor + * @param {google.api.ILabelDescriptor=} [properties] Properties to set + */ + function LabelDescriptor(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * LabelDescriptor key. + * @member {string} key + * @memberof google.api.LabelDescriptor + * @instance + */ + LabelDescriptor.prototype.key = '' + + /** + * LabelDescriptor valueType. + * @member {google.api.LabelDescriptor.ValueType} valueType + * @memberof google.api.LabelDescriptor + * @instance + */ + LabelDescriptor.prototype.valueType = 0 + + /** + * LabelDescriptor description. + * @member {string} description + * @memberof google.api.LabelDescriptor + * @instance + */ + LabelDescriptor.prototype.description = '' + + /** + * Creates a new LabelDescriptor instance using the specified properties. + * @function create + * @memberof google.api.LabelDescriptor + * @static + * @param {google.api.ILabelDescriptor=} [properties] Properties to set + * @returns {google.api.LabelDescriptor} LabelDescriptor instance + */ + LabelDescriptor.create = function create(properties) { + return new LabelDescriptor(properties) + } + + /** + * Encodes the specified LabelDescriptor message. Does not implicitly {@link google.api.LabelDescriptor.verify|verify} messages. + * @function encode + * @memberof google.api.LabelDescriptor + * @static + * @param {google.api.ILabelDescriptor} message LabelDescriptor message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LabelDescriptor.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.key != null && + Object.hasOwnProperty.call(message, 'key') + ) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.key) + if ( + message.valueType != null && + Object.hasOwnProperty.call(message, 'valueType') + ) + writer + .uint32(/* id 2, wireType 0 =*/ 16) + .int32(message.valueType) + if ( + message.description != null && + Object.hasOwnProperty.call(message, 'description') + ) + writer + .uint32(/* id 3, wireType 2 =*/ 26) + .string(message.description) + return writer + } + + /** + * Encodes the specified LabelDescriptor message, length delimited. Does not implicitly {@link google.api.LabelDescriptor.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.LabelDescriptor + * @static + * @param {google.api.ILabelDescriptor} message LabelDescriptor message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LabelDescriptor.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a LabelDescriptor message from the specified reader or buffer. + * @function decode + * @memberof google.api.LabelDescriptor + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.LabelDescriptor} LabelDescriptor + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LabelDescriptor.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.api.LabelDescriptor() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.key = reader.string() + break + case 2: + message.valueType = reader.int32() + break + case 3: + message.description = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a LabelDescriptor message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.LabelDescriptor + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.LabelDescriptor} LabelDescriptor + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LabelDescriptor.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a LabelDescriptor message. + * @function verify + * @memberof google.api.LabelDescriptor + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + LabelDescriptor.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.key != null && message.hasOwnProperty('key')) + if (!$util.isString(message.key)) + return 'key: string expected' + if ( + message.valueType != null && + message.hasOwnProperty('valueType') + ) + switch (message.valueType) { + default: + return 'valueType: enum value expected' + case 0: + case 1: + case 2: + break + } + if ( + message.description != null && + message.hasOwnProperty('description') + ) + if (!$util.isString(message.description)) + return 'description: string expected' + return null + } + + /** + * Creates a LabelDescriptor message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.LabelDescriptor + * @static + * @param {Object.} object Plain object + * @returns {google.api.LabelDescriptor} LabelDescriptor + */ + LabelDescriptor.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.LabelDescriptor) + return object + var message = new $root.google.api.LabelDescriptor() + if (object.key != null) message.key = String(object.key) + switch (object.valueType) { + case 'STRING': + case 0: + message.valueType = 0 + break + case 'BOOL': + case 1: + message.valueType = 1 + break + case 'INT64': + case 2: + message.valueType = 2 + break + } + if (object.description != null) + message.description = String(object.description) + return message + } + + /** + * Creates a plain object from a LabelDescriptor message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.LabelDescriptor + * @static + * @param {google.api.LabelDescriptor} message LabelDescriptor + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + LabelDescriptor.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.key = '' + object.valueType = options.enums === String ? 'STRING' : 0 + object.description = '' + } + if (message.key != null && message.hasOwnProperty('key')) + object.key = message.key + if ( + message.valueType != null && + message.hasOwnProperty('valueType') + ) + object.valueType = + options.enums === String + ? $root.google.api.LabelDescriptor.ValueType[ + message.valueType + ] + : message.valueType + if ( + message.description != null && + message.hasOwnProperty('description') + ) + object.description = message.description + return object + } + + /** + * Converts this LabelDescriptor to JSON. + * @function toJSON + * @memberof google.api.LabelDescriptor + * @instance + * @returns {Object.} JSON object + */ + LabelDescriptor.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + /** + * ValueType enum. + * @name google.api.LabelDescriptor.ValueType + * @enum {number} + * @property {number} STRING=0 STRING value + * @property {number} BOOL=1 BOOL value + * @property {number} INT64=2 INT64 value + */ + LabelDescriptor.ValueType = (function () { + var valuesById = {}, + values = Object.create(valuesById) + values[(valuesById[0] = 'STRING')] = 0 + values[(valuesById[1] = 'BOOL')] = 1 + values[(valuesById[2] = 'INT64')] = 2 + return values + })() + + return LabelDescriptor + })() + + /** + * LaunchStage enum. + * @name google.api.LaunchStage + * @enum {number} + * @property {number} LAUNCH_STAGE_UNSPECIFIED=0 LAUNCH_STAGE_UNSPECIFIED value + * @property {number} UNIMPLEMENTED=6 UNIMPLEMENTED value + * @property {number} PRELAUNCH=7 PRELAUNCH value + * @property {number} EARLY_ACCESS=1 EARLY_ACCESS value + * @property {number} ALPHA=2 ALPHA value + * @property {number} BETA=3 BETA value + * @property {number} GA=4 GA value + * @property {number} DEPRECATED=5 DEPRECATED value + */ + api.LaunchStage = (function () { + var valuesById = {}, + values = Object.create(valuesById) + values[(valuesById[0] = 'LAUNCH_STAGE_UNSPECIFIED')] = 0 + values[(valuesById[6] = 'UNIMPLEMENTED')] = 6 + values[(valuesById[7] = 'PRELAUNCH')] = 7 + values[(valuesById[1] = 'EARLY_ACCESS')] = 1 + values[(valuesById[2] = 'ALPHA')] = 2 + values[(valuesById[3] = 'BETA')] = 3 + values[(valuesById[4] = 'GA')] = 4 + values[(valuesById[5] = 'DEPRECATED')] = 5 + return values + })() + + api.ResourceDescriptor = (function () { + /** + * Properties of a ResourceDescriptor. + * @memberof google.api + * @interface IResourceDescriptor + * @property {string|null} [type] ResourceDescriptor type + * @property {Array.|null} [pattern] ResourceDescriptor pattern + * @property {string|null} [nameField] ResourceDescriptor nameField + * @property {google.api.ResourceDescriptor.History|null} [history] ResourceDescriptor history + * @property {string|null} [plural] ResourceDescriptor plural + * @property {string|null} [singular] ResourceDescriptor singular + */ + + /** + * Constructs a new ResourceDescriptor. + * @memberof google.api + * @classdesc Represents a ResourceDescriptor. + * @implements IResourceDescriptor + * @constructor + * @param {google.api.IResourceDescriptor=} [properties] Properties to set + */ + function ResourceDescriptor(properties) { + this.pattern = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * ResourceDescriptor type. + * @member {string} type + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.type = '' + + /** + * ResourceDescriptor pattern. + * @member {Array.} pattern + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.pattern = $util.emptyArray + + /** + * ResourceDescriptor nameField. + * @member {string} nameField + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.nameField = '' + + /** + * ResourceDescriptor history. + * @member {google.api.ResourceDescriptor.History} history + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.history = 0 + + /** + * ResourceDescriptor plural. + * @member {string} plural + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.plural = '' + + /** + * ResourceDescriptor singular. + * @member {string} singular + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.singular = '' + + /** + * Creates a new ResourceDescriptor instance using the specified properties. + * @function create + * @memberof google.api.ResourceDescriptor + * @static + * @param {google.api.IResourceDescriptor=} [properties] Properties to set + * @returns {google.api.ResourceDescriptor} ResourceDescriptor instance + */ + ResourceDescriptor.create = function create(properties) { + return new ResourceDescriptor(properties) + } + + /** + * Encodes the specified ResourceDescriptor message. Does not implicitly {@link google.api.ResourceDescriptor.verify|verify} messages. + * @function encode + * @memberof google.api.ResourceDescriptor + * @static + * @param {google.api.IResourceDescriptor} message ResourceDescriptor message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResourceDescriptor.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.type != null && + Object.hasOwnProperty.call(message, 'type') + ) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.type) + if (message.pattern != null && message.pattern.length) + for (var i = 0; i < message.pattern.length; ++i) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.pattern[i]) + if ( + message.nameField != null && + Object.hasOwnProperty.call(message, 'nameField') + ) + writer + .uint32(/* id 3, wireType 2 =*/ 26) + .string(message.nameField) + if ( + message.history != null && + Object.hasOwnProperty.call(message, 'history') + ) + writer + .uint32(/* id 4, wireType 0 =*/ 32) + .int32(message.history) + if ( + message.plural != null && + Object.hasOwnProperty.call(message, 'plural') + ) + writer + .uint32(/* id 5, wireType 2 =*/ 42) + .string(message.plural) + if ( + message.singular != null && + Object.hasOwnProperty.call(message, 'singular') + ) + writer + .uint32(/* id 6, wireType 2 =*/ 50) + .string(message.singular) + return writer + } + + /** + * Encodes the specified ResourceDescriptor message, length delimited. Does not implicitly {@link google.api.ResourceDescriptor.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.ResourceDescriptor + * @static + * @param {google.api.IResourceDescriptor} message ResourceDescriptor message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResourceDescriptor.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a ResourceDescriptor message from the specified reader or buffer. + * @function decode + * @memberof google.api.ResourceDescriptor + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.ResourceDescriptor} ResourceDescriptor + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResourceDescriptor.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.api.ResourceDescriptor() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.type = reader.string() + break + case 2: + if (!(message.pattern && message.pattern.length)) + message.pattern = [] + message.pattern.push(reader.string()) + break + case 3: + message.nameField = reader.string() + break + case 4: + message.history = reader.int32() + break + case 5: + message.plural = reader.string() + break + case 6: + message.singular = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a ResourceDescriptor message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.ResourceDescriptor + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.ResourceDescriptor} ResourceDescriptor + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResourceDescriptor.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a ResourceDescriptor message. + * @function verify + * @memberof google.api.ResourceDescriptor + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ResourceDescriptor.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.type != null && message.hasOwnProperty('type')) + if (!$util.isString(message.type)) + return 'type: string expected' + if ( + message.pattern != null && + message.hasOwnProperty('pattern') + ) { + if (!Array.isArray(message.pattern)) + return 'pattern: array expected' + for (var i = 0; i < message.pattern.length; ++i) + if (!$util.isString(message.pattern[i])) + return 'pattern: string[] expected' + } + if ( + message.nameField != null && + message.hasOwnProperty('nameField') + ) + if (!$util.isString(message.nameField)) + return 'nameField: string expected' + if ( + message.history != null && + message.hasOwnProperty('history') + ) + switch (message.history) { + default: + return 'history: enum value expected' + case 0: + case 1: + case 2: + break + } + if (message.plural != null && message.hasOwnProperty('plural')) + if (!$util.isString(message.plural)) + return 'plural: string expected' + if ( + message.singular != null && + message.hasOwnProperty('singular') + ) + if (!$util.isString(message.singular)) + return 'singular: string expected' + return null + } + + /** + * Creates a ResourceDescriptor message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.ResourceDescriptor + * @static + * @param {Object.} object Plain object + * @returns {google.api.ResourceDescriptor} ResourceDescriptor + */ + ResourceDescriptor.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.ResourceDescriptor) + return object + var message = new $root.google.api.ResourceDescriptor() + if (object.type != null) message.type = String(object.type) + if (object.pattern) { + if (!Array.isArray(object.pattern)) + throw TypeError( + '.google.api.ResourceDescriptor.pattern: array expected' + ) + message.pattern = [] + for (var i = 0; i < object.pattern.length; ++i) + message.pattern[i] = String(object.pattern[i]) + } + if (object.nameField != null) + message.nameField = String(object.nameField) + switch (object.history) { + case 'HISTORY_UNSPECIFIED': + case 0: + message.history = 0 + break + case 'ORIGINALLY_SINGLE_PATTERN': + case 1: + message.history = 1 + break + case 'FUTURE_MULTI_PATTERN': + case 2: + message.history = 2 + break + } + if (object.plural != null) + message.plural = String(object.plural) + if (object.singular != null) + message.singular = String(object.singular) + return message + } + + /** + * Creates a plain object from a ResourceDescriptor message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.ResourceDescriptor + * @static + * @param {google.api.ResourceDescriptor} message ResourceDescriptor + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ResourceDescriptor.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) object.pattern = [] + if (options.defaults) { + object.type = '' + object.nameField = '' + object.history = + options.enums === String ? 'HISTORY_UNSPECIFIED' : 0 + object.plural = '' + object.singular = '' + } + if (message.type != null && message.hasOwnProperty('type')) + object.type = message.type + if (message.pattern && message.pattern.length) { + object.pattern = [] + for (var j = 0; j < message.pattern.length; ++j) + object.pattern[j] = message.pattern[j] + } + if ( + message.nameField != null && + message.hasOwnProperty('nameField') + ) + object.nameField = message.nameField + if ( + message.history != null && + message.hasOwnProperty('history') + ) + object.history = + options.enums === String + ? $root.google.api.ResourceDescriptor.History[ + message.history + ] + : message.history + if (message.plural != null && message.hasOwnProperty('plural')) + object.plural = message.plural + if ( + message.singular != null && + message.hasOwnProperty('singular') + ) + object.singular = message.singular + return object + } + + /** + * Converts this ResourceDescriptor to JSON. + * @function toJSON + * @memberof google.api.ResourceDescriptor + * @instance + * @returns {Object.} JSON object + */ + ResourceDescriptor.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + /** + * History enum. + * @name google.api.ResourceDescriptor.History + * @enum {number} + * @property {number} HISTORY_UNSPECIFIED=0 HISTORY_UNSPECIFIED value + * @property {number} ORIGINALLY_SINGLE_PATTERN=1 ORIGINALLY_SINGLE_PATTERN value + * @property {number} FUTURE_MULTI_PATTERN=2 FUTURE_MULTI_PATTERN value + */ + ResourceDescriptor.History = (function () { + var valuesById = {}, + values = Object.create(valuesById) + values[(valuesById[0] = 'HISTORY_UNSPECIFIED')] = 0 + values[(valuesById[1] = 'ORIGINALLY_SINGLE_PATTERN')] = 1 + values[(valuesById[2] = 'FUTURE_MULTI_PATTERN')] = 2 + return values + })() + + return ResourceDescriptor + })() + + api.ResourceReference = (function () { + /** + * Properties of a ResourceReference. + * @memberof google.api + * @interface IResourceReference + * @property {string|null} [type] ResourceReference type + * @property {string|null} [childType] ResourceReference childType + */ + + /** + * Constructs a new ResourceReference. + * @memberof google.api + * @classdesc Represents a ResourceReference. + * @implements IResourceReference + * @constructor + * @param {google.api.IResourceReference=} [properties] Properties to set + */ + function ResourceReference(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * ResourceReference type. + * @member {string} type + * @memberof google.api.ResourceReference + * @instance + */ + ResourceReference.prototype.type = '' + + /** + * ResourceReference childType. + * @member {string} childType + * @memberof google.api.ResourceReference + * @instance + */ + ResourceReference.prototype.childType = '' + + /** + * Creates a new ResourceReference instance using the specified properties. + * @function create + * @memberof google.api.ResourceReference + * @static + * @param {google.api.IResourceReference=} [properties] Properties to set + * @returns {google.api.ResourceReference} ResourceReference instance + */ + ResourceReference.create = function create(properties) { + return new ResourceReference(properties) + } + + /** + * Encodes the specified ResourceReference message. Does not implicitly {@link google.api.ResourceReference.verify|verify} messages. + * @function encode + * @memberof google.api.ResourceReference + * @static + * @param {google.api.IResourceReference} message ResourceReference message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResourceReference.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.type != null && + Object.hasOwnProperty.call(message, 'type') + ) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.type) + if ( + message.childType != null && + Object.hasOwnProperty.call(message, 'childType') + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.childType) + return writer + } + + /** + * Encodes the specified ResourceReference message, length delimited. Does not implicitly {@link google.api.ResourceReference.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.ResourceReference + * @static + * @param {google.api.IResourceReference} message ResourceReference message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResourceReference.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a ResourceReference message from the specified reader or buffer. + * @function decode + * @memberof google.api.ResourceReference + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.ResourceReference} ResourceReference + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResourceReference.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.api.ResourceReference() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.type = reader.string() + break + case 2: + message.childType = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a ResourceReference message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.ResourceReference + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.ResourceReference} ResourceReference + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResourceReference.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a ResourceReference message. + * @function verify + * @memberof google.api.ResourceReference + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ResourceReference.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.type != null && message.hasOwnProperty('type')) + if (!$util.isString(message.type)) + return 'type: string expected' + if ( + message.childType != null && + message.hasOwnProperty('childType') + ) + if (!$util.isString(message.childType)) + return 'childType: string expected' + return null + } + + /** + * Creates a ResourceReference message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.ResourceReference + * @static + * @param {Object.} object Plain object + * @returns {google.api.ResourceReference} ResourceReference + */ + ResourceReference.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.ResourceReference) + return object + var message = new $root.google.api.ResourceReference() + if (object.type != null) message.type = String(object.type) + if (object.childType != null) + message.childType = String(object.childType) + return message + } + + /** + * Creates a plain object from a ResourceReference message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.ResourceReference + * @static + * @param {google.api.ResourceReference} message ResourceReference + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ResourceReference.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.type = '' + object.childType = '' + } + if (message.type != null && message.hasOwnProperty('type')) + object.type = message.type + if ( + message.childType != null && + message.hasOwnProperty('childType') + ) + object.childType = message.childType + return object + } + + /** + * Converts this ResourceReference to JSON. + * @function toJSON + * @memberof google.api.ResourceReference + * @instance + * @returns {Object.} JSON object + */ + ResourceReference.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return ResourceReference + })() + + api.Http = (function () { + /** + * Properties of a Http. + * @memberof google.api + * @interface IHttp + * @property {Array.|null} [rules] Http rules + * @property {boolean|null} [fullyDecodeReservedExpansion] Http fullyDecodeReservedExpansion + */ + + /** + * Constructs a new Http. + * @memberof google.api + * @classdesc Represents a Http. + * @implements IHttp + * @constructor + * @param {google.api.IHttp=} [properties] Properties to set + */ + function Http(properties) { + this.rules = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * Http rules. + * @member {Array.} rules + * @memberof google.api.Http + * @instance + */ + Http.prototype.rules = $util.emptyArray + + /** + * Http fullyDecodeReservedExpansion. + * @member {boolean} fullyDecodeReservedExpansion + * @memberof google.api.Http + * @instance + */ + Http.prototype.fullyDecodeReservedExpansion = false + + /** + * Creates a new Http instance using the specified properties. + * @function create + * @memberof google.api.Http + * @static + * @param {google.api.IHttp=} [properties] Properties to set + * @returns {google.api.Http} Http instance + */ + Http.create = function create(properties) { + return new Http(properties) + } + + /** + * Encodes the specified Http message. Does not implicitly {@link google.api.Http.verify|verify} messages. + * @function encode + * @memberof google.api.Http + * @static + * @param {google.api.IHttp} message Http message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Http.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.rules != null && message.rules.length) + for (var i = 0; i < message.rules.length; ++i) + $root.google.api.HttpRule.encode( + message.rules[i], + writer.uint32(/* id 1, wireType 2 =*/ 10).fork() + ).ldelim() + if ( + message.fullyDecodeReservedExpansion != null && + Object.hasOwnProperty.call( + message, + 'fullyDecodeReservedExpansion' + ) + ) + writer + .uint32(/* id 2, wireType 0 =*/ 16) + .bool(message.fullyDecodeReservedExpansion) + return writer + } + + /** + * Encodes the specified Http message, length delimited. Does not implicitly {@link google.api.Http.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.Http + * @static + * @param {google.api.IHttp} message Http message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Http.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a Http message from the specified reader or buffer. + * @function decode + * @memberof google.api.Http + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.Http} Http + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Http.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.api.Http() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + if (!(message.rules && message.rules.length)) + message.rules = [] + message.rules.push( + $root.google.api.HttpRule.decode( + reader, + reader.uint32() + ) + ) + break + case 2: + message.fullyDecodeReservedExpansion = reader.bool() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a Http message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.Http + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.Http} Http + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Http.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a Http message. + * @function verify + * @memberof google.api.Http + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Http.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.rules != null && message.hasOwnProperty('rules')) { + if (!Array.isArray(message.rules)) + return 'rules: array expected' + for (var i = 0; i < message.rules.length; ++i) { + var error = $root.google.api.HttpRule.verify( + message.rules[i] + ) + if (error) return 'rules.' + error + } + } + if ( + message.fullyDecodeReservedExpansion != null && + message.hasOwnProperty('fullyDecodeReservedExpansion') + ) + if (typeof message.fullyDecodeReservedExpansion !== 'boolean') + return 'fullyDecodeReservedExpansion: boolean expected' + return null + } + + /** + * Creates a Http message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.Http + * @static + * @param {Object.} object Plain object + * @returns {google.api.Http} Http + */ + Http.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.Http) return object + var message = new $root.google.api.Http() + if (object.rules) { + if (!Array.isArray(object.rules)) + throw TypeError('.google.api.Http.rules: array expected') + message.rules = [] + for (var i = 0; i < object.rules.length; ++i) { + if (typeof object.rules[i] !== 'object') + throw TypeError('.google.api.Http.rules: object expected') + message.rules[i] = $root.google.api.HttpRule.fromObject( + object.rules[i] + ) + } + } + if (object.fullyDecodeReservedExpansion != null) + message.fullyDecodeReservedExpansion = Boolean( + object.fullyDecodeReservedExpansion + ) + return message + } + + /** + * Creates a plain object from a Http message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.Http + * @static + * @param {google.api.Http} message Http + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Http.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) object.rules = [] + if (options.defaults) + object.fullyDecodeReservedExpansion = false + if (message.rules && message.rules.length) { + object.rules = [] + for (var j = 0; j < message.rules.length; ++j) + object.rules[j] = $root.google.api.HttpRule.toObject( + message.rules[j], + options + ) + } + if ( + message.fullyDecodeReservedExpansion != null && + message.hasOwnProperty('fullyDecodeReservedExpansion') + ) + object.fullyDecodeReservedExpansion = + message.fullyDecodeReservedExpansion + return object + } + + /** + * Converts this Http to JSON. + * @function toJSON + * @memberof google.api.Http + * @instance + * @returns {Object.} JSON object + */ + Http.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return Http + })() + + api.HttpRule = (function () { + /** + * Properties of a HttpRule. + * @memberof google.api + * @interface IHttpRule + * @property {string|null} [selector] HttpRule selector + * @property {string|null} [get] HttpRule get + * @property {string|null} [put] HttpRule put + * @property {string|null} [post] HttpRule post + * @property {string|null} ["delete"] HttpRule delete + * @property {string|null} [patch] HttpRule patch + * @property {google.api.ICustomHttpPattern|null} [custom] HttpRule custom + * @property {string|null} [body] HttpRule body + * @property {string|null} [responseBody] HttpRule responseBody + * @property {Array.|null} [additionalBindings] HttpRule additionalBindings + */ + + /** + * Constructs a new HttpRule. + * @memberof google.api + * @classdesc Represents a HttpRule. + * @implements IHttpRule + * @constructor + * @param {google.api.IHttpRule=} [properties] Properties to set + */ + function HttpRule(properties) { + this.additionalBindings = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * HttpRule selector. + * @member {string} selector + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.selector = '' + + /** + * HttpRule get. + * @member {string} get + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.get = '' + + /** + * HttpRule put. + * @member {string} put + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.put = '' + + /** + * HttpRule post. + * @member {string} post + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.post = '' + + /** + * HttpRule delete. + * @member {string} delete + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype['delete'] = '' + + /** + * HttpRule patch. + * @member {string} patch + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.patch = '' + + /** + * HttpRule custom. + * @member {google.api.ICustomHttpPattern|null|undefined} custom + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.custom = null + + /** + * HttpRule body. + * @member {string} body + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.body = '' + + /** + * HttpRule responseBody. + * @member {string} responseBody + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.responseBody = '' + + /** + * HttpRule additionalBindings. + * @member {Array.} additionalBindings + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.additionalBindings = $util.emptyArray + + // OneOf field names bound to virtual getters and setters + var $oneOfFields + + /** + * HttpRule pattern. + * @member {"get"|"put"|"post"|"delete"|"patch"|"custom"|undefined} pattern + * @memberof google.api.HttpRule + * @instance + */ + Object.defineProperty(HttpRule.prototype, 'pattern', { + get: $util.oneOfGetter( + ($oneOfFields = [ + 'get', + 'put', + 'post', + 'delete', + 'patch', + 'custom' + ]) + ), + set: $util.oneOfSetter($oneOfFields) + }) + + /** + * Creates a new HttpRule instance using the specified properties. + * @function create + * @memberof google.api.HttpRule + * @static + * @param {google.api.IHttpRule=} [properties] Properties to set + * @returns {google.api.HttpRule} HttpRule instance + */ + HttpRule.create = function create(properties) { + return new HttpRule(properties) + } + + /** + * Encodes the specified HttpRule message. Does not implicitly {@link google.api.HttpRule.verify|verify} messages. + * @function encode + * @memberof google.api.HttpRule + * @static + * @param {google.api.IHttpRule} message HttpRule message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + HttpRule.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.selector != null && + Object.hasOwnProperty.call(message, 'selector') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.selector) + if ( + message.get != null && + Object.hasOwnProperty.call(message, 'get') + ) + writer.uint32(/* id 2, wireType 2 =*/ 18).string(message.get) + if ( + message.put != null && + Object.hasOwnProperty.call(message, 'put') + ) + writer.uint32(/* id 3, wireType 2 =*/ 26).string(message.put) + if ( + message.post != null && + Object.hasOwnProperty.call(message, 'post') + ) + writer.uint32(/* id 4, wireType 2 =*/ 34).string(message.post) + if ( + message['delete'] != null && + Object.hasOwnProperty.call(message, 'delete') + ) + writer + .uint32(/* id 5, wireType 2 =*/ 42) + .string(message['delete']) + if ( + message.patch != null && + Object.hasOwnProperty.call(message, 'patch') + ) + writer + .uint32(/* id 6, wireType 2 =*/ 50) + .string(message.patch) + if ( + message.body != null && + Object.hasOwnProperty.call(message, 'body') + ) + writer.uint32(/* id 7, wireType 2 =*/ 58).string(message.body) + if ( + message.custom != null && + Object.hasOwnProperty.call(message, 'custom') + ) + $root.google.api.CustomHttpPattern.encode( + message.custom, + writer.uint32(/* id 8, wireType 2 =*/ 66).fork() + ).ldelim() + if ( + message.additionalBindings != null && + message.additionalBindings.length + ) + for (var i = 0; i < message.additionalBindings.length; ++i) + $root.google.api.HttpRule.encode( + message.additionalBindings[i], + writer.uint32(/* id 11, wireType 2 =*/ 90).fork() + ).ldelim() + if ( + message.responseBody != null && + Object.hasOwnProperty.call(message, 'responseBody') + ) + writer + .uint32(/* id 12, wireType 2 =*/ 98) + .string(message.responseBody) + return writer + } + + /** + * Encodes the specified HttpRule message, length delimited. Does not implicitly {@link google.api.HttpRule.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.HttpRule + * @static + * @param {google.api.IHttpRule} message HttpRule message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + HttpRule.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a HttpRule message from the specified reader or buffer. + * @function decode + * @memberof google.api.HttpRule + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.HttpRule} HttpRule + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + HttpRule.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.api.HttpRule() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.selector = reader.string() + break + case 2: + message.get = reader.string() + break + case 3: + message.put = reader.string() + break + case 4: + message.post = reader.string() + break + case 5: + message['delete'] = reader.string() + break + case 6: + message.patch = reader.string() + break + case 8: + message.custom = $root.google.api.CustomHttpPattern.decode( + reader, + reader.uint32() + ) + break + case 7: + message.body = reader.string() + break + case 12: + message.responseBody = reader.string() + break + case 11: + if ( + !( + message.additionalBindings && + message.additionalBindings.length + ) + ) + message.additionalBindings = [] + message.additionalBindings.push( + $root.google.api.HttpRule.decode( + reader, + reader.uint32() + ) + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a HttpRule message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.HttpRule + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.HttpRule} HttpRule + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + HttpRule.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a HttpRule message. + * @function verify + * @memberof google.api.HttpRule + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + HttpRule.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + var properties = {} + if ( + message.selector != null && + message.hasOwnProperty('selector') + ) + if (!$util.isString(message.selector)) + return 'selector: string expected' + if (message.get != null && message.hasOwnProperty('get')) { + properties.pattern = 1 + if (!$util.isString(message.get)) + return 'get: string expected' + } + if (message.put != null && message.hasOwnProperty('put')) { + if (properties.pattern === 1) + return 'pattern: multiple values' + properties.pattern = 1 + if (!$util.isString(message.put)) + return 'put: string expected' + } + if (message.post != null && message.hasOwnProperty('post')) { + if (properties.pattern === 1) + return 'pattern: multiple values' + properties.pattern = 1 + if (!$util.isString(message.post)) + return 'post: string expected' + } + if ( + message['delete'] != null && + message.hasOwnProperty('delete') + ) { + if (properties.pattern === 1) + return 'pattern: multiple values' + properties.pattern = 1 + if (!$util.isString(message['delete'])) + return 'delete: string expected' + } + if (message.patch != null && message.hasOwnProperty('patch')) { + if (properties.pattern === 1) + return 'pattern: multiple values' + properties.pattern = 1 + if (!$util.isString(message.patch)) + return 'patch: string expected' + } + if ( + message.custom != null && + message.hasOwnProperty('custom') + ) { + if (properties.pattern === 1) + return 'pattern: multiple values' + properties.pattern = 1 + { + var error = $root.google.api.CustomHttpPattern.verify( + message.custom + ) + if (error) return 'custom.' + error + } + } + if (message.body != null && message.hasOwnProperty('body')) + if (!$util.isString(message.body)) + return 'body: string expected' + if ( + message.responseBody != null && + message.hasOwnProperty('responseBody') + ) + if (!$util.isString(message.responseBody)) + return 'responseBody: string expected' + if ( + message.additionalBindings != null && + message.hasOwnProperty('additionalBindings') + ) { + if (!Array.isArray(message.additionalBindings)) + return 'additionalBindings: array expected' + for (var i = 0; i < message.additionalBindings.length; ++i) { + var error = $root.google.api.HttpRule.verify( + message.additionalBindings[i] + ) + if (error) return 'additionalBindings.' + error + } + } + return null + } + + /** + * Creates a HttpRule message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.HttpRule + * @static + * @param {Object.} object Plain object + * @returns {google.api.HttpRule} HttpRule + */ + HttpRule.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.HttpRule) return object + var message = new $root.google.api.HttpRule() + if (object.selector != null) + message.selector = String(object.selector) + if (object.get != null) message.get = String(object.get) + if (object.put != null) message.put = String(object.put) + if (object.post != null) message.post = String(object.post) + if (object['delete'] != null) + message['delete'] = String(object['delete']) + if (object.patch != null) message.patch = String(object.patch) + if (object.custom != null) { + if (typeof object.custom !== 'object') + throw TypeError( + '.google.api.HttpRule.custom: object expected' + ) + message.custom = $root.google.api.CustomHttpPattern.fromObject( + object.custom + ) + } + if (object.body != null) message.body = String(object.body) + if (object.responseBody != null) + message.responseBody = String(object.responseBody) + if (object.additionalBindings) { + if (!Array.isArray(object.additionalBindings)) + throw TypeError( + '.google.api.HttpRule.additionalBindings: array expected' + ) + message.additionalBindings = [] + for (var i = 0; i < object.additionalBindings.length; ++i) { + if (typeof object.additionalBindings[i] !== 'object') + throw TypeError( + '.google.api.HttpRule.additionalBindings: object expected' + ) + message.additionalBindings[ + i + ] = $root.google.api.HttpRule.fromObject( + object.additionalBindings[i] + ) + } + } + return message + } + + /** + * Creates a plain object from a HttpRule message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.HttpRule + * @static + * @param {google.api.HttpRule} message HttpRule + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + HttpRule.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) + object.additionalBindings = [] + if (options.defaults) { + object.selector = '' + object.body = '' + object.responseBody = '' + } + if ( + message.selector != null && + message.hasOwnProperty('selector') + ) + object.selector = message.selector + if (message.get != null && message.hasOwnProperty('get')) { + object.get = message.get + if (options.oneofs) object.pattern = 'get' + } + if (message.put != null && message.hasOwnProperty('put')) { + object.put = message.put + if (options.oneofs) object.pattern = 'put' + } + if (message.post != null && message.hasOwnProperty('post')) { + object.post = message.post + if (options.oneofs) object.pattern = 'post' + } + if ( + message['delete'] != null && + message.hasOwnProperty('delete') + ) { + object['delete'] = message['delete'] + if (options.oneofs) object.pattern = 'delete' + } + if (message.patch != null && message.hasOwnProperty('patch')) { + object.patch = message.patch + if (options.oneofs) object.pattern = 'patch' + } + if (message.body != null && message.hasOwnProperty('body')) + object.body = message.body + if ( + message.custom != null && + message.hasOwnProperty('custom') + ) { + object.custom = $root.google.api.CustomHttpPattern.toObject( + message.custom, + options + ) + if (options.oneofs) object.pattern = 'custom' + } + if ( + message.additionalBindings && + message.additionalBindings.length + ) { + object.additionalBindings = [] + for (var j = 0; j < message.additionalBindings.length; ++j) + object.additionalBindings[ + j + ] = $root.google.api.HttpRule.toObject( + message.additionalBindings[j], + options + ) + } + if ( + message.responseBody != null && + message.hasOwnProperty('responseBody') + ) + object.responseBody = message.responseBody + return object + } + + /** + * Converts this HttpRule to JSON. + * @function toJSON + * @memberof google.api.HttpRule + * @instance + * @returns {Object.} JSON object + */ + HttpRule.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return HttpRule + })() + + api.CustomHttpPattern = (function () { + /** + * Properties of a CustomHttpPattern. + * @memberof google.api + * @interface ICustomHttpPattern + * @property {string|null} [kind] CustomHttpPattern kind + * @property {string|null} [path] CustomHttpPattern path + */ + + /** + * Constructs a new CustomHttpPattern. + * @memberof google.api + * @classdesc Represents a CustomHttpPattern. + * @implements ICustomHttpPattern + * @constructor + * @param {google.api.ICustomHttpPattern=} [properties] Properties to set + */ + function CustomHttpPattern(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * CustomHttpPattern kind. + * @member {string} kind + * @memberof google.api.CustomHttpPattern + * @instance + */ + CustomHttpPattern.prototype.kind = '' + + /** + * CustomHttpPattern path. + * @member {string} path + * @memberof google.api.CustomHttpPattern + * @instance + */ + CustomHttpPattern.prototype.path = '' + + /** + * Creates a new CustomHttpPattern instance using the specified properties. + * @function create + * @memberof google.api.CustomHttpPattern + * @static + * @param {google.api.ICustomHttpPattern=} [properties] Properties to set + * @returns {google.api.CustomHttpPattern} CustomHttpPattern instance + */ + CustomHttpPattern.create = function create(properties) { + return new CustomHttpPattern(properties) + } + + /** + * Encodes the specified CustomHttpPattern message. Does not implicitly {@link google.api.CustomHttpPattern.verify|verify} messages. + * @function encode + * @memberof google.api.CustomHttpPattern + * @static + * @param {google.api.ICustomHttpPattern} message CustomHttpPattern message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CustomHttpPattern.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.kind != null && + Object.hasOwnProperty.call(message, 'kind') + ) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.kind) + if ( + message.path != null && + Object.hasOwnProperty.call(message, 'path') + ) + writer.uint32(/* id 2, wireType 2 =*/ 18).string(message.path) + return writer + } + + /** + * Encodes the specified CustomHttpPattern message, length delimited. Does not implicitly {@link google.api.CustomHttpPattern.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.CustomHttpPattern + * @static + * @param {google.api.ICustomHttpPattern} message CustomHttpPattern message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CustomHttpPattern.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a CustomHttpPattern message from the specified reader or buffer. + * @function decode + * @memberof google.api.CustomHttpPattern + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.CustomHttpPattern} CustomHttpPattern + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CustomHttpPattern.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.api.CustomHttpPattern() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.kind = reader.string() + break + case 2: + message.path = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a CustomHttpPattern message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.CustomHttpPattern + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.CustomHttpPattern} CustomHttpPattern + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CustomHttpPattern.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a CustomHttpPattern message. + * @function verify + * @memberof google.api.CustomHttpPattern + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CustomHttpPattern.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.kind != null && message.hasOwnProperty('kind')) + if (!$util.isString(message.kind)) + return 'kind: string expected' + if (message.path != null && message.hasOwnProperty('path')) + if (!$util.isString(message.path)) + return 'path: string expected' + return null + } + + /** + * Creates a CustomHttpPattern message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.CustomHttpPattern + * @static + * @param {Object.} object Plain object + * @returns {google.api.CustomHttpPattern} CustomHttpPattern + */ + CustomHttpPattern.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.CustomHttpPattern) + return object + var message = new $root.google.api.CustomHttpPattern() + if (object.kind != null) message.kind = String(object.kind) + if (object.path != null) message.path = String(object.path) + return message + } + + /** + * Creates a plain object from a CustomHttpPattern message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.CustomHttpPattern + * @static + * @param {google.api.CustomHttpPattern} message CustomHttpPattern + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CustomHttpPattern.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.kind = '' + object.path = '' + } + if (message.kind != null && message.hasOwnProperty('kind')) + object.kind = message.kind + if (message.path != null && message.hasOwnProperty('path')) + object.path = message.path + return object + } + + /** + * Converts this CustomHttpPattern to JSON. + * @function toJSON + * @memberof google.api.CustomHttpPattern + * @instance + * @returns {Object.} JSON object + */ + CustomHttpPattern.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return CustomHttpPattern + })() + + api.Distribution = (function () { + /** + * Properties of a Distribution. + * @memberof google.api + * @interface IDistribution + * @property {number|Long|null} [count] Distribution count + * @property {number|null} [mean] Distribution mean + * @property {number|null} [sumOfSquaredDeviation] Distribution sumOfSquaredDeviation + * @property {google.api.Distribution.IRange|null} [range] Distribution range + * @property {google.api.Distribution.IBucketOptions|null} [bucketOptions] Distribution bucketOptions + * @property {Array.|null} [bucketCounts] Distribution bucketCounts + * @property {Array.|null} [exemplars] Distribution exemplars + */ + + /** + * Constructs a new Distribution. + * @memberof google.api + * @classdesc Represents a Distribution. + * @implements IDistribution + * @constructor + * @param {google.api.IDistribution=} [properties] Properties to set + */ + function Distribution(properties) { + this.bucketCounts = [] + this.exemplars = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * Distribution count. + * @member {number|Long} count + * @memberof google.api.Distribution + * @instance + */ + Distribution.prototype.count = $util.Long + ? $util.Long.fromBits(0, 0, false) + : 0 + + /** + * Distribution mean. + * @member {number} mean + * @memberof google.api.Distribution + * @instance + */ + Distribution.prototype.mean = 0 + + /** + * Distribution sumOfSquaredDeviation. + * @member {number} sumOfSquaredDeviation + * @memberof google.api.Distribution + * @instance + */ + Distribution.prototype.sumOfSquaredDeviation = 0 + + /** + * Distribution range. + * @member {google.api.Distribution.IRange|null|undefined} range + * @memberof google.api.Distribution + * @instance + */ + Distribution.prototype.range = null + + /** + * Distribution bucketOptions. + * @member {google.api.Distribution.IBucketOptions|null|undefined} bucketOptions + * @memberof google.api.Distribution + * @instance + */ + Distribution.prototype.bucketOptions = null + + /** + * Distribution bucketCounts. + * @member {Array.} bucketCounts + * @memberof google.api.Distribution + * @instance + */ + Distribution.prototype.bucketCounts = $util.emptyArray + + /** + * Distribution exemplars. + * @member {Array.} exemplars + * @memberof google.api.Distribution + * @instance + */ + Distribution.prototype.exemplars = $util.emptyArray + + /** + * Creates a new Distribution instance using the specified properties. + * @function create + * @memberof google.api.Distribution + * @static + * @param {google.api.IDistribution=} [properties] Properties to set + * @returns {google.api.Distribution} Distribution instance + */ + Distribution.create = function create(properties) { + return new Distribution(properties) + } + + /** + * Encodes the specified Distribution message. Does not implicitly {@link google.api.Distribution.verify|verify} messages. + * @function encode + * @memberof google.api.Distribution + * @static + * @param {google.api.IDistribution} message Distribution message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Distribution.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.count != null && + Object.hasOwnProperty.call(message, 'count') + ) + writer.uint32(/* id 1, wireType 0 =*/ 8).int64(message.count) + if ( + message.mean != null && + Object.hasOwnProperty.call(message, 'mean') + ) + writer.uint32(/* id 2, wireType 1 =*/ 17).double(message.mean) + if ( + message.sumOfSquaredDeviation != null && + Object.hasOwnProperty.call(message, 'sumOfSquaredDeviation') + ) + writer + .uint32(/* id 3, wireType 1 =*/ 25) + .double(message.sumOfSquaredDeviation) + if ( + message.range != null && + Object.hasOwnProperty.call(message, 'range') + ) + $root.google.api.Distribution.Range.encode( + message.range, + writer.uint32(/* id 4, wireType 2 =*/ 34).fork() + ).ldelim() + if ( + message.bucketOptions != null && + Object.hasOwnProperty.call(message, 'bucketOptions') + ) + $root.google.api.Distribution.BucketOptions.encode( + message.bucketOptions, + writer.uint32(/* id 6, wireType 2 =*/ 50).fork() + ).ldelim() + if ( + message.bucketCounts != null && + message.bucketCounts.length + ) { + writer.uint32(/* id 7, wireType 2 =*/ 58).fork() + for (var i = 0; i < message.bucketCounts.length; ++i) + writer.int64(message.bucketCounts[i]) + writer.ldelim() + } + if (message.exemplars != null && message.exemplars.length) + for (var i = 0; i < message.exemplars.length; ++i) + $root.google.api.Distribution.Exemplar.encode( + message.exemplars[i], + writer.uint32(/* id 10, wireType 2 =*/ 82).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified Distribution message, length delimited. Does not implicitly {@link google.api.Distribution.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.Distribution + * @static + * @param {google.api.IDistribution} message Distribution message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Distribution.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a Distribution message from the specified reader or buffer. + * @function decode + * @memberof google.api.Distribution + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.Distribution} Distribution + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Distribution.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.api.Distribution() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.count = reader.int64() + break + case 2: + message.mean = reader.double() + break + case 3: + message.sumOfSquaredDeviation = reader.double() + break + case 4: + message.range = $root.google.api.Distribution.Range.decode( + reader, + reader.uint32() + ) + break + case 6: + message.bucketOptions = $root.google.api.Distribution.BucketOptions.decode( + reader, + reader.uint32() + ) + break + case 7: + if ( + !(message.bucketCounts && message.bucketCounts.length) + ) + message.bucketCounts = [] + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos + while (reader.pos < end2) + message.bucketCounts.push(reader.int64()) + } else message.bucketCounts.push(reader.int64()) + break + case 10: + if (!(message.exemplars && message.exemplars.length)) + message.exemplars = [] + message.exemplars.push( + $root.google.api.Distribution.Exemplar.decode( + reader, + reader.uint32() + ) + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a Distribution message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.Distribution + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.Distribution} Distribution + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Distribution.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a Distribution message. + * @function verify + * @memberof google.api.Distribution + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Distribution.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.count != null && message.hasOwnProperty('count')) + if ( + !$util.isInteger(message.count) && + !( + message.count && + $util.isInteger(message.count.low) && + $util.isInteger(message.count.high) + ) + ) + return 'count: integer|Long expected' + if (message.mean != null && message.hasOwnProperty('mean')) + if (typeof message.mean !== 'number') + return 'mean: number expected' + if ( + message.sumOfSquaredDeviation != null && + message.hasOwnProperty('sumOfSquaredDeviation') + ) + if (typeof message.sumOfSquaredDeviation !== 'number') + return 'sumOfSquaredDeviation: number expected' + if (message.range != null && message.hasOwnProperty('range')) { + var error = $root.google.api.Distribution.Range.verify( + message.range + ) + if (error) return 'range.' + error + } + if ( + message.bucketOptions != null && + message.hasOwnProperty('bucketOptions') + ) { + var error = $root.google.api.Distribution.BucketOptions.verify( + message.bucketOptions + ) + if (error) return 'bucketOptions.' + error + } + if ( + message.bucketCounts != null && + message.hasOwnProperty('bucketCounts') + ) { + if (!Array.isArray(message.bucketCounts)) + return 'bucketCounts: array expected' + for (var i = 0; i < message.bucketCounts.length; ++i) + if ( + !$util.isInteger(message.bucketCounts[i]) && + !( + message.bucketCounts[i] && + $util.isInteger(message.bucketCounts[i].low) && + $util.isInteger(message.bucketCounts[i].high) + ) + ) + return 'bucketCounts: integer|Long[] expected' + } + if ( + message.exemplars != null && + message.hasOwnProperty('exemplars') + ) { + if (!Array.isArray(message.exemplars)) + return 'exemplars: array expected' + for (var i = 0; i < message.exemplars.length; ++i) { + var error = $root.google.api.Distribution.Exemplar.verify( + message.exemplars[i] + ) + if (error) return 'exemplars.' + error + } + } + return null + } + + /** + * Creates a Distribution message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.Distribution + * @static + * @param {Object.} object Plain object + * @returns {google.api.Distribution} Distribution + */ + Distribution.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.Distribution) + return object + var message = new $root.google.api.Distribution() + if (object.count != null) + if ($util.Long) + (message.count = $util.Long.fromValue( + object.count + )).unsigned = false + else if (typeof object.count === 'string') + message.count = parseInt(object.count, 10) + else if (typeof object.count === 'number') + message.count = object.count + else if (typeof object.count === 'object') + message.count = new $util.LongBits( + object.count.low >>> 0, + object.count.high >>> 0 + ).toNumber() + if (object.mean != null) message.mean = Number(object.mean) + if (object.sumOfSquaredDeviation != null) + message.sumOfSquaredDeviation = Number( + object.sumOfSquaredDeviation + ) + if (object.range != null) { + if (typeof object.range !== 'object') + throw TypeError( + '.google.api.Distribution.range: object expected' + ) + message.range = $root.google.api.Distribution.Range.fromObject( + object.range + ) + } + if (object.bucketOptions != null) { + if (typeof object.bucketOptions !== 'object') + throw TypeError( + '.google.api.Distribution.bucketOptions: object expected' + ) + message.bucketOptions = $root.google.api.Distribution.BucketOptions.fromObject( + object.bucketOptions + ) + } + if (object.bucketCounts) { + if (!Array.isArray(object.bucketCounts)) + throw TypeError( + '.google.api.Distribution.bucketCounts: array expected' + ) + message.bucketCounts = [] + for (var i = 0; i < object.bucketCounts.length; ++i) + if ($util.Long) + (message.bucketCounts[i] = $util.Long.fromValue( + object.bucketCounts[i] + )).unsigned = false + else if (typeof object.bucketCounts[i] === 'string') + message.bucketCounts[i] = parseInt( + object.bucketCounts[i], + 10 + ) + else if (typeof object.bucketCounts[i] === 'number') + message.bucketCounts[i] = object.bucketCounts[i] + else if (typeof object.bucketCounts[i] === 'object') + message.bucketCounts[i] = new $util.LongBits( + object.bucketCounts[i].low >>> 0, + object.bucketCounts[i].high >>> 0 + ).toNumber() + } + if (object.exemplars) { + if (!Array.isArray(object.exemplars)) + throw TypeError( + '.google.api.Distribution.exemplars: array expected' + ) + message.exemplars = [] + for (var i = 0; i < object.exemplars.length; ++i) { + if (typeof object.exemplars[i] !== 'object') + throw TypeError( + '.google.api.Distribution.exemplars: object expected' + ) + message.exemplars[ + i + ] = $root.google.api.Distribution.Exemplar.fromObject( + object.exemplars[i] + ) + } + } + return message + } + + /** + * Creates a plain object from a Distribution message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.Distribution + * @static + * @param {google.api.Distribution} message Distribution + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Distribution.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) { + object.bucketCounts = [] + object.exemplars = [] + } + if (options.defaults) { + if ($util.Long) { + var long = new $util.Long(0, 0, false) + object.count = + options.longs === String + ? long.toString() + : options.longs === Number + ? long.toNumber() + : long + } else object.count = options.longs === String ? '0' : 0 + object.mean = 0 + object.sumOfSquaredDeviation = 0 + object.range = null + object.bucketOptions = null + } + if (message.count != null && message.hasOwnProperty('count')) + if (typeof message.count === 'number') + object.count = + options.longs === String + ? String(message.count) + : message.count + else + object.count = + options.longs === String + ? $util.Long.prototype.toString.call(message.count) + : options.longs === Number + ? new $util.LongBits( + message.count.low >>> 0, + message.count.high >>> 0 + ).toNumber() + : message.count + if (message.mean != null && message.hasOwnProperty('mean')) + object.mean = + options.json && !isFinite(message.mean) + ? String(message.mean) + : message.mean + if ( + message.sumOfSquaredDeviation != null && + message.hasOwnProperty('sumOfSquaredDeviation') + ) + object.sumOfSquaredDeviation = + options.json && !isFinite(message.sumOfSquaredDeviation) + ? String(message.sumOfSquaredDeviation) + : message.sumOfSquaredDeviation + if (message.range != null && message.hasOwnProperty('range')) + object.range = $root.google.api.Distribution.Range.toObject( + message.range, + options + ) + if ( + message.bucketOptions != null && + message.hasOwnProperty('bucketOptions') + ) + object.bucketOptions = $root.google.api.Distribution.BucketOptions.toObject( + message.bucketOptions, + options + ) + if (message.bucketCounts && message.bucketCounts.length) { + object.bucketCounts = [] + for (var j = 0; j < message.bucketCounts.length; ++j) + if (typeof message.bucketCounts[j] === 'number') + object.bucketCounts[j] = + options.longs === String + ? String(message.bucketCounts[j]) + : message.bucketCounts[j] + else + object.bucketCounts[j] = + options.longs === String + ? $util.Long.prototype.toString.call( + message.bucketCounts[j] + ) + : options.longs === Number + ? new $util.LongBits( + message.bucketCounts[j].low >>> 0, + message.bucketCounts[j].high >>> 0 + ).toNumber() + : message.bucketCounts[j] + } + if (message.exemplars && message.exemplars.length) { + object.exemplars = [] + for (var j = 0; j < message.exemplars.length; ++j) + object.exemplars[ + j + ] = $root.google.api.Distribution.Exemplar.toObject( + message.exemplars[j], + options + ) + } + return object + } + + /** + * Converts this Distribution to JSON. + * @function toJSON + * @memberof google.api.Distribution + * @instance + * @returns {Object.} JSON object + */ + Distribution.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + Distribution.Range = (function () { + /** + * Properties of a Range. + * @memberof google.api.Distribution + * @interface IRange + * @property {number|null} [min] Range min + * @property {number|null} [max] Range max + */ + + /** + * Constructs a new Range. + * @memberof google.api.Distribution + * @classdesc Represents a Range. + * @implements IRange + * @constructor + * @param {google.api.Distribution.IRange=} [properties] Properties to set + */ + function Range(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * Range min. + * @member {number} min + * @memberof google.api.Distribution.Range + * @instance + */ + Range.prototype.min = 0 + + /** + * Range max. + * @member {number} max + * @memberof google.api.Distribution.Range + * @instance + */ + Range.prototype.max = 0 + + /** + * Creates a new Range instance using the specified properties. + * @function create + * @memberof google.api.Distribution.Range + * @static + * @param {google.api.Distribution.IRange=} [properties] Properties to set + * @returns {google.api.Distribution.Range} Range instance + */ + Range.create = function create(properties) { + return new Range(properties) + } + + /** + * Encodes the specified Range message. Does not implicitly {@link google.api.Distribution.Range.verify|verify} messages. + * @function encode + * @memberof google.api.Distribution.Range + * @static + * @param {google.api.Distribution.IRange} message Range message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Range.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.min != null && + Object.hasOwnProperty.call(message, 'min') + ) + writer.uint32(/* id 1, wireType 1 =*/ 9).double(message.min) + if ( + message.max != null && + Object.hasOwnProperty.call(message, 'max') + ) + writer + .uint32(/* id 2, wireType 1 =*/ 17) + .double(message.max) + return writer + } + + /** + * Encodes the specified Range message, length delimited. Does not implicitly {@link google.api.Distribution.Range.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.Distribution.Range + * @static + * @param {google.api.Distribution.IRange} message Range message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Range.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a Range message from the specified reader or buffer. + * @function decode + * @memberof google.api.Distribution.Range + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.Distribution.Range} Range + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Range.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.api.Distribution.Range() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.min = reader.double() + break + case 2: + message.max = reader.double() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a Range message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.Distribution.Range + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.Distribution.Range} Range + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Range.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a Range message. + * @function verify + * @memberof google.api.Distribution.Range + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Range.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.min != null && message.hasOwnProperty('min')) + if (typeof message.min !== 'number') + return 'min: number expected' + if (message.max != null && message.hasOwnProperty('max')) + if (typeof message.max !== 'number') + return 'max: number expected' + return null + } + + /** + * Creates a Range message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.Distribution.Range + * @static + * @param {Object.} object Plain object + * @returns {google.api.Distribution.Range} Range + */ + Range.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.Distribution.Range) + return object + var message = new $root.google.api.Distribution.Range() + if (object.min != null) message.min = Number(object.min) + if (object.max != null) message.max = Number(object.max) + return message + } + + /** + * Creates a plain object from a Range message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.Distribution.Range + * @static + * @param {google.api.Distribution.Range} message Range + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Range.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.min = 0 + object.max = 0 + } + if (message.min != null && message.hasOwnProperty('min')) + object.min = + options.json && !isFinite(message.min) + ? String(message.min) + : message.min + if (message.max != null && message.hasOwnProperty('max')) + object.max = + options.json && !isFinite(message.max) + ? String(message.max) + : message.max + return object + } + + /** + * Converts this Range to JSON. + * @function toJSON + * @memberof google.api.Distribution.Range + * @instance + * @returns {Object.} JSON object + */ + Range.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return Range + })() + + Distribution.BucketOptions = (function () { + /** + * Properties of a BucketOptions. + * @memberof google.api.Distribution + * @interface IBucketOptions + * @property {google.api.Distribution.BucketOptions.ILinear|null} [linearBuckets] BucketOptions linearBuckets + * @property {google.api.Distribution.BucketOptions.IExponential|null} [exponentialBuckets] BucketOptions exponentialBuckets + * @property {google.api.Distribution.BucketOptions.IExplicit|null} [explicitBuckets] BucketOptions explicitBuckets + */ + + /** + * Constructs a new BucketOptions. + * @memberof google.api.Distribution + * @classdesc Represents a BucketOptions. + * @implements IBucketOptions + * @constructor + * @param {google.api.Distribution.IBucketOptions=} [properties] Properties to set + */ + function BucketOptions(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * BucketOptions linearBuckets. + * @member {google.api.Distribution.BucketOptions.ILinear|null|undefined} linearBuckets + * @memberof google.api.Distribution.BucketOptions + * @instance + */ + BucketOptions.prototype.linearBuckets = null + + /** + * BucketOptions exponentialBuckets. + * @member {google.api.Distribution.BucketOptions.IExponential|null|undefined} exponentialBuckets + * @memberof google.api.Distribution.BucketOptions + * @instance + */ + BucketOptions.prototype.exponentialBuckets = null + + /** + * BucketOptions explicitBuckets. + * @member {google.api.Distribution.BucketOptions.IExplicit|null|undefined} explicitBuckets + * @memberof google.api.Distribution.BucketOptions + * @instance + */ + BucketOptions.prototype.explicitBuckets = null + + // OneOf field names bound to virtual getters and setters + var $oneOfFields + + /** + * BucketOptions options. + * @member {"linearBuckets"|"exponentialBuckets"|"explicitBuckets"|undefined} options + * @memberof google.api.Distribution.BucketOptions + * @instance + */ + Object.defineProperty(BucketOptions.prototype, 'options', { + get: $util.oneOfGetter( + ($oneOfFields = [ + 'linearBuckets', + 'exponentialBuckets', + 'explicitBuckets' + ]) + ), + set: $util.oneOfSetter($oneOfFields) + }) + + /** + * Creates a new BucketOptions instance using the specified properties. + * @function create + * @memberof google.api.Distribution.BucketOptions + * @static + * @param {google.api.Distribution.IBucketOptions=} [properties] Properties to set + * @returns {google.api.Distribution.BucketOptions} BucketOptions instance + */ + BucketOptions.create = function create(properties) { + return new BucketOptions(properties) + } + + /** + * Encodes the specified BucketOptions message. Does not implicitly {@link google.api.Distribution.BucketOptions.verify|verify} messages. + * @function encode + * @memberof google.api.Distribution.BucketOptions + * @static + * @param {google.api.Distribution.IBucketOptions} message BucketOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BucketOptions.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.linearBuckets != null && + Object.hasOwnProperty.call(message, 'linearBuckets') + ) + $root.google.api.Distribution.BucketOptions.Linear.encode( + message.linearBuckets, + writer.uint32(/* id 1, wireType 2 =*/ 10).fork() + ).ldelim() + if ( + message.exponentialBuckets != null && + Object.hasOwnProperty.call(message, 'exponentialBuckets') + ) + $root.google.api.Distribution.BucketOptions.Exponential.encode( + message.exponentialBuckets, + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + ).ldelim() + if ( + message.explicitBuckets != null && + Object.hasOwnProperty.call(message, 'explicitBuckets') + ) + $root.google.api.Distribution.BucketOptions.Explicit.encode( + message.explicitBuckets, + writer.uint32(/* id 3, wireType 2 =*/ 26).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified BucketOptions message, length delimited. Does not implicitly {@link google.api.Distribution.BucketOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.Distribution.BucketOptions + * @static + * @param {google.api.Distribution.IBucketOptions} message BucketOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BucketOptions.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a BucketOptions message from the specified reader or buffer. + * @function decode + * @memberof google.api.Distribution.BucketOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.Distribution.BucketOptions} BucketOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BucketOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.api.Distribution.BucketOptions() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.linearBuckets = $root.google.api.Distribution.BucketOptions.Linear.decode( + reader, + reader.uint32() + ) + break + case 2: + message.exponentialBuckets = $root.google.api.Distribution.BucketOptions.Exponential.decode( + reader, + reader.uint32() + ) + break + case 3: + message.explicitBuckets = $root.google.api.Distribution.BucketOptions.Explicit.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a BucketOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.Distribution.BucketOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.Distribution.BucketOptions} BucketOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BucketOptions.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a BucketOptions message. + * @function verify + * @memberof google.api.Distribution.BucketOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BucketOptions.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + var properties = {} + if ( + message.linearBuckets != null && + message.hasOwnProperty('linearBuckets') + ) { + properties.options = 1 + { + var error = $root.google.api.Distribution.BucketOptions.Linear.verify( + message.linearBuckets + ) + if (error) return 'linearBuckets.' + error + } + } + if ( + message.exponentialBuckets != null && + message.hasOwnProperty('exponentialBuckets') + ) { + if (properties.options === 1) + return 'options: multiple values' + properties.options = 1 + { + var error = $root.google.api.Distribution.BucketOptions.Exponential.verify( + message.exponentialBuckets + ) + if (error) return 'exponentialBuckets.' + error + } + } + if ( + message.explicitBuckets != null && + message.hasOwnProperty('explicitBuckets') + ) { + if (properties.options === 1) + return 'options: multiple values' + properties.options = 1 + { + var error = $root.google.api.Distribution.BucketOptions.Explicit.verify( + message.explicitBuckets + ) + if (error) return 'explicitBuckets.' + error + } + } + return null + } + + /** + * Creates a BucketOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.Distribution.BucketOptions + * @static + * @param {Object.} object Plain object + * @returns {google.api.Distribution.BucketOptions} BucketOptions + */ + BucketOptions.fromObject = function fromObject(object) { + if ( + object instanceof + $root.google.api.Distribution.BucketOptions + ) + return object + var message = new $root.google.api.Distribution.BucketOptions() + if (object.linearBuckets != null) { + if (typeof object.linearBuckets !== 'object') + throw TypeError( + '.google.api.Distribution.BucketOptions.linearBuckets: object expected' + ) + message.linearBuckets = $root.google.api.Distribution.BucketOptions.Linear.fromObject( + object.linearBuckets + ) + } + if (object.exponentialBuckets != null) { + if (typeof object.exponentialBuckets !== 'object') + throw TypeError( + '.google.api.Distribution.BucketOptions.exponentialBuckets: object expected' + ) + message.exponentialBuckets = $root.google.api.Distribution.BucketOptions.Exponential.fromObject( + object.exponentialBuckets + ) + } + if (object.explicitBuckets != null) { + if (typeof object.explicitBuckets !== 'object') + throw TypeError( + '.google.api.Distribution.BucketOptions.explicitBuckets: object expected' + ) + message.explicitBuckets = $root.google.api.Distribution.BucketOptions.Explicit.fromObject( + object.explicitBuckets + ) + } + return message + } + + /** + * Creates a plain object from a BucketOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.Distribution.BucketOptions + * @static + * @param {google.api.Distribution.BucketOptions} message BucketOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BucketOptions.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if ( + message.linearBuckets != null && + message.hasOwnProperty('linearBuckets') + ) { + object.linearBuckets = $root.google.api.Distribution.BucketOptions.Linear.toObject( + message.linearBuckets, + options + ) + if (options.oneofs) object.options = 'linearBuckets' + } + if ( + message.exponentialBuckets != null && + message.hasOwnProperty('exponentialBuckets') + ) { + object.exponentialBuckets = $root.google.api.Distribution.BucketOptions.Exponential.toObject( + message.exponentialBuckets, + options + ) + if (options.oneofs) object.options = 'exponentialBuckets' + } + if ( + message.explicitBuckets != null && + message.hasOwnProperty('explicitBuckets') + ) { + object.explicitBuckets = $root.google.api.Distribution.BucketOptions.Explicit.toObject( + message.explicitBuckets, + options + ) + if (options.oneofs) object.options = 'explicitBuckets' + } + return object + } + + /** + * Converts this BucketOptions to JSON. + * @function toJSON + * @memberof google.api.Distribution.BucketOptions + * @instance + * @returns {Object.} JSON object + */ + BucketOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + BucketOptions.Linear = (function () { + /** + * Properties of a Linear. + * @memberof google.api.Distribution.BucketOptions + * @interface ILinear + * @property {number|null} [numFiniteBuckets] Linear numFiniteBuckets + * @property {number|null} [width] Linear width + * @property {number|null} [offset] Linear offset + */ + + /** + * Constructs a new Linear. + * @memberof google.api.Distribution.BucketOptions + * @classdesc Represents a Linear. + * @implements ILinear + * @constructor + * @param {google.api.Distribution.BucketOptions.ILinear=} [properties] Properties to set + */ + function Linear(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * Linear numFiniteBuckets. + * @member {number} numFiniteBuckets + * @memberof google.api.Distribution.BucketOptions.Linear + * @instance + */ + Linear.prototype.numFiniteBuckets = 0 + + /** + * Linear width. + * @member {number} width + * @memberof google.api.Distribution.BucketOptions.Linear + * @instance + */ + Linear.prototype.width = 0 + + /** + * Linear offset. + * @member {number} offset + * @memberof google.api.Distribution.BucketOptions.Linear + * @instance + */ + Linear.prototype.offset = 0 + + /** + * Creates a new Linear instance using the specified properties. + * @function create + * @memberof google.api.Distribution.BucketOptions.Linear + * @static + * @param {google.api.Distribution.BucketOptions.ILinear=} [properties] Properties to set + * @returns {google.api.Distribution.BucketOptions.Linear} Linear instance + */ + Linear.create = function create(properties) { + return new Linear(properties) + } + + /** + * Encodes the specified Linear message. Does not implicitly {@link google.api.Distribution.BucketOptions.Linear.verify|verify} messages. + * @function encode + * @memberof google.api.Distribution.BucketOptions.Linear + * @static + * @param {google.api.Distribution.BucketOptions.ILinear} message Linear message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Linear.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.numFiniteBuckets != null && + Object.hasOwnProperty.call(message, 'numFiniteBuckets') + ) + writer + .uint32(/* id 1, wireType 0 =*/ 8) + .int32(message.numFiniteBuckets) + if ( + message.width != null && + Object.hasOwnProperty.call(message, 'width') + ) + writer + .uint32(/* id 2, wireType 1 =*/ 17) + .double(message.width) + if ( + message.offset != null && + Object.hasOwnProperty.call(message, 'offset') + ) + writer + .uint32(/* id 3, wireType 1 =*/ 25) + .double(message.offset) + return writer + } + + /** + * Encodes the specified Linear message, length delimited. Does not implicitly {@link google.api.Distribution.BucketOptions.Linear.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.Distribution.BucketOptions.Linear + * @static + * @param {google.api.Distribution.BucketOptions.ILinear} message Linear message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Linear.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a Linear message from the specified reader or buffer. + * @function decode + * @memberof google.api.Distribution.BucketOptions.Linear + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.Distribution.BucketOptions.Linear} Linear + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Linear.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.api.Distribution.BucketOptions.Linear() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.numFiniteBuckets = reader.int32() + break + case 2: + message.width = reader.double() + break + case 3: + message.offset = reader.double() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a Linear message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.Distribution.BucketOptions.Linear + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.Distribution.BucketOptions.Linear} Linear + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Linear.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a Linear message. + * @function verify + * @memberof google.api.Distribution.BucketOptions.Linear + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Linear.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.numFiniteBuckets != null && + message.hasOwnProperty('numFiniteBuckets') + ) + if (!$util.isInteger(message.numFiniteBuckets)) + return 'numFiniteBuckets: integer expected' + if ( + message.width != null && + message.hasOwnProperty('width') + ) + if (typeof message.width !== 'number') + return 'width: number expected' + if ( + message.offset != null && + message.hasOwnProperty('offset') + ) + if (typeof message.offset !== 'number') + return 'offset: number expected' + return null + } + + /** + * Creates a Linear message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.Distribution.BucketOptions.Linear + * @static + * @param {Object.} object Plain object + * @returns {google.api.Distribution.BucketOptions.Linear} Linear + */ + Linear.fromObject = function fromObject(object) { + if ( + object instanceof + $root.google.api.Distribution.BucketOptions.Linear + ) + return object + var message = new $root.google.api.Distribution.BucketOptions.Linear() + if (object.numFiniteBuckets != null) + message.numFiniteBuckets = object.numFiniteBuckets | 0 + if (object.width != null) + message.width = Number(object.width) + if (object.offset != null) + message.offset = Number(object.offset) + return message + } + + /** + * Creates a plain object from a Linear message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.Distribution.BucketOptions.Linear + * @static + * @param {google.api.Distribution.BucketOptions.Linear} message Linear + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Linear.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.numFiniteBuckets = 0 + object.width = 0 + object.offset = 0 + } + if ( + message.numFiniteBuckets != null && + message.hasOwnProperty('numFiniteBuckets') + ) + object.numFiniteBuckets = message.numFiniteBuckets + if ( + message.width != null && + message.hasOwnProperty('width') + ) + object.width = + options.json && !isFinite(message.width) + ? String(message.width) + : message.width + if ( + message.offset != null && + message.hasOwnProperty('offset') + ) + object.offset = + options.json && !isFinite(message.offset) + ? String(message.offset) + : message.offset + return object + } + + /** + * Converts this Linear to JSON. + * @function toJSON + * @memberof google.api.Distribution.BucketOptions.Linear + * @instance + * @returns {Object.} JSON object + */ + Linear.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return Linear + })() + + BucketOptions.Exponential = (function () { + /** + * Properties of an Exponential. + * @memberof google.api.Distribution.BucketOptions + * @interface IExponential + * @property {number|null} [numFiniteBuckets] Exponential numFiniteBuckets + * @property {number|null} [growthFactor] Exponential growthFactor + * @property {number|null} [scale] Exponential scale + */ + + /** + * Constructs a new Exponential. + * @memberof google.api.Distribution.BucketOptions + * @classdesc Represents an Exponential. + * @implements IExponential + * @constructor + * @param {google.api.Distribution.BucketOptions.IExponential=} [properties] Properties to set + */ + function Exponential(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * Exponential numFiniteBuckets. + * @member {number} numFiniteBuckets + * @memberof google.api.Distribution.BucketOptions.Exponential + * @instance + */ + Exponential.prototype.numFiniteBuckets = 0 + + /** + * Exponential growthFactor. + * @member {number} growthFactor + * @memberof google.api.Distribution.BucketOptions.Exponential + * @instance + */ + Exponential.prototype.growthFactor = 0 + + /** + * Exponential scale. + * @member {number} scale + * @memberof google.api.Distribution.BucketOptions.Exponential + * @instance + */ + Exponential.prototype.scale = 0 + + /** + * Creates a new Exponential instance using the specified properties. + * @function create + * @memberof google.api.Distribution.BucketOptions.Exponential + * @static + * @param {google.api.Distribution.BucketOptions.IExponential=} [properties] Properties to set + * @returns {google.api.Distribution.BucketOptions.Exponential} Exponential instance + */ + Exponential.create = function create(properties) { + return new Exponential(properties) + } + + /** + * Encodes the specified Exponential message. Does not implicitly {@link google.api.Distribution.BucketOptions.Exponential.verify|verify} messages. + * @function encode + * @memberof google.api.Distribution.BucketOptions.Exponential + * @static + * @param {google.api.Distribution.BucketOptions.IExponential} message Exponential message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Exponential.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.numFiniteBuckets != null && + Object.hasOwnProperty.call(message, 'numFiniteBuckets') + ) + writer + .uint32(/* id 1, wireType 0 =*/ 8) + .int32(message.numFiniteBuckets) + if ( + message.growthFactor != null && + Object.hasOwnProperty.call(message, 'growthFactor') + ) + writer + .uint32(/* id 2, wireType 1 =*/ 17) + .double(message.growthFactor) + if ( + message.scale != null && + Object.hasOwnProperty.call(message, 'scale') + ) + writer + .uint32(/* id 3, wireType 1 =*/ 25) + .double(message.scale) + return writer + } + + /** + * Encodes the specified Exponential message, length delimited. Does not implicitly {@link google.api.Distribution.BucketOptions.Exponential.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.Distribution.BucketOptions.Exponential + * @static + * @param {google.api.Distribution.BucketOptions.IExponential} message Exponential message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Exponential.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an Exponential message from the specified reader or buffer. + * @function decode + * @memberof google.api.Distribution.BucketOptions.Exponential + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.Distribution.BucketOptions.Exponential} Exponential + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Exponential.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.api.Distribution.BucketOptions.Exponential() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.numFiniteBuckets = reader.int32() + break + case 2: + message.growthFactor = reader.double() + break + case 3: + message.scale = reader.double() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an Exponential message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.Distribution.BucketOptions.Exponential + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.Distribution.BucketOptions.Exponential} Exponential + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Exponential.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an Exponential message. + * @function verify + * @memberof google.api.Distribution.BucketOptions.Exponential + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Exponential.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.numFiniteBuckets != null && + message.hasOwnProperty('numFiniteBuckets') + ) + if (!$util.isInteger(message.numFiniteBuckets)) + return 'numFiniteBuckets: integer expected' + if ( + message.growthFactor != null && + message.hasOwnProperty('growthFactor') + ) + if (typeof message.growthFactor !== 'number') + return 'growthFactor: number expected' + if ( + message.scale != null && + message.hasOwnProperty('scale') + ) + if (typeof message.scale !== 'number') + return 'scale: number expected' + return null + } + + /** + * Creates an Exponential message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.Distribution.BucketOptions.Exponential + * @static + * @param {Object.} object Plain object + * @returns {google.api.Distribution.BucketOptions.Exponential} Exponential + */ + Exponential.fromObject = function fromObject(object) { + if ( + object instanceof + $root.google.api.Distribution.BucketOptions.Exponential + ) + return object + var message = new $root.google.api.Distribution.BucketOptions.Exponential() + if (object.numFiniteBuckets != null) + message.numFiniteBuckets = object.numFiniteBuckets | 0 + if (object.growthFactor != null) + message.growthFactor = Number(object.growthFactor) + if (object.scale != null) + message.scale = Number(object.scale) + return message + } + + /** + * Creates a plain object from an Exponential message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.Distribution.BucketOptions.Exponential + * @static + * @param {google.api.Distribution.BucketOptions.Exponential} message Exponential + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Exponential.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.numFiniteBuckets = 0 + object.growthFactor = 0 + object.scale = 0 + } + if ( + message.numFiniteBuckets != null && + message.hasOwnProperty('numFiniteBuckets') + ) + object.numFiniteBuckets = message.numFiniteBuckets + if ( + message.growthFactor != null && + message.hasOwnProperty('growthFactor') + ) + object.growthFactor = + options.json && !isFinite(message.growthFactor) + ? String(message.growthFactor) + : message.growthFactor + if ( + message.scale != null && + message.hasOwnProperty('scale') + ) + object.scale = + options.json && !isFinite(message.scale) + ? String(message.scale) + : message.scale + return object + } + + /** + * Converts this Exponential to JSON. + * @function toJSON + * @memberof google.api.Distribution.BucketOptions.Exponential + * @instance + * @returns {Object.} JSON object + */ + Exponential.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return Exponential + })() + + BucketOptions.Explicit = (function () { + /** + * Properties of an Explicit. + * @memberof google.api.Distribution.BucketOptions + * @interface IExplicit + * @property {Array.|null} [bounds] Explicit bounds + */ + + /** + * Constructs a new Explicit. + * @memberof google.api.Distribution.BucketOptions + * @classdesc Represents an Explicit. + * @implements IExplicit + * @constructor + * @param {google.api.Distribution.BucketOptions.IExplicit=} [properties] Properties to set + */ + function Explicit(properties) { + this.bounds = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * Explicit bounds. + * @member {Array.} bounds + * @memberof google.api.Distribution.BucketOptions.Explicit + * @instance + */ + Explicit.prototype.bounds = $util.emptyArray + + /** + * Creates a new Explicit instance using the specified properties. + * @function create + * @memberof google.api.Distribution.BucketOptions.Explicit + * @static + * @param {google.api.Distribution.BucketOptions.IExplicit=} [properties] Properties to set + * @returns {google.api.Distribution.BucketOptions.Explicit} Explicit instance + */ + Explicit.create = function create(properties) { + return new Explicit(properties) + } + + /** + * Encodes the specified Explicit message. Does not implicitly {@link google.api.Distribution.BucketOptions.Explicit.verify|verify} messages. + * @function encode + * @memberof google.api.Distribution.BucketOptions.Explicit + * @static + * @param {google.api.Distribution.BucketOptions.IExplicit} message Explicit message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Explicit.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.bounds != null && message.bounds.length) { + writer.uint32(/* id 1, wireType 2 =*/ 10).fork() + for (var i = 0; i < message.bounds.length; ++i) + writer.double(message.bounds[i]) + writer.ldelim() + } + return writer + } + + /** + * Encodes the specified Explicit message, length delimited. Does not implicitly {@link google.api.Distribution.BucketOptions.Explicit.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.Distribution.BucketOptions.Explicit + * @static + * @param {google.api.Distribution.BucketOptions.IExplicit} message Explicit message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Explicit.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an Explicit message from the specified reader or buffer. + * @function decode + * @memberof google.api.Distribution.BucketOptions.Explicit + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.Distribution.BucketOptions.Explicit} Explicit + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Explicit.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.api.Distribution.BucketOptions.Explicit() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + if (!(message.bounds && message.bounds.length)) + message.bounds = [] + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos + while (reader.pos < end2) + message.bounds.push(reader.double()) + } else message.bounds.push(reader.double()) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an Explicit message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.Distribution.BucketOptions.Explicit + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.Distribution.BucketOptions.Explicit} Explicit + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Explicit.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an Explicit message. + * @function verify + * @memberof google.api.Distribution.BucketOptions.Explicit + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Explicit.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.bounds != null && + message.hasOwnProperty('bounds') + ) { + if (!Array.isArray(message.bounds)) + return 'bounds: array expected' + for (var i = 0; i < message.bounds.length; ++i) + if (typeof message.bounds[i] !== 'number') + return 'bounds: number[] expected' + } + return null + } + + /** + * Creates an Explicit message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.Distribution.BucketOptions.Explicit + * @static + * @param {Object.} object Plain object + * @returns {google.api.Distribution.BucketOptions.Explicit} Explicit + */ + Explicit.fromObject = function fromObject(object) { + if ( + object instanceof + $root.google.api.Distribution.BucketOptions.Explicit + ) + return object + var message = new $root.google.api.Distribution.BucketOptions.Explicit() + if (object.bounds) { + if (!Array.isArray(object.bounds)) + throw TypeError( + '.google.api.Distribution.BucketOptions.Explicit.bounds: array expected' + ) + message.bounds = [] + for (var i = 0; i < object.bounds.length; ++i) + message.bounds[i] = Number(object.bounds[i]) + } + return message + } + + /** + * Creates a plain object from an Explicit message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.Distribution.BucketOptions.Explicit + * @static + * @param {google.api.Distribution.BucketOptions.Explicit} message Explicit + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Explicit.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) object.bounds = [] + if (message.bounds && message.bounds.length) { + object.bounds = [] + for (var j = 0; j < message.bounds.length; ++j) + object.bounds[j] = + options.json && !isFinite(message.bounds[j]) + ? String(message.bounds[j]) + : message.bounds[j] + } + return object + } + + /** + * Converts this Explicit to JSON. + * @function toJSON + * @memberof google.api.Distribution.BucketOptions.Explicit + * @instance + * @returns {Object.} JSON object + */ + Explicit.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return Explicit + })() + + return BucketOptions + })() + + Distribution.Exemplar = (function () { + /** + * Properties of an Exemplar. + * @memberof google.api.Distribution + * @interface IExemplar + * @property {number|null} [value] Exemplar value + * @property {google.protobuf.ITimestamp|null} [timestamp] Exemplar timestamp + * @property {Array.|null} [attachments] Exemplar attachments + */ + + /** + * Constructs a new Exemplar. + * @memberof google.api.Distribution + * @classdesc Represents an Exemplar. + * @implements IExemplar + * @constructor + * @param {google.api.Distribution.IExemplar=} [properties] Properties to set + */ + function Exemplar(properties) { + this.attachments = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * Exemplar value. + * @member {number} value + * @memberof google.api.Distribution.Exemplar + * @instance + */ + Exemplar.prototype.value = 0 + + /** + * Exemplar timestamp. + * @member {google.protobuf.ITimestamp|null|undefined} timestamp + * @memberof google.api.Distribution.Exemplar + * @instance + */ + Exemplar.prototype.timestamp = null + + /** + * Exemplar attachments. + * @member {Array.} attachments + * @memberof google.api.Distribution.Exemplar + * @instance + */ + Exemplar.prototype.attachments = $util.emptyArray + + /** + * Creates a new Exemplar instance using the specified properties. + * @function create + * @memberof google.api.Distribution.Exemplar + * @static + * @param {google.api.Distribution.IExemplar=} [properties] Properties to set + * @returns {google.api.Distribution.Exemplar} Exemplar instance + */ + Exemplar.create = function create(properties) { + return new Exemplar(properties) + } + + /** + * Encodes the specified Exemplar message. Does not implicitly {@link google.api.Distribution.Exemplar.verify|verify} messages. + * @function encode + * @memberof google.api.Distribution.Exemplar + * @static + * @param {google.api.Distribution.IExemplar} message Exemplar message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Exemplar.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.value != null && + Object.hasOwnProperty.call(message, 'value') + ) + writer + .uint32(/* id 1, wireType 1 =*/ 9) + .double(message.value) + if ( + message.timestamp != null && + Object.hasOwnProperty.call(message, 'timestamp') + ) + $root.google.protobuf.Timestamp.encode( + message.timestamp, + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + ).ldelim() + if (message.attachments != null && message.attachments.length) + for (var i = 0; i < message.attachments.length; ++i) + $root.google.protobuf.Any.encode( + message.attachments[i], + writer.uint32(/* id 3, wireType 2 =*/ 26).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified Exemplar message, length delimited. Does not implicitly {@link google.api.Distribution.Exemplar.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.Distribution.Exemplar + * @static + * @param {google.api.Distribution.IExemplar} message Exemplar message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Exemplar.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an Exemplar message from the specified reader or buffer. + * @function decode + * @memberof google.api.Distribution.Exemplar + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.Distribution.Exemplar} Exemplar + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Exemplar.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.api.Distribution.Exemplar() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.value = reader.double() + break + case 2: + message.timestamp = $root.google.protobuf.Timestamp.decode( + reader, + reader.uint32() + ) + break + case 3: + if ( + !(message.attachments && message.attachments.length) + ) + message.attachments = [] + message.attachments.push( + $root.google.protobuf.Any.decode( + reader, + reader.uint32() + ) + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an Exemplar message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.Distribution.Exemplar + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.Distribution.Exemplar} Exemplar + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Exemplar.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an Exemplar message. + * @function verify + * @memberof google.api.Distribution.Exemplar + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Exemplar.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.value != null && message.hasOwnProperty('value')) + if (typeof message.value !== 'number') + return 'value: number expected' + if ( + message.timestamp != null && + message.hasOwnProperty('timestamp') + ) { + var error = $root.google.protobuf.Timestamp.verify( + message.timestamp + ) + if (error) return 'timestamp.' + error + } + if ( + message.attachments != null && + message.hasOwnProperty('attachments') + ) { + if (!Array.isArray(message.attachments)) + return 'attachments: array expected' + for (var i = 0; i < message.attachments.length; ++i) { + var error = $root.google.protobuf.Any.verify( + message.attachments[i] + ) + if (error) return 'attachments.' + error + } + } + return null + } + + /** + * Creates an Exemplar message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.Distribution.Exemplar + * @static + * @param {Object.} object Plain object + * @returns {google.api.Distribution.Exemplar} Exemplar + */ + Exemplar.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.Distribution.Exemplar) + return object + var message = new $root.google.api.Distribution.Exemplar() + if (object.value != null) message.value = Number(object.value) + if (object.timestamp != null) { + if (typeof object.timestamp !== 'object') + throw TypeError( + '.google.api.Distribution.Exemplar.timestamp: object expected' + ) + message.timestamp = $root.google.protobuf.Timestamp.fromObject( + object.timestamp + ) + } + if (object.attachments) { + if (!Array.isArray(object.attachments)) + throw TypeError( + '.google.api.Distribution.Exemplar.attachments: array expected' + ) + message.attachments = [] + for (var i = 0; i < object.attachments.length; ++i) { + if (typeof object.attachments[i] !== 'object') + throw TypeError( + '.google.api.Distribution.Exemplar.attachments: object expected' + ) + message.attachments[ + i + ] = $root.google.protobuf.Any.fromObject( + object.attachments[i] + ) + } + } + return message + } + + /** + * Creates a plain object from an Exemplar message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.Distribution.Exemplar + * @static + * @param {google.api.Distribution.Exemplar} message Exemplar + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Exemplar.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) + object.attachments = [] + if (options.defaults) { + object.value = 0 + object.timestamp = null + } + if (message.value != null && message.hasOwnProperty('value')) + object.value = + options.json && !isFinite(message.value) + ? String(message.value) + : message.value + if ( + message.timestamp != null && + message.hasOwnProperty('timestamp') + ) + object.timestamp = $root.google.protobuf.Timestamp.toObject( + message.timestamp, + options + ) + if (message.attachments && message.attachments.length) { + object.attachments = [] + for (var j = 0; j < message.attachments.length; ++j) + object.attachments[ + j + ] = $root.google.protobuf.Any.toObject( + message.attachments[j], + options + ) + } + return object + } + + /** + * Converts this Exemplar to JSON. + * @function toJSON + * @memberof google.api.Distribution.Exemplar + * @instance + * @returns {Object.} JSON object + */ + Exemplar.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return Exemplar + })() + + return Distribution + })() + + api.MetricDescriptor = (function () { + /** + * Properties of a MetricDescriptor. + * @memberof google.api + * @interface IMetricDescriptor + * @property {string|null} [name] MetricDescriptor name + * @property {string|null} [type] MetricDescriptor type + * @property {Array.|null} [labels] MetricDescriptor labels + * @property {google.api.MetricDescriptor.MetricKind|null} [metricKind] MetricDescriptor metricKind + * @property {google.api.MetricDescriptor.ValueType|null} [valueType] MetricDescriptor valueType + * @property {string|null} [unit] MetricDescriptor unit + * @property {string|null} [description] MetricDescriptor description + * @property {string|null} [displayName] MetricDescriptor displayName + * @property {google.api.MetricDescriptor.IMetricDescriptorMetadata|null} [metadata] MetricDescriptor metadata + * @property {google.api.LaunchStage|null} [launchStage] MetricDescriptor launchStage + * @property {Array.|null} [monitoredResourceTypes] MetricDescriptor monitoredResourceTypes + */ + + /** + * Constructs a new MetricDescriptor. + * @memberof google.api + * @classdesc Represents a MetricDescriptor. + * @implements IMetricDescriptor + * @constructor + * @param {google.api.IMetricDescriptor=} [properties] Properties to set + */ + function MetricDescriptor(properties) { + this.labels = [] + this.monitoredResourceTypes = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * MetricDescriptor name. + * @member {string} name + * @memberof google.api.MetricDescriptor + * @instance + */ + MetricDescriptor.prototype.name = '' + + /** + * MetricDescriptor type. + * @member {string} type + * @memberof google.api.MetricDescriptor + * @instance + */ + MetricDescriptor.prototype.type = '' + + /** + * MetricDescriptor labels. + * @member {Array.} labels + * @memberof google.api.MetricDescriptor + * @instance + */ + MetricDescriptor.prototype.labels = $util.emptyArray + + /** + * MetricDescriptor metricKind. + * @member {google.api.MetricDescriptor.MetricKind} metricKind + * @memberof google.api.MetricDescriptor + * @instance + */ + MetricDescriptor.prototype.metricKind = 0 + + /** + * MetricDescriptor valueType. + * @member {google.api.MetricDescriptor.ValueType} valueType + * @memberof google.api.MetricDescriptor + * @instance + */ + MetricDescriptor.prototype.valueType = 0 + + /** + * MetricDescriptor unit. + * @member {string} unit + * @memberof google.api.MetricDescriptor + * @instance + */ + MetricDescriptor.prototype.unit = '' + + /** + * MetricDescriptor description. + * @member {string} description + * @memberof google.api.MetricDescriptor + * @instance + */ + MetricDescriptor.prototype.description = '' + + /** + * MetricDescriptor displayName. + * @member {string} displayName + * @memberof google.api.MetricDescriptor + * @instance + */ + MetricDescriptor.prototype.displayName = '' + + /** + * MetricDescriptor metadata. + * @member {google.api.MetricDescriptor.IMetricDescriptorMetadata|null|undefined} metadata + * @memberof google.api.MetricDescriptor + * @instance + */ + MetricDescriptor.prototype.metadata = null + + /** + * MetricDescriptor launchStage. + * @member {google.api.LaunchStage} launchStage + * @memberof google.api.MetricDescriptor + * @instance + */ + MetricDescriptor.prototype.launchStage = 0 + + /** + * MetricDescriptor monitoredResourceTypes. + * @member {Array.} monitoredResourceTypes + * @memberof google.api.MetricDescriptor + * @instance + */ + MetricDescriptor.prototype.monitoredResourceTypes = + $util.emptyArray + + /** + * Creates a new MetricDescriptor instance using the specified properties. + * @function create + * @memberof google.api.MetricDescriptor + * @static + * @param {google.api.IMetricDescriptor=} [properties] Properties to set + * @returns {google.api.MetricDescriptor} MetricDescriptor instance + */ + MetricDescriptor.create = function create(properties) { + return new MetricDescriptor(properties) + } + + /** + * Encodes the specified MetricDescriptor message. Does not implicitly {@link google.api.MetricDescriptor.verify|verify} messages. + * @function encode + * @memberof google.api.MetricDescriptor + * @static + * @param {google.api.IMetricDescriptor} message MetricDescriptor message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MetricDescriptor.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.name != null && + Object.hasOwnProperty.call(message, 'name') + ) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.name) + if (message.labels != null && message.labels.length) + for (var i = 0; i < message.labels.length; ++i) + $root.google.api.LabelDescriptor.encode( + message.labels[i], + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + ).ldelim() + if ( + message.metricKind != null && + Object.hasOwnProperty.call(message, 'metricKind') + ) + writer + .uint32(/* id 3, wireType 0 =*/ 24) + .int32(message.metricKind) + if ( + message.valueType != null && + Object.hasOwnProperty.call(message, 'valueType') + ) + writer + .uint32(/* id 4, wireType 0 =*/ 32) + .int32(message.valueType) + if ( + message.unit != null && + Object.hasOwnProperty.call(message, 'unit') + ) + writer.uint32(/* id 5, wireType 2 =*/ 42).string(message.unit) + if ( + message.description != null && + Object.hasOwnProperty.call(message, 'description') + ) + writer + .uint32(/* id 6, wireType 2 =*/ 50) + .string(message.description) + if ( + message.displayName != null && + Object.hasOwnProperty.call(message, 'displayName') + ) + writer + .uint32(/* id 7, wireType 2 =*/ 58) + .string(message.displayName) + if ( + message.type != null && + Object.hasOwnProperty.call(message, 'type') + ) + writer.uint32(/* id 8, wireType 2 =*/ 66).string(message.type) + if ( + message.metadata != null && + Object.hasOwnProperty.call(message, 'metadata') + ) + $root.google.api.MetricDescriptor.MetricDescriptorMetadata.encode( + message.metadata, + writer.uint32(/* id 10, wireType 2 =*/ 82).fork() + ).ldelim() + if ( + message.launchStage != null && + Object.hasOwnProperty.call(message, 'launchStage') + ) + writer + .uint32(/* id 12, wireType 0 =*/ 96) + .int32(message.launchStage) + if ( + message.monitoredResourceTypes != null && + message.monitoredResourceTypes.length + ) + for ( + var i = 0; + i < message.monitoredResourceTypes.length; + ++i + ) + writer + .uint32(/* id 13, wireType 2 =*/ 106) + .string(message.monitoredResourceTypes[i]) + return writer + } + + /** + * Encodes the specified MetricDescriptor message, length delimited. Does not implicitly {@link google.api.MetricDescriptor.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.MetricDescriptor + * @static + * @param {google.api.IMetricDescriptor} message MetricDescriptor message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MetricDescriptor.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a MetricDescriptor message from the specified reader or buffer. + * @function decode + * @memberof google.api.MetricDescriptor + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.MetricDescriptor} MetricDescriptor + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MetricDescriptor.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.api.MetricDescriptor() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + case 8: + message.type = reader.string() + break + case 2: + if (!(message.labels && message.labels.length)) + message.labels = [] + message.labels.push( + $root.google.api.LabelDescriptor.decode( + reader, + reader.uint32() + ) + ) + break + case 3: + message.metricKind = reader.int32() + break + case 4: + message.valueType = reader.int32() + break + case 5: + message.unit = reader.string() + break + case 6: + message.description = reader.string() + break + case 7: + message.displayName = reader.string() + break + case 10: + message.metadata = $root.google.api.MetricDescriptor.MetricDescriptorMetadata.decode( + reader, + reader.uint32() + ) + break + case 12: + message.launchStage = reader.int32() + break + case 13: + if ( + !( + message.monitoredResourceTypes && + message.monitoredResourceTypes.length + ) + ) + message.monitoredResourceTypes = [] + message.monitoredResourceTypes.push(reader.string()) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a MetricDescriptor message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.MetricDescriptor + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.MetricDescriptor} MetricDescriptor + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MetricDescriptor.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a MetricDescriptor message. + * @function verify + * @memberof google.api.MetricDescriptor + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + MetricDescriptor.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + if (message.type != null && message.hasOwnProperty('type')) + if (!$util.isString(message.type)) + return 'type: string expected' + if ( + message.labels != null && + message.hasOwnProperty('labels') + ) { + if (!Array.isArray(message.labels)) + return 'labels: array expected' + for (var i = 0; i < message.labels.length; ++i) { + var error = $root.google.api.LabelDescriptor.verify( + message.labels[i] + ) + if (error) return 'labels.' + error + } + } + if ( + message.metricKind != null && + message.hasOwnProperty('metricKind') + ) + switch (message.metricKind) { + default: + return 'metricKind: enum value expected' + case 0: + case 1: + case 2: + case 3: + break + } + if ( + message.valueType != null && + message.hasOwnProperty('valueType') + ) + switch (message.valueType) { + default: + return 'valueType: enum value expected' + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + break + } + if (message.unit != null && message.hasOwnProperty('unit')) + if (!$util.isString(message.unit)) + return 'unit: string expected' + if ( + message.description != null && + message.hasOwnProperty('description') + ) + if (!$util.isString(message.description)) + return 'description: string expected' + if ( + message.displayName != null && + message.hasOwnProperty('displayName') + ) + if (!$util.isString(message.displayName)) + return 'displayName: string expected' + if ( + message.metadata != null && + message.hasOwnProperty('metadata') + ) { + var error = $root.google.api.MetricDescriptor.MetricDescriptorMetadata.verify( + message.metadata + ) + if (error) return 'metadata.' + error + } + if ( + message.launchStage != null && + message.hasOwnProperty('launchStage') + ) + switch (message.launchStage) { + default: + return 'launchStage: enum value expected' + case 0: + case 6: + case 7: + case 1: + case 2: + case 3: + case 4: + case 5: + break + } + if ( + message.monitoredResourceTypes != null && + message.hasOwnProperty('monitoredResourceTypes') + ) { + if (!Array.isArray(message.monitoredResourceTypes)) + return 'monitoredResourceTypes: array expected' + for ( + var i = 0; + i < message.monitoredResourceTypes.length; + ++i + ) + if (!$util.isString(message.monitoredResourceTypes[i])) + return 'monitoredResourceTypes: string[] expected' + } + return null + } + + /** + * Creates a MetricDescriptor message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.MetricDescriptor + * @static + * @param {Object.} object Plain object + * @returns {google.api.MetricDescriptor} MetricDescriptor + */ + MetricDescriptor.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.MetricDescriptor) + return object + var message = new $root.google.api.MetricDescriptor() + if (object.name != null) message.name = String(object.name) + if (object.type != null) message.type = String(object.type) + if (object.labels) { + if (!Array.isArray(object.labels)) + throw TypeError( + '.google.api.MetricDescriptor.labels: array expected' + ) + message.labels = [] + for (var i = 0; i < object.labels.length; ++i) { + if (typeof object.labels[i] !== 'object') + throw TypeError( + '.google.api.MetricDescriptor.labels: object expected' + ) + message.labels[ + i + ] = $root.google.api.LabelDescriptor.fromObject( + object.labels[i] + ) + } + } + switch (object.metricKind) { + case 'METRIC_KIND_UNSPECIFIED': + case 0: + message.metricKind = 0 + break + case 'GAUGE': + case 1: + message.metricKind = 1 + break + case 'DELTA': + case 2: + message.metricKind = 2 + break + case 'CUMULATIVE': + case 3: + message.metricKind = 3 + break + } + switch (object.valueType) { + case 'VALUE_TYPE_UNSPECIFIED': + case 0: + message.valueType = 0 + break + case 'BOOL': + case 1: + message.valueType = 1 + break + case 'INT64': + case 2: + message.valueType = 2 + break + case 'DOUBLE': + case 3: + message.valueType = 3 + break + case 'STRING': + case 4: + message.valueType = 4 + break + case 'DISTRIBUTION': + case 5: + message.valueType = 5 + break + case 'MONEY': + case 6: + message.valueType = 6 + break + } + if (object.unit != null) message.unit = String(object.unit) + if (object.description != null) + message.description = String(object.description) + if (object.displayName != null) + message.displayName = String(object.displayName) + if (object.metadata != null) { + if (typeof object.metadata !== 'object') + throw TypeError( + '.google.api.MetricDescriptor.metadata: object expected' + ) + message.metadata = $root.google.api.MetricDescriptor.MetricDescriptorMetadata.fromObject( + object.metadata + ) + } + switch (object.launchStage) { + case 'LAUNCH_STAGE_UNSPECIFIED': + case 0: + message.launchStage = 0 + break + case 'UNIMPLEMENTED': + case 6: + message.launchStage = 6 + break + case 'PRELAUNCH': + case 7: + message.launchStage = 7 + break + case 'EARLY_ACCESS': + case 1: + message.launchStage = 1 + break + case 'ALPHA': + case 2: + message.launchStage = 2 + break + case 'BETA': + case 3: + message.launchStage = 3 + break + case 'GA': + case 4: + message.launchStage = 4 + break + case 'DEPRECATED': + case 5: + message.launchStage = 5 + break + } + if (object.monitoredResourceTypes) { + if (!Array.isArray(object.monitoredResourceTypes)) + throw TypeError( + '.google.api.MetricDescriptor.monitoredResourceTypes: array expected' + ) + message.monitoredResourceTypes = [] + for (var i = 0; i < object.monitoredResourceTypes.length; ++i) + message.monitoredResourceTypes[i] = String( + object.monitoredResourceTypes[i] + ) + } + return message + } + + /** + * Creates a plain object from a MetricDescriptor message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.MetricDescriptor + * @static + * @param {google.api.MetricDescriptor} message MetricDescriptor + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MetricDescriptor.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) { + object.labels = [] + object.monitoredResourceTypes = [] + } + if (options.defaults) { + object.name = '' + object.metricKind = + options.enums === String ? 'METRIC_KIND_UNSPECIFIED' : 0 + object.valueType = + options.enums === String ? 'VALUE_TYPE_UNSPECIFIED' : 0 + object.unit = '' + object.description = '' + object.displayName = '' + object.type = '' + object.metadata = null + object.launchStage = + options.enums === String ? 'LAUNCH_STAGE_UNSPECIFIED' : 0 + } + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + if (message.labels && message.labels.length) { + object.labels = [] + for (var j = 0; j < message.labels.length; ++j) + object.labels[ + j + ] = $root.google.api.LabelDescriptor.toObject( + message.labels[j], + options + ) + } + if ( + message.metricKind != null && + message.hasOwnProperty('metricKind') + ) + object.metricKind = + options.enums === String + ? $root.google.api.MetricDescriptor.MetricKind[ + message.metricKind + ] + : message.metricKind + if ( + message.valueType != null && + message.hasOwnProperty('valueType') + ) + object.valueType = + options.enums === String + ? $root.google.api.MetricDescriptor.ValueType[ + message.valueType + ] + : message.valueType + if (message.unit != null && message.hasOwnProperty('unit')) + object.unit = message.unit + if ( + message.description != null && + message.hasOwnProperty('description') + ) + object.description = message.description + if ( + message.displayName != null && + message.hasOwnProperty('displayName') + ) + object.displayName = message.displayName + if (message.type != null && message.hasOwnProperty('type')) + object.type = message.type + if ( + message.metadata != null && + message.hasOwnProperty('metadata') + ) + object.metadata = $root.google.api.MetricDescriptor.MetricDescriptorMetadata.toObject( + message.metadata, + options + ) + if ( + message.launchStage != null && + message.hasOwnProperty('launchStage') + ) + object.launchStage = + options.enums === String + ? $root.google.api.LaunchStage[message.launchStage] + : message.launchStage + if ( + message.monitoredResourceTypes && + message.monitoredResourceTypes.length + ) { + object.monitoredResourceTypes = [] + for ( + var j = 0; + j < message.monitoredResourceTypes.length; + ++j + ) + object.monitoredResourceTypes[j] = + message.monitoredResourceTypes[j] + } + return object + } + + /** + * Converts this MetricDescriptor to JSON. + * @function toJSON + * @memberof google.api.MetricDescriptor + * @instance + * @returns {Object.} JSON object + */ + MetricDescriptor.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + MetricDescriptor.MetricDescriptorMetadata = (function () { + /** + * Properties of a MetricDescriptorMetadata. + * @memberof google.api.MetricDescriptor + * @interface IMetricDescriptorMetadata + * @property {google.api.LaunchStage|null} [launchStage] MetricDescriptorMetadata launchStage + * @property {google.protobuf.IDuration|null} [samplePeriod] MetricDescriptorMetadata samplePeriod + * @property {google.protobuf.IDuration|null} [ingestDelay] MetricDescriptorMetadata ingestDelay + */ + + /** + * Constructs a new MetricDescriptorMetadata. + * @memberof google.api.MetricDescriptor + * @classdesc Represents a MetricDescriptorMetadata. + * @implements IMetricDescriptorMetadata + * @constructor + * @param {google.api.MetricDescriptor.IMetricDescriptorMetadata=} [properties] Properties to set + */ + function MetricDescriptorMetadata(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * MetricDescriptorMetadata launchStage. + * @member {google.api.LaunchStage} launchStage + * @memberof google.api.MetricDescriptor.MetricDescriptorMetadata + * @instance + */ + MetricDescriptorMetadata.prototype.launchStage = 0 + + /** + * MetricDescriptorMetadata samplePeriod. + * @member {google.protobuf.IDuration|null|undefined} samplePeriod + * @memberof google.api.MetricDescriptor.MetricDescriptorMetadata + * @instance + */ + MetricDescriptorMetadata.prototype.samplePeriod = null + + /** + * MetricDescriptorMetadata ingestDelay. + * @member {google.protobuf.IDuration|null|undefined} ingestDelay + * @memberof google.api.MetricDescriptor.MetricDescriptorMetadata + * @instance + */ + MetricDescriptorMetadata.prototype.ingestDelay = null + + /** + * Creates a new MetricDescriptorMetadata instance using the specified properties. + * @function create + * @memberof google.api.MetricDescriptor.MetricDescriptorMetadata + * @static + * @param {google.api.MetricDescriptor.IMetricDescriptorMetadata=} [properties] Properties to set + * @returns {google.api.MetricDescriptor.MetricDescriptorMetadata} MetricDescriptorMetadata instance + */ + MetricDescriptorMetadata.create = function create(properties) { + return new MetricDescriptorMetadata(properties) + } + + /** + * Encodes the specified MetricDescriptorMetadata message. Does not implicitly {@link google.api.MetricDescriptor.MetricDescriptorMetadata.verify|verify} messages. + * @function encode + * @memberof google.api.MetricDescriptor.MetricDescriptorMetadata + * @static + * @param {google.api.MetricDescriptor.IMetricDescriptorMetadata} message MetricDescriptorMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MetricDescriptorMetadata.encode = function encode( + message, + writer + ) { + if (!writer) writer = $Writer.create() + if ( + message.launchStage != null && + Object.hasOwnProperty.call(message, 'launchStage') + ) + writer + .uint32(/* id 1, wireType 0 =*/ 8) + .int32(message.launchStage) + if ( + message.samplePeriod != null && + Object.hasOwnProperty.call(message, 'samplePeriod') + ) + $root.google.protobuf.Duration.encode( + message.samplePeriod, + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + ).ldelim() + if ( + message.ingestDelay != null && + Object.hasOwnProperty.call(message, 'ingestDelay') + ) + $root.google.protobuf.Duration.encode( + message.ingestDelay, + writer.uint32(/* id 3, wireType 2 =*/ 26).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified MetricDescriptorMetadata message, length delimited. Does not implicitly {@link google.api.MetricDescriptor.MetricDescriptorMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.MetricDescriptor.MetricDescriptorMetadata + * @static + * @param {google.api.MetricDescriptor.IMetricDescriptorMetadata} message MetricDescriptorMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MetricDescriptorMetadata.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a MetricDescriptorMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.api.MetricDescriptor.MetricDescriptorMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.MetricDescriptor.MetricDescriptorMetadata} MetricDescriptorMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MetricDescriptorMetadata.decode = function decode( + reader, + length + ) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.api.MetricDescriptor.MetricDescriptorMetadata() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.launchStage = reader.int32() + break + case 2: + message.samplePeriod = $root.google.protobuf.Duration.decode( + reader, + reader.uint32() + ) + break + case 3: + message.ingestDelay = $root.google.protobuf.Duration.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a MetricDescriptorMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.MetricDescriptor.MetricDescriptorMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.MetricDescriptor.MetricDescriptorMetadata} MetricDescriptorMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MetricDescriptorMetadata.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a MetricDescriptorMetadata message. + * @function verify + * @memberof google.api.MetricDescriptor.MetricDescriptorMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + MetricDescriptorMetadata.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.launchStage != null && + message.hasOwnProperty('launchStage') + ) + switch (message.launchStage) { + default: + return 'launchStage: enum value expected' + case 0: + case 6: + case 7: + case 1: + case 2: + case 3: + case 4: + case 5: + break + } + if ( + message.samplePeriod != null && + message.hasOwnProperty('samplePeriod') + ) { + var error = $root.google.protobuf.Duration.verify( + message.samplePeriod + ) + if (error) return 'samplePeriod.' + error + } + if ( + message.ingestDelay != null && + message.hasOwnProperty('ingestDelay') + ) { + var error = $root.google.protobuf.Duration.verify( + message.ingestDelay + ) + if (error) return 'ingestDelay.' + error + } + return null + } + + /** + * Creates a MetricDescriptorMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.MetricDescriptor.MetricDescriptorMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.api.MetricDescriptor.MetricDescriptorMetadata} MetricDescriptorMetadata + */ + MetricDescriptorMetadata.fromObject = function fromObject( + object + ) { + if ( + object instanceof + $root.google.api.MetricDescriptor.MetricDescriptorMetadata + ) + return object + var message = new $root.google.api.MetricDescriptor.MetricDescriptorMetadata() + switch (object.launchStage) { + case 'LAUNCH_STAGE_UNSPECIFIED': + case 0: + message.launchStage = 0 + break + case 'UNIMPLEMENTED': + case 6: + message.launchStage = 6 + break + case 'PRELAUNCH': + case 7: + message.launchStage = 7 + break + case 'EARLY_ACCESS': + case 1: + message.launchStage = 1 + break + case 'ALPHA': + case 2: + message.launchStage = 2 + break + case 'BETA': + case 3: + message.launchStage = 3 + break + case 'GA': + case 4: + message.launchStage = 4 + break + case 'DEPRECATED': + case 5: + message.launchStage = 5 + break + } + if (object.samplePeriod != null) { + if (typeof object.samplePeriod !== 'object') + throw TypeError( + '.google.api.MetricDescriptor.MetricDescriptorMetadata.samplePeriod: object expected' + ) + message.samplePeriod = $root.google.protobuf.Duration.fromObject( + object.samplePeriod + ) + } + if (object.ingestDelay != null) { + if (typeof object.ingestDelay !== 'object') + throw TypeError( + '.google.api.MetricDescriptor.MetricDescriptorMetadata.ingestDelay: object expected' + ) + message.ingestDelay = $root.google.protobuf.Duration.fromObject( + object.ingestDelay + ) + } + return message + } + + /** + * Creates a plain object from a MetricDescriptorMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.MetricDescriptor.MetricDescriptorMetadata + * @static + * @param {google.api.MetricDescriptor.MetricDescriptorMetadata} message MetricDescriptorMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MetricDescriptorMetadata.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.launchStage = + options.enums === String ? 'LAUNCH_STAGE_UNSPECIFIED' : 0 + object.samplePeriod = null + object.ingestDelay = null + } + if ( + message.launchStage != null && + message.hasOwnProperty('launchStage') + ) + object.launchStage = + options.enums === String + ? $root.google.api.LaunchStage[message.launchStage] + : message.launchStage + if ( + message.samplePeriod != null && + message.hasOwnProperty('samplePeriod') + ) + object.samplePeriod = $root.google.protobuf.Duration.toObject( + message.samplePeriod, + options + ) + if ( + message.ingestDelay != null && + message.hasOwnProperty('ingestDelay') + ) + object.ingestDelay = $root.google.protobuf.Duration.toObject( + message.ingestDelay, + options + ) + return object + } + + /** + * Converts this MetricDescriptorMetadata to JSON. + * @function toJSON + * @memberof google.api.MetricDescriptor.MetricDescriptorMetadata + * @instance + * @returns {Object.} JSON object + */ + MetricDescriptorMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return MetricDescriptorMetadata + })() + + /** + * MetricKind enum. + * @name google.api.MetricDescriptor.MetricKind + * @enum {number} + * @property {number} METRIC_KIND_UNSPECIFIED=0 METRIC_KIND_UNSPECIFIED value + * @property {number} GAUGE=1 GAUGE value + * @property {number} DELTA=2 DELTA value + * @property {number} CUMULATIVE=3 CUMULATIVE value + */ + MetricDescriptor.MetricKind = (function () { + var valuesById = {}, + values = Object.create(valuesById) + values[(valuesById[0] = 'METRIC_KIND_UNSPECIFIED')] = 0 + values[(valuesById[1] = 'GAUGE')] = 1 + values[(valuesById[2] = 'DELTA')] = 2 + values[(valuesById[3] = 'CUMULATIVE')] = 3 + return values + })() + + /** + * ValueType enum. + * @name google.api.MetricDescriptor.ValueType + * @enum {number} + * @property {number} VALUE_TYPE_UNSPECIFIED=0 VALUE_TYPE_UNSPECIFIED value + * @property {number} BOOL=1 BOOL value + * @property {number} INT64=2 INT64 value + * @property {number} DOUBLE=3 DOUBLE value + * @property {number} STRING=4 STRING value + * @property {number} DISTRIBUTION=5 DISTRIBUTION value + * @property {number} MONEY=6 MONEY value + */ + MetricDescriptor.ValueType = (function () { + var valuesById = {}, + values = Object.create(valuesById) + values[(valuesById[0] = 'VALUE_TYPE_UNSPECIFIED')] = 0 + values[(valuesById[1] = 'BOOL')] = 1 + values[(valuesById[2] = 'INT64')] = 2 + values[(valuesById[3] = 'DOUBLE')] = 3 + values[(valuesById[4] = 'STRING')] = 4 + values[(valuesById[5] = 'DISTRIBUTION')] = 5 + values[(valuesById[6] = 'MONEY')] = 6 + return values + })() + + return MetricDescriptor + })() + + api.Metric = (function () { + /** + * Properties of a Metric. + * @memberof google.api + * @interface IMetric + * @property {string|null} [type] Metric type + * @property {Object.|null} [labels] Metric labels + */ + + /** + * Constructs a new Metric. + * @memberof google.api + * @classdesc Represents a Metric. + * @implements IMetric + * @constructor + * @param {google.api.IMetric=} [properties] Properties to set + */ + function Metric(properties) { + this.labels = {} + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * Metric type. + * @member {string} type + * @memberof google.api.Metric + * @instance + */ + Metric.prototype.type = '' + + /** + * Metric labels. + * @member {Object.} labels + * @memberof google.api.Metric + * @instance + */ + Metric.prototype.labels = $util.emptyObject + + /** + * Creates a new Metric instance using the specified properties. + * @function create + * @memberof google.api.Metric + * @static + * @param {google.api.IMetric=} [properties] Properties to set + * @returns {google.api.Metric} Metric instance + */ + Metric.create = function create(properties) { + return new Metric(properties) + } + + /** + * Encodes the specified Metric message. Does not implicitly {@link google.api.Metric.verify|verify} messages. + * @function encode + * @memberof google.api.Metric + * @static + * @param {google.api.IMetric} message Metric message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Metric.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.labels != null && + Object.hasOwnProperty.call(message, 'labels') + ) + for ( + var keys = Object.keys(message.labels), i = 0; + i < keys.length; + ++i + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .fork() + .uint32(/* id 1, wireType 2 =*/ 10) + .string(keys[i]) + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.labels[keys[i]]) + .ldelim() + if ( + message.type != null && + Object.hasOwnProperty.call(message, 'type') + ) + writer.uint32(/* id 3, wireType 2 =*/ 26).string(message.type) + return writer + } + + /** + * Encodes the specified Metric message, length delimited. Does not implicitly {@link google.api.Metric.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.Metric + * @static + * @param {google.api.IMetric} message Metric message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Metric.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a Metric message from the specified reader or buffer. + * @function decode + * @memberof google.api.Metric + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.Metric} Metric + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Metric.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.api.Metric(), + key, + value + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 3: + message.type = reader.string() + break + case 2: + if (message.labels === $util.emptyObject) + message.labels = {} + var end2 = reader.uint32() + reader.pos + key = '' + value = '' + while (reader.pos < end2) { + var tag2 = reader.uint32() + switch (tag2 >>> 3) { + case 1: + key = reader.string() + break + case 2: + value = reader.string() + break + default: + reader.skipType(tag2 & 7) + break + } + } + message.labels[key] = value + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a Metric message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.Metric + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.Metric} Metric + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Metric.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a Metric message. + * @function verify + * @memberof google.api.Metric + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Metric.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.type != null && message.hasOwnProperty('type')) + if (!$util.isString(message.type)) + return 'type: string expected' + if ( + message.labels != null && + message.hasOwnProperty('labels') + ) { + if (!$util.isObject(message.labels)) + return 'labels: object expected' + var key = Object.keys(message.labels) + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.labels[key[i]])) + return 'labels: string{k:string} expected' + } + return null + } + + /** + * Creates a Metric message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.Metric + * @static + * @param {Object.} object Plain object + * @returns {google.api.Metric} Metric + */ + Metric.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.Metric) return object + var message = new $root.google.api.Metric() + if (object.type != null) message.type = String(object.type) + if (object.labels) { + if (typeof object.labels !== 'object') + throw TypeError( + '.google.api.Metric.labels: object expected' + ) + message.labels = {} + for ( + var keys = Object.keys(object.labels), i = 0; + i < keys.length; + ++i + ) + message.labels[keys[i]] = String(object.labels[keys[i]]) + } + return message + } + + /** + * Creates a plain object from a Metric message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.Metric + * @static + * @param {google.api.Metric} message Metric + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Metric.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.objects || options.defaults) object.labels = {} + if (options.defaults) object.type = '' + var keys2 + if ( + message.labels && + (keys2 = Object.keys(message.labels)).length + ) { + object.labels = {} + for (var j = 0; j < keys2.length; ++j) + object.labels[keys2[j]] = message.labels[keys2[j]] + } + if (message.type != null && message.hasOwnProperty('type')) + object.type = message.type + return object + } + + /** + * Converts this Metric to JSON. + * @function toJSON + * @memberof google.api.Metric + * @instance + * @returns {Object.} JSON object + */ + Metric.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return Metric + })() + + return api + })() + + google.protobuf = (function () { + /** + * Namespace protobuf. + * @memberof google + * @namespace + */ + var protobuf = {} + + protobuf.FileDescriptorSet = (function () { + /** + * Properties of a FileDescriptorSet. + * @memberof google.protobuf + * @interface IFileDescriptorSet + * @property {Array.|null} [file] FileDescriptorSet file + */ + + /** + * Constructs a new FileDescriptorSet. + * @memberof google.protobuf + * @classdesc Represents a FileDescriptorSet. + * @implements IFileDescriptorSet + * @constructor + * @param {google.protobuf.IFileDescriptorSet=} [properties] Properties to set + */ + function FileDescriptorSet(properties) { + this.file = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * FileDescriptorSet file. + * @member {Array.} file + * @memberof google.protobuf.FileDescriptorSet + * @instance + */ + FileDescriptorSet.prototype.file = $util.emptyArray + + /** + * Creates a new FileDescriptorSet instance using the specified properties. + * @function create + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {google.protobuf.IFileDescriptorSet=} [properties] Properties to set + * @returns {google.protobuf.FileDescriptorSet} FileDescriptorSet instance + */ + FileDescriptorSet.create = function create(properties) { + return new FileDescriptorSet(properties) + } + + /** + * Encodes the specified FileDescriptorSet message. Does not implicitly {@link google.protobuf.FileDescriptorSet.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {google.protobuf.IFileDescriptorSet} message FileDescriptorSet message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FileDescriptorSet.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.file != null && message.file.length) + for (var i = 0; i < message.file.length; ++i) + $root.google.protobuf.FileDescriptorProto.encode( + message.file[i], + writer.uint32(/* id 1, wireType 2 =*/ 10).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified FileDescriptorSet message, length delimited. Does not implicitly {@link google.protobuf.FileDescriptorSet.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {google.protobuf.IFileDescriptorSet} message FileDescriptorSet message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FileDescriptorSet.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a FileDescriptorSet message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FileDescriptorSet} FileDescriptorSet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FileDescriptorSet.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.FileDescriptorSet() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + if (!(message.file && message.file.length)) + message.file = [] + message.file.push( + $root.google.protobuf.FileDescriptorProto.decode( + reader, + reader.uint32() + ) + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a FileDescriptorSet message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FileDescriptorSet} FileDescriptorSet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FileDescriptorSet.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a FileDescriptorSet message. + * @function verify + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FileDescriptorSet.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.file != null && message.hasOwnProperty('file')) { + if (!Array.isArray(message.file)) + return 'file: array expected' + for (var i = 0; i < message.file.length; ++i) { + var error = $root.google.protobuf.FileDescriptorProto.verify( + message.file[i] + ) + if (error) return 'file.' + error + } + } + return null + } + + /** + * Creates a FileDescriptorSet message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FileDescriptorSet} FileDescriptorSet + */ + FileDescriptorSet.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FileDescriptorSet) + return object + var message = new $root.google.protobuf.FileDescriptorSet() + if (object.file) { + if (!Array.isArray(object.file)) + throw TypeError( + '.google.protobuf.FileDescriptorSet.file: array expected' + ) + message.file = [] + for (var i = 0; i < object.file.length; ++i) { + if (typeof object.file[i] !== 'object') + throw TypeError( + '.google.protobuf.FileDescriptorSet.file: object expected' + ) + message.file[ + i + ] = $root.google.protobuf.FileDescriptorProto.fromObject( + object.file[i] + ) + } + } + return message + } + + /** + * Creates a plain object from a FileDescriptorSet message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {google.protobuf.FileDescriptorSet} message FileDescriptorSet + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FileDescriptorSet.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) object.file = [] + if (message.file && message.file.length) { + object.file = [] + for (var j = 0; j < message.file.length; ++j) + object.file[ + j + ] = $root.google.protobuf.FileDescriptorProto.toObject( + message.file[j], + options + ) + } + return object + } + + /** + * Converts this FileDescriptorSet to JSON. + * @function toJSON + * @memberof google.protobuf.FileDescriptorSet + * @instance + * @returns {Object.} JSON object + */ + FileDescriptorSet.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return FileDescriptorSet + })() + + protobuf.FileDescriptorProto = (function () { + /** + * Properties of a FileDescriptorProto. + * @memberof google.protobuf + * @interface IFileDescriptorProto + * @property {string|null} [name] FileDescriptorProto name + * @property {string|null} ["package"] FileDescriptorProto package + * @property {Array.|null} [dependency] FileDescriptorProto dependency + * @property {Array.|null} [publicDependency] FileDescriptorProto publicDependency + * @property {Array.|null} [weakDependency] FileDescriptorProto weakDependency + * @property {Array.|null} [messageType] FileDescriptorProto messageType + * @property {Array.|null} [enumType] FileDescriptorProto enumType + * @property {Array.|null} [service] FileDescriptorProto service + * @property {Array.|null} [extension] FileDescriptorProto extension + * @property {google.protobuf.IFileOptions|null} [options] FileDescriptorProto options + * @property {google.protobuf.ISourceCodeInfo|null} [sourceCodeInfo] FileDescriptorProto sourceCodeInfo + * @property {string|null} [syntax] FileDescriptorProto syntax + */ + + /** + * Constructs a new FileDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a FileDescriptorProto. + * @implements IFileDescriptorProto + * @constructor + * @param {google.protobuf.IFileDescriptorProto=} [properties] Properties to set + */ + function FileDescriptorProto(properties) { + this.dependency = [] + this.publicDependency = [] + this.weakDependency = [] + this.messageType = [] + this.enumType = [] + this.service = [] + this.extension = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * FileDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.name = '' + + /** + * FileDescriptorProto package. + * @member {string} package + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype['package'] = '' + + /** + * FileDescriptorProto dependency. + * @member {Array.} dependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.dependency = $util.emptyArray + + /** + * FileDescriptorProto publicDependency. + * @member {Array.} publicDependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.publicDependency = $util.emptyArray + + /** + * FileDescriptorProto weakDependency. + * @member {Array.} weakDependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.weakDependency = $util.emptyArray + + /** + * FileDescriptorProto messageType. + * @member {Array.} messageType + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.messageType = $util.emptyArray + + /** + * FileDescriptorProto enumType. + * @member {Array.} enumType + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.enumType = $util.emptyArray + + /** + * FileDescriptorProto service. + * @member {Array.} service + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.service = $util.emptyArray + + /** + * FileDescriptorProto extension. + * @member {Array.} extension + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.extension = $util.emptyArray + + /** + * FileDescriptorProto options. + * @member {google.protobuf.IFileOptions|null|undefined} options + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.options = null + + /** + * FileDescriptorProto sourceCodeInfo. + * @member {google.protobuf.ISourceCodeInfo|null|undefined} sourceCodeInfo + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.sourceCodeInfo = null + + /** + * FileDescriptorProto syntax. + * @member {string} syntax + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.syntax = '' + + /** + * Creates a new FileDescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {google.protobuf.IFileDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.FileDescriptorProto} FileDescriptorProto instance + */ + FileDescriptorProto.create = function create(properties) { + return new FileDescriptorProto(properties) + } + + /** + * Encodes the specified FileDescriptorProto message. Does not implicitly {@link google.protobuf.FileDescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {google.protobuf.IFileDescriptorProto} message FileDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FileDescriptorProto.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.name != null && + Object.hasOwnProperty.call(message, 'name') + ) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.name) + if ( + message['package'] != null && + Object.hasOwnProperty.call(message, 'package') + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message['package']) + if (message.dependency != null && message.dependency.length) + for (var i = 0; i < message.dependency.length; ++i) + writer + .uint32(/* id 3, wireType 2 =*/ 26) + .string(message.dependency[i]) + if (message.messageType != null && message.messageType.length) + for (var i = 0; i < message.messageType.length; ++i) + $root.google.protobuf.DescriptorProto.encode( + message.messageType[i], + writer.uint32(/* id 4, wireType 2 =*/ 34).fork() + ).ldelim() + if (message.enumType != null && message.enumType.length) + for (var i = 0; i < message.enumType.length; ++i) + $root.google.protobuf.EnumDescriptorProto.encode( + message.enumType[i], + writer.uint32(/* id 5, wireType 2 =*/ 42).fork() + ).ldelim() + if (message.service != null && message.service.length) + for (var i = 0; i < message.service.length; ++i) + $root.google.protobuf.ServiceDescriptorProto.encode( + message.service[i], + writer.uint32(/* id 6, wireType 2 =*/ 50).fork() + ).ldelim() + if (message.extension != null && message.extension.length) + for (var i = 0; i < message.extension.length; ++i) + $root.google.protobuf.FieldDescriptorProto.encode( + message.extension[i], + writer.uint32(/* id 7, wireType 2 =*/ 58).fork() + ).ldelim() + if ( + message.options != null && + Object.hasOwnProperty.call(message, 'options') + ) + $root.google.protobuf.FileOptions.encode( + message.options, + writer.uint32(/* id 8, wireType 2 =*/ 66).fork() + ).ldelim() + if ( + message.sourceCodeInfo != null && + Object.hasOwnProperty.call(message, 'sourceCodeInfo') + ) + $root.google.protobuf.SourceCodeInfo.encode( + message.sourceCodeInfo, + writer.uint32(/* id 9, wireType 2 =*/ 74).fork() + ).ldelim() + if ( + message.publicDependency != null && + message.publicDependency.length + ) + for (var i = 0; i < message.publicDependency.length; ++i) + writer + .uint32(/* id 10, wireType 0 =*/ 80) + .int32(message.publicDependency[i]) + if ( + message.weakDependency != null && + message.weakDependency.length + ) + for (var i = 0; i < message.weakDependency.length; ++i) + writer + .uint32(/* id 11, wireType 0 =*/ 88) + .int32(message.weakDependency[i]) + if ( + message.syntax != null && + Object.hasOwnProperty.call(message, 'syntax') + ) + writer + .uint32(/* id 12, wireType 2 =*/ 98) + .string(message.syntax) + return writer + } + + /** + * Encodes the specified FileDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.FileDescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {google.protobuf.IFileDescriptorProto} message FileDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FileDescriptorProto.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a FileDescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FileDescriptorProto} FileDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FileDescriptorProto.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.FileDescriptorProto() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + case 2: + message['package'] = reader.string() + break + case 3: + if (!(message.dependency && message.dependency.length)) + message.dependency = [] + message.dependency.push(reader.string()) + break + case 10: + if ( + !( + message.publicDependency && + message.publicDependency.length + ) + ) + message.publicDependency = [] + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos + while (reader.pos < end2) + message.publicDependency.push(reader.int32()) + } else message.publicDependency.push(reader.int32()) + break + case 11: + if ( + !( + message.weakDependency && + message.weakDependency.length + ) + ) + message.weakDependency = [] + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos + while (reader.pos < end2) + message.weakDependency.push(reader.int32()) + } else message.weakDependency.push(reader.int32()) + break + case 4: + if (!(message.messageType && message.messageType.length)) + message.messageType = [] + message.messageType.push( + $root.google.protobuf.DescriptorProto.decode( + reader, + reader.uint32() + ) + ) + break + case 5: + if (!(message.enumType && message.enumType.length)) + message.enumType = [] + message.enumType.push( + $root.google.protobuf.EnumDescriptorProto.decode( + reader, + reader.uint32() + ) + ) + break + case 6: + if (!(message.service && message.service.length)) + message.service = [] + message.service.push( + $root.google.protobuf.ServiceDescriptorProto.decode( + reader, + reader.uint32() + ) + ) + break + case 7: + if (!(message.extension && message.extension.length)) + message.extension = [] + message.extension.push( + $root.google.protobuf.FieldDescriptorProto.decode( + reader, + reader.uint32() + ) + ) + break + case 8: + message.options = $root.google.protobuf.FileOptions.decode( + reader, + reader.uint32() + ) + break + case 9: + message.sourceCodeInfo = $root.google.protobuf.SourceCodeInfo.decode( + reader, + reader.uint32() + ) + break + case 12: + message.syntax = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a FileDescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FileDescriptorProto} FileDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FileDescriptorProto.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a FileDescriptorProto message. + * @function verify + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FileDescriptorProto.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + if ( + message['package'] != null && + message.hasOwnProperty('package') + ) + if (!$util.isString(message['package'])) + return 'package: string expected' + if ( + message.dependency != null && + message.hasOwnProperty('dependency') + ) { + if (!Array.isArray(message.dependency)) + return 'dependency: array expected' + for (var i = 0; i < message.dependency.length; ++i) + if (!$util.isString(message.dependency[i])) + return 'dependency: string[] expected' + } + if ( + message.publicDependency != null && + message.hasOwnProperty('publicDependency') + ) { + if (!Array.isArray(message.publicDependency)) + return 'publicDependency: array expected' + for (var i = 0; i < message.publicDependency.length; ++i) + if (!$util.isInteger(message.publicDependency[i])) + return 'publicDependency: integer[] expected' + } + if ( + message.weakDependency != null && + message.hasOwnProperty('weakDependency') + ) { + if (!Array.isArray(message.weakDependency)) + return 'weakDependency: array expected' + for (var i = 0; i < message.weakDependency.length; ++i) + if (!$util.isInteger(message.weakDependency[i])) + return 'weakDependency: integer[] expected' + } + if ( + message.messageType != null && + message.hasOwnProperty('messageType') + ) { + if (!Array.isArray(message.messageType)) + return 'messageType: array expected' + for (var i = 0; i < message.messageType.length; ++i) { + var error = $root.google.protobuf.DescriptorProto.verify( + message.messageType[i] + ) + if (error) return 'messageType.' + error + } + } + if ( + message.enumType != null && + message.hasOwnProperty('enumType') + ) { + if (!Array.isArray(message.enumType)) + return 'enumType: array expected' + for (var i = 0; i < message.enumType.length; ++i) { + var error = $root.google.protobuf.EnumDescriptorProto.verify( + message.enumType[i] + ) + if (error) return 'enumType.' + error + } + } + if ( + message.service != null && + message.hasOwnProperty('service') + ) { + if (!Array.isArray(message.service)) + return 'service: array expected' + for (var i = 0; i < message.service.length; ++i) { + var error = $root.google.protobuf.ServiceDescriptorProto.verify( + message.service[i] + ) + if (error) return 'service.' + error + } + } + if ( + message.extension != null && + message.hasOwnProperty('extension') + ) { + if (!Array.isArray(message.extension)) + return 'extension: array expected' + for (var i = 0; i < message.extension.length; ++i) { + var error = $root.google.protobuf.FieldDescriptorProto.verify( + message.extension[i] + ) + if (error) return 'extension.' + error + } + } + if ( + message.options != null && + message.hasOwnProperty('options') + ) { + var error = $root.google.protobuf.FileOptions.verify( + message.options + ) + if (error) return 'options.' + error + } + if ( + message.sourceCodeInfo != null && + message.hasOwnProperty('sourceCodeInfo') + ) { + var error = $root.google.protobuf.SourceCodeInfo.verify( + message.sourceCodeInfo + ) + if (error) return 'sourceCodeInfo.' + error + } + if (message.syntax != null && message.hasOwnProperty('syntax')) + if (!$util.isString(message.syntax)) + return 'syntax: string expected' + return null + } + + /** + * Creates a FileDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FileDescriptorProto} FileDescriptorProto + */ + FileDescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FileDescriptorProto) + return object + var message = new $root.google.protobuf.FileDescriptorProto() + if (object.name != null) message.name = String(object.name) + if (object['package'] != null) + message['package'] = String(object['package']) + if (object.dependency) { + if (!Array.isArray(object.dependency)) + throw TypeError( + '.google.protobuf.FileDescriptorProto.dependency: array expected' + ) + message.dependency = [] + for (var i = 0; i < object.dependency.length; ++i) + message.dependency[i] = String(object.dependency[i]) + } + if (object.publicDependency) { + if (!Array.isArray(object.publicDependency)) + throw TypeError( + '.google.protobuf.FileDescriptorProto.publicDependency: array expected' + ) + message.publicDependency = [] + for (var i = 0; i < object.publicDependency.length; ++i) + message.publicDependency[i] = object.publicDependency[i] | 0 + } + if (object.weakDependency) { + if (!Array.isArray(object.weakDependency)) + throw TypeError( + '.google.protobuf.FileDescriptorProto.weakDependency: array expected' + ) + message.weakDependency = [] + for (var i = 0; i < object.weakDependency.length; ++i) + message.weakDependency[i] = object.weakDependency[i] | 0 + } + if (object.messageType) { + if (!Array.isArray(object.messageType)) + throw TypeError( + '.google.protobuf.FileDescriptorProto.messageType: array expected' + ) + message.messageType = [] + for (var i = 0; i < object.messageType.length; ++i) { + if (typeof object.messageType[i] !== 'object') + throw TypeError( + '.google.protobuf.FileDescriptorProto.messageType: object expected' + ) + message.messageType[ + i + ] = $root.google.protobuf.DescriptorProto.fromObject( + object.messageType[i] + ) + } + } + if (object.enumType) { + if (!Array.isArray(object.enumType)) + throw TypeError( + '.google.protobuf.FileDescriptorProto.enumType: array expected' + ) + message.enumType = [] + for (var i = 0; i < object.enumType.length; ++i) { + if (typeof object.enumType[i] !== 'object') + throw TypeError( + '.google.protobuf.FileDescriptorProto.enumType: object expected' + ) + message.enumType[ + i + ] = $root.google.protobuf.EnumDescriptorProto.fromObject( + object.enumType[i] + ) + } + } + if (object.service) { + if (!Array.isArray(object.service)) + throw TypeError( + '.google.protobuf.FileDescriptorProto.service: array expected' + ) + message.service = [] + for (var i = 0; i < object.service.length; ++i) { + if (typeof object.service[i] !== 'object') + throw TypeError( + '.google.protobuf.FileDescriptorProto.service: object expected' + ) + message.service[ + i + ] = $root.google.protobuf.ServiceDescriptorProto.fromObject( + object.service[i] + ) + } + } + if (object.extension) { + if (!Array.isArray(object.extension)) + throw TypeError( + '.google.protobuf.FileDescriptorProto.extension: array expected' + ) + message.extension = [] + for (var i = 0; i < object.extension.length; ++i) { + if (typeof object.extension[i] !== 'object') + throw TypeError( + '.google.protobuf.FileDescriptorProto.extension: object expected' + ) + message.extension[ + i + ] = $root.google.protobuf.FieldDescriptorProto.fromObject( + object.extension[i] + ) + } + } + if (object.options != null) { + if (typeof object.options !== 'object') + throw TypeError( + '.google.protobuf.FileDescriptorProto.options: object expected' + ) + message.options = $root.google.protobuf.FileOptions.fromObject( + object.options + ) + } + if (object.sourceCodeInfo != null) { + if (typeof object.sourceCodeInfo !== 'object') + throw TypeError( + '.google.protobuf.FileDescriptorProto.sourceCodeInfo: object expected' + ) + message.sourceCodeInfo = $root.google.protobuf.SourceCodeInfo.fromObject( + object.sourceCodeInfo + ) + } + if (object.syntax != null) + message.syntax = String(object.syntax) + return message + } + + /** + * Creates a plain object from a FileDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {google.protobuf.FileDescriptorProto} message FileDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FileDescriptorProto.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) { + object.dependency = [] + object.messageType = [] + object.enumType = [] + object.service = [] + object.extension = [] + object.publicDependency = [] + object.weakDependency = [] + } + if (options.defaults) { + object.name = '' + object['package'] = '' + object.options = null + object.sourceCodeInfo = null + object.syntax = '' + } + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + if ( + message['package'] != null && + message.hasOwnProperty('package') + ) + object['package'] = message['package'] + if (message.dependency && message.dependency.length) { + object.dependency = [] + for (var j = 0; j < message.dependency.length; ++j) + object.dependency[j] = message.dependency[j] + } + if (message.messageType && message.messageType.length) { + object.messageType = [] + for (var j = 0; j < message.messageType.length; ++j) + object.messageType[ + j + ] = $root.google.protobuf.DescriptorProto.toObject( + message.messageType[j], + options + ) + } + if (message.enumType && message.enumType.length) { + object.enumType = [] + for (var j = 0; j < message.enumType.length; ++j) + object.enumType[ + j + ] = $root.google.protobuf.EnumDescriptorProto.toObject( + message.enumType[j], + options + ) + } + if (message.service && message.service.length) { + object.service = [] + for (var j = 0; j < message.service.length; ++j) + object.service[ + j + ] = $root.google.protobuf.ServiceDescriptorProto.toObject( + message.service[j], + options + ) + } + if (message.extension && message.extension.length) { + object.extension = [] + for (var j = 0; j < message.extension.length; ++j) + object.extension[ + j + ] = $root.google.protobuf.FieldDescriptorProto.toObject( + message.extension[j], + options + ) + } + if ( + message.options != null && + message.hasOwnProperty('options') + ) + object.options = $root.google.protobuf.FileOptions.toObject( + message.options, + options + ) + if ( + message.sourceCodeInfo != null && + message.hasOwnProperty('sourceCodeInfo') + ) + object.sourceCodeInfo = $root.google.protobuf.SourceCodeInfo.toObject( + message.sourceCodeInfo, + options + ) + if ( + message.publicDependency && + message.publicDependency.length + ) { + object.publicDependency = [] + for (var j = 0; j < message.publicDependency.length; ++j) + object.publicDependency[j] = message.publicDependency[j] + } + if (message.weakDependency && message.weakDependency.length) { + object.weakDependency = [] + for (var j = 0; j < message.weakDependency.length; ++j) + object.weakDependency[j] = message.weakDependency[j] + } + if (message.syntax != null && message.hasOwnProperty('syntax')) + object.syntax = message.syntax + return object + } + + /** + * Converts this FileDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.FileDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + FileDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return FileDescriptorProto + })() + + protobuf.DescriptorProto = (function () { + /** + * Properties of a DescriptorProto. + * @memberof google.protobuf + * @interface IDescriptorProto + * @property {string|null} [name] DescriptorProto name + * @property {Array.|null} [field] DescriptorProto field + * @property {Array.|null} [extension] DescriptorProto extension + * @property {Array.|null} [nestedType] DescriptorProto nestedType + * @property {Array.|null} [enumType] DescriptorProto enumType + * @property {Array.|null} [extensionRange] DescriptorProto extensionRange + * @property {Array.|null} [oneofDecl] DescriptorProto oneofDecl + * @property {google.protobuf.IMessageOptions|null} [options] DescriptorProto options + * @property {Array.|null} [reservedRange] DescriptorProto reservedRange + * @property {Array.|null} [reservedName] DescriptorProto reservedName + */ + + /** + * Constructs a new DescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a DescriptorProto. + * @implements IDescriptorProto + * @constructor + * @param {google.protobuf.IDescriptorProto=} [properties] Properties to set + */ + function DescriptorProto(properties) { + this.field = [] + this.extension = [] + this.nestedType = [] + this.enumType = [] + this.extensionRange = [] + this.oneofDecl = [] + this.reservedRange = [] + this.reservedName = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * DescriptorProto name. + * @member {string} name + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.name = '' + + /** + * DescriptorProto field. + * @member {Array.} field + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.field = $util.emptyArray + + /** + * DescriptorProto extension. + * @member {Array.} extension + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.extension = $util.emptyArray + + /** + * DescriptorProto nestedType. + * @member {Array.} nestedType + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.nestedType = $util.emptyArray + + /** + * DescriptorProto enumType. + * @member {Array.} enumType + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.enumType = $util.emptyArray + + /** + * DescriptorProto extensionRange. + * @member {Array.} extensionRange + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.extensionRange = $util.emptyArray + + /** + * DescriptorProto oneofDecl. + * @member {Array.} oneofDecl + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.oneofDecl = $util.emptyArray + + /** + * DescriptorProto options. + * @member {google.protobuf.IMessageOptions|null|undefined} options + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.options = null + + /** + * DescriptorProto reservedRange. + * @member {Array.} reservedRange + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.reservedRange = $util.emptyArray + + /** + * DescriptorProto reservedName. + * @member {Array.} reservedName + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.reservedName = $util.emptyArray + + /** + * Creates a new DescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.DescriptorProto + * @static + * @param {google.protobuf.IDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.DescriptorProto} DescriptorProto instance + */ + DescriptorProto.create = function create(properties) { + return new DescriptorProto(properties) + } + + /** + * Encodes the specified DescriptorProto message. Does not implicitly {@link google.protobuf.DescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.DescriptorProto + * @static + * @param {google.protobuf.IDescriptorProto} message DescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DescriptorProto.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.name != null && + Object.hasOwnProperty.call(message, 'name') + ) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.name) + if (message.field != null && message.field.length) + for (var i = 0; i < message.field.length; ++i) + $root.google.protobuf.FieldDescriptorProto.encode( + message.field[i], + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + ).ldelim() + if (message.nestedType != null && message.nestedType.length) + for (var i = 0; i < message.nestedType.length; ++i) + $root.google.protobuf.DescriptorProto.encode( + message.nestedType[i], + writer.uint32(/* id 3, wireType 2 =*/ 26).fork() + ).ldelim() + if (message.enumType != null && message.enumType.length) + for (var i = 0; i < message.enumType.length; ++i) + $root.google.protobuf.EnumDescriptorProto.encode( + message.enumType[i], + writer.uint32(/* id 4, wireType 2 =*/ 34).fork() + ).ldelim() + if ( + message.extensionRange != null && + message.extensionRange.length + ) + for (var i = 0; i < message.extensionRange.length; ++i) + $root.google.protobuf.DescriptorProto.ExtensionRange.encode( + message.extensionRange[i], + writer.uint32(/* id 5, wireType 2 =*/ 42).fork() + ).ldelim() + if (message.extension != null && message.extension.length) + for (var i = 0; i < message.extension.length; ++i) + $root.google.protobuf.FieldDescriptorProto.encode( + message.extension[i], + writer.uint32(/* id 6, wireType 2 =*/ 50).fork() + ).ldelim() + if ( + message.options != null && + Object.hasOwnProperty.call(message, 'options') + ) + $root.google.protobuf.MessageOptions.encode( + message.options, + writer.uint32(/* id 7, wireType 2 =*/ 58).fork() + ).ldelim() + if (message.oneofDecl != null && message.oneofDecl.length) + for (var i = 0; i < message.oneofDecl.length; ++i) + $root.google.protobuf.OneofDescriptorProto.encode( + message.oneofDecl[i], + writer.uint32(/* id 8, wireType 2 =*/ 66).fork() + ).ldelim() + if ( + message.reservedRange != null && + message.reservedRange.length + ) + for (var i = 0; i < message.reservedRange.length; ++i) + $root.google.protobuf.DescriptorProto.ReservedRange.encode( + message.reservedRange[i], + writer.uint32(/* id 9, wireType 2 =*/ 74).fork() + ).ldelim() + if (message.reservedName != null && message.reservedName.length) + for (var i = 0; i < message.reservedName.length; ++i) + writer + .uint32(/* id 10, wireType 2 =*/ 82) + .string(message.reservedName[i]) + return writer + } + + /** + * Encodes the specified DescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.DescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.DescriptorProto + * @static + * @param {google.protobuf.IDescriptorProto} message DescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DescriptorProto.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a DescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.DescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.DescriptorProto} DescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DescriptorProto.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.DescriptorProto() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + case 2: + if (!(message.field && message.field.length)) + message.field = [] + message.field.push( + $root.google.protobuf.FieldDescriptorProto.decode( + reader, + reader.uint32() + ) + ) + break + case 6: + if (!(message.extension && message.extension.length)) + message.extension = [] + message.extension.push( + $root.google.protobuf.FieldDescriptorProto.decode( + reader, + reader.uint32() + ) + ) + break + case 3: + if (!(message.nestedType && message.nestedType.length)) + message.nestedType = [] + message.nestedType.push( + $root.google.protobuf.DescriptorProto.decode( + reader, + reader.uint32() + ) + ) + break + case 4: + if (!(message.enumType && message.enumType.length)) + message.enumType = [] + message.enumType.push( + $root.google.protobuf.EnumDescriptorProto.decode( + reader, + reader.uint32() + ) + ) + break + case 5: + if ( + !( + message.extensionRange && + message.extensionRange.length + ) + ) + message.extensionRange = [] + message.extensionRange.push( + $root.google.protobuf.DescriptorProto.ExtensionRange.decode( + reader, + reader.uint32() + ) + ) + break + case 8: + if (!(message.oneofDecl && message.oneofDecl.length)) + message.oneofDecl = [] + message.oneofDecl.push( + $root.google.protobuf.OneofDescriptorProto.decode( + reader, + reader.uint32() + ) + ) + break + case 7: + message.options = $root.google.protobuf.MessageOptions.decode( + reader, + reader.uint32() + ) + break + case 9: + if ( + !(message.reservedRange && message.reservedRange.length) + ) + message.reservedRange = [] + message.reservedRange.push( + $root.google.protobuf.DescriptorProto.ReservedRange.decode( + reader, + reader.uint32() + ) + ) + break + case 10: + if ( + !(message.reservedName && message.reservedName.length) + ) + message.reservedName = [] + message.reservedName.push(reader.string()) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a DescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.DescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.DescriptorProto} DescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DescriptorProto.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a DescriptorProto message. + * @function verify + * @memberof google.protobuf.DescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DescriptorProto.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + if (message.field != null && message.hasOwnProperty('field')) { + if (!Array.isArray(message.field)) + return 'field: array expected' + for (var i = 0; i < message.field.length; ++i) { + var error = $root.google.protobuf.FieldDescriptorProto.verify( + message.field[i] + ) + if (error) return 'field.' + error + } + } + if ( + message.extension != null && + message.hasOwnProperty('extension') + ) { + if (!Array.isArray(message.extension)) + return 'extension: array expected' + for (var i = 0; i < message.extension.length; ++i) { + var error = $root.google.protobuf.FieldDescriptorProto.verify( + message.extension[i] + ) + if (error) return 'extension.' + error + } + } + if ( + message.nestedType != null && + message.hasOwnProperty('nestedType') + ) { + if (!Array.isArray(message.nestedType)) + return 'nestedType: array expected' + for (var i = 0; i < message.nestedType.length; ++i) { + var error = $root.google.protobuf.DescriptorProto.verify( + message.nestedType[i] + ) + if (error) return 'nestedType.' + error + } + } + if ( + message.enumType != null && + message.hasOwnProperty('enumType') + ) { + if (!Array.isArray(message.enumType)) + return 'enumType: array expected' + for (var i = 0; i < message.enumType.length; ++i) { + var error = $root.google.protobuf.EnumDescriptorProto.verify( + message.enumType[i] + ) + if (error) return 'enumType.' + error + } + } + if ( + message.extensionRange != null && + message.hasOwnProperty('extensionRange') + ) { + if (!Array.isArray(message.extensionRange)) + return 'extensionRange: array expected' + for (var i = 0; i < message.extensionRange.length; ++i) { + var error = $root.google.protobuf.DescriptorProto.ExtensionRange.verify( + message.extensionRange[i] + ) + if (error) return 'extensionRange.' + error + } + } + if ( + message.oneofDecl != null && + message.hasOwnProperty('oneofDecl') + ) { + if (!Array.isArray(message.oneofDecl)) + return 'oneofDecl: array expected' + for (var i = 0; i < message.oneofDecl.length; ++i) { + var error = $root.google.protobuf.OneofDescriptorProto.verify( + message.oneofDecl[i] + ) + if (error) return 'oneofDecl.' + error + } + } + if ( + message.options != null && + message.hasOwnProperty('options') + ) { + var error = $root.google.protobuf.MessageOptions.verify( + message.options + ) + if (error) return 'options.' + error + } + if ( + message.reservedRange != null && + message.hasOwnProperty('reservedRange') + ) { + if (!Array.isArray(message.reservedRange)) + return 'reservedRange: array expected' + for (var i = 0; i < message.reservedRange.length; ++i) { + var error = $root.google.protobuf.DescriptorProto.ReservedRange.verify( + message.reservedRange[i] + ) + if (error) return 'reservedRange.' + error + } + } + if ( + message.reservedName != null && + message.hasOwnProperty('reservedName') + ) { + if (!Array.isArray(message.reservedName)) + return 'reservedName: array expected' + for (var i = 0; i < message.reservedName.length; ++i) + if (!$util.isString(message.reservedName[i])) + return 'reservedName: string[] expected' + } + return null + } + + /** + * Creates a DescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.DescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.DescriptorProto} DescriptorProto + */ + DescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.DescriptorProto) + return object + var message = new $root.google.protobuf.DescriptorProto() + if (object.name != null) message.name = String(object.name) + if (object.field) { + if (!Array.isArray(object.field)) + throw TypeError( + '.google.protobuf.DescriptorProto.field: array expected' + ) + message.field = [] + for (var i = 0; i < object.field.length; ++i) { + if (typeof object.field[i] !== 'object') + throw TypeError( + '.google.protobuf.DescriptorProto.field: object expected' + ) + message.field[ + i + ] = $root.google.protobuf.FieldDescriptorProto.fromObject( + object.field[i] + ) + } + } + if (object.extension) { + if (!Array.isArray(object.extension)) + throw TypeError( + '.google.protobuf.DescriptorProto.extension: array expected' + ) + message.extension = [] + for (var i = 0; i < object.extension.length; ++i) { + if (typeof object.extension[i] !== 'object') + throw TypeError( + '.google.protobuf.DescriptorProto.extension: object expected' + ) + message.extension[ + i + ] = $root.google.protobuf.FieldDescriptorProto.fromObject( + object.extension[i] + ) + } + } + if (object.nestedType) { + if (!Array.isArray(object.nestedType)) + throw TypeError( + '.google.protobuf.DescriptorProto.nestedType: array expected' + ) + message.nestedType = [] + for (var i = 0; i < object.nestedType.length; ++i) { + if (typeof object.nestedType[i] !== 'object') + throw TypeError( + '.google.protobuf.DescriptorProto.nestedType: object expected' + ) + message.nestedType[ + i + ] = $root.google.protobuf.DescriptorProto.fromObject( + object.nestedType[i] + ) + } + } + if (object.enumType) { + if (!Array.isArray(object.enumType)) + throw TypeError( + '.google.protobuf.DescriptorProto.enumType: array expected' + ) + message.enumType = [] + for (var i = 0; i < object.enumType.length; ++i) { + if (typeof object.enumType[i] !== 'object') + throw TypeError( + '.google.protobuf.DescriptorProto.enumType: object expected' + ) + message.enumType[ + i + ] = $root.google.protobuf.EnumDescriptorProto.fromObject( + object.enumType[i] + ) + } + } + if (object.extensionRange) { + if (!Array.isArray(object.extensionRange)) + throw TypeError( + '.google.protobuf.DescriptorProto.extensionRange: array expected' + ) + message.extensionRange = [] + for (var i = 0; i < object.extensionRange.length; ++i) { + if (typeof object.extensionRange[i] !== 'object') + throw TypeError( + '.google.protobuf.DescriptorProto.extensionRange: object expected' + ) + message.extensionRange[ + i + ] = $root.google.protobuf.DescriptorProto.ExtensionRange.fromObject( + object.extensionRange[i] + ) + } + } + if (object.oneofDecl) { + if (!Array.isArray(object.oneofDecl)) + throw TypeError( + '.google.protobuf.DescriptorProto.oneofDecl: array expected' + ) + message.oneofDecl = [] + for (var i = 0; i < object.oneofDecl.length; ++i) { + if (typeof object.oneofDecl[i] !== 'object') + throw TypeError( + '.google.protobuf.DescriptorProto.oneofDecl: object expected' + ) + message.oneofDecl[ + i + ] = $root.google.protobuf.OneofDescriptorProto.fromObject( + object.oneofDecl[i] + ) + } + } + if (object.options != null) { + if (typeof object.options !== 'object') + throw TypeError( + '.google.protobuf.DescriptorProto.options: object expected' + ) + message.options = $root.google.protobuf.MessageOptions.fromObject( + object.options + ) + } + if (object.reservedRange) { + if (!Array.isArray(object.reservedRange)) + throw TypeError( + '.google.protobuf.DescriptorProto.reservedRange: array expected' + ) + message.reservedRange = [] + for (var i = 0; i < object.reservedRange.length; ++i) { + if (typeof object.reservedRange[i] !== 'object') + throw TypeError( + '.google.protobuf.DescriptorProto.reservedRange: object expected' + ) + message.reservedRange[ + i + ] = $root.google.protobuf.DescriptorProto.ReservedRange.fromObject( + object.reservedRange[i] + ) + } + } + if (object.reservedName) { + if (!Array.isArray(object.reservedName)) + throw TypeError( + '.google.protobuf.DescriptorProto.reservedName: array expected' + ) + message.reservedName = [] + for (var i = 0; i < object.reservedName.length; ++i) + message.reservedName[i] = String(object.reservedName[i]) + } + return message + } + + /** + * Creates a plain object from a DescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.DescriptorProto + * @static + * @param {google.protobuf.DescriptorProto} message DescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DescriptorProto.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) { + object.field = [] + object.nestedType = [] + object.enumType = [] + object.extensionRange = [] + object.extension = [] + object.oneofDecl = [] + object.reservedRange = [] + object.reservedName = [] + } + if (options.defaults) { + object.name = '' + object.options = null + } + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + if (message.field && message.field.length) { + object.field = [] + for (var j = 0; j < message.field.length; ++j) + object.field[ + j + ] = $root.google.protobuf.FieldDescriptorProto.toObject( + message.field[j], + options + ) + } + if (message.nestedType && message.nestedType.length) { + object.nestedType = [] + for (var j = 0; j < message.nestedType.length; ++j) + object.nestedType[ + j + ] = $root.google.protobuf.DescriptorProto.toObject( + message.nestedType[j], + options + ) + } + if (message.enumType && message.enumType.length) { + object.enumType = [] + for (var j = 0; j < message.enumType.length; ++j) + object.enumType[ + j + ] = $root.google.protobuf.EnumDescriptorProto.toObject( + message.enumType[j], + options + ) + } + if (message.extensionRange && message.extensionRange.length) { + object.extensionRange = [] + for (var j = 0; j < message.extensionRange.length; ++j) + object.extensionRange[ + j + ] = $root.google.protobuf.DescriptorProto.ExtensionRange.toObject( + message.extensionRange[j], + options + ) + } + if (message.extension && message.extension.length) { + object.extension = [] + for (var j = 0; j < message.extension.length; ++j) + object.extension[ + j + ] = $root.google.protobuf.FieldDescriptorProto.toObject( + message.extension[j], + options + ) + } + if ( + message.options != null && + message.hasOwnProperty('options') + ) + object.options = $root.google.protobuf.MessageOptions.toObject( + message.options, + options + ) + if (message.oneofDecl && message.oneofDecl.length) { + object.oneofDecl = [] + for (var j = 0; j < message.oneofDecl.length; ++j) + object.oneofDecl[ + j + ] = $root.google.protobuf.OneofDescriptorProto.toObject( + message.oneofDecl[j], + options + ) + } + if (message.reservedRange && message.reservedRange.length) { + object.reservedRange = [] + for (var j = 0; j < message.reservedRange.length; ++j) + object.reservedRange[ + j + ] = $root.google.protobuf.DescriptorProto.ReservedRange.toObject( + message.reservedRange[j], + options + ) + } + if (message.reservedName && message.reservedName.length) { + object.reservedName = [] + for (var j = 0; j < message.reservedName.length; ++j) + object.reservedName[j] = message.reservedName[j] + } + return object + } + + /** + * Converts this DescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.DescriptorProto + * @instance + * @returns {Object.} JSON object + */ + DescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + DescriptorProto.ExtensionRange = (function () { + /** + * Properties of an ExtensionRange. + * @memberof google.protobuf.DescriptorProto + * @interface IExtensionRange + * @property {number|null} [start] ExtensionRange start + * @property {number|null} [end] ExtensionRange end + * @property {google.protobuf.IExtensionRangeOptions|null} [options] ExtensionRange options + */ + + /** + * Constructs a new ExtensionRange. + * @memberof google.protobuf.DescriptorProto + * @classdesc Represents an ExtensionRange. + * @implements IExtensionRange + * @constructor + * @param {google.protobuf.DescriptorProto.IExtensionRange=} [properties] Properties to set + */ + function ExtensionRange(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * ExtensionRange start. + * @member {number} start + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @instance + */ + ExtensionRange.prototype.start = 0 + + /** + * ExtensionRange end. + * @member {number} end + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @instance + */ + ExtensionRange.prototype.end = 0 + + /** + * ExtensionRange options. + * @member {google.protobuf.IExtensionRangeOptions|null|undefined} options + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @instance + */ + ExtensionRange.prototype.options = null + + /** + * Creates a new ExtensionRange instance using the specified properties. + * @function create + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {google.protobuf.DescriptorProto.IExtensionRange=} [properties] Properties to set + * @returns {google.protobuf.DescriptorProto.ExtensionRange} ExtensionRange instance + */ + ExtensionRange.create = function create(properties) { + return new ExtensionRange(properties) + } + + /** + * Encodes the specified ExtensionRange message. Does not implicitly {@link google.protobuf.DescriptorProto.ExtensionRange.verify|verify} messages. + * @function encode + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {google.protobuf.DescriptorProto.IExtensionRange} message ExtensionRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExtensionRange.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.start != null && + Object.hasOwnProperty.call(message, 'start') + ) + writer + .uint32(/* id 1, wireType 0 =*/ 8) + .int32(message.start) + if ( + message.end != null && + Object.hasOwnProperty.call(message, 'end') + ) + writer.uint32(/* id 2, wireType 0 =*/ 16).int32(message.end) + if ( + message.options != null && + Object.hasOwnProperty.call(message, 'options') + ) + $root.google.protobuf.ExtensionRangeOptions.encode( + message.options, + writer.uint32(/* id 3, wireType 2 =*/ 26).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified ExtensionRange message, length delimited. Does not implicitly {@link google.protobuf.DescriptorProto.ExtensionRange.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {google.protobuf.DescriptorProto.IExtensionRange} message ExtensionRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExtensionRange.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an ExtensionRange message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.DescriptorProto.ExtensionRange} ExtensionRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExtensionRange.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.DescriptorProto.ExtensionRange() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.start = reader.int32() + break + case 2: + message.end = reader.int32() + break + case 3: + message.options = $root.google.protobuf.ExtensionRangeOptions.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an ExtensionRange message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.DescriptorProto.ExtensionRange} ExtensionRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExtensionRange.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an ExtensionRange message. + * @function verify + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExtensionRange.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.start != null && message.hasOwnProperty('start')) + if (!$util.isInteger(message.start)) + return 'start: integer expected' + if (message.end != null && message.hasOwnProperty('end')) + if (!$util.isInteger(message.end)) + return 'end: integer expected' + if ( + message.options != null && + message.hasOwnProperty('options') + ) { + var error = $root.google.protobuf.ExtensionRangeOptions.verify( + message.options + ) + if (error) return 'options.' + error + } + return null + } + + /** + * Creates an ExtensionRange message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.DescriptorProto.ExtensionRange} ExtensionRange + */ + ExtensionRange.fromObject = function fromObject(object) { + if ( + object instanceof + $root.google.protobuf.DescriptorProto.ExtensionRange + ) + return object + var message = new $root.google.protobuf.DescriptorProto.ExtensionRange() + if (object.start != null) message.start = object.start | 0 + if (object.end != null) message.end = object.end | 0 + if (object.options != null) { + if (typeof object.options !== 'object') + throw TypeError( + '.google.protobuf.DescriptorProto.ExtensionRange.options: object expected' + ) + message.options = $root.google.protobuf.ExtensionRangeOptions.fromObject( + object.options + ) + } + return message + } + + /** + * Creates a plain object from an ExtensionRange message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {google.protobuf.DescriptorProto.ExtensionRange} message ExtensionRange + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExtensionRange.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.start = 0 + object.end = 0 + object.options = null + } + if (message.start != null && message.hasOwnProperty('start')) + object.start = message.start + if (message.end != null && message.hasOwnProperty('end')) + object.end = message.end + if ( + message.options != null && + message.hasOwnProperty('options') + ) + object.options = $root.google.protobuf.ExtensionRangeOptions.toObject( + message.options, + options + ) + return object + } + + /** + * Converts this ExtensionRange to JSON. + * @function toJSON + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @instance + * @returns {Object.} JSON object + */ + ExtensionRange.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return ExtensionRange + })() + + DescriptorProto.ReservedRange = (function () { + /** + * Properties of a ReservedRange. + * @memberof google.protobuf.DescriptorProto + * @interface IReservedRange + * @property {number|null} [start] ReservedRange start + * @property {number|null} [end] ReservedRange end + */ + + /** + * Constructs a new ReservedRange. + * @memberof google.protobuf.DescriptorProto + * @classdesc Represents a ReservedRange. + * @implements IReservedRange + * @constructor + * @param {google.protobuf.DescriptorProto.IReservedRange=} [properties] Properties to set + */ + function ReservedRange(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * ReservedRange start. + * @member {number} start + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @instance + */ + ReservedRange.prototype.start = 0 + + /** + * ReservedRange end. + * @member {number} end + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @instance + */ + ReservedRange.prototype.end = 0 + + /** + * Creates a new ReservedRange instance using the specified properties. + * @function create + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {google.protobuf.DescriptorProto.IReservedRange=} [properties] Properties to set + * @returns {google.protobuf.DescriptorProto.ReservedRange} ReservedRange instance + */ + ReservedRange.create = function create(properties) { + return new ReservedRange(properties) + } + + /** + * Encodes the specified ReservedRange message. Does not implicitly {@link google.protobuf.DescriptorProto.ReservedRange.verify|verify} messages. + * @function encode + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {google.protobuf.DescriptorProto.IReservedRange} message ReservedRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReservedRange.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.start != null && + Object.hasOwnProperty.call(message, 'start') + ) + writer + .uint32(/* id 1, wireType 0 =*/ 8) + .int32(message.start) + if ( + message.end != null && + Object.hasOwnProperty.call(message, 'end') + ) + writer.uint32(/* id 2, wireType 0 =*/ 16).int32(message.end) + return writer + } + + /** + * Encodes the specified ReservedRange message, length delimited. Does not implicitly {@link google.protobuf.DescriptorProto.ReservedRange.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {google.protobuf.DescriptorProto.IReservedRange} message ReservedRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReservedRange.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a ReservedRange message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.DescriptorProto.ReservedRange} ReservedRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReservedRange.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.DescriptorProto.ReservedRange() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.start = reader.int32() + break + case 2: + message.end = reader.int32() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a ReservedRange message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.DescriptorProto.ReservedRange} ReservedRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReservedRange.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a ReservedRange message. + * @function verify + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ReservedRange.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.start != null && message.hasOwnProperty('start')) + if (!$util.isInteger(message.start)) + return 'start: integer expected' + if (message.end != null && message.hasOwnProperty('end')) + if (!$util.isInteger(message.end)) + return 'end: integer expected' + return null + } + + /** + * Creates a ReservedRange message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.DescriptorProto.ReservedRange} ReservedRange + */ + ReservedRange.fromObject = function fromObject(object) { + if ( + object instanceof + $root.google.protobuf.DescriptorProto.ReservedRange + ) + return object + var message = new $root.google.protobuf.DescriptorProto.ReservedRange() + if (object.start != null) message.start = object.start | 0 + if (object.end != null) message.end = object.end | 0 + return message + } + + /** + * Creates a plain object from a ReservedRange message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {google.protobuf.DescriptorProto.ReservedRange} message ReservedRange + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ReservedRange.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.start = 0 + object.end = 0 + } + if (message.start != null && message.hasOwnProperty('start')) + object.start = message.start + if (message.end != null && message.hasOwnProperty('end')) + object.end = message.end + return object + } + + /** + * Converts this ReservedRange to JSON. + * @function toJSON + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @instance + * @returns {Object.} JSON object + */ + ReservedRange.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return ReservedRange + })() + + return DescriptorProto + })() + + protobuf.ExtensionRangeOptions = (function () { + /** + * Properties of an ExtensionRangeOptions. + * @memberof google.protobuf + * @interface IExtensionRangeOptions + * @property {Array.|null} [uninterpretedOption] ExtensionRangeOptions uninterpretedOption + */ + + /** + * Constructs a new ExtensionRangeOptions. + * @memberof google.protobuf + * @classdesc Represents an ExtensionRangeOptions. + * @implements IExtensionRangeOptions + * @constructor + * @param {google.protobuf.IExtensionRangeOptions=} [properties] Properties to set + */ + function ExtensionRangeOptions(properties) { + this.uninterpretedOption = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * ExtensionRangeOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.ExtensionRangeOptions + * @instance + */ + ExtensionRangeOptions.prototype.uninterpretedOption = + $util.emptyArray + + /** + * Creates a new ExtensionRangeOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.ExtensionRangeOptions + * @static + * @param {google.protobuf.IExtensionRangeOptions=} [properties] Properties to set + * @returns {google.protobuf.ExtensionRangeOptions} ExtensionRangeOptions instance + */ + ExtensionRangeOptions.create = function create(properties) { + return new ExtensionRangeOptions(properties) + } + + /** + * Encodes the specified ExtensionRangeOptions message. Does not implicitly {@link google.protobuf.ExtensionRangeOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.ExtensionRangeOptions + * @static + * @param {google.protobuf.IExtensionRangeOptions} message ExtensionRangeOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExtensionRangeOptions.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.uninterpretedOption != null && + message.uninterpretedOption.length + ) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode( + message.uninterpretedOption[i], + writer.uint32(/* id 999, wireType 2 =*/ 7994).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified ExtensionRangeOptions message, length delimited. Does not implicitly {@link google.protobuf.ExtensionRangeOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.ExtensionRangeOptions + * @static + * @param {google.protobuf.IExtensionRangeOptions} message ExtensionRangeOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExtensionRangeOptions.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an ExtensionRangeOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.ExtensionRangeOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.ExtensionRangeOptions} ExtensionRangeOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExtensionRangeOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.ExtensionRangeOptions() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 999: + if ( + !( + message.uninterpretedOption && + message.uninterpretedOption.length + ) + ) + message.uninterpretedOption = [] + message.uninterpretedOption.push( + $root.google.protobuf.UninterpretedOption.decode( + reader, + reader.uint32() + ) + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an ExtensionRangeOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.ExtensionRangeOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.ExtensionRangeOptions} ExtensionRangeOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExtensionRangeOptions.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an ExtensionRangeOptions message. + * @function verify + * @memberof google.protobuf.ExtensionRangeOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExtensionRangeOptions.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.uninterpretedOption != null && + message.hasOwnProperty('uninterpretedOption') + ) { + if (!Array.isArray(message.uninterpretedOption)) + return 'uninterpretedOption: array expected' + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify( + message.uninterpretedOption[i] + ) + if (error) return 'uninterpretedOption.' + error + } + } + return null + } + + /** + * Creates an ExtensionRangeOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.ExtensionRangeOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.ExtensionRangeOptions} ExtensionRangeOptions + */ + ExtensionRangeOptions.fromObject = function fromObject(object) { + if ( + object instanceof $root.google.protobuf.ExtensionRangeOptions + ) + return object + var message = new $root.google.protobuf.ExtensionRangeOptions() + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError( + '.google.protobuf.ExtensionRangeOptions.uninterpretedOption: array expected' + ) + message.uninterpretedOption = [] + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== 'object') + throw TypeError( + '.google.protobuf.ExtensionRangeOptions.uninterpretedOption: object expected' + ) + message.uninterpretedOption[ + i + ] = $root.google.protobuf.UninterpretedOption.fromObject( + object.uninterpretedOption[i] + ) + } + } + return message + } + + /** + * Creates a plain object from an ExtensionRangeOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.ExtensionRangeOptions + * @static + * @param {google.protobuf.ExtensionRangeOptions} message ExtensionRangeOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExtensionRangeOptions.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) + object.uninterpretedOption = [] + if ( + message.uninterpretedOption && + message.uninterpretedOption.length + ) { + object.uninterpretedOption = [] + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[ + j + ] = $root.google.protobuf.UninterpretedOption.toObject( + message.uninterpretedOption[j], + options + ) + } + return object + } + + /** + * Converts this ExtensionRangeOptions to JSON. + * @function toJSON + * @memberof google.protobuf.ExtensionRangeOptions + * @instance + * @returns {Object.} JSON object + */ + ExtensionRangeOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return ExtensionRangeOptions + })() + + protobuf.FieldDescriptorProto = (function () { + /** + * Properties of a FieldDescriptorProto. + * @memberof google.protobuf + * @interface IFieldDescriptorProto + * @property {string|null} [name] FieldDescriptorProto name + * @property {number|null} [number] FieldDescriptorProto number + * @property {google.protobuf.FieldDescriptorProto.Label|null} [label] FieldDescriptorProto label + * @property {google.protobuf.FieldDescriptorProto.Type|null} [type] FieldDescriptorProto type + * @property {string|null} [typeName] FieldDescriptorProto typeName + * @property {string|null} [extendee] FieldDescriptorProto extendee + * @property {string|null} [defaultValue] FieldDescriptorProto defaultValue + * @property {number|null} [oneofIndex] FieldDescriptorProto oneofIndex + * @property {string|null} [jsonName] FieldDescriptorProto jsonName + * @property {google.protobuf.IFieldOptions|null} [options] FieldDescriptorProto options + * @property {boolean|null} [proto3Optional] FieldDescriptorProto proto3Optional + */ + + /** + * Constructs a new FieldDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a FieldDescriptorProto. + * @implements IFieldDescriptorProto + * @constructor + * @param {google.protobuf.IFieldDescriptorProto=} [properties] Properties to set + */ + function FieldDescriptorProto(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * FieldDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.name = '' + + /** + * FieldDescriptorProto number. + * @member {number} number + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.number = 0 + + /** + * FieldDescriptorProto label. + * @member {google.protobuf.FieldDescriptorProto.Label} label + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.label = 1 + + /** + * FieldDescriptorProto type. + * @member {google.protobuf.FieldDescriptorProto.Type} type + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.type = 1 + + /** + * FieldDescriptorProto typeName. + * @member {string} typeName + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.typeName = '' + + /** + * FieldDescriptorProto extendee. + * @member {string} extendee + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.extendee = '' + + /** + * FieldDescriptorProto defaultValue. + * @member {string} defaultValue + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.defaultValue = '' + + /** + * FieldDescriptorProto oneofIndex. + * @member {number} oneofIndex + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.oneofIndex = 0 + + /** + * FieldDescriptorProto jsonName. + * @member {string} jsonName + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.jsonName = '' + + /** + * FieldDescriptorProto options. + * @member {google.protobuf.IFieldOptions|null|undefined} options + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.options = null + + /** + * FieldDescriptorProto proto3Optional. + * @member {boolean} proto3Optional + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.proto3Optional = false + + /** + * Creates a new FieldDescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {google.protobuf.IFieldDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.FieldDescriptorProto} FieldDescriptorProto instance + */ + FieldDescriptorProto.create = function create(properties) { + return new FieldDescriptorProto(properties) + } + + /** + * Encodes the specified FieldDescriptorProto message. Does not implicitly {@link google.protobuf.FieldDescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {google.protobuf.IFieldDescriptorProto} message FieldDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FieldDescriptorProto.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.name != null && + Object.hasOwnProperty.call(message, 'name') + ) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.name) + if ( + message.extendee != null && + Object.hasOwnProperty.call(message, 'extendee') + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.extendee) + if ( + message.number != null && + Object.hasOwnProperty.call(message, 'number') + ) + writer + .uint32(/* id 3, wireType 0 =*/ 24) + .int32(message.number) + if ( + message.label != null && + Object.hasOwnProperty.call(message, 'label') + ) + writer.uint32(/* id 4, wireType 0 =*/ 32).int32(message.label) + if ( + message.type != null && + Object.hasOwnProperty.call(message, 'type') + ) + writer.uint32(/* id 5, wireType 0 =*/ 40).int32(message.type) + if ( + message.typeName != null && + Object.hasOwnProperty.call(message, 'typeName') + ) + writer + .uint32(/* id 6, wireType 2 =*/ 50) + .string(message.typeName) + if ( + message.defaultValue != null && + Object.hasOwnProperty.call(message, 'defaultValue') + ) + writer + .uint32(/* id 7, wireType 2 =*/ 58) + .string(message.defaultValue) + if ( + message.options != null && + Object.hasOwnProperty.call(message, 'options') + ) + $root.google.protobuf.FieldOptions.encode( + message.options, + writer.uint32(/* id 8, wireType 2 =*/ 66).fork() + ).ldelim() + if ( + message.oneofIndex != null && + Object.hasOwnProperty.call(message, 'oneofIndex') + ) + writer + .uint32(/* id 9, wireType 0 =*/ 72) + .int32(message.oneofIndex) + if ( + message.jsonName != null && + Object.hasOwnProperty.call(message, 'jsonName') + ) + writer + .uint32(/* id 10, wireType 2 =*/ 82) + .string(message.jsonName) + if ( + message.proto3Optional != null && + Object.hasOwnProperty.call(message, 'proto3Optional') + ) + writer + .uint32(/* id 17, wireType 0 =*/ 136) + .bool(message.proto3Optional) + return writer + } + + /** + * Encodes the specified FieldDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.FieldDescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {google.protobuf.IFieldDescriptorProto} message FieldDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FieldDescriptorProto.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a FieldDescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FieldDescriptorProto} FieldDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FieldDescriptorProto.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.FieldDescriptorProto() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + case 3: + message.number = reader.int32() + break + case 4: + message.label = reader.int32() + break + case 5: + message.type = reader.int32() + break + case 6: + message.typeName = reader.string() + break + case 2: + message.extendee = reader.string() + break + case 7: + message.defaultValue = reader.string() + break + case 9: + message.oneofIndex = reader.int32() + break + case 10: + message.jsonName = reader.string() + break + case 8: + message.options = $root.google.protobuf.FieldOptions.decode( + reader, + reader.uint32() + ) + break + case 17: + message.proto3Optional = reader.bool() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a FieldDescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FieldDescriptorProto} FieldDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FieldDescriptorProto.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a FieldDescriptorProto message. + * @function verify + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FieldDescriptorProto.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + if (message.number != null && message.hasOwnProperty('number')) + if (!$util.isInteger(message.number)) + return 'number: integer expected' + if (message.label != null && message.hasOwnProperty('label')) + switch (message.label) { + default: + return 'label: enum value expected' + case 1: + case 2: + case 3: + break + } + if (message.type != null && message.hasOwnProperty('type')) + switch (message.type) { + default: + return 'type: enum value expected' + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + case 15: + case 16: + case 17: + case 18: + break + } + if ( + message.typeName != null && + message.hasOwnProperty('typeName') + ) + if (!$util.isString(message.typeName)) + return 'typeName: string expected' + if ( + message.extendee != null && + message.hasOwnProperty('extendee') + ) + if (!$util.isString(message.extendee)) + return 'extendee: string expected' + if ( + message.defaultValue != null && + message.hasOwnProperty('defaultValue') + ) + if (!$util.isString(message.defaultValue)) + return 'defaultValue: string expected' + if ( + message.oneofIndex != null && + message.hasOwnProperty('oneofIndex') + ) + if (!$util.isInteger(message.oneofIndex)) + return 'oneofIndex: integer expected' + if ( + message.jsonName != null && + message.hasOwnProperty('jsonName') + ) + if (!$util.isString(message.jsonName)) + return 'jsonName: string expected' + if ( + message.options != null && + message.hasOwnProperty('options') + ) { + var error = $root.google.protobuf.FieldOptions.verify( + message.options + ) + if (error) return 'options.' + error + } + if ( + message.proto3Optional != null && + message.hasOwnProperty('proto3Optional') + ) + if (typeof message.proto3Optional !== 'boolean') + return 'proto3Optional: boolean expected' + return null + } + + /** + * Creates a FieldDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FieldDescriptorProto} FieldDescriptorProto + */ + FieldDescriptorProto.fromObject = function fromObject(object) { + if ( + object instanceof $root.google.protobuf.FieldDescriptorProto + ) + return object + var message = new $root.google.protobuf.FieldDescriptorProto() + if (object.name != null) message.name = String(object.name) + if (object.number != null) message.number = object.number | 0 + switch (object.label) { + case 'LABEL_OPTIONAL': + case 1: + message.label = 1 + break + case 'LABEL_REQUIRED': + case 2: + message.label = 2 + break + case 'LABEL_REPEATED': + case 3: + message.label = 3 + break + } + switch (object.type) { + case 'TYPE_DOUBLE': + case 1: + message.type = 1 + break + case 'TYPE_FLOAT': + case 2: + message.type = 2 + break + case 'TYPE_INT64': + case 3: + message.type = 3 + break + case 'TYPE_UINT64': + case 4: + message.type = 4 + break + case 'TYPE_INT32': + case 5: + message.type = 5 + break + case 'TYPE_FIXED64': + case 6: + message.type = 6 + break + case 'TYPE_FIXED32': + case 7: + message.type = 7 + break + case 'TYPE_BOOL': + case 8: + message.type = 8 + break + case 'TYPE_STRING': + case 9: + message.type = 9 + break + case 'TYPE_GROUP': + case 10: + message.type = 10 + break + case 'TYPE_MESSAGE': + case 11: + message.type = 11 + break + case 'TYPE_BYTES': + case 12: + message.type = 12 + break + case 'TYPE_UINT32': + case 13: + message.type = 13 + break + case 'TYPE_ENUM': + case 14: + message.type = 14 + break + case 'TYPE_SFIXED32': + case 15: + message.type = 15 + break + case 'TYPE_SFIXED64': + case 16: + message.type = 16 + break + case 'TYPE_SINT32': + case 17: + message.type = 17 + break + case 'TYPE_SINT64': + case 18: + message.type = 18 + break + } + if (object.typeName != null) + message.typeName = String(object.typeName) + if (object.extendee != null) + message.extendee = String(object.extendee) + if (object.defaultValue != null) + message.defaultValue = String(object.defaultValue) + if (object.oneofIndex != null) + message.oneofIndex = object.oneofIndex | 0 + if (object.jsonName != null) + message.jsonName = String(object.jsonName) + if (object.options != null) { + if (typeof object.options !== 'object') + throw TypeError( + '.google.protobuf.FieldDescriptorProto.options: object expected' + ) + message.options = $root.google.protobuf.FieldOptions.fromObject( + object.options + ) + } + if (object.proto3Optional != null) + message.proto3Optional = Boolean(object.proto3Optional) + return message + } + + /** + * Creates a plain object from a FieldDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {google.protobuf.FieldDescriptorProto} message FieldDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FieldDescriptorProto.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.name = '' + object.extendee = '' + object.number = 0 + object.label = options.enums === String ? 'LABEL_OPTIONAL' : 1 + object.type = options.enums === String ? 'TYPE_DOUBLE' : 1 + object.typeName = '' + object.defaultValue = '' + object.options = null + object.oneofIndex = 0 + object.jsonName = '' + object.proto3Optional = false + } + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + if ( + message.extendee != null && + message.hasOwnProperty('extendee') + ) + object.extendee = message.extendee + if (message.number != null && message.hasOwnProperty('number')) + object.number = message.number + if (message.label != null && message.hasOwnProperty('label')) + object.label = + options.enums === String + ? $root.google.protobuf.FieldDescriptorProto.Label[ + message.label + ] + : message.label + if (message.type != null && message.hasOwnProperty('type')) + object.type = + options.enums === String + ? $root.google.protobuf.FieldDescriptorProto.Type[ + message.type + ] + : message.type + if ( + message.typeName != null && + message.hasOwnProperty('typeName') + ) + object.typeName = message.typeName + if ( + message.defaultValue != null && + message.hasOwnProperty('defaultValue') + ) + object.defaultValue = message.defaultValue + if ( + message.options != null && + message.hasOwnProperty('options') + ) + object.options = $root.google.protobuf.FieldOptions.toObject( + message.options, + options + ) + if ( + message.oneofIndex != null && + message.hasOwnProperty('oneofIndex') + ) + object.oneofIndex = message.oneofIndex + if ( + message.jsonName != null && + message.hasOwnProperty('jsonName') + ) + object.jsonName = message.jsonName + if ( + message.proto3Optional != null && + message.hasOwnProperty('proto3Optional') + ) + object.proto3Optional = message.proto3Optional + return object + } + + /** + * Converts this FieldDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.FieldDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + FieldDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + /** + * Type enum. + * @name google.protobuf.FieldDescriptorProto.Type + * @enum {number} + * @property {number} TYPE_DOUBLE=1 TYPE_DOUBLE value + * @property {number} TYPE_FLOAT=2 TYPE_FLOAT value + * @property {number} TYPE_INT64=3 TYPE_INT64 value + * @property {number} TYPE_UINT64=4 TYPE_UINT64 value + * @property {number} TYPE_INT32=5 TYPE_INT32 value + * @property {number} TYPE_FIXED64=6 TYPE_FIXED64 value + * @property {number} TYPE_FIXED32=7 TYPE_FIXED32 value + * @property {number} TYPE_BOOL=8 TYPE_BOOL value + * @property {number} TYPE_STRING=9 TYPE_STRING value + * @property {number} TYPE_GROUP=10 TYPE_GROUP value + * @property {number} TYPE_MESSAGE=11 TYPE_MESSAGE value + * @property {number} TYPE_BYTES=12 TYPE_BYTES value + * @property {number} TYPE_UINT32=13 TYPE_UINT32 value + * @property {number} TYPE_ENUM=14 TYPE_ENUM value + * @property {number} TYPE_SFIXED32=15 TYPE_SFIXED32 value + * @property {number} TYPE_SFIXED64=16 TYPE_SFIXED64 value + * @property {number} TYPE_SINT32=17 TYPE_SINT32 value + * @property {number} TYPE_SINT64=18 TYPE_SINT64 value + */ + FieldDescriptorProto.Type = (function () { + var valuesById = {}, + values = Object.create(valuesById) + values[(valuesById[1] = 'TYPE_DOUBLE')] = 1 + values[(valuesById[2] = 'TYPE_FLOAT')] = 2 + values[(valuesById[3] = 'TYPE_INT64')] = 3 + values[(valuesById[4] = 'TYPE_UINT64')] = 4 + values[(valuesById[5] = 'TYPE_INT32')] = 5 + values[(valuesById[6] = 'TYPE_FIXED64')] = 6 + values[(valuesById[7] = 'TYPE_FIXED32')] = 7 + values[(valuesById[8] = 'TYPE_BOOL')] = 8 + values[(valuesById[9] = 'TYPE_STRING')] = 9 + values[(valuesById[10] = 'TYPE_GROUP')] = 10 + values[(valuesById[11] = 'TYPE_MESSAGE')] = 11 + values[(valuesById[12] = 'TYPE_BYTES')] = 12 + values[(valuesById[13] = 'TYPE_UINT32')] = 13 + values[(valuesById[14] = 'TYPE_ENUM')] = 14 + values[(valuesById[15] = 'TYPE_SFIXED32')] = 15 + values[(valuesById[16] = 'TYPE_SFIXED64')] = 16 + values[(valuesById[17] = 'TYPE_SINT32')] = 17 + values[(valuesById[18] = 'TYPE_SINT64')] = 18 + return values + })() + + /** + * Label enum. + * @name google.protobuf.FieldDescriptorProto.Label + * @enum {number} + * @property {number} LABEL_OPTIONAL=1 LABEL_OPTIONAL value + * @property {number} LABEL_REQUIRED=2 LABEL_REQUIRED value + * @property {number} LABEL_REPEATED=3 LABEL_REPEATED value + */ + FieldDescriptorProto.Label = (function () { + var valuesById = {}, + values = Object.create(valuesById) + values[(valuesById[1] = 'LABEL_OPTIONAL')] = 1 + values[(valuesById[2] = 'LABEL_REQUIRED')] = 2 + values[(valuesById[3] = 'LABEL_REPEATED')] = 3 + return values + })() + + return FieldDescriptorProto + })() + + protobuf.OneofDescriptorProto = (function () { + /** + * Properties of an OneofDescriptorProto. + * @memberof google.protobuf + * @interface IOneofDescriptorProto + * @property {string|null} [name] OneofDescriptorProto name + * @property {google.protobuf.IOneofOptions|null} [options] OneofDescriptorProto options + */ + + /** + * Constructs a new OneofDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents an OneofDescriptorProto. + * @implements IOneofDescriptorProto + * @constructor + * @param {google.protobuf.IOneofDescriptorProto=} [properties] Properties to set + */ + function OneofDescriptorProto(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * OneofDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.OneofDescriptorProto + * @instance + */ + OneofDescriptorProto.prototype.name = '' + + /** + * OneofDescriptorProto options. + * @member {google.protobuf.IOneofOptions|null|undefined} options + * @memberof google.protobuf.OneofDescriptorProto + * @instance + */ + OneofDescriptorProto.prototype.options = null + + /** + * Creates a new OneofDescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {google.protobuf.IOneofDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.OneofDescriptorProto} OneofDescriptorProto instance + */ + OneofDescriptorProto.create = function create(properties) { + return new OneofDescriptorProto(properties) + } + + /** + * Encodes the specified OneofDescriptorProto message. Does not implicitly {@link google.protobuf.OneofDescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {google.protobuf.IOneofDescriptorProto} message OneofDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OneofDescriptorProto.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.name != null && + Object.hasOwnProperty.call(message, 'name') + ) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.name) + if ( + message.options != null && + Object.hasOwnProperty.call(message, 'options') + ) + $root.google.protobuf.OneofOptions.encode( + message.options, + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified OneofDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.OneofDescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {google.protobuf.IOneofDescriptorProto} message OneofDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OneofDescriptorProto.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an OneofDescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.OneofDescriptorProto} OneofDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OneofDescriptorProto.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.OneofDescriptorProto() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + case 2: + message.options = $root.google.protobuf.OneofOptions.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an OneofDescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.OneofDescriptorProto} OneofDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OneofDescriptorProto.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an OneofDescriptorProto message. + * @function verify + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + OneofDescriptorProto.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + if ( + message.options != null && + message.hasOwnProperty('options') + ) { + var error = $root.google.protobuf.OneofOptions.verify( + message.options + ) + if (error) return 'options.' + error + } + return null + } + + /** + * Creates an OneofDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.OneofDescriptorProto} OneofDescriptorProto + */ + OneofDescriptorProto.fromObject = function fromObject(object) { + if ( + object instanceof $root.google.protobuf.OneofDescriptorProto + ) + return object + var message = new $root.google.protobuf.OneofDescriptorProto() + if (object.name != null) message.name = String(object.name) + if (object.options != null) { + if (typeof object.options !== 'object') + throw TypeError( + '.google.protobuf.OneofDescriptorProto.options: object expected' + ) + message.options = $root.google.protobuf.OneofOptions.fromObject( + object.options + ) + } + return message + } + + /** + * Creates a plain object from an OneofDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {google.protobuf.OneofDescriptorProto} message OneofDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + OneofDescriptorProto.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.name = '' + object.options = null + } + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + if ( + message.options != null && + message.hasOwnProperty('options') + ) + object.options = $root.google.protobuf.OneofOptions.toObject( + message.options, + options + ) + return object + } + + /** + * Converts this OneofDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.OneofDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + OneofDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return OneofDescriptorProto + })() + + protobuf.EnumDescriptorProto = (function () { + /** + * Properties of an EnumDescriptorProto. + * @memberof google.protobuf + * @interface IEnumDescriptorProto + * @property {string|null} [name] EnumDescriptorProto name + * @property {Array.|null} [value] EnumDescriptorProto value + * @property {google.protobuf.IEnumOptions|null} [options] EnumDescriptorProto options + * @property {Array.|null} [reservedRange] EnumDescriptorProto reservedRange + * @property {Array.|null} [reservedName] EnumDescriptorProto reservedName + */ + + /** + * Constructs a new EnumDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents an EnumDescriptorProto. + * @implements IEnumDescriptorProto + * @constructor + * @param {google.protobuf.IEnumDescriptorProto=} [properties] Properties to set + */ + function EnumDescriptorProto(properties) { + this.value = [] + this.reservedRange = [] + this.reservedName = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * EnumDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.name = '' + + /** + * EnumDescriptorProto value. + * @member {Array.} value + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.value = $util.emptyArray + + /** + * EnumDescriptorProto options. + * @member {google.protobuf.IEnumOptions|null|undefined} options + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.options = null + + /** + * EnumDescriptorProto reservedRange. + * @member {Array.} reservedRange + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.reservedRange = $util.emptyArray + + /** + * EnumDescriptorProto reservedName. + * @member {Array.} reservedName + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.reservedName = $util.emptyArray + + /** + * Creates a new EnumDescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {google.protobuf.IEnumDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.EnumDescriptorProto} EnumDescriptorProto instance + */ + EnumDescriptorProto.create = function create(properties) { + return new EnumDescriptorProto(properties) + } + + /** + * Encodes the specified EnumDescriptorProto message. Does not implicitly {@link google.protobuf.EnumDescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {google.protobuf.IEnumDescriptorProto} message EnumDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumDescriptorProto.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.name != null && + Object.hasOwnProperty.call(message, 'name') + ) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.name) + if (message.value != null && message.value.length) + for (var i = 0; i < message.value.length; ++i) + $root.google.protobuf.EnumValueDescriptorProto.encode( + message.value[i], + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + ).ldelim() + if ( + message.options != null && + Object.hasOwnProperty.call(message, 'options') + ) + $root.google.protobuf.EnumOptions.encode( + message.options, + writer.uint32(/* id 3, wireType 2 =*/ 26).fork() + ).ldelim() + if ( + message.reservedRange != null && + message.reservedRange.length + ) + for (var i = 0; i < message.reservedRange.length; ++i) + $root.google.protobuf.EnumDescriptorProto.EnumReservedRange.encode( + message.reservedRange[i], + writer.uint32(/* id 4, wireType 2 =*/ 34).fork() + ).ldelim() + if (message.reservedName != null && message.reservedName.length) + for (var i = 0; i < message.reservedName.length; ++i) + writer + .uint32(/* id 5, wireType 2 =*/ 42) + .string(message.reservedName[i]) + return writer + } + + /** + * Encodes the specified EnumDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.EnumDescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {google.protobuf.IEnumDescriptorProto} message EnumDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumDescriptorProto.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an EnumDescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.EnumDescriptorProto} EnumDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumDescriptorProto.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.EnumDescriptorProto() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + case 2: + if (!(message.value && message.value.length)) + message.value = [] + message.value.push( + $root.google.protobuf.EnumValueDescriptorProto.decode( + reader, + reader.uint32() + ) + ) + break + case 3: + message.options = $root.google.protobuf.EnumOptions.decode( + reader, + reader.uint32() + ) + break + case 4: + if ( + !(message.reservedRange && message.reservedRange.length) + ) + message.reservedRange = [] + message.reservedRange.push( + $root.google.protobuf.EnumDescriptorProto.EnumReservedRange.decode( + reader, + reader.uint32() + ) + ) + break + case 5: + if ( + !(message.reservedName && message.reservedName.length) + ) + message.reservedName = [] + message.reservedName.push(reader.string()) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an EnumDescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.EnumDescriptorProto} EnumDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumDescriptorProto.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an EnumDescriptorProto message. + * @function verify + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + EnumDescriptorProto.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + if (message.value != null && message.hasOwnProperty('value')) { + if (!Array.isArray(message.value)) + return 'value: array expected' + for (var i = 0; i < message.value.length; ++i) { + var error = $root.google.protobuf.EnumValueDescriptorProto.verify( + message.value[i] + ) + if (error) return 'value.' + error + } + } + if ( + message.options != null && + message.hasOwnProperty('options') + ) { + var error = $root.google.protobuf.EnumOptions.verify( + message.options + ) + if (error) return 'options.' + error + } + if ( + message.reservedRange != null && + message.hasOwnProperty('reservedRange') + ) { + if (!Array.isArray(message.reservedRange)) + return 'reservedRange: array expected' + for (var i = 0; i < message.reservedRange.length; ++i) { + var error = $root.google.protobuf.EnumDescriptorProto.EnumReservedRange.verify( + message.reservedRange[i] + ) + if (error) return 'reservedRange.' + error + } + } + if ( + message.reservedName != null && + message.hasOwnProperty('reservedName') + ) { + if (!Array.isArray(message.reservedName)) + return 'reservedName: array expected' + for (var i = 0; i < message.reservedName.length; ++i) + if (!$util.isString(message.reservedName[i])) + return 'reservedName: string[] expected' + } + return null + } + + /** + * Creates an EnumDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.EnumDescriptorProto} EnumDescriptorProto + */ + EnumDescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.EnumDescriptorProto) + return object + var message = new $root.google.protobuf.EnumDescriptorProto() + if (object.name != null) message.name = String(object.name) + if (object.value) { + if (!Array.isArray(object.value)) + throw TypeError( + '.google.protobuf.EnumDescriptorProto.value: array expected' + ) + message.value = [] + for (var i = 0; i < object.value.length; ++i) { + if (typeof object.value[i] !== 'object') + throw TypeError( + '.google.protobuf.EnumDescriptorProto.value: object expected' + ) + message.value[ + i + ] = $root.google.protobuf.EnumValueDescriptorProto.fromObject( + object.value[i] + ) + } + } + if (object.options != null) { + if (typeof object.options !== 'object') + throw TypeError( + '.google.protobuf.EnumDescriptorProto.options: object expected' + ) + message.options = $root.google.protobuf.EnumOptions.fromObject( + object.options + ) + } + if (object.reservedRange) { + if (!Array.isArray(object.reservedRange)) + throw TypeError( + '.google.protobuf.EnumDescriptorProto.reservedRange: array expected' + ) + message.reservedRange = [] + for (var i = 0; i < object.reservedRange.length; ++i) { + if (typeof object.reservedRange[i] !== 'object') + throw TypeError( + '.google.protobuf.EnumDescriptorProto.reservedRange: object expected' + ) + message.reservedRange[ + i + ] = $root.google.protobuf.EnumDescriptorProto.EnumReservedRange.fromObject( + object.reservedRange[i] + ) + } + } + if (object.reservedName) { + if (!Array.isArray(object.reservedName)) + throw TypeError( + '.google.protobuf.EnumDescriptorProto.reservedName: array expected' + ) + message.reservedName = [] + for (var i = 0; i < object.reservedName.length; ++i) + message.reservedName[i] = String(object.reservedName[i]) + } + return message + } + + /** + * Creates a plain object from an EnumDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {google.protobuf.EnumDescriptorProto} message EnumDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EnumDescriptorProto.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) { + object.value = [] + object.reservedRange = [] + object.reservedName = [] + } + if (options.defaults) { + object.name = '' + object.options = null + } + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + if (message.value && message.value.length) { + object.value = [] + for (var j = 0; j < message.value.length; ++j) + object.value[ + j + ] = $root.google.protobuf.EnumValueDescriptorProto.toObject( + message.value[j], + options + ) + } + if ( + message.options != null && + message.hasOwnProperty('options') + ) + object.options = $root.google.protobuf.EnumOptions.toObject( + message.options, + options + ) + if (message.reservedRange && message.reservedRange.length) { + object.reservedRange = [] + for (var j = 0; j < message.reservedRange.length; ++j) + object.reservedRange[ + j + ] = $root.google.protobuf.EnumDescriptorProto.EnumReservedRange.toObject( + message.reservedRange[j], + options + ) + } + if (message.reservedName && message.reservedName.length) { + object.reservedName = [] + for (var j = 0; j < message.reservedName.length; ++j) + object.reservedName[j] = message.reservedName[j] + } + return object + } + + /** + * Converts this EnumDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.EnumDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + EnumDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + EnumDescriptorProto.EnumReservedRange = (function () { + /** + * Properties of an EnumReservedRange. + * @memberof google.protobuf.EnumDescriptorProto + * @interface IEnumReservedRange + * @property {number|null} [start] EnumReservedRange start + * @property {number|null} [end] EnumReservedRange end + */ + + /** + * Constructs a new EnumReservedRange. + * @memberof google.protobuf.EnumDescriptorProto + * @classdesc Represents an EnumReservedRange. + * @implements IEnumReservedRange + * @constructor + * @param {google.protobuf.EnumDescriptorProto.IEnumReservedRange=} [properties] Properties to set + */ + function EnumReservedRange(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * EnumReservedRange start. + * @member {number} start + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @instance + */ + EnumReservedRange.prototype.start = 0 + + /** + * EnumReservedRange end. + * @member {number} end + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @instance + */ + EnumReservedRange.prototype.end = 0 + + /** + * Creates a new EnumReservedRange instance using the specified properties. + * @function create + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @static + * @param {google.protobuf.EnumDescriptorProto.IEnumReservedRange=} [properties] Properties to set + * @returns {google.protobuf.EnumDescriptorProto.EnumReservedRange} EnumReservedRange instance + */ + EnumReservedRange.create = function create(properties) { + return new EnumReservedRange(properties) + } + + /** + * Encodes the specified EnumReservedRange message. Does not implicitly {@link google.protobuf.EnumDescriptorProto.EnumReservedRange.verify|verify} messages. + * @function encode + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @static + * @param {google.protobuf.EnumDescriptorProto.IEnumReservedRange} message EnumReservedRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumReservedRange.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.start != null && + Object.hasOwnProperty.call(message, 'start') + ) + writer + .uint32(/* id 1, wireType 0 =*/ 8) + .int32(message.start) + if ( + message.end != null && + Object.hasOwnProperty.call(message, 'end') + ) + writer.uint32(/* id 2, wireType 0 =*/ 16).int32(message.end) + return writer + } + + /** + * Encodes the specified EnumReservedRange message, length delimited. Does not implicitly {@link google.protobuf.EnumDescriptorProto.EnumReservedRange.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @static + * @param {google.protobuf.EnumDescriptorProto.IEnumReservedRange} message EnumReservedRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumReservedRange.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an EnumReservedRange message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.EnumDescriptorProto.EnumReservedRange} EnumReservedRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumReservedRange.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.EnumDescriptorProto.EnumReservedRange() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.start = reader.int32() + break + case 2: + message.end = reader.int32() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an EnumReservedRange message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.EnumDescriptorProto.EnumReservedRange} EnumReservedRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumReservedRange.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an EnumReservedRange message. + * @function verify + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + EnumReservedRange.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.start != null && message.hasOwnProperty('start')) + if (!$util.isInteger(message.start)) + return 'start: integer expected' + if (message.end != null && message.hasOwnProperty('end')) + if (!$util.isInteger(message.end)) + return 'end: integer expected' + return null + } + + /** + * Creates an EnumReservedRange message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.EnumDescriptorProto.EnumReservedRange} EnumReservedRange + */ + EnumReservedRange.fromObject = function fromObject(object) { + if ( + object instanceof + $root.google.protobuf.EnumDescriptorProto.EnumReservedRange + ) + return object + var message = new $root.google.protobuf.EnumDescriptorProto.EnumReservedRange() + if (object.start != null) message.start = object.start | 0 + if (object.end != null) message.end = object.end | 0 + return message + } + + /** + * Creates a plain object from an EnumReservedRange message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @static + * @param {google.protobuf.EnumDescriptorProto.EnumReservedRange} message EnumReservedRange + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EnumReservedRange.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.start = 0 + object.end = 0 + } + if (message.start != null && message.hasOwnProperty('start')) + object.start = message.start + if (message.end != null && message.hasOwnProperty('end')) + object.end = message.end + return object + } + + /** + * Converts this EnumReservedRange to JSON. + * @function toJSON + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @instance + * @returns {Object.} JSON object + */ + EnumReservedRange.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return EnumReservedRange + })() + + return EnumDescriptorProto + })() + + protobuf.EnumValueDescriptorProto = (function () { + /** + * Properties of an EnumValueDescriptorProto. + * @memberof google.protobuf + * @interface IEnumValueDescriptorProto + * @property {string|null} [name] EnumValueDescriptorProto name + * @property {number|null} [number] EnumValueDescriptorProto number + * @property {google.protobuf.IEnumValueOptions|null} [options] EnumValueDescriptorProto options + */ + + /** + * Constructs a new EnumValueDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents an EnumValueDescriptorProto. + * @implements IEnumValueDescriptorProto + * @constructor + * @param {google.protobuf.IEnumValueDescriptorProto=} [properties] Properties to set + */ + function EnumValueDescriptorProto(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * EnumValueDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.EnumValueDescriptorProto + * @instance + */ + EnumValueDescriptorProto.prototype.name = '' + + /** + * EnumValueDescriptorProto number. + * @member {number} number + * @memberof google.protobuf.EnumValueDescriptorProto + * @instance + */ + EnumValueDescriptorProto.prototype.number = 0 + + /** + * EnumValueDescriptorProto options. + * @member {google.protobuf.IEnumValueOptions|null|undefined} options + * @memberof google.protobuf.EnumValueDescriptorProto + * @instance + */ + EnumValueDescriptorProto.prototype.options = null + + /** + * Creates a new EnumValueDescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {google.protobuf.IEnumValueDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.EnumValueDescriptorProto} EnumValueDescriptorProto instance + */ + EnumValueDescriptorProto.create = function create(properties) { + return new EnumValueDescriptorProto(properties) + } + + /** + * Encodes the specified EnumValueDescriptorProto message. Does not implicitly {@link google.protobuf.EnumValueDescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {google.protobuf.IEnumValueDescriptorProto} message EnumValueDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumValueDescriptorProto.encode = function encode( + message, + writer + ) { + if (!writer) writer = $Writer.create() + if ( + message.name != null && + Object.hasOwnProperty.call(message, 'name') + ) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.name) + if ( + message.number != null && + Object.hasOwnProperty.call(message, 'number') + ) + writer + .uint32(/* id 2, wireType 0 =*/ 16) + .int32(message.number) + if ( + message.options != null && + Object.hasOwnProperty.call(message, 'options') + ) + $root.google.protobuf.EnumValueOptions.encode( + message.options, + writer.uint32(/* id 3, wireType 2 =*/ 26).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified EnumValueDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.EnumValueDescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {google.protobuf.IEnumValueDescriptorProto} message EnumValueDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumValueDescriptorProto.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an EnumValueDescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.EnumValueDescriptorProto} EnumValueDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumValueDescriptorProto.decode = function decode( + reader, + length + ) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.EnumValueDescriptorProto() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + case 2: + message.number = reader.int32() + break + case 3: + message.options = $root.google.protobuf.EnumValueOptions.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an EnumValueDescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.EnumValueDescriptorProto} EnumValueDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumValueDescriptorProto.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an EnumValueDescriptorProto message. + * @function verify + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + EnumValueDescriptorProto.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + if (message.number != null && message.hasOwnProperty('number')) + if (!$util.isInteger(message.number)) + return 'number: integer expected' + if ( + message.options != null && + message.hasOwnProperty('options') + ) { + var error = $root.google.protobuf.EnumValueOptions.verify( + message.options + ) + if (error) return 'options.' + error + } + return null + } + + /** + * Creates an EnumValueDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.EnumValueDescriptorProto} EnumValueDescriptorProto + */ + EnumValueDescriptorProto.fromObject = function fromObject( + object + ) { + if ( + object instanceof + $root.google.protobuf.EnumValueDescriptorProto + ) + return object + var message = new $root.google.protobuf.EnumValueDescriptorProto() + if (object.name != null) message.name = String(object.name) + if (object.number != null) message.number = object.number | 0 + if (object.options != null) { + if (typeof object.options !== 'object') + throw TypeError( + '.google.protobuf.EnumValueDescriptorProto.options: object expected' + ) + message.options = $root.google.protobuf.EnumValueOptions.fromObject( + object.options + ) + } + return message + } + + /** + * Creates a plain object from an EnumValueDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {google.protobuf.EnumValueDescriptorProto} message EnumValueDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EnumValueDescriptorProto.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.name = '' + object.number = 0 + object.options = null + } + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + if (message.number != null && message.hasOwnProperty('number')) + object.number = message.number + if ( + message.options != null && + message.hasOwnProperty('options') + ) + object.options = $root.google.protobuf.EnumValueOptions.toObject( + message.options, + options + ) + return object + } + + /** + * Converts this EnumValueDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.EnumValueDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + EnumValueDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return EnumValueDescriptorProto + })() + + protobuf.ServiceDescriptorProto = (function () { + /** + * Properties of a ServiceDescriptorProto. + * @memberof google.protobuf + * @interface IServiceDescriptorProto + * @property {string|null} [name] ServiceDescriptorProto name + * @property {Array.|null} [method] ServiceDescriptorProto method + * @property {google.protobuf.IServiceOptions|null} [options] ServiceDescriptorProto options + */ + + /** + * Constructs a new ServiceDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a ServiceDescriptorProto. + * @implements IServiceDescriptorProto + * @constructor + * @param {google.protobuf.IServiceDescriptorProto=} [properties] Properties to set + */ + function ServiceDescriptorProto(properties) { + this.method = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * ServiceDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.ServiceDescriptorProto + * @instance + */ + ServiceDescriptorProto.prototype.name = '' + + /** + * ServiceDescriptorProto method. + * @member {Array.} method + * @memberof google.protobuf.ServiceDescriptorProto + * @instance + */ + ServiceDescriptorProto.prototype.method = $util.emptyArray + + /** + * ServiceDescriptorProto options. + * @member {google.protobuf.IServiceOptions|null|undefined} options + * @memberof google.protobuf.ServiceDescriptorProto + * @instance + */ + ServiceDescriptorProto.prototype.options = null + + /** + * Creates a new ServiceDescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {google.protobuf.IServiceDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.ServiceDescriptorProto} ServiceDescriptorProto instance + */ + ServiceDescriptorProto.create = function create(properties) { + return new ServiceDescriptorProto(properties) + } + + /** + * Encodes the specified ServiceDescriptorProto message. Does not implicitly {@link google.protobuf.ServiceDescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {google.protobuf.IServiceDescriptorProto} message ServiceDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ServiceDescriptorProto.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.name != null && + Object.hasOwnProperty.call(message, 'name') + ) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.name) + if (message.method != null && message.method.length) + for (var i = 0; i < message.method.length; ++i) + $root.google.protobuf.MethodDescriptorProto.encode( + message.method[i], + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + ).ldelim() + if ( + message.options != null && + Object.hasOwnProperty.call(message, 'options') + ) + $root.google.protobuf.ServiceOptions.encode( + message.options, + writer.uint32(/* id 3, wireType 2 =*/ 26).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified ServiceDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.ServiceDescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {google.protobuf.IServiceDescriptorProto} message ServiceDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ServiceDescriptorProto.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a ServiceDescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.ServiceDescriptorProto} ServiceDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ServiceDescriptorProto.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.ServiceDescriptorProto() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + case 2: + if (!(message.method && message.method.length)) + message.method = [] + message.method.push( + $root.google.protobuf.MethodDescriptorProto.decode( + reader, + reader.uint32() + ) + ) + break + case 3: + message.options = $root.google.protobuf.ServiceOptions.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a ServiceDescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.ServiceDescriptorProto} ServiceDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ServiceDescriptorProto.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a ServiceDescriptorProto message. + * @function verify + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ServiceDescriptorProto.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + if ( + message.method != null && + message.hasOwnProperty('method') + ) { + if (!Array.isArray(message.method)) + return 'method: array expected' + for (var i = 0; i < message.method.length; ++i) { + var error = $root.google.protobuf.MethodDescriptorProto.verify( + message.method[i] + ) + if (error) return 'method.' + error + } + } + if ( + message.options != null && + message.hasOwnProperty('options') + ) { + var error = $root.google.protobuf.ServiceOptions.verify( + message.options + ) + if (error) return 'options.' + error + } + return null + } + + /** + * Creates a ServiceDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.ServiceDescriptorProto} ServiceDescriptorProto + */ + ServiceDescriptorProto.fromObject = function fromObject(object) { + if ( + object instanceof $root.google.protobuf.ServiceDescriptorProto + ) + return object + var message = new $root.google.protobuf.ServiceDescriptorProto() + if (object.name != null) message.name = String(object.name) + if (object.method) { + if (!Array.isArray(object.method)) + throw TypeError( + '.google.protobuf.ServiceDescriptorProto.method: array expected' + ) + message.method = [] + for (var i = 0; i < object.method.length; ++i) { + if (typeof object.method[i] !== 'object') + throw TypeError( + '.google.protobuf.ServiceDescriptorProto.method: object expected' + ) + message.method[ + i + ] = $root.google.protobuf.MethodDescriptorProto.fromObject( + object.method[i] + ) + } + } + if (object.options != null) { + if (typeof object.options !== 'object') + throw TypeError( + '.google.protobuf.ServiceDescriptorProto.options: object expected' + ) + message.options = $root.google.protobuf.ServiceOptions.fromObject( + object.options + ) + } + return message + } + + /** + * Creates a plain object from a ServiceDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {google.protobuf.ServiceDescriptorProto} message ServiceDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ServiceDescriptorProto.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) object.method = [] + if (options.defaults) { + object.name = '' + object.options = null + } + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + if (message.method && message.method.length) { + object.method = [] + for (var j = 0; j < message.method.length; ++j) + object.method[ + j + ] = $root.google.protobuf.MethodDescriptorProto.toObject( + message.method[j], + options + ) + } + if ( + message.options != null && + message.hasOwnProperty('options') + ) + object.options = $root.google.protobuf.ServiceOptions.toObject( + message.options, + options + ) + return object + } + + /** + * Converts this ServiceDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.ServiceDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + ServiceDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return ServiceDescriptorProto + })() + + protobuf.MethodDescriptorProto = (function () { + /** + * Properties of a MethodDescriptorProto. + * @memberof google.protobuf + * @interface IMethodDescriptorProto + * @property {string|null} [name] MethodDescriptorProto name + * @property {string|null} [inputType] MethodDescriptorProto inputType + * @property {string|null} [outputType] MethodDescriptorProto outputType + * @property {google.protobuf.IMethodOptions|null} [options] MethodDescriptorProto options + * @property {boolean|null} [clientStreaming] MethodDescriptorProto clientStreaming + * @property {boolean|null} [serverStreaming] MethodDescriptorProto serverStreaming + */ + + /** + * Constructs a new MethodDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a MethodDescriptorProto. + * @implements IMethodDescriptorProto + * @constructor + * @param {google.protobuf.IMethodDescriptorProto=} [properties] Properties to set + */ + function MethodDescriptorProto(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * MethodDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.name = '' + + /** + * MethodDescriptorProto inputType. + * @member {string} inputType + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.inputType = '' + + /** + * MethodDescriptorProto outputType. + * @member {string} outputType + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.outputType = '' + + /** + * MethodDescriptorProto options. + * @member {google.protobuf.IMethodOptions|null|undefined} options + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.options = null + + /** + * MethodDescriptorProto clientStreaming. + * @member {boolean} clientStreaming + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.clientStreaming = false + + /** + * MethodDescriptorProto serverStreaming. + * @member {boolean} serverStreaming + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.serverStreaming = false + + /** + * Creates a new MethodDescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {google.protobuf.IMethodDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.MethodDescriptorProto} MethodDescriptorProto instance + */ + MethodDescriptorProto.create = function create(properties) { + return new MethodDescriptorProto(properties) + } + + /** + * Encodes the specified MethodDescriptorProto message. Does not implicitly {@link google.protobuf.MethodDescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {google.protobuf.IMethodDescriptorProto} message MethodDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MethodDescriptorProto.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.name != null && + Object.hasOwnProperty.call(message, 'name') + ) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.name) + if ( + message.inputType != null && + Object.hasOwnProperty.call(message, 'inputType') + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.inputType) + if ( + message.outputType != null && + Object.hasOwnProperty.call(message, 'outputType') + ) + writer + .uint32(/* id 3, wireType 2 =*/ 26) + .string(message.outputType) + if ( + message.options != null && + Object.hasOwnProperty.call(message, 'options') + ) + $root.google.protobuf.MethodOptions.encode( + message.options, + writer.uint32(/* id 4, wireType 2 =*/ 34).fork() + ).ldelim() + if ( + message.clientStreaming != null && + Object.hasOwnProperty.call(message, 'clientStreaming') + ) + writer + .uint32(/* id 5, wireType 0 =*/ 40) + .bool(message.clientStreaming) + if ( + message.serverStreaming != null && + Object.hasOwnProperty.call(message, 'serverStreaming') + ) + writer + .uint32(/* id 6, wireType 0 =*/ 48) + .bool(message.serverStreaming) + return writer + } + + /** + * Encodes the specified MethodDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.MethodDescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {google.protobuf.IMethodDescriptorProto} message MethodDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MethodDescriptorProto.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a MethodDescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.MethodDescriptorProto} MethodDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MethodDescriptorProto.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.MethodDescriptorProto() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + case 2: + message.inputType = reader.string() + break + case 3: + message.outputType = reader.string() + break + case 4: + message.options = $root.google.protobuf.MethodOptions.decode( + reader, + reader.uint32() + ) + break + case 5: + message.clientStreaming = reader.bool() + break + case 6: + message.serverStreaming = reader.bool() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a MethodDescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.MethodDescriptorProto} MethodDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MethodDescriptorProto.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a MethodDescriptorProto message. + * @function verify + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + MethodDescriptorProto.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + if ( + message.inputType != null && + message.hasOwnProperty('inputType') + ) + if (!$util.isString(message.inputType)) + return 'inputType: string expected' + if ( + message.outputType != null && + message.hasOwnProperty('outputType') + ) + if (!$util.isString(message.outputType)) + return 'outputType: string expected' + if ( + message.options != null && + message.hasOwnProperty('options') + ) { + var error = $root.google.protobuf.MethodOptions.verify( + message.options + ) + if (error) return 'options.' + error + } + if ( + message.clientStreaming != null && + message.hasOwnProperty('clientStreaming') + ) + if (typeof message.clientStreaming !== 'boolean') + return 'clientStreaming: boolean expected' + if ( + message.serverStreaming != null && + message.hasOwnProperty('serverStreaming') + ) + if (typeof message.serverStreaming !== 'boolean') + return 'serverStreaming: boolean expected' + return null + } + + /** + * Creates a MethodDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.MethodDescriptorProto} MethodDescriptorProto + */ + MethodDescriptorProto.fromObject = function fromObject(object) { + if ( + object instanceof $root.google.protobuf.MethodDescriptorProto + ) + return object + var message = new $root.google.protobuf.MethodDescriptorProto() + if (object.name != null) message.name = String(object.name) + if (object.inputType != null) + message.inputType = String(object.inputType) + if (object.outputType != null) + message.outputType = String(object.outputType) + if (object.options != null) { + if (typeof object.options !== 'object') + throw TypeError( + '.google.protobuf.MethodDescriptorProto.options: object expected' + ) + message.options = $root.google.protobuf.MethodOptions.fromObject( + object.options + ) + } + if (object.clientStreaming != null) + message.clientStreaming = Boolean(object.clientStreaming) + if (object.serverStreaming != null) + message.serverStreaming = Boolean(object.serverStreaming) + return message + } + + /** + * Creates a plain object from a MethodDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {google.protobuf.MethodDescriptorProto} message MethodDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MethodDescriptorProto.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.name = '' + object.inputType = '' + object.outputType = '' + object.options = null + object.clientStreaming = false + object.serverStreaming = false + } + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + if ( + message.inputType != null && + message.hasOwnProperty('inputType') + ) + object.inputType = message.inputType + if ( + message.outputType != null && + message.hasOwnProperty('outputType') + ) + object.outputType = message.outputType + if ( + message.options != null && + message.hasOwnProperty('options') + ) + object.options = $root.google.protobuf.MethodOptions.toObject( + message.options, + options + ) + if ( + message.clientStreaming != null && + message.hasOwnProperty('clientStreaming') + ) + object.clientStreaming = message.clientStreaming + if ( + message.serverStreaming != null && + message.hasOwnProperty('serverStreaming') + ) + object.serverStreaming = message.serverStreaming + return object + } + + /** + * Converts this MethodDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.MethodDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + MethodDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return MethodDescriptorProto + })() + + protobuf.FileOptions = (function () { + /** + * Properties of a FileOptions. + * @memberof google.protobuf + * @interface IFileOptions + * @property {string|null} [javaPackage] FileOptions javaPackage + * @property {string|null} [javaOuterClassname] FileOptions javaOuterClassname + * @property {boolean|null} [javaMultipleFiles] FileOptions javaMultipleFiles + * @property {boolean|null} [javaGenerateEqualsAndHash] FileOptions javaGenerateEqualsAndHash + * @property {boolean|null} [javaStringCheckUtf8] FileOptions javaStringCheckUtf8 + * @property {google.protobuf.FileOptions.OptimizeMode|null} [optimizeFor] FileOptions optimizeFor + * @property {string|null} [goPackage] FileOptions goPackage + * @property {boolean|null} [ccGenericServices] FileOptions ccGenericServices + * @property {boolean|null} [javaGenericServices] FileOptions javaGenericServices + * @property {boolean|null} [pyGenericServices] FileOptions pyGenericServices + * @property {boolean|null} [phpGenericServices] FileOptions phpGenericServices + * @property {boolean|null} [deprecated] FileOptions deprecated + * @property {boolean|null} [ccEnableArenas] FileOptions ccEnableArenas + * @property {string|null} [objcClassPrefix] FileOptions objcClassPrefix + * @property {string|null} [csharpNamespace] FileOptions csharpNamespace + * @property {string|null} [swiftPrefix] FileOptions swiftPrefix + * @property {string|null} [phpClassPrefix] FileOptions phpClassPrefix + * @property {string|null} [phpNamespace] FileOptions phpNamespace + * @property {string|null} [phpMetadataNamespace] FileOptions phpMetadataNamespace + * @property {string|null} [rubyPackage] FileOptions rubyPackage + * @property {Array.|null} [uninterpretedOption] FileOptions uninterpretedOption + * @property {Array.|null} [".google.api.resourceDefinition"] FileOptions .google.api.resourceDefinition + */ + + /** + * Constructs a new FileOptions. + * @memberof google.protobuf + * @classdesc Represents a FileOptions. + * @implements IFileOptions + * @constructor + * @param {google.protobuf.IFileOptions=} [properties] Properties to set + */ + function FileOptions(properties) { + this.uninterpretedOption = [] + this['.google.api.resourceDefinition'] = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * FileOptions javaPackage. + * @member {string} javaPackage + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaPackage = '' + + /** + * FileOptions javaOuterClassname. + * @member {string} javaOuterClassname + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaOuterClassname = '' + + /** + * FileOptions javaMultipleFiles. + * @member {boolean} javaMultipleFiles + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaMultipleFiles = false + + /** + * FileOptions javaGenerateEqualsAndHash. + * @member {boolean} javaGenerateEqualsAndHash + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaGenerateEqualsAndHash = false + + /** + * FileOptions javaStringCheckUtf8. + * @member {boolean} javaStringCheckUtf8 + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaStringCheckUtf8 = false + + /** + * FileOptions optimizeFor. + * @member {google.protobuf.FileOptions.OptimizeMode} optimizeFor + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.optimizeFor = 1 + + /** + * FileOptions goPackage. + * @member {string} goPackage + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.goPackage = '' + + /** + * FileOptions ccGenericServices. + * @member {boolean} ccGenericServices + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.ccGenericServices = false + + /** + * FileOptions javaGenericServices. + * @member {boolean} javaGenericServices + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaGenericServices = false + + /** + * FileOptions pyGenericServices. + * @member {boolean} pyGenericServices + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.pyGenericServices = false + + /** + * FileOptions phpGenericServices. + * @member {boolean} phpGenericServices + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.phpGenericServices = false + + /** + * FileOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.deprecated = false + + /** + * FileOptions ccEnableArenas. + * @member {boolean} ccEnableArenas + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.ccEnableArenas = true + + /** + * FileOptions objcClassPrefix. + * @member {string} objcClassPrefix + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.objcClassPrefix = '' + + /** + * FileOptions csharpNamespace. + * @member {string} csharpNamespace + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.csharpNamespace = '' + + /** + * FileOptions swiftPrefix. + * @member {string} swiftPrefix + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.swiftPrefix = '' + + /** + * FileOptions phpClassPrefix. + * @member {string} phpClassPrefix + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.phpClassPrefix = '' + + /** + * FileOptions phpNamespace. + * @member {string} phpNamespace + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.phpNamespace = '' + + /** + * FileOptions phpMetadataNamespace. + * @member {string} phpMetadataNamespace + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.phpMetadataNamespace = '' + + /** + * FileOptions rubyPackage. + * @member {string} rubyPackage + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.rubyPackage = '' + + /** + * FileOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.uninterpretedOption = $util.emptyArray + + /** + * FileOptions .google.api.resourceDefinition. + * @member {Array.} .google.api.resourceDefinition + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype['.google.api.resourceDefinition'] = + $util.emptyArray + + /** + * Creates a new FileOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.FileOptions + * @static + * @param {google.protobuf.IFileOptions=} [properties] Properties to set + * @returns {google.protobuf.FileOptions} FileOptions instance + */ + FileOptions.create = function create(properties) { + return new FileOptions(properties) + } + + /** + * Encodes the specified FileOptions message. Does not implicitly {@link google.protobuf.FileOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FileOptions + * @static + * @param {google.protobuf.IFileOptions} message FileOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FileOptions.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.javaPackage != null && + Object.hasOwnProperty.call(message, 'javaPackage') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.javaPackage) + if ( + message.javaOuterClassname != null && + Object.hasOwnProperty.call(message, 'javaOuterClassname') + ) + writer + .uint32(/* id 8, wireType 2 =*/ 66) + .string(message.javaOuterClassname) + if ( + message.optimizeFor != null && + Object.hasOwnProperty.call(message, 'optimizeFor') + ) + writer + .uint32(/* id 9, wireType 0 =*/ 72) + .int32(message.optimizeFor) + if ( + message.javaMultipleFiles != null && + Object.hasOwnProperty.call(message, 'javaMultipleFiles') + ) + writer + .uint32(/* id 10, wireType 0 =*/ 80) + .bool(message.javaMultipleFiles) + if ( + message.goPackage != null && + Object.hasOwnProperty.call(message, 'goPackage') + ) + writer + .uint32(/* id 11, wireType 2 =*/ 90) + .string(message.goPackage) + if ( + message.ccGenericServices != null && + Object.hasOwnProperty.call(message, 'ccGenericServices') + ) + writer + .uint32(/* id 16, wireType 0 =*/ 128) + .bool(message.ccGenericServices) + if ( + message.javaGenericServices != null && + Object.hasOwnProperty.call(message, 'javaGenericServices') + ) + writer + .uint32(/* id 17, wireType 0 =*/ 136) + .bool(message.javaGenericServices) + if ( + message.pyGenericServices != null && + Object.hasOwnProperty.call(message, 'pyGenericServices') + ) + writer + .uint32(/* id 18, wireType 0 =*/ 144) + .bool(message.pyGenericServices) + if ( + message.javaGenerateEqualsAndHash != null && + Object.hasOwnProperty.call( + message, + 'javaGenerateEqualsAndHash' + ) + ) + writer + .uint32(/* id 20, wireType 0 =*/ 160) + .bool(message.javaGenerateEqualsAndHash) + if ( + message.deprecated != null && + Object.hasOwnProperty.call(message, 'deprecated') + ) + writer + .uint32(/* id 23, wireType 0 =*/ 184) + .bool(message.deprecated) + if ( + message.javaStringCheckUtf8 != null && + Object.hasOwnProperty.call(message, 'javaStringCheckUtf8') + ) + writer + .uint32(/* id 27, wireType 0 =*/ 216) + .bool(message.javaStringCheckUtf8) + if ( + message.ccEnableArenas != null && + Object.hasOwnProperty.call(message, 'ccEnableArenas') + ) + writer + .uint32(/* id 31, wireType 0 =*/ 248) + .bool(message.ccEnableArenas) + if ( + message.objcClassPrefix != null && + Object.hasOwnProperty.call(message, 'objcClassPrefix') + ) + writer + .uint32(/* id 36, wireType 2 =*/ 290) + .string(message.objcClassPrefix) + if ( + message.csharpNamespace != null && + Object.hasOwnProperty.call(message, 'csharpNamespace') + ) + writer + .uint32(/* id 37, wireType 2 =*/ 298) + .string(message.csharpNamespace) + if ( + message.swiftPrefix != null && + Object.hasOwnProperty.call(message, 'swiftPrefix') + ) + writer + .uint32(/* id 39, wireType 2 =*/ 314) + .string(message.swiftPrefix) + if ( + message.phpClassPrefix != null && + Object.hasOwnProperty.call(message, 'phpClassPrefix') + ) + writer + .uint32(/* id 40, wireType 2 =*/ 322) + .string(message.phpClassPrefix) + if ( + message.phpNamespace != null && + Object.hasOwnProperty.call(message, 'phpNamespace') + ) + writer + .uint32(/* id 41, wireType 2 =*/ 330) + .string(message.phpNamespace) + if ( + message.phpGenericServices != null && + Object.hasOwnProperty.call(message, 'phpGenericServices') + ) + writer + .uint32(/* id 42, wireType 0 =*/ 336) + .bool(message.phpGenericServices) + if ( + message.phpMetadataNamespace != null && + Object.hasOwnProperty.call(message, 'phpMetadataNamespace') + ) + writer + .uint32(/* id 44, wireType 2 =*/ 354) + .string(message.phpMetadataNamespace) + if ( + message.rubyPackage != null && + Object.hasOwnProperty.call(message, 'rubyPackage') + ) + writer + .uint32(/* id 45, wireType 2 =*/ 362) + .string(message.rubyPackage) + if ( + message.uninterpretedOption != null && + message.uninterpretedOption.length + ) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode( + message.uninterpretedOption[i], + writer.uint32(/* id 999, wireType 2 =*/ 7994).fork() + ).ldelim() + if ( + message['.google.api.resourceDefinition'] != null && + message['.google.api.resourceDefinition'].length + ) + for ( + var i = 0; + i < message['.google.api.resourceDefinition'].length; + ++i + ) + $root.google.api.ResourceDescriptor.encode( + message['.google.api.resourceDefinition'][i], + writer.uint32(/* id 1053, wireType 2 =*/ 8426).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified FileOptions message, length delimited. Does not implicitly {@link google.protobuf.FileOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FileOptions + * @static + * @param {google.protobuf.IFileOptions} message FileOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FileOptions.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a FileOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FileOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FileOptions} FileOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FileOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.FileOptions() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.javaPackage = reader.string() + break + case 8: + message.javaOuterClassname = reader.string() + break + case 10: + message.javaMultipleFiles = reader.bool() + break + case 20: + message.javaGenerateEqualsAndHash = reader.bool() + break + case 27: + message.javaStringCheckUtf8 = reader.bool() + break + case 9: + message.optimizeFor = reader.int32() + break + case 11: + message.goPackage = reader.string() + break + case 16: + message.ccGenericServices = reader.bool() + break + case 17: + message.javaGenericServices = reader.bool() + break + case 18: + message.pyGenericServices = reader.bool() + break + case 42: + message.phpGenericServices = reader.bool() + break + case 23: + message.deprecated = reader.bool() + break + case 31: + message.ccEnableArenas = reader.bool() + break + case 36: + message.objcClassPrefix = reader.string() + break + case 37: + message.csharpNamespace = reader.string() + break + case 39: + message.swiftPrefix = reader.string() + break + case 40: + message.phpClassPrefix = reader.string() + break + case 41: + message.phpNamespace = reader.string() + break + case 44: + message.phpMetadataNamespace = reader.string() + break + case 45: + message.rubyPackage = reader.string() + break + case 999: + if ( + !( + message.uninterpretedOption && + message.uninterpretedOption.length + ) + ) + message.uninterpretedOption = [] + message.uninterpretedOption.push( + $root.google.protobuf.UninterpretedOption.decode( + reader, + reader.uint32() + ) + ) + break + case 1053: + if ( + !( + message['.google.api.resourceDefinition'] && + message['.google.api.resourceDefinition'].length + ) + ) + message['.google.api.resourceDefinition'] = [] + message['.google.api.resourceDefinition'].push( + $root.google.api.ResourceDescriptor.decode( + reader, + reader.uint32() + ) + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a FileOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FileOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FileOptions} FileOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FileOptions.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a FileOptions message. + * @function verify + * @memberof google.protobuf.FileOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FileOptions.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.javaPackage != null && + message.hasOwnProperty('javaPackage') + ) + if (!$util.isString(message.javaPackage)) + return 'javaPackage: string expected' + if ( + message.javaOuterClassname != null && + message.hasOwnProperty('javaOuterClassname') + ) + if (!$util.isString(message.javaOuterClassname)) + return 'javaOuterClassname: string expected' + if ( + message.javaMultipleFiles != null && + message.hasOwnProperty('javaMultipleFiles') + ) + if (typeof message.javaMultipleFiles !== 'boolean') + return 'javaMultipleFiles: boolean expected' + if ( + message.javaGenerateEqualsAndHash != null && + message.hasOwnProperty('javaGenerateEqualsAndHash') + ) + if (typeof message.javaGenerateEqualsAndHash !== 'boolean') + return 'javaGenerateEqualsAndHash: boolean expected' + if ( + message.javaStringCheckUtf8 != null && + message.hasOwnProperty('javaStringCheckUtf8') + ) + if (typeof message.javaStringCheckUtf8 !== 'boolean') + return 'javaStringCheckUtf8: boolean expected' + if ( + message.optimizeFor != null && + message.hasOwnProperty('optimizeFor') + ) + switch (message.optimizeFor) { + default: + return 'optimizeFor: enum value expected' + case 1: + case 2: + case 3: + break + } + if ( + message.goPackage != null && + message.hasOwnProperty('goPackage') + ) + if (!$util.isString(message.goPackage)) + return 'goPackage: string expected' + if ( + message.ccGenericServices != null && + message.hasOwnProperty('ccGenericServices') + ) + if (typeof message.ccGenericServices !== 'boolean') + return 'ccGenericServices: boolean expected' + if ( + message.javaGenericServices != null && + message.hasOwnProperty('javaGenericServices') + ) + if (typeof message.javaGenericServices !== 'boolean') + return 'javaGenericServices: boolean expected' + if ( + message.pyGenericServices != null && + message.hasOwnProperty('pyGenericServices') + ) + if (typeof message.pyGenericServices !== 'boolean') + return 'pyGenericServices: boolean expected' + if ( + message.phpGenericServices != null && + message.hasOwnProperty('phpGenericServices') + ) + if (typeof message.phpGenericServices !== 'boolean') + return 'phpGenericServices: boolean expected' + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + if (typeof message.deprecated !== 'boolean') + return 'deprecated: boolean expected' + if ( + message.ccEnableArenas != null && + message.hasOwnProperty('ccEnableArenas') + ) + if (typeof message.ccEnableArenas !== 'boolean') + return 'ccEnableArenas: boolean expected' + if ( + message.objcClassPrefix != null && + message.hasOwnProperty('objcClassPrefix') + ) + if (!$util.isString(message.objcClassPrefix)) + return 'objcClassPrefix: string expected' + if ( + message.csharpNamespace != null && + message.hasOwnProperty('csharpNamespace') + ) + if (!$util.isString(message.csharpNamespace)) + return 'csharpNamespace: string expected' + if ( + message.swiftPrefix != null && + message.hasOwnProperty('swiftPrefix') + ) + if (!$util.isString(message.swiftPrefix)) + return 'swiftPrefix: string expected' + if ( + message.phpClassPrefix != null && + message.hasOwnProperty('phpClassPrefix') + ) + if (!$util.isString(message.phpClassPrefix)) + return 'phpClassPrefix: string expected' + if ( + message.phpNamespace != null && + message.hasOwnProperty('phpNamespace') + ) + if (!$util.isString(message.phpNamespace)) + return 'phpNamespace: string expected' + if ( + message.phpMetadataNamespace != null && + message.hasOwnProperty('phpMetadataNamespace') + ) + if (!$util.isString(message.phpMetadataNamespace)) + return 'phpMetadataNamespace: string expected' + if ( + message.rubyPackage != null && + message.hasOwnProperty('rubyPackage') + ) + if (!$util.isString(message.rubyPackage)) + return 'rubyPackage: string expected' + if ( + message.uninterpretedOption != null && + message.hasOwnProperty('uninterpretedOption') + ) { + if (!Array.isArray(message.uninterpretedOption)) + return 'uninterpretedOption: array expected' + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify( + message.uninterpretedOption[i] + ) + if (error) return 'uninterpretedOption.' + error + } + } + if ( + message['.google.api.resourceDefinition'] != null && + message.hasOwnProperty('.google.api.resourceDefinition') + ) { + if (!Array.isArray(message['.google.api.resourceDefinition'])) + return '.google.api.resourceDefinition: array expected' + for ( + var i = 0; + i < message['.google.api.resourceDefinition'].length; + ++i + ) { + var error = $root.google.api.ResourceDescriptor.verify( + message['.google.api.resourceDefinition'][i] + ) + if (error) return '.google.api.resourceDefinition.' + error + } + } + return null + } + + /** + * Creates a FileOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FileOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FileOptions} FileOptions + */ + FileOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FileOptions) + return object + var message = new $root.google.protobuf.FileOptions() + if (object.javaPackage != null) + message.javaPackage = String(object.javaPackage) + if (object.javaOuterClassname != null) + message.javaOuterClassname = String(object.javaOuterClassname) + if (object.javaMultipleFiles != null) + message.javaMultipleFiles = Boolean(object.javaMultipleFiles) + if (object.javaGenerateEqualsAndHash != null) + message.javaGenerateEqualsAndHash = Boolean( + object.javaGenerateEqualsAndHash + ) + if (object.javaStringCheckUtf8 != null) + message.javaStringCheckUtf8 = Boolean( + object.javaStringCheckUtf8 + ) + switch (object.optimizeFor) { + case 'SPEED': + case 1: + message.optimizeFor = 1 + break + case 'CODE_SIZE': + case 2: + message.optimizeFor = 2 + break + case 'LITE_RUNTIME': + case 3: + message.optimizeFor = 3 + break + } + if (object.goPackage != null) + message.goPackage = String(object.goPackage) + if (object.ccGenericServices != null) + message.ccGenericServices = Boolean(object.ccGenericServices) + if (object.javaGenericServices != null) + message.javaGenericServices = Boolean( + object.javaGenericServices + ) + if (object.pyGenericServices != null) + message.pyGenericServices = Boolean(object.pyGenericServices) + if (object.phpGenericServices != null) + message.phpGenericServices = Boolean( + object.phpGenericServices + ) + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated) + if (object.ccEnableArenas != null) + message.ccEnableArenas = Boolean(object.ccEnableArenas) + if (object.objcClassPrefix != null) + message.objcClassPrefix = String(object.objcClassPrefix) + if (object.csharpNamespace != null) + message.csharpNamespace = String(object.csharpNamespace) + if (object.swiftPrefix != null) + message.swiftPrefix = String(object.swiftPrefix) + if (object.phpClassPrefix != null) + message.phpClassPrefix = String(object.phpClassPrefix) + if (object.phpNamespace != null) + message.phpNamespace = String(object.phpNamespace) + if (object.phpMetadataNamespace != null) + message.phpMetadataNamespace = String( + object.phpMetadataNamespace + ) + if (object.rubyPackage != null) + message.rubyPackage = String(object.rubyPackage) + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError( + '.google.protobuf.FileOptions.uninterpretedOption: array expected' + ) + message.uninterpretedOption = [] + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== 'object') + throw TypeError( + '.google.protobuf.FileOptions.uninterpretedOption: object expected' + ) + message.uninterpretedOption[ + i + ] = $root.google.protobuf.UninterpretedOption.fromObject( + object.uninterpretedOption[i] + ) + } + } + if (object['.google.api.resourceDefinition']) { + if (!Array.isArray(object['.google.api.resourceDefinition'])) + throw TypeError( + '.google.protobuf.FileOptions..google.api.resourceDefinition: array expected' + ) + message['.google.api.resourceDefinition'] = [] + for ( + var i = 0; + i < object['.google.api.resourceDefinition'].length; + ++i + ) { + if ( + typeof object['.google.api.resourceDefinition'][i] !== + 'object' + ) + throw TypeError( + '.google.protobuf.FileOptions..google.api.resourceDefinition: object expected' + ) + message['.google.api.resourceDefinition'][ + i + ] = $root.google.api.ResourceDescriptor.fromObject( + object['.google.api.resourceDefinition'][i] + ) + } + } + return message + } + + /** + * Creates a plain object from a FileOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FileOptions + * @static + * @param {google.protobuf.FileOptions} message FileOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FileOptions.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) { + object.uninterpretedOption = [] + object['.google.api.resourceDefinition'] = [] + } + if (options.defaults) { + object.javaPackage = '' + object.javaOuterClassname = '' + object.optimizeFor = options.enums === String ? 'SPEED' : 1 + object.javaMultipleFiles = false + object.goPackage = '' + object.ccGenericServices = false + object.javaGenericServices = false + object.pyGenericServices = false + object.javaGenerateEqualsAndHash = false + object.deprecated = false + object.javaStringCheckUtf8 = false + object.ccEnableArenas = true + object.objcClassPrefix = '' + object.csharpNamespace = '' + object.swiftPrefix = '' + object.phpClassPrefix = '' + object.phpNamespace = '' + object.phpGenericServices = false + object.phpMetadataNamespace = '' + object.rubyPackage = '' + } + if ( + message.javaPackage != null && + message.hasOwnProperty('javaPackage') + ) + object.javaPackage = message.javaPackage + if ( + message.javaOuterClassname != null && + message.hasOwnProperty('javaOuterClassname') + ) + object.javaOuterClassname = message.javaOuterClassname + if ( + message.optimizeFor != null && + message.hasOwnProperty('optimizeFor') + ) + object.optimizeFor = + options.enums === String + ? $root.google.protobuf.FileOptions.OptimizeMode[ + message.optimizeFor + ] + : message.optimizeFor + if ( + message.javaMultipleFiles != null && + message.hasOwnProperty('javaMultipleFiles') + ) + object.javaMultipleFiles = message.javaMultipleFiles + if ( + message.goPackage != null && + message.hasOwnProperty('goPackage') + ) + object.goPackage = message.goPackage + if ( + message.ccGenericServices != null && + message.hasOwnProperty('ccGenericServices') + ) + object.ccGenericServices = message.ccGenericServices + if ( + message.javaGenericServices != null && + message.hasOwnProperty('javaGenericServices') + ) + object.javaGenericServices = message.javaGenericServices + if ( + message.pyGenericServices != null && + message.hasOwnProperty('pyGenericServices') + ) + object.pyGenericServices = message.pyGenericServices + if ( + message.javaGenerateEqualsAndHash != null && + message.hasOwnProperty('javaGenerateEqualsAndHash') + ) + object.javaGenerateEqualsAndHash = + message.javaGenerateEqualsAndHash + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + object.deprecated = message.deprecated + if ( + message.javaStringCheckUtf8 != null && + message.hasOwnProperty('javaStringCheckUtf8') + ) + object.javaStringCheckUtf8 = message.javaStringCheckUtf8 + if ( + message.ccEnableArenas != null && + message.hasOwnProperty('ccEnableArenas') + ) + object.ccEnableArenas = message.ccEnableArenas + if ( + message.objcClassPrefix != null && + message.hasOwnProperty('objcClassPrefix') + ) + object.objcClassPrefix = message.objcClassPrefix + if ( + message.csharpNamespace != null && + message.hasOwnProperty('csharpNamespace') + ) + object.csharpNamespace = message.csharpNamespace + if ( + message.swiftPrefix != null && + message.hasOwnProperty('swiftPrefix') + ) + object.swiftPrefix = message.swiftPrefix + if ( + message.phpClassPrefix != null && + message.hasOwnProperty('phpClassPrefix') + ) + object.phpClassPrefix = message.phpClassPrefix + if ( + message.phpNamespace != null && + message.hasOwnProperty('phpNamespace') + ) + object.phpNamespace = message.phpNamespace + if ( + message.phpGenericServices != null && + message.hasOwnProperty('phpGenericServices') + ) + object.phpGenericServices = message.phpGenericServices + if ( + message.phpMetadataNamespace != null && + message.hasOwnProperty('phpMetadataNamespace') + ) + object.phpMetadataNamespace = message.phpMetadataNamespace + if ( + message.rubyPackage != null && + message.hasOwnProperty('rubyPackage') + ) + object.rubyPackage = message.rubyPackage + if ( + message.uninterpretedOption && + message.uninterpretedOption.length + ) { + object.uninterpretedOption = [] + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[ + j + ] = $root.google.protobuf.UninterpretedOption.toObject( + message.uninterpretedOption[j], + options + ) + } + if ( + message['.google.api.resourceDefinition'] && + message['.google.api.resourceDefinition'].length + ) { + object['.google.api.resourceDefinition'] = [] + for ( + var j = 0; + j < message['.google.api.resourceDefinition'].length; + ++j + ) + object['.google.api.resourceDefinition'][ + j + ] = $root.google.api.ResourceDescriptor.toObject( + message['.google.api.resourceDefinition'][j], + options + ) + } + return object + } + + /** + * Converts this FileOptions to JSON. + * @function toJSON + * @memberof google.protobuf.FileOptions + * @instance + * @returns {Object.} JSON object + */ + FileOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + /** + * OptimizeMode enum. + * @name google.protobuf.FileOptions.OptimizeMode + * @enum {number} + * @property {number} SPEED=1 SPEED value + * @property {number} CODE_SIZE=2 CODE_SIZE value + * @property {number} LITE_RUNTIME=3 LITE_RUNTIME value + */ + FileOptions.OptimizeMode = (function () { + var valuesById = {}, + values = Object.create(valuesById) + values[(valuesById[1] = 'SPEED')] = 1 + values[(valuesById[2] = 'CODE_SIZE')] = 2 + values[(valuesById[3] = 'LITE_RUNTIME')] = 3 + return values + })() + + return FileOptions + })() + + protobuf.MessageOptions = (function () { + /** + * Properties of a MessageOptions. + * @memberof google.protobuf + * @interface IMessageOptions + * @property {boolean|null} [messageSetWireFormat] MessageOptions messageSetWireFormat + * @property {boolean|null} [noStandardDescriptorAccessor] MessageOptions noStandardDescriptorAccessor + * @property {boolean|null} [deprecated] MessageOptions deprecated + * @property {boolean|null} [mapEntry] MessageOptions mapEntry + * @property {Array.|null} [uninterpretedOption] MessageOptions uninterpretedOption + * @property {google.api.IResourceDescriptor|null} [".google.api.resource"] MessageOptions .google.api.resource + */ + + /** + * Constructs a new MessageOptions. + * @memberof google.protobuf + * @classdesc Represents a MessageOptions. + * @implements IMessageOptions + * @constructor + * @param {google.protobuf.IMessageOptions=} [properties] Properties to set + */ + function MessageOptions(properties) { + this.uninterpretedOption = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * MessageOptions messageSetWireFormat. + * @member {boolean} messageSetWireFormat + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.messageSetWireFormat = false + + /** + * MessageOptions noStandardDescriptorAccessor. + * @member {boolean} noStandardDescriptorAccessor + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.noStandardDescriptorAccessor = false + + /** + * MessageOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.deprecated = false + + /** + * MessageOptions mapEntry. + * @member {boolean} mapEntry + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.mapEntry = false + + /** + * MessageOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.uninterpretedOption = $util.emptyArray + + /** + * MessageOptions .google.api.resource. + * @member {google.api.IResourceDescriptor|null|undefined} .google.api.resource + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype['.google.api.resource'] = null + + /** + * Creates a new MessageOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.MessageOptions + * @static + * @param {google.protobuf.IMessageOptions=} [properties] Properties to set + * @returns {google.protobuf.MessageOptions} MessageOptions instance + */ + MessageOptions.create = function create(properties) { + return new MessageOptions(properties) + } + + /** + * Encodes the specified MessageOptions message. Does not implicitly {@link google.protobuf.MessageOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.MessageOptions + * @static + * @param {google.protobuf.IMessageOptions} message MessageOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MessageOptions.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.messageSetWireFormat != null && + Object.hasOwnProperty.call(message, 'messageSetWireFormat') + ) + writer + .uint32(/* id 1, wireType 0 =*/ 8) + .bool(message.messageSetWireFormat) + if ( + message.noStandardDescriptorAccessor != null && + Object.hasOwnProperty.call( + message, + 'noStandardDescriptorAccessor' + ) + ) + writer + .uint32(/* id 2, wireType 0 =*/ 16) + .bool(message.noStandardDescriptorAccessor) + if ( + message.deprecated != null && + Object.hasOwnProperty.call(message, 'deprecated') + ) + writer + .uint32(/* id 3, wireType 0 =*/ 24) + .bool(message.deprecated) + if ( + message.mapEntry != null && + Object.hasOwnProperty.call(message, 'mapEntry') + ) + writer + .uint32(/* id 7, wireType 0 =*/ 56) + .bool(message.mapEntry) + if ( + message.uninterpretedOption != null && + message.uninterpretedOption.length + ) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode( + message.uninterpretedOption[i], + writer.uint32(/* id 999, wireType 2 =*/ 7994).fork() + ).ldelim() + if ( + message['.google.api.resource'] != null && + Object.hasOwnProperty.call(message, '.google.api.resource') + ) + $root.google.api.ResourceDescriptor.encode( + message['.google.api.resource'], + writer.uint32(/* id 1053, wireType 2 =*/ 8426).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified MessageOptions message, length delimited. Does not implicitly {@link google.protobuf.MessageOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.MessageOptions + * @static + * @param {google.protobuf.IMessageOptions} message MessageOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MessageOptions.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a MessageOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.MessageOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.MessageOptions} MessageOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MessageOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.MessageOptions() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.messageSetWireFormat = reader.bool() + break + case 2: + message.noStandardDescriptorAccessor = reader.bool() + break + case 3: + message.deprecated = reader.bool() + break + case 7: + message.mapEntry = reader.bool() + break + case 999: + if ( + !( + message.uninterpretedOption && + message.uninterpretedOption.length + ) + ) + message.uninterpretedOption = [] + message.uninterpretedOption.push( + $root.google.protobuf.UninterpretedOption.decode( + reader, + reader.uint32() + ) + ) + break + case 1053: + message[ + '.google.api.resource' + ] = $root.google.api.ResourceDescriptor.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a MessageOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.MessageOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.MessageOptions} MessageOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MessageOptions.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a MessageOptions message. + * @function verify + * @memberof google.protobuf.MessageOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + MessageOptions.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.messageSetWireFormat != null && + message.hasOwnProperty('messageSetWireFormat') + ) + if (typeof message.messageSetWireFormat !== 'boolean') + return 'messageSetWireFormat: boolean expected' + if ( + message.noStandardDescriptorAccessor != null && + message.hasOwnProperty('noStandardDescriptorAccessor') + ) + if (typeof message.noStandardDescriptorAccessor !== 'boolean') + return 'noStandardDescriptorAccessor: boolean expected' + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + if (typeof message.deprecated !== 'boolean') + return 'deprecated: boolean expected' + if ( + message.mapEntry != null && + message.hasOwnProperty('mapEntry') + ) + if (typeof message.mapEntry !== 'boolean') + return 'mapEntry: boolean expected' + if ( + message.uninterpretedOption != null && + message.hasOwnProperty('uninterpretedOption') + ) { + if (!Array.isArray(message.uninterpretedOption)) + return 'uninterpretedOption: array expected' + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify( + message.uninterpretedOption[i] + ) + if (error) return 'uninterpretedOption.' + error + } + } + if ( + message['.google.api.resource'] != null && + message.hasOwnProperty('.google.api.resource') + ) { + var error = $root.google.api.ResourceDescriptor.verify( + message['.google.api.resource'] + ) + if (error) return '.google.api.resource.' + error + } + return null + } + + /** + * Creates a MessageOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.MessageOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.MessageOptions} MessageOptions + */ + MessageOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.MessageOptions) + return object + var message = new $root.google.protobuf.MessageOptions() + if (object.messageSetWireFormat != null) + message.messageSetWireFormat = Boolean( + object.messageSetWireFormat + ) + if (object.noStandardDescriptorAccessor != null) + message.noStandardDescriptorAccessor = Boolean( + object.noStandardDescriptorAccessor + ) + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated) + if (object.mapEntry != null) + message.mapEntry = Boolean(object.mapEntry) + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError( + '.google.protobuf.MessageOptions.uninterpretedOption: array expected' + ) + message.uninterpretedOption = [] + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== 'object') + throw TypeError( + '.google.protobuf.MessageOptions.uninterpretedOption: object expected' + ) + message.uninterpretedOption[ + i + ] = $root.google.protobuf.UninterpretedOption.fromObject( + object.uninterpretedOption[i] + ) + } + } + if (object['.google.api.resource'] != null) { + if (typeof object['.google.api.resource'] !== 'object') + throw TypeError( + '.google.protobuf.MessageOptions..google.api.resource: object expected' + ) + message[ + '.google.api.resource' + ] = $root.google.api.ResourceDescriptor.fromObject( + object['.google.api.resource'] + ) + } + return message + } + + /** + * Creates a plain object from a MessageOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.MessageOptions + * @static + * @param {google.protobuf.MessageOptions} message MessageOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MessageOptions.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) + object.uninterpretedOption = [] + if (options.defaults) { + object.messageSetWireFormat = false + object.noStandardDescriptorAccessor = false + object.deprecated = false + object.mapEntry = false + object['.google.api.resource'] = null + } + if ( + message.messageSetWireFormat != null && + message.hasOwnProperty('messageSetWireFormat') + ) + object.messageSetWireFormat = message.messageSetWireFormat + if ( + message.noStandardDescriptorAccessor != null && + message.hasOwnProperty('noStandardDescriptorAccessor') + ) + object.noStandardDescriptorAccessor = + message.noStandardDescriptorAccessor + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + object.deprecated = message.deprecated + if ( + message.mapEntry != null && + message.hasOwnProperty('mapEntry') + ) + object.mapEntry = message.mapEntry + if ( + message.uninterpretedOption && + message.uninterpretedOption.length + ) { + object.uninterpretedOption = [] + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[ + j + ] = $root.google.protobuf.UninterpretedOption.toObject( + message.uninterpretedOption[j], + options + ) + } + if ( + message['.google.api.resource'] != null && + message.hasOwnProperty('.google.api.resource') + ) + object[ + '.google.api.resource' + ] = $root.google.api.ResourceDescriptor.toObject( + message['.google.api.resource'], + options + ) + return object + } + + /** + * Converts this MessageOptions to JSON. + * @function toJSON + * @memberof google.protobuf.MessageOptions + * @instance + * @returns {Object.} JSON object + */ + MessageOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return MessageOptions + })() + + protobuf.FieldOptions = (function () { + /** + * Properties of a FieldOptions. + * @memberof google.protobuf + * @interface IFieldOptions + * @property {google.protobuf.FieldOptions.CType|null} [ctype] FieldOptions ctype + * @property {boolean|null} [packed] FieldOptions packed + * @property {google.protobuf.FieldOptions.JSType|null} [jstype] FieldOptions jstype + * @property {boolean|null} [lazy] FieldOptions lazy + * @property {boolean|null} [deprecated] FieldOptions deprecated + * @property {boolean|null} [weak] FieldOptions weak + * @property {Array.|null} [uninterpretedOption] FieldOptions uninterpretedOption + * @property {Array.|null} [".google.api.fieldBehavior"] FieldOptions .google.api.fieldBehavior + * @property {google.api.IResourceReference|null} [".google.api.resourceReference"] FieldOptions .google.api.resourceReference + */ + + /** + * Constructs a new FieldOptions. + * @memberof google.protobuf + * @classdesc Represents a FieldOptions. + * @implements IFieldOptions + * @constructor + * @param {google.protobuf.IFieldOptions=} [properties] Properties to set + */ + function FieldOptions(properties) { + this.uninterpretedOption = [] + this['.google.api.fieldBehavior'] = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * FieldOptions ctype. + * @member {google.protobuf.FieldOptions.CType} ctype + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.ctype = 0 + + /** + * FieldOptions packed. + * @member {boolean} packed + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.packed = false + + /** + * FieldOptions jstype. + * @member {google.protobuf.FieldOptions.JSType} jstype + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.jstype = 0 + + /** + * FieldOptions lazy. + * @member {boolean} lazy + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.lazy = false + + /** + * FieldOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.deprecated = false + + /** + * FieldOptions weak. + * @member {boolean} weak + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.weak = false + + /** + * FieldOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.uninterpretedOption = $util.emptyArray + + /** + * FieldOptions .google.api.fieldBehavior. + * @member {Array.} .google.api.fieldBehavior + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype['.google.api.fieldBehavior'] = + $util.emptyArray + + /** + * FieldOptions .google.api.resourceReference. + * @member {google.api.IResourceReference|null|undefined} .google.api.resourceReference + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype['.google.api.resourceReference'] = null + + /** + * Creates a new FieldOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.FieldOptions + * @static + * @param {google.protobuf.IFieldOptions=} [properties] Properties to set + * @returns {google.protobuf.FieldOptions} FieldOptions instance + */ + FieldOptions.create = function create(properties) { + return new FieldOptions(properties) + } + + /** + * Encodes the specified FieldOptions message. Does not implicitly {@link google.protobuf.FieldOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FieldOptions + * @static + * @param {google.protobuf.IFieldOptions} message FieldOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FieldOptions.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.ctype != null && + Object.hasOwnProperty.call(message, 'ctype') + ) + writer.uint32(/* id 1, wireType 0 =*/ 8).int32(message.ctype) + if ( + message.packed != null && + Object.hasOwnProperty.call(message, 'packed') + ) + writer.uint32(/* id 2, wireType 0 =*/ 16).bool(message.packed) + if ( + message.deprecated != null && + Object.hasOwnProperty.call(message, 'deprecated') + ) + writer + .uint32(/* id 3, wireType 0 =*/ 24) + .bool(message.deprecated) + if ( + message.lazy != null && + Object.hasOwnProperty.call(message, 'lazy') + ) + writer.uint32(/* id 5, wireType 0 =*/ 40).bool(message.lazy) + if ( + message.jstype != null && + Object.hasOwnProperty.call(message, 'jstype') + ) + writer + .uint32(/* id 6, wireType 0 =*/ 48) + .int32(message.jstype) + if ( + message.weak != null && + Object.hasOwnProperty.call(message, 'weak') + ) + writer.uint32(/* id 10, wireType 0 =*/ 80).bool(message.weak) + if ( + message.uninterpretedOption != null && + message.uninterpretedOption.length + ) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode( + message.uninterpretedOption[i], + writer.uint32(/* id 999, wireType 2 =*/ 7994).fork() + ).ldelim() + if ( + message['.google.api.fieldBehavior'] != null && + message['.google.api.fieldBehavior'].length + ) { + writer.uint32(/* id 1052, wireType 2 =*/ 8418).fork() + for ( + var i = 0; + i < message['.google.api.fieldBehavior'].length; + ++i + ) + writer.int32(message['.google.api.fieldBehavior'][i]) + writer.ldelim() + } + if ( + message['.google.api.resourceReference'] != null && + Object.hasOwnProperty.call( + message, + '.google.api.resourceReference' + ) + ) + $root.google.api.ResourceReference.encode( + message['.google.api.resourceReference'], + writer.uint32(/* id 1055, wireType 2 =*/ 8442).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified FieldOptions message, length delimited. Does not implicitly {@link google.protobuf.FieldOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FieldOptions + * @static + * @param {google.protobuf.IFieldOptions} message FieldOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FieldOptions.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a FieldOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FieldOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FieldOptions} FieldOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FieldOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.FieldOptions() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.ctype = reader.int32() + break + case 2: + message.packed = reader.bool() + break + case 6: + message.jstype = reader.int32() + break + case 5: + message.lazy = reader.bool() + break + case 3: + message.deprecated = reader.bool() + break + case 10: + message.weak = reader.bool() + break + case 999: + if ( + !( + message.uninterpretedOption && + message.uninterpretedOption.length + ) + ) + message.uninterpretedOption = [] + message.uninterpretedOption.push( + $root.google.protobuf.UninterpretedOption.decode( + reader, + reader.uint32() + ) + ) + break + case 1052: + if ( + !( + message['.google.api.fieldBehavior'] && + message['.google.api.fieldBehavior'].length + ) + ) + message['.google.api.fieldBehavior'] = [] + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos + while (reader.pos < end2) + message['.google.api.fieldBehavior'].push( + reader.int32() + ) + } else + message['.google.api.fieldBehavior'].push( + reader.int32() + ) + break + case 1055: + message[ + '.google.api.resourceReference' + ] = $root.google.api.ResourceReference.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a FieldOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FieldOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FieldOptions} FieldOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FieldOptions.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a FieldOptions message. + * @function verify + * @memberof google.protobuf.FieldOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FieldOptions.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.ctype != null && message.hasOwnProperty('ctype')) + switch (message.ctype) { + default: + return 'ctype: enum value expected' + case 0: + case 1: + case 2: + break + } + if (message.packed != null && message.hasOwnProperty('packed')) + if (typeof message.packed !== 'boolean') + return 'packed: boolean expected' + if (message.jstype != null && message.hasOwnProperty('jstype')) + switch (message.jstype) { + default: + return 'jstype: enum value expected' + case 0: + case 1: + case 2: + break + } + if (message.lazy != null && message.hasOwnProperty('lazy')) + if (typeof message.lazy !== 'boolean') + return 'lazy: boolean expected' + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + if (typeof message.deprecated !== 'boolean') + return 'deprecated: boolean expected' + if (message.weak != null && message.hasOwnProperty('weak')) + if (typeof message.weak !== 'boolean') + return 'weak: boolean expected' + if ( + message.uninterpretedOption != null && + message.hasOwnProperty('uninterpretedOption') + ) { + if (!Array.isArray(message.uninterpretedOption)) + return 'uninterpretedOption: array expected' + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify( + message.uninterpretedOption[i] + ) + if (error) return 'uninterpretedOption.' + error + } + } + if ( + message['.google.api.fieldBehavior'] != null && + message.hasOwnProperty('.google.api.fieldBehavior') + ) { + if (!Array.isArray(message['.google.api.fieldBehavior'])) + return '.google.api.fieldBehavior: array expected' + for ( + var i = 0; + i < message['.google.api.fieldBehavior'].length; + ++i + ) + switch (message['.google.api.fieldBehavior'][i]) { + default: + return '.google.api.fieldBehavior: enum value[] expected' + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + break + } + } + if ( + message['.google.api.resourceReference'] != null && + message.hasOwnProperty('.google.api.resourceReference') + ) { + var error = $root.google.api.ResourceReference.verify( + message['.google.api.resourceReference'] + ) + if (error) return '.google.api.resourceReference.' + error + } + return null + } + + /** + * Creates a FieldOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FieldOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FieldOptions} FieldOptions + */ + FieldOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FieldOptions) + return object + var message = new $root.google.protobuf.FieldOptions() + switch (object.ctype) { + case 'STRING': + case 0: + message.ctype = 0 + break + case 'CORD': + case 1: + message.ctype = 1 + break + case 'STRING_PIECE': + case 2: + message.ctype = 2 + break + } + if (object.packed != null) + message.packed = Boolean(object.packed) + switch (object.jstype) { + case 'JS_NORMAL': + case 0: + message.jstype = 0 + break + case 'JS_STRING': + case 1: + message.jstype = 1 + break + case 'JS_NUMBER': + case 2: + message.jstype = 2 + break + } + if (object.lazy != null) message.lazy = Boolean(object.lazy) + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated) + if (object.weak != null) message.weak = Boolean(object.weak) + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError( + '.google.protobuf.FieldOptions.uninterpretedOption: array expected' + ) + message.uninterpretedOption = [] + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== 'object') + throw TypeError( + '.google.protobuf.FieldOptions.uninterpretedOption: object expected' + ) + message.uninterpretedOption[ + i + ] = $root.google.protobuf.UninterpretedOption.fromObject( + object.uninterpretedOption[i] + ) + } + } + if (object['.google.api.fieldBehavior']) { + if (!Array.isArray(object['.google.api.fieldBehavior'])) + throw TypeError( + '.google.protobuf.FieldOptions..google.api.fieldBehavior: array expected' + ) + message['.google.api.fieldBehavior'] = [] + for ( + var i = 0; + i < object['.google.api.fieldBehavior'].length; + ++i + ) + switch (object['.google.api.fieldBehavior'][i]) { + default: + case 'FIELD_BEHAVIOR_UNSPECIFIED': + case 0: + message['.google.api.fieldBehavior'][i] = 0 + break + case 'OPTIONAL': + case 1: + message['.google.api.fieldBehavior'][i] = 1 + break + case 'REQUIRED': + case 2: + message['.google.api.fieldBehavior'][i] = 2 + break + case 'OUTPUT_ONLY': + case 3: + message['.google.api.fieldBehavior'][i] = 3 + break + case 'INPUT_ONLY': + case 4: + message['.google.api.fieldBehavior'][i] = 4 + break + case 'IMMUTABLE': + case 5: + message['.google.api.fieldBehavior'][i] = 5 + break + } + } + if (object['.google.api.resourceReference'] != null) { + if ( + typeof object['.google.api.resourceReference'] !== 'object' + ) + throw TypeError( + '.google.protobuf.FieldOptions..google.api.resourceReference: object expected' + ) + message[ + '.google.api.resourceReference' + ] = $root.google.api.ResourceReference.fromObject( + object['.google.api.resourceReference'] + ) + } + return message + } + + /** + * Creates a plain object from a FieldOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FieldOptions + * @static + * @param {google.protobuf.FieldOptions} message FieldOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FieldOptions.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) { + object.uninterpretedOption = [] + object['.google.api.fieldBehavior'] = [] + } + if (options.defaults) { + object.ctype = options.enums === String ? 'STRING' : 0 + object.packed = false + object.deprecated = false + object.lazy = false + object.jstype = options.enums === String ? 'JS_NORMAL' : 0 + object.weak = false + object['.google.api.resourceReference'] = null + } + if (message.ctype != null && message.hasOwnProperty('ctype')) + object.ctype = + options.enums === String + ? $root.google.protobuf.FieldOptions.CType[message.ctype] + : message.ctype + if (message.packed != null && message.hasOwnProperty('packed')) + object.packed = message.packed + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + object.deprecated = message.deprecated + if (message.lazy != null && message.hasOwnProperty('lazy')) + object.lazy = message.lazy + if (message.jstype != null && message.hasOwnProperty('jstype')) + object.jstype = + options.enums === String + ? $root.google.protobuf.FieldOptions.JSType[ + message.jstype + ] + : message.jstype + if (message.weak != null && message.hasOwnProperty('weak')) + object.weak = message.weak + if ( + message.uninterpretedOption && + message.uninterpretedOption.length + ) { + object.uninterpretedOption = [] + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[ + j + ] = $root.google.protobuf.UninterpretedOption.toObject( + message.uninterpretedOption[j], + options + ) + } + if ( + message['.google.api.fieldBehavior'] && + message['.google.api.fieldBehavior'].length + ) { + object['.google.api.fieldBehavior'] = [] + for ( + var j = 0; + j < message['.google.api.fieldBehavior'].length; + ++j + ) + object['.google.api.fieldBehavior'][j] = + options.enums === String + ? $root.google.api.FieldBehavior[ + message['.google.api.fieldBehavior'][j] + ] + : message['.google.api.fieldBehavior'][j] + } + if ( + message['.google.api.resourceReference'] != null && + message.hasOwnProperty('.google.api.resourceReference') + ) + object[ + '.google.api.resourceReference' + ] = $root.google.api.ResourceReference.toObject( + message['.google.api.resourceReference'], + options + ) + return object + } + + /** + * Converts this FieldOptions to JSON. + * @function toJSON + * @memberof google.protobuf.FieldOptions + * @instance + * @returns {Object.} JSON object + */ + FieldOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + /** + * CType enum. + * @name google.protobuf.FieldOptions.CType + * @enum {number} + * @property {number} STRING=0 STRING value + * @property {number} CORD=1 CORD value + * @property {number} STRING_PIECE=2 STRING_PIECE value + */ + FieldOptions.CType = (function () { + var valuesById = {}, + values = Object.create(valuesById) + values[(valuesById[0] = 'STRING')] = 0 + values[(valuesById[1] = 'CORD')] = 1 + values[(valuesById[2] = 'STRING_PIECE')] = 2 + return values + })() + + /** + * JSType enum. + * @name google.protobuf.FieldOptions.JSType + * @enum {number} + * @property {number} JS_NORMAL=0 JS_NORMAL value + * @property {number} JS_STRING=1 JS_STRING value + * @property {number} JS_NUMBER=2 JS_NUMBER value + */ + FieldOptions.JSType = (function () { + var valuesById = {}, + values = Object.create(valuesById) + values[(valuesById[0] = 'JS_NORMAL')] = 0 + values[(valuesById[1] = 'JS_STRING')] = 1 + values[(valuesById[2] = 'JS_NUMBER')] = 2 + return values + })() + + return FieldOptions + })() + + protobuf.OneofOptions = (function () { + /** + * Properties of an OneofOptions. + * @memberof google.protobuf + * @interface IOneofOptions + * @property {Array.|null} [uninterpretedOption] OneofOptions uninterpretedOption + */ + + /** + * Constructs a new OneofOptions. + * @memberof google.protobuf + * @classdesc Represents an OneofOptions. + * @implements IOneofOptions + * @constructor + * @param {google.protobuf.IOneofOptions=} [properties] Properties to set + */ + function OneofOptions(properties) { + this.uninterpretedOption = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * OneofOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.OneofOptions + * @instance + */ + OneofOptions.prototype.uninterpretedOption = $util.emptyArray + + /** + * Creates a new OneofOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.OneofOptions + * @static + * @param {google.protobuf.IOneofOptions=} [properties] Properties to set + * @returns {google.protobuf.OneofOptions} OneofOptions instance + */ + OneofOptions.create = function create(properties) { + return new OneofOptions(properties) + } + + /** + * Encodes the specified OneofOptions message. Does not implicitly {@link google.protobuf.OneofOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.OneofOptions + * @static + * @param {google.protobuf.IOneofOptions} message OneofOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OneofOptions.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.uninterpretedOption != null && + message.uninterpretedOption.length + ) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode( + message.uninterpretedOption[i], + writer.uint32(/* id 999, wireType 2 =*/ 7994).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified OneofOptions message, length delimited. Does not implicitly {@link google.protobuf.OneofOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.OneofOptions + * @static + * @param {google.protobuf.IOneofOptions} message OneofOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OneofOptions.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an OneofOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.OneofOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.OneofOptions} OneofOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OneofOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.OneofOptions() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 999: + if ( + !( + message.uninterpretedOption && + message.uninterpretedOption.length + ) + ) + message.uninterpretedOption = [] + message.uninterpretedOption.push( + $root.google.protobuf.UninterpretedOption.decode( + reader, + reader.uint32() + ) + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an OneofOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.OneofOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.OneofOptions} OneofOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OneofOptions.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an OneofOptions message. + * @function verify + * @memberof google.protobuf.OneofOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + OneofOptions.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.uninterpretedOption != null && + message.hasOwnProperty('uninterpretedOption') + ) { + if (!Array.isArray(message.uninterpretedOption)) + return 'uninterpretedOption: array expected' + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify( + message.uninterpretedOption[i] + ) + if (error) return 'uninterpretedOption.' + error + } + } + return null + } + + /** + * Creates an OneofOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.OneofOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.OneofOptions} OneofOptions + */ + OneofOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.OneofOptions) + return object + var message = new $root.google.protobuf.OneofOptions() + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError( + '.google.protobuf.OneofOptions.uninterpretedOption: array expected' + ) + message.uninterpretedOption = [] + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== 'object') + throw TypeError( + '.google.protobuf.OneofOptions.uninterpretedOption: object expected' + ) + message.uninterpretedOption[ + i + ] = $root.google.protobuf.UninterpretedOption.fromObject( + object.uninterpretedOption[i] + ) + } + } + return message + } + + /** + * Creates a plain object from an OneofOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.OneofOptions + * @static + * @param {google.protobuf.OneofOptions} message OneofOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + OneofOptions.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) + object.uninterpretedOption = [] + if ( + message.uninterpretedOption && + message.uninterpretedOption.length + ) { + object.uninterpretedOption = [] + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[ + j + ] = $root.google.protobuf.UninterpretedOption.toObject( + message.uninterpretedOption[j], + options + ) + } + return object + } + + /** + * Converts this OneofOptions to JSON. + * @function toJSON + * @memberof google.protobuf.OneofOptions + * @instance + * @returns {Object.} JSON object + */ + OneofOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return OneofOptions + })() + + protobuf.EnumOptions = (function () { + /** + * Properties of an EnumOptions. + * @memberof google.protobuf + * @interface IEnumOptions + * @property {boolean|null} [allowAlias] EnumOptions allowAlias + * @property {boolean|null} [deprecated] EnumOptions deprecated + * @property {Array.|null} [uninterpretedOption] EnumOptions uninterpretedOption + */ + + /** + * Constructs a new EnumOptions. + * @memberof google.protobuf + * @classdesc Represents an EnumOptions. + * @implements IEnumOptions + * @constructor + * @param {google.protobuf.IEnumOptions=} [properties] Properties to set + */ + function EnumOptions(properties) { + this.uninterpretedOption = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * EnumOptions allowAlias. + * @member {boolean} allowAlias + * @memberof google.protobuf.EnumOptions + * @instance + */ + EnumOptions.prototype.allowAlias = false + + /** + * EnumOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.EnumOptions + * @instance + */ + EnumOptions.prototype.deprecated = false + + /** + * EnumOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.EnumOptions + * @instance + */ + EnumOptions.prototype.uninterpretedOption = $util.emptyArray + + /** + * Creates a new EnumOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.EnumOptions + * @static + * @param {google.protobuf.IEnumOptions=} [properties] Properties to set + * @returns {google.protobuf.EnumOptions} EnumOptions instance + */ + EnumOptions.create = function create(properties) { + return new EnumOptions(properties) + } + + /** + * Encodes the specified EnumOptions message. Does not implicitly {@link google.protobuf.EnumOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.EnumOptions + * @static + * @param {google.protobuf.IEnumOptions} message EnumOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumOptions.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.allowAlias != null && + Object.hasOwnProperty.call(message, 'allowAlias') + ) + writer + .uint32(/* id 2, wireType 0 =*/ 16) + .bool(message.allowAlias) + if ( + message.deprecated != null && + Object.hasOwnProperty.call(message, 'deprecated') + ) + writer + .uint32(/* id 3, wireType 0 =*/ 24) + .bool(message.deprecated) + if ( + message.uninterpretedOption != null && + message.uninterpretedOption.length + ) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode( + message.uninterpretedOption[i], + writer.uint32(/* id 999, wireType 2 =*/ 7994).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified EnumOptions message, length delimited. Does not implicitly {@link google.protobuf.EnumOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.EnumOptions + * @static + * @param {google.protobuf.IEnumOptions} message EnumOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumOptions.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an EnumOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.EnumOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.EnumOptions} EnumOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.EnumOptions() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 2: + message.allowAlias = reader.bool() + break + case 3: + message.deprecated = reader.bool() + break + case 999: + if ( + !( + message.uninterpretedOption && + message.uninterpretedOption.length + ) + ) + message.uninterpretedOption = [] + message.uninterpretedOption.push( + $root.google.protobuf.UninterpretedOption.decode( + reader, + reader.uint32() + ) + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an EnumOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.EnumOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.EnumOptions} EnumOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumOptions.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an EnumOptions message. + * @function verify + * @memberof google.protobuf.EnumOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + EnumOptions.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.allowAlias != null && + message.hasOwnProperty('allowAlias') + ) + if (typeof message.allowAlias !== 'boolean') + return 'allowAlias: boolean expected' + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + if (typeof message.deprecated !== 'boolean') + return 'deprecated: boolean expected' + if ( + message.uninterpretedOption != null && + message.hasOwnProperty('uninterpretedOption') + ) { + if (!Array.isArray(message.uninterpretedOption)) + return 'uninterpretedOption: array expected' + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify( + message.uninterpretedOption[i] + ) + if (error) return 'uninterpretedOption.' + error + } + } + return null + } + + /** + * Creates an EnumOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.EnumOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.EnumOptions} EnumOptions + */ + EnumOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.EnumOptions) + return object + var message = new $root.google.protobuf.EnumOptions() + if (object.allowAlias != null) + message.allowAlias = Boolean(object.allowAlias) + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated) + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError( + '.google.protobuf.EnumOptions.uninterpretedOption: array expected' + ) + message.uninterpretedOption = [] + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== 'object') + throw TypeError( + '.google.protobuf.EnumOptions.uninterpretedOption: object expected' + ) + message.uninterpretedOption[ + i + ] = $root.google.protobuf.UninterpretedOption.fromObject( + object.uninterpretedOption[i] + ) + } + } + return message + } + + /** + * Creates a plain object from an EnumOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.EnumOptions + * @static + * @param {google.protobuf.EnumOptions} message EnumOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EnumOptions.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) + object.uninterpretedOption = [] + if (options.defaults) { + object.allowAlias = false + object.deprecated = false + } + if ( + message.allowAlias != null && + message.hasOwnProperty('allowAlias') + ) + object.allowAlias = message.allowAlias + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + object.deprecated = message.deprecated + if ( + message.uninterpretedOption && + message.uninterpretedOption.length + ) { + object.uninterpretedOption = [] + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[ + j + ] = $root.google.protobuf.UninterpretedOption.toObject( + message.uninterpretedOption[j], + options + ) + } + return object + } + + /** + * Converts this EnumOptions to JSON. + * @function toJSON + * @memberof google.protobuf.EnumOptions + * @instance + * @returns {Object.} JSON object + */ + EnumOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return EnumOptions + })() + + protobuf.EnumValueOptions = (function () { + /** + * Properties of an EnumValueOptions. + * @memberof google.protobuf + * @interface IEnumValueOptions + * @property {boolean|null} [deprecated] EnumValueOptions deprecated + * @property {Array.|null} [uninterpretedOption] EnumValueOptions uninterpretedOption + */ + + /** + * Constructs a new EnumValueOptions. + * @memberof google.protobuf + * @classdesc Represents an EnumValueOptions. + * @implements IEnumValueOptions + * @constructor + * @param {google.protobuf.IEnumValueOptions=} [properties] Properties to set + */ + function EnumValueOptions(properties) { + this.uninterpretedOption = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * EnumValueOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.EnumValueOptions + * @instance + */ + EnumValueOptions.prototype.deprecated = false + + /** + * EnumValueOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.EnumValueOptions + * @instance + */ + EnumValueOptions.prototype.uninterpretedOption = $util.emptyArray + + /** + * Creates a new EnumValueOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {google.protobuf.IEnumValueOptions=} [properties] Properties to set + * @returns {google.protobuf.EnumValueOptions} EnumValueOptions instance + */ + EnumValueOptions.create = function create(properties) { + return new EnumValueOptions(properties) + } + + /** + * Encodes the specified EnumValueOptions message. Does not implicitly {@link google.protobuf.EnumValueOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {google.protobuf.IEnumValueOptions} message EnumValueOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumValueOptions.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.deprecated != null && + Object.hasOwnProperty.call(message, 'deprecated') + ) + writer + .uint32(/* id 1, wireType 0 =*/ 8) + .bool(message.deprecated) + if ( + message.uninterpretedOption != null && + message.uninterpretedOption.length + ) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode( + message.uninterpretedOption[i], + writer.uint32(/* id 999, wireType 2 =*/ 7994).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified EnumValueOptions message, length delimited. Does not implicitly {@link google.protobuf.EnumValueOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {google.protobuf.IEnumValueOptions} message EnumValueOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumValueOptions.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an EnumValueOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.EnumValueOptions} EnumValueOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumValueOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.EnumValueOptions() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.deprecated = reader.bool() + break + case 999: + if ( + !( + message.uninterpretedOption && + message.uninterpretedOption.length + ) + ) + message.uninterpretedOption = [] + message.uninterpretedOption.push( + $root.google.protobuf.UninterpretedOption.decode( + reader, + reader.uint32() + ) + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an EnumValueOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.EnumValueOptions} EnumValueOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumValueOptions.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an EnumValueOptions message. + * @function verify + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + EnumValueOptions.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + if (typeof message.deprecated !== 'boolean') + return 'deprecated: boolean expected' + if ( + message.uninterpretedOption != null && + message.hasOwnProperty('uninterpretedOption') + ) { + if (!Array.isArray(message.uninterpretedOption)) + return 'uninterpretedOption: array expected' + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify( + message.uninterpretedOption[i] + ) + if (error) return 'uninterpretedOption.' + error + } + } + return null + } + + /** + * Creates an EnumValueOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.EnumValueOptions} EnumValueOptions + */ + EnumValueOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.EnumValueOptions) + return object + var message = new $root.google.protobuf.EnumValueOptions() + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated) + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError( + '.google.protobuf.EnumValueOptions.uninterpretedOption: array expected' + ) + message.uninterpretedOption = [] + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== 'object') + throw TypeError( + '.google.protobuf.EnumValueOptions.uninterpretedOption: object expected' + ) + message.uninterpretedOption[ + i + ] = $root.google.protobuf.UninterpretedOption.fromObject( + object.uninterpretedOption[i] + ) + } + } + return message + } + + /** + * Creates a plain object from an EnumValueOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {google.protobuf.EnumValueOptions} message EnumValueOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EnumValueOptions.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) + object.uninterpretedOption = [] + if (options.defaults) object.deprecated = false + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + object.deprecated = message.deprecated + if ( + message.uninterpretedOption && + message.uninterpretedOption.length + ) { + object.uninterpretedOption = [] + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[ + j + ] = $root.google.protobuf.UninterpretedOption.toObject( + message.uninterpretedOption[j], + options + ) + } + return object + } + + /** + * Converts this EnumValueOptions to JSON. + * @function toJSON + * @memberof google.protobuf.EnumValueOptions + * @instance + * @returns {Object.} JSON object + */ + EnumValueOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return EnumValueOptions + })() + + protobuf.ServiceOptions = (function () { + /** + * Properties of a ServiceOptions. + * @memberof google.protobuf + * @interface IServiceOptions + * @property {boolean|null} [deprecated] ServiceOptions deprecated + * @property {Array.|null} [uninterpretedOption] ServiceOptions uninterpretedOption + * @property {string|null} [".google.api.defaultHost"] ServiceOptions .google.api.defaultHost + * @property {string|null} [".google.api.oauthScopes"] ServiceOptions .google.api.oauthScopes + */ + + /** + * Constructs a new ServiceOptions. + * @memberof google.protobuf + * @classdesc Represents a ServiceOptions. + * @implements IServiceOptions + * @constructor + * @param {google.protobuf.IServiceOptions=} [properties] Properties to set + */ + function ServiceOptions(properties) { + this.uninterpretedOption = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * ServiceOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.ServiceOptions + * @instance + */ + ServiceOptions.prototype.deprecated = false + + /** + * ServiceOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.ServiceOptions + * @instance + */ + ServiceOptions.prototype.uninterpretedOption = $util.emptyArray + + /** + * ServiceOptions .google.api.defaultHost. + * @member {string} .google.api.defaultHost + * @memberof google.protobuf.ServiceOptions + * @instance + */ + ServiceOptions.prototype['.google.api.defaultHost'] = '' + + /** + * ServiceOptions .google.api.oauthScopes. + * @member {string} .google.api.oauthScopes + * @memberof google.protobuf.ServiceOptions + * @instance + */ + ServiceOptions.prototype['.google.api.oauthScopes'] = '' + + /** + * Creates a new ServiceOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.ServiceOptions + * @static + * @param {google.protobuf.IServiceOptions=} [properties] Properties to set + * @returns {google.protobuf.ServiceOptions} ServiceOptions instance + */ + ServiceOptions.create = function create(properties) { + return new ServiceOptions(properties) + } + + /** + * Encodes the specified ServiceOptions message. Does not implicitly {@link google.protobuf.ServiceOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.ServiceOptions + * @static + * @param {google.protobuf.IServiceOptions} message ServiceOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ServiceOptions.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.deprecated != null && + Object.hasOwnProperty.call(message, 'deprecated') + ) + writer + .uint32(/* id 33, wireType 0 =*/ 264) + .bool(message.deprecated) + if ( + message.uninterpretedOption != null && + message.uninterpretedOption.length + ) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode( + message.uninterpretedOption[i], + writer.uint32(/* id 999, wireType 2 =*/ 7994).fork() + ).ldelim() + if ( + message['.google.api.defaultHost'] != null && + Object.hasOwnProperty.call(message, '.google.api.defaultHost') + ) + writer + .uint32(/* id 1049, wireType 2 =*/ 8394) + .string(message['.google.api.defaultHost']) + if ( + message['.google.api.oauthScopes'] != null && + Object.hasOwnProperty.call(message, '.google.api.oauthScopes') + ) + writer + .uint32(/* id 1050, wireType 2 =*/ 8402) + .string(message['.google.api.oauthScopes']) + return writer + } + + /** + * Encodes the specified ServiceOptions message, length delimited. Does not implicitly {@link google.protobuf.ServiceOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.ServiceOptions + * @static + * @param {google.protobuf.IServiceOptions} message ServiceOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ServiceOptions.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a ServiceOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.ServiceOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.ServiceOptions} ServiceOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ServiceOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.ServiceOptions() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool() + break + case 999: + if ( + !( + message.uninterpretedOption && + message.uninterpretedOption.length + ) + ) + message.uninterpretedOption = [] + message.uninterpretedOption.push( + $root.google.protobuf.UninterpretedOption.decode( + reader, + reader.uint32() + ) + ) + break + case 1049: + message['.google.api.defaultHost'] = reader.string() + break + case 1050: + message['.google.api.oauthScopes'] = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a ServiceOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.ServiceOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.ServiceOptions} ServiceOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ServiceOptions.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a ServiceOptions message. + * @function verify + * @memberof google.protobuf.ServiceOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ServiceOptions.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + if (typeof message.deprecated !== 'boolean') + return 'deprecated: boolean expected' + if ( + message.uninterpretedOption != null && + message.hasOwnProperty('uninterpretedOption') + ) { + if (!Array.isArray(message.uninterpretedOption)) + return 'uninterpretedOption: array expected' + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify( + message.uninterpretedOption[i] + ) + if (error) return 'uninterpretedOption.' + error + } + } + if ( + message['.google.api.defaultHost'] != null && + message.hasOwnProperty('.google.api.defaultHost') + ) + if (!$util.isString(message['.google.api.defaultHost'])) + return '.google.api.defaultHost: string expected' + if ( + message['.google.api.oauthScopes'] != null && + message.hasOwnProperty('.google.api.oauthScopes') + ) + if (!$util.isString(message['.google.api.oauthScopes'])) + return '.google.api.oauthScopes: string expected' + return null + } + + /** + * Creates a ServiceOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.ServiceOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.ServiceOptions} ServiceOptions + */ + ServiceOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.ServiceOptions) + return object + var message = new $root.google.protobuf.ServiceOptions() + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated) + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError( + '.google.protobuf.ServiceOptions.uninterpretedOption: array expected' + ) + message.uninterpretedOption = [] + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== 'object') + throw TypeError( + '.google.protobuf.ServiceOptions.uninterpretedOption: object expected' + ) + message.uninterpretedOption[ + i + ] = $root.google.protobuf.UninterpretedOption.fromObject( + object.uninterpretedOption[i] + ) + } + } + if (object['.google.api.defaultHost'] != null) + message['.google.api.defaultHost'] = String( + object['.google.api.defaultHost'] + ) + if (object['.google.api.oauthScopes'] != null) + message['.google.api.oauthScopes'] = String( + object['.google.api.oauthScopes'] + ) + return message + } + + /** + * Creates a plain object from a ServiceOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.ServiceOptions + * @static + * @param {google.protobuf.ServiceOptions} message ServiceOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ServiceOptions.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) + object.uninterpretedOption = [] + if (options.defaults) { + object.deprecated = false + object['.google.api.defaultHost'] = '' + object['.google.api.oauthScopes'] = '' + } + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + object.deprecated = message.deprecated + if ( + message.uninterpretedOption && + message.uninterpretedOption.length + ) { + object.uninterpretedOption = [] + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[ + j + ] = $root.google.protobuf.UninterpretedOption.toObject( + message.uninterpretedOption[j], + options + ) + } + if ( + message['.google.api.defaultHost'] != null && + message.hasOwnProperty('.google.api.defaultHost') + ) + object['.google.api.defaultHost'] = + message['.google.api.defaultHost'] + if ( + message['.google.api.oauthScopes'] != null && + message.hasOwnProperty('.google.api.oauthScopes') + ) + object['.google.api.oauthScopes'] = + message['.google.api.oauthScopes'] + return object + } + + /** + * Converts this ServiceOptions to JSON. + * @function toJSON + * @memberof google.protobuf.ServiceOptions + * @instance + * @returns {Object.} JSON object + */ + ServiceOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return ServiceOptions + })() + + protobuf.MethodOptions = (function () { + /** + * Properties of a MethodOptions. + * @memberof google.protobuf + * @interface IMethodOptions + * @property {boolean|null} [deprecated] MethodOptions deprecated + * @property {google.protobuf.MethodOptions.IdempotencyLevel|null} [idempotencyLevel] MethodOptions idempotencyLevel + * @property {Array.|null} [uninterpretedOption] MethodOptions uninterpretedOption + * @property {google.api.IHttpRule|null} [".google.api.http"] MethodOptions .google.api.http + * @property {Array.|null} [".google.api.methodSignature"] MethodOptions .google.api.methodSignature + */ + + /** + * Constructs a new MethodOptions. + * @memberof google.protobuf + * @classdesc Represents a MethodOptions. + * @implements IMethodOptions + * @constructor + * @param {google.protobuf.IMethodOptions=} [properties] Properties to set + */ + function MethodOptions(properties) { + this.uninterpretedOption = [] + this['.google.api.methodSignature'] = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * MethodOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype.deprecated = false + + /** + * MethodOptions idempotencyLevel. + * @member {google.protobuf.MethodOptions.IdempotencyLevel} idempotencyLevel + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype.idempotencyLevel = 0 + + /** + * MethodOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype.uninterpretedOption = $util.emptyArray + + /** + * MethodOptions .google.api.http. + * @member {google.api.IHttpRule|null|undefined} .google.api.http + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype['.google.api.http'] = null + + /** + * MethodOptions .google.api.methodSignature. + * @member {Array.} .google.api.methodSignature + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype['.google.api.methodSignature'] = + $util.emptyArray + + /** + * Creates a new MethodOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.MethodOptions + * @static + * @param {google.protobuf.IMethodOptions=} [properties] Properties to set + * @returns {google.protobuf.MethodOptions} MethodOptions instance + */ + MethodOptions.create = function create(properties) { + return new MethodOptions(properties) + } + + /** + * Encodes the specified MethodOptions message. Does not implicitly {@link google.protobuf.MethodOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.MethodOptions + * @static + * @param {google.protobuf.IMethodOptions} message MethodOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MethodOptions.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.deprecated != null && + Object.hasOwnProperty.call(message, 'deprecated') + ) + writer + .uint32(/* id 33, wireType 0 =*/ 264) + .bool(message.deprecated) + if ( + message.idempotencyLevel != null && + Object.hasOwnProperty.call(message, 'idempotencyLevel') + ) + writer + .uint32(/* id 34, wireType 0 =*/ 272) + .int32(message.idempotencyLevel) + if ( + message.uninterpretedOption != null && + message.uninterpretedOption.length + ) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode( + message.uninterpretedOption[i], + writer.uint32(/* id 999, wireType 2 =*/ 7994).fork() + ).ldelim() + if ( + message['.google.api.methodSignature'] != null && + message['.google.api.methodSignature'].length + ) + for ( + var i = 0; + i < message['.google.api.methodSignature'].length; + ++i + ) + writer + .uint32(/* id 1051, wireType 2 =*/ 8410) + .string(message['.google.api.methodSignature'][i]) + if ( + message['.google.api.http'] != null && + Object.hasOwnProperty.call(message, '.google.api.http') + ) + $root.google.api.HttpRule.encode( + message['.google.api.http'], + writer + .uint32(/* id 72295728, wireType 2 =*/ 578365826) + .fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified MethodOptions message, length delimited. Does not implicitly {@link google.protobuf.MethodOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.MethodOptions + * @static + * @param {google.protobuf.IMethodOptions} message MethodOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MethodOptions.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a MethodOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.MethodOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.MethodOptions} MethodOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MethodOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.MethodOptions() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool() + break + case 34: + message.idempotencyLevel = reader.int32() + break + case 999: + if ( + !( + message.uninterpretedOption && + message.uninterpretedOption.length + ) + ) + message.uninterpretedOption = [] + message.uninterpretedOption.push( + $root.google.protobuf.UninterpretedOption.decode( + reader, + reader.uint32() + ) + ) + break + case 72295728: + message[ + '.google.api.http' + ] = $root.google.api.HttpRule.decode( + reader, + reader.uint32() + ) + break + case 1051: + if ( + !( + message['.google.api.methodSignature'] && + message['.google.api.methodSignature'].length + ) + ) + message['.google.api.methodSignature'] = [] + message['.google.api.methodSignature'].push( + reader.string() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a MethodOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.MethodOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.MethodOptions} MethodOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MethodOptions.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a MethodOptions message. + * @function verify + * @memberof google.protobuf.MethodOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + MethodOptions.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + if (typeof message.deprecated !== 'boolean') + return 'deprecated: boolean expected' + if ( + message.idempotencyLevel != null && + message.hasOwnProperty('idempotencyLevel') + ) + switch (message.idempotencyLevel) { + default: + return 'idempotencyLevel: enum value expected' + case 0: + case 1: + case 2: + break + } + if ( + message.uninterpretedOption != null && + message.hasOwnProperty('uninterpretedOption') + ) { + if (!Array.isArray(message.uninterpretedOption)) + return 'uninterpretedOption: array expected' + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify( + message.uninterpretedOption[i] + ) + if (error) return 'uninterpretedOption.' + error + } + } + if ( + message['.google.api.http'] != null && + message.hasOwnProperty('.google.api.http') + ) { + var error = $root.google.api.HttpRule.verify( + message['.google.api.http'] + ) + if (error) return '.google.api.http.' + error + } + if ( + message['.google.api.methodSignature'] != null && + message.hasOwnProperty('.google.api.methodSignature') + ) { + if (!Array.isArray(message['.google.api.methodSignature'])) + return '.google.api.methodSignature: array expected' + for ( + var i = 0; + i < message['.google.api.methodSignature'].length; + ++i + ) + if ( + !$util.isString(message['.google.api.methodSignature'][i]) + ) + return '.google.api.methodSignature: string[] expected' + } + return null + } + + /** + * Creates a MethodOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.MethodOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.MethodOptions} MethodOptions + */ + MethodOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.MethodOptions) + return object + var message = new $root.google.protobuf.MethodOptions() + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated) + switch (object.idempotencyLevel) { + case 'IDEMPOTENCY_UNKNOWN': + case 0: + message.idempotencyLevel = 0 + break + case 'NO_SIDE_EFFECTS': + case 1: + message.idempotencyLevel = 1 + break + case 'IDEMPOTENT': + case 2: + message.idempotencyLevel = 2 + break + } + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError( + '.google.protobuf.MethodOptions.uninterpretedOption: array expected' + ) + message.uninterpretedOption = [] + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== 'object') + throw TypeError( + '.google.protobuf.MethodOptions.uninterpretedOption: object expected' + ) + message.uninterpretedOption[ + i + ] = $root.google.protobuf.UninterpretedOption.fromObject( + object.uninterpretedOption[i] + ) + } + } + if (object['.google.api.http'] != null) { + if (typeof object['.google.api.http'] !== 'object') + throw TypeError( + '.google.protobuf.MethodOptions..google.api.http: object expected' + ) + message[ + '.google.api.http' + ] = $root.google.api.HttpRule.fromObject( + object['.google.api.http'] + ) + } + if (object['.google.api.methodSignature']) { + if (!Array.isArray(object['.google.api.methodSignature'])) + throw TypeError( + '.google.protobuf.MethodOptions..google.api.methodSignature: array expected' + ) + message['.google.api.methodSignature'] = [] + for ( + var i = 0; + i < object['.google.api.methodSignature'].length; + ++i + ) + message['.google.api.methodSignature'][i] = String( + object['.google.api.methodSignature'][i] + ) + } + return message + } + + /** + * Creates a plain object from a MethodOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.MethodOptions + * @static + * @param {google.protobuf.MethodOptions} message MethodOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MethodOptions.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) { + object.uninterpretedOption = [] + object['.google.api.methodSignature'] = [] + } + if (options.defaults) { + object.deprecated = false + object.idempotencyLevel = + options.enums === String ? 'IDEMPOTENCY_UNKNOWN' : 0 + object['.google.api.http'] = null + } + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + object.deprecated = message.deprecated + if ( + message.idempotencyLevel != null && + message.hasOwnProperty('idempotencyLevel') + ) + object.idempotencyLevel = + options.enums === String + ? $root.google.protobuf.MethodOptions.IdempotencyLevel[ + message.idempotencyLevel + ] + : message.idempotencyLevel + if ( + message.uninterpretedOption && + message.uninterpretedOption.length + ) { + object.uninterpretedOption = [] + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[ + j + ] = $root.google.protobuf.UninterpretedOption.toObject( + message.uninterpretedOption[j], + options + ) + } + if ( + message['.google.api.methodSignature'] && + message['.google.api.methodSignature'].length + ) { + object['.google.api.methodSignature'] = [] + for ( + var j = 0; + j < message['.google.api.methodSignature'].length; + ++j + ) + object['.google.api.methodSignature'][j] = + message['.google.api.methodSignature'][j] + } + if ( + message['.google.api.http'] != null && + message.hasOwnProperty('.google.api.http') + ) + object[ + '.google.api.http' + ] = $root.google.api.HttpRule.toObject( + message['.google.api.http'], + options + ) + return object + } + + /** + * Converts this MethodOptions to JSON. + * @function toJSON + * @memberof google.protobuf.MethodOptions + * @instance + * @returns {Object.} JSON object + */ + MethodOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + /** + * IdempotencyLevel enum. + * @name google.protobuf.MethodOptions.IdempotencyLevel + * @enum {number} + * @property {number} IDEMPOTENCY_UNKNOWN=0 IDEMPOTENCY_UNKNOWN value + * @property {number} NO_SIDE_EFFECTS=1 NO_SIDE_EFFECTS value + * @property {number} IDEMPOTENT=2 IDEMPOTENT value + */ + MethodOptions.IdempotencyLevel = (function () { + var valuesById = {}, + values = Object.create(valuesById) + values[(valuesById[0] = 'IDEMPOTENCY_UNKNOWN')] = 0 + values[(valuesById[1] = 'NO_SIDE_EFFECTS')] = 1 + values[(valuesById[2] = 'IDEMPOTENT')] = 2 + return values + })() + + return MethodOptions + })() + + protobuf.UninterpretedOption = (function () { + /** + * Properties of an UninterpretedOption. + * @memberof google.protobuf + * @interface IUninterpretedOption + * @property {Array.|null} [name] UninterpretedOption name + * @property {string|null} [identifierValue] UninterpretedOption identifierValue + * @property {number|Long|null} [positiveIntValue] UninterpretedOption positiveIntValue + * @property {number|Long|null} [negativeIntValue] UninterpretedOption negativeIntValue + * @property {number|null} [doubleValue] UninterpretedOption doubleValue + * @property {Uint8Array|null} [stringValue] UninterpretedOption stringValue + * @property {string|null} [aggregateValue] UninterpretedOption aggregateValue + */ + + /** + * Constructs a new UninterpretedOption. + * @memberof google.protobuf + * @classdesc Represents an UninterpretedOption. + * @implements IUninterpretedOption + * @constructor + * @param {google.protobuf.IUninterpretedOption=} [properties] Properties to set + */ + function UninterpretedOption(properties) { + this.name = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * UninterpretedOption name. + * @member {Array.} name + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.name = $util.emptyArray + + /** + * UninterpretedOption identifierValue. + * @member {string} identifierValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.identifierValue = '' + + /** + * UninterpretedOption positiveIntValue. + * @member {number|Long} positiveIntValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.positiveIntValue = $util.Long + ? $util.Long.fromBits(0, 0, true) + : 0 + + /** + * UninterpretedOption negativeIntValue. + * @member {number|Long} negativeIntValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.negativeIntValue = $util.Long + ? $util.Long.fromBits(0, 0, false) + : 0 + + /** + * UninterpretedOption doubleValue. + * @member {number} doubleValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.doubleValue = 0 + + /** + * UninterpretedOption stringValue. + * @member {Uint8Array} stringValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.stringValue = $util.newBuffer([]) + + /** + * UninterpretedOption aggregateValue. + * @member {string} aggregateValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.aggregateValue = '' + + /** + * Creates a new UninterpretedOption instance using the specified properties. + * @function create + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {google.protobuf.IUninterpretedOption=} [properties] Properties to set + * @returns {google.protobuf.UninterpretedOption} UninterpretedOption instance + */ + UninterpretedOption.create = function create(properties) { + return new UninterpretedOption(properties) + } + + /** + * Encodes the specified UninterpretedOption message. Does not implicitly {@link google.protobuf.UninterpretedOption.verify|verify} messages. + * @function encode + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {google.protobuf.IUninterpretedOption} message UninterpretedOption message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UninterpretedOption.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.name != null && message.name.length) + for (var i = 0; i < message.name.length; ++i) + $root.google.protobuf.UninterpretedOption.NamePart.encode( + message.name[i], + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + ).ldelim() + if ( + message.identifierValue != null && + Object.hasOwnProperty.call(message, 'identifierValue') + ) + writer + .uint32(/* id 3, wireType 2 =*/ 26) + .string(message.identifierValue) + if ( + message.positiveIntValue != null && + Object.hasOwnProperty.call(message, 'positiveIntValue') + ) + writer + .uint32(/* id 4, wireType 0 =*/ 32) + .uint64(message.positiveIntValue) + if ( + message.negativeIntValue != null && + Object.hasOwnProperty.call(message, 'negativeIntValue') + ) + writer + .uint32(/* id 5, wireType 0 =*/ 40) + .int64(message.negativeIntValue) + if ( + message.doubleValue != null && + Object.hasOwnProperty.call(message, 'doubleValue') + ) + writer + .uint32(/* id 6, wireType 1 =*/ 49) + .double(message.doubleValue) + if ( + message.stringValue != null && + Object.hasOwnProperty.call(message, 'stringValue') + ) + writer + .uint32(/* id 7, wireType 2 =*/ 58) + .bytes(message.stringValue) + if ( + message.aggregateValue != null && + Object.hasOwnProperty.call(message, 'aggregateValue') + ) + writer + .uint32(/* id 8, wireType 2 =*/ 66) + .string(message.aggregateValue) + return writer + } + + /** + * Encodes the specified UninterpretedOption message, length delimited. Does not implicitly {@link google.protobuf.UninterpretedOption.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {google.protobuf.IUninterpretedOption} message UninterpretedOption message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UninterpretedOption.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an UninterpretedOption message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.UninterpretedOption} UninterpretedOption + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UninterpretedOption.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.UninterpretedOption() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 2: + if (!(message.name && message.name.length)) + message.name = [] + message.name.push( + $root.google.protobuf.UninterpretedOption.NamePart.decode( + reader, + reader.uint32() + ) + ) + break + case 3: + message.identifierValue = reader.string() + break + case 4: + message.positiveIntValue = reader.uint64() + break + case 5: + message.negativeIntValue = reader.int64() + break + case 6: + message.doubleValue = reader.double() + break + case 7: + message.stringValue = reader.bytes() + break + case 8: + message.aggregateValue = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an UninterpretedOption message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.UninterpretedOption} UninterpretedOption + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UninterpretedOption.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an UninterpretedOption message. + * @function verify + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UninterpretedOption.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) { + if (!Array.isArray(message.name)) + return 'name: array expected' + for (var i = 0; i < message.name.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.NamePart.verify( + message.name[i] + ) + if (error) return 'name.' + error + } + } + if ( + message.identifierValue != null && + message.hasOwnProperty('identifierValue') + ) + if (!$util.isString(message.identifierValue)) + return 'identifierValue: string expected' + if ( + message.positiveIntValue != null && + message.hasOwnProperty('positiveIntValue') + ) + if ( + !$util.isInteger(message.positiveIntValue) && + !( + message.positiveIntValue && + $util.isInteger(message.positiveIntValue.low) && + $util.isInteger(message.positiveIntValue.high) + ) + ) + return 'positiveIntValue: integer|Long expected' + if ( + message.negativeIntValue != null && + message.hasOwnProperty('negativeIntValue') + ) + if ( + !$util.isInteger(message.negativeIntValue) && + !( + message.negativeIntValue && + $util.isInteger(message.negativeIntValue.low) && + $util.isInteger(message.negativeIntValue.high) + ) + ) + return 'negativeIntValue: integer|Long expected' + if ( + message.doubleValue != null && + message.hasOwnProperty('doubleValue') + ) + if (typeof message.doubleValue !== 'number') + return 'doubleValue: number expected' + if ( + message.stringValue != null && + message.hasOwnProperty('stringValue') + ) + if ( + !( + (message.stringValue && + typeof message.stringValue.length === 'number') || + $util.isString(message.stringValue) + ) + ) + return 'stringValue: buffer expected' + if ( + message.aggregateValue != null && + message.hasOwnProperty('aggregateValue') + ) + if (!$util.isString(message.aggregateValue)) + return 'aggregateValue: string expected' + return null + } + + /** + * Creates an UninterpretedOption message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.UninterpretedOption} UninterpretedOption + */ + UninterpretedOption.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.UninterpretedOption) + return object + var message = new $root.google.protobuf.UninterpretedOption() + if (object.name) { + if (!Array.isArray(object.name)) + throw TypeError( + '.google.protobuf.UninterpretedOption.name: array expected' + ) + message.name = [] + for (var i = 0; i < object.name.length; ++i) { + if (typeof object.name[i] !== 'object') + throw TypeError( + '.google.protobuf.UninterpretedOption.name: object expected' + ) + message.name[ + i + ] = $root.google.protobuf.UninterpretedOption.NamePart.fromObject( + object.name[i] + ) + } + } + if (object.identifierValue != null) + message.identifierValue = String(object.identifierValue) + if (object.positiveIntValue != null) + if ($util.Long) + (message.positiveIntValue = $util.Long.fromValue( + object.positiveIntValue + )).unsigned = true + else if (typeof object.positiveIntValue === 'string') + message.positiveIntValue = parseInt( + object.positiveIntValue, + 10 + ) + else if (typeof object.positiveIntValue === 'number') + message.positiveIntValue = object.positiveIntValue + else if (typeof object.positiveIntValue === 'object') + message.positiveIntValue = new $util.LongBits( + object.positiveIntValue.low >>> 0, + object.positiveIntValue.high >>> 0 + ).toNumber(true) + if (object.negativeIntValue != null) + if ($util.Long) + (message.negativeIntValue = $util.Long.fromValue( + object.negativeIntValue + )).unsigned = false + else if (typeof object.negativeIntValue === 'string') + message.negativeIntValue = parseInt( + object.negativeIntValue, + 10 + ) + else if (typeof object.negativeIntValue === 'number') + message.negativeIntValue = object.negativeIntValue + else if (typeof object.negativeIntValue === 'object') + message.negativeIntValue = new $util.LongBits( + object.negativeIntValue.low >>> 0, + object.negativeIntValue.high >>> 0 + ).toNumber() + if (object.doubleValue != null) + message.doubleValue = Number(object.doubleValue) + if (object.stringValue != null) + if (typeof object.stringValue === 'string') + $util.base64.decode( + object.stringValue, + (message.stringValue = $util.newBuffer( + $util.base64.length(object.stringValue) + )), + 0 + ) + else if (object.stringValue.length) + message.stringValue = object.stringValue + if (object.aggregateValue != null) + message.aggregateValue = String(object.aggregateValue) + return message + } + + /** + * Creates a plain object from an UninterpretedOption message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {google.protobuf.UninterpretedOption} message UninterpretedOption + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UninterpretedOption.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) object.name = [] + if (options.defaults) { + object.identifierValue = '' + if ($util.Long) { + var long = new $util.Long(0, 0, true) + object.positiveIntValue = + options.longs === String + ? long.toString() + : options.longs === Number + ? long.toNumber() + : long + } else + object.positiveIntValue = options.longs === String ? '0' : 0 + if ($util.Long) { + var long = new $util.Long(0, 0, false) + object.negativeIntValue = + options.longs === String + ? long.toString() + : options.longs === Number + ? long.toNumber() + : long + } else + object.negativeIntValue = options.longs === String ? '0' : 0 + object.doubleValue = 0 + if (options.bytes === String) object.stringValue = '' + else { + object.stringValue = [] + if (options.bytes !== Array) + object.stringValue = $util.newBuffer(object.stringValue) + } + object.aggregateValue = '' + } + if (message.name && message.name.length) { + object.name = [] + for (var j = 0; j < message.name.length; ++j) + object.name[ + j + ] = $root.google.protobuf.UninterpretedOption.NamePart.toObject( + message.name[j], + options + ) + } + if ( + message.identifierValue != null && + message.hasOwnProperty('identifierValue') + ) + object.identifierValue = message.identifierValue + if ( + message.positiveIntValue != null && + message.hasOwnProperty('positiveIntValue') + ) + if (typeof message.positiveIntValue === 'number') + object.positiveIntValue = + options.longs === String + ? String(message.positiveIntValue) + : message.positiveIntValue + else + object.positiveIntValue = + options.longs === String + ? $util.Long.prototype.toString.call( + message.positiveIntValue + ) + : options.longs === Number + ? new $util.LongBits( + message.positiveIntValue.low >>> 0, + message.positiveIntValue.high >>> 0 + ).toNumber(true) + : message.positiveIntValue + if ( + message.negativeIntValue != null && + message.hasOwnProperty('negativeIntValue') + ) + if (typeof message.negativeIntValue === 'number') + object.negativeIntValue = + options.longs === String + ? String(message.negativeIntValue) + : message.negativeIntValue + else + object.negativeIntValue = + options.longs === String + ? $util.Long.prototype.toString.call( + message.negativeIntValue + ) + : options.longs === Number + ? new $util.LongBits( + message.negativeIntValue.low >>> 0, + message.negativeIntValue.high >>> 0 + ).toNumber() + : message.negativeIntValue + if ( + message.doubleValue != null && + message.hasOwnProperty('doubleValue') + ) + object.doubleValue = + options.json && !isFinite(message.doubleValue) + ? String(message.doubleValue) + : message.doubleValue + if ( + message.stringValue != null && + message.hasOwnProperty('stringValue') + ) + object.stringValue = + options.bytes === String + ? $util.base64.encode( + message.stringValue, + 0, + message.stringValue.length + ) + : options.bytes === Array + ? Array.prototype.slice.call(message.stringValue) + : message.stringValue + if ( + message.aggregateValue != null && + message.hasOwnProperty('aggregateValue') + ) + object.aggregateValue = message.aggregateValue + return object + } + + /** + * Converts this UninterpretedOption to JSON. + * @function toJSON + * @memberof google.protobuf.UninterpretedOption + * @instance + * @returns {Object.} JSON object + */ + UninterpretedOption.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + UninterpretedOption.NamePart = (function () { + /** + * Properties of a NamePart. + * @memberof google.protobuf.UninterpretedOption + * @interface INamePart + * @property {string} namePart NamePart namePart + * @property {boolean} isExtension NamePart isExtension + */ + + /** + * Constructs a new NamePart. + * @memberof google.protobuf.UninterpretedOption + * @classdesc Represents a NamePart. + * @implements INamePart + * @constructor + * @param {google.protobuf.UninterpretedOption.INamePart=} [properties] Properties to set + */ + function NamePart(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * NamePart namePart. + * @member {string} namePart + * @memberof google.protobuf.UninterpretedOption.NamePart + * @instance + */ + NamePart.prototype.namePart = '' + + /** + * NamePart isExtension. + * @member {boolean} isExtension + * @memberof google.protobuf.UninterpretedOption.NamePart + * @instance + */ + NamePart.prototype.isExtension = false + + /** + * Creates a new NamePart instance using the specified properties. + * @function create + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {google.protobuf.UninterpretedOption.INamePart=} [properties] Properties to set + * @returns {google.protobuf.UninterpretedOption.NamePart} NamePart instance + */ + NamePart.create = function create(properties) { + return new NamePart(properties) + } + + /** + * Encodes the specified NamePart message. Does not implicitly {@link google.protobuf.UninterpretedOption.NamePart.verify|verify} messages. + * @function encode + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {google.protobuf.UninterpretedOption.INamePart} message NamePart message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + NamePart.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.namePart) + writer + .uint32(/* id 2, wireType 0 =*/ 16) + .bool(message.isExtension) + return writer + } + + /** + * Encodes the specified NamePart message, length delimited. Does not implicitly {@link google.protobuf.UninterpretedOption.NamePart.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {google.protobuf.UninterpretedOption.INamePart} message NamePart message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + NamePart.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a NamePart message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.UninterpretedOption.NamePart} NamePart + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + NamePart.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.UninterpretedOption.NamePart() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.namePart = reader.string() + break + case 2: + message.isExtension = reader.bool() + break + default: + reader.skipType(tag & 7) + break + } + } + if (!message.hasOwnProperty('namePart')) + throw $util.ProtocolError("missing required 'namePart'", { + instance: message + }) + if (!message.hasOwnProperty('isExtension')) + throw $util.ProtocolError( + "missing required 'isExtension'", + { instance: message } + ) + return message + } + + /** + * Decodes a NamePart message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.UninterpretedOption.NamePart} NamePart + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + NamePart.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a NamePart message. + * @function verify + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + NamePart.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (!$util.isString(message.namePart)) + return 'namePart: string expected' + if (typeof message.isExtension !== 'boolean') + return 'isExtension: boolean expected' + return null + } + + /** + * Creates a NamePart message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.UninterpretedOption.NamePart} NamePart + */ + NamePart.fromObject = function fromObject(object) { + if ( + object instanceof + $root.google.protobuf.UninterpretedOption.NamePart + ) + return object + var message = new $root.google.protobuf.UninterpretedOption.NamePart() + if (object.namePart != null) + message.namePart = String(object.namePart) + if (object.isExtension != null) + message.isExtension = Boolean(object.isExtension) + return message + } + + /** + * Creates a plain object from a NamePart message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {google.protobuf.UninterpretedOption.NamePart} message NamePart + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + NamePart.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.namePart = '' + object.isExtension = false + } + if ( + message.namePart != null && + message.hasOwnProperty('namePart') + ) + object.namePart = message.namePart + if ( + message.isExtension != null && + message.hasOwnProperty('isExtension') + ) + object.isExtension = message.isExtension + return object + } + + /** + * Converts this NamePart to JSON. + * @function toJSON + * @memberof google.protobuf.UninterpretedOption.NamePart + * @instance + * @returns {Object.} JSON object + */ + NamePart.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return NamePart + })() + + return UninterpretedOption + })() + + protobuf.SourceCodeInfo = (function () { + /** + * Properties of a SourceCodeInfo. + * @memberof google.protobuf + * @interface ISourceCodeInfo + * @property {Array.|null} [location] SourceCodeInfo location + */ + + /** + * Constructs a new SourceCodeInfo. + * @memberof google.protobuf + * @classdesc Represents a SourceCodeInfo. + * @implements ISourceCodeInfo + * @constructor + * @param {google.protobuf.ISourceCodeInfo=} [properties] Properties to set + */ + function SourceCodeInfo(properties) { + this.location = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * SourceCodeInfo location. + * @member {Array.} location + * @memberof google.protobuf.SourceCodeInfo + * @instance + */ + SourceCodeInfo.prototype.location = $util.emptyArray + + /** + * Creates a new SourceCodeInfo instance using the specified properties. + * @function create + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {google.protobuf.ISourceCodeInfo=} [properties] Properties to set + * @returns {google.protobuf.SourceCodeInfo} SourceCodeInfo instance + */ + SourceCodeInfo.create = function create(properties) { + return new SourceCodeInfo(properties) + } + + /** + * Encodes the specified SourceCodeInfo message. Does not implicitly {@link google.protobuf.SourceCodeInfo.verify|verify} messages. + * @function encode + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {google.protobuf.ISourceCodeInfo} message SourceCodeInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SourceCodeInfo.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.location != null && message.location.length) + for (var i = 0; i < message.location.length; ++i) + $root.google.protobuf.SourceCodeInfo.Location.encode( + message.location[i], + writer.uint32(/* id 1, wireType 2 =*/ 10).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified SourceCodeInfo message, length delimited. Does not implicitly {@link google.protobuf.SourceCodeInfo.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {google.protobuf.ISourceCodeInfo} message SourceCodeInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SourceCodeInfo.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a SourceCodeInfo message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.SourceCodeInfo} SourceCodeInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SourceCodeInfo.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.SourceCodeInfo() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + if (!(message.location && message.location.length)) + message.location = [] + message.location.push( + $root.google.protobuf.SourceCodeInfo.Location.decode( + reader, + reader.uint32() + ) + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a SourceCodeInfo message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.SourceCodeInfo} SourceCodeInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SourceCodeInfo.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a SourceCodeInfo message. + * @function verify + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SourceCodeInfo.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.location != null && + message.hasOwnProperty('location') + ) { + if (!Array.isArray(message.location)) + return 'location: array expected' + for (var i = 0; i < message.location.length; ++i) { + var error = $root.google.protobuf.SourceCodeInfo.Location.verify( + message.location[i] + ) + if (error) return 'location.' + error + } + } + return null + } + + /** + * Creates a SourceCodeInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.SourceCodeInfo} SourceCodeInfo + */ + SourceCodeInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.SourceCodeInfo) + return object + var message = new $root.google.protobuf.SourceCodeInfo() + if (object.location) { + if (!Array.isArray(object.location)) + throw TypeError( + '.google.protobuf.SourceCodeInfo.location: array expected' + ) + message.location = [] + for (var i = 0; i < object.location.length; ++i) { + if (typeof object.location[i] !== 'object') + throw TypeError( + '.google.protobuf.SourceCodeInfo.location: object expected' + ) + message.location[ + i + ] = $root.google.protobuf.SourceCodeInfo.Location.fromObject( + object.location[i] + ) + } + } + return message + } + + /** + * Creates a plain object from a SourceCodeInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {google.protobuf.SourceCodeInfo} message SourceCodeInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SourceCodeInfo.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) object.location = [] + if (message.location && message.location.length) { + object.location = [] + for (var j = 0; j < message.location.length; ++j) + object.location[ + j + ] = $root.google.protobuf.SourceCodeInfo.Location.toObject( + message.location[j], + options + ) + } + return object + } + + /** + * Converts this SourceCodeInfo to JSON. + * @function toJSON + * @memberof google.protobuf.SourceCodeInfo + * @instance + * @returns {Object.} JSON object + */ + SourceCodeInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + SourceCodeInfo.Location = (function () { + /** + * Properties of a Location. + * @memberof google.protobuf.SourceCodeInfo + * @interface ILocation + * @property {Array.|null} [path] Location path + * @property {Array.|null} [span] Location span + * @property {string|null} [leadingComments] Location leadingComments + * @property {string|null} [trailingComments] Location trailingComments + * @property {Array.|null} [leadingDetachedComments] Location leadingDetachedComments + */ + + /** + * Constructs a new Location. + * @memberof google.protobuf.SourceCodeInfo + * @classdesc Represents a Location. + * @implements ILocation + * @constructor + * @param {google.protobuf.SourceCodeInfo.ILocation=} [properties] Properties to set + */ + function Location(properties) { + this.path = [] + this.span = [] + this.leadingDetachedComments = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * Location path. + * @member {Array.} path + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.path = $util.emptyArray + + /** + * Location span. + * @member {Array.} span + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.span = $util.emptyArray + + /** + * Location leadingComments. + * @member {string} leadingComments + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.leadingComments = '' + + /** + * Location trailingComments. + * @member {string} trailingComments + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.trailingComments = '' + + /** + * Location leadingDetachedComments. + * @member {Array.} leadingDetachedComments + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.leadingDetachedComments = $util.emptyArray + + /** + * Creates a new Location instance using the specified properties. + * @function create + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {google.protobuf.SourceCodeInfo.ILocation=} [properties] Properties to set + * @returns {google.protobuf.SourceCodeInfo.Location} Location instance + */ + Location.create = function create(properties) { + return new Location(properties) + } + + /** + * Encodes the specified Location message. Does not implicitly {@link google.protobuf.SourceCodeInfo.Location.verify|verify} messages. + * @function encode + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {google.protobuf.SourceCodeInfo.ILocation} message Location message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Location.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.path != null && message.path.length) { + writer.uint32(/* id 1, wireType 2 =*/ 10).fork() + for (var i = 0; i < message.path.length; ++i) + writer.int32(message.path[i]) + writer.ldelim() + } + if (message.span != null && message.span.length) { + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + for (var i = 0; i < message.span.length; ++i) + writer.int32(message.span[i]) + writer.ldelim() + } + if ( + message.leadingComments != null && + Object.hasOwnProperty.call(message, 'leadingComments') + ) + writer + .uint32(/* id 3, wireType 2 =*/ 26) + .string(message.leadingComments) + if ( + message.trailingComments != null && + Object.hasOwnProperty.call(message, 'trailingComments') + ) + writer + .uint32(/* id 4, wireType 2 =*/ 34) + .string(message.trailingComments) + if ( + message.leadingDetachedComments != null && + message.leadingDetachedComments.length + ) + for ( + var i = 0; + i < message.leadingDetachedComments.length; + ++i + ) + writer + .uint32(/* id 6, wireType 2 =*/ 50) + .string(message.leadingDetachedComments[i]) + return writer + } + + /** + * Encodes the specified Location message, length delimited. Does not implicitly {@link google.protobuf.SourceCodeInfo.Location.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {google.protobuf.SourceCodeInfo.ILocation} message Location message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Location.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a Location message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.SourceCodeInfo.Location} Location + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Location.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.SourceCodeInfo.Location() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + if (!(message.path && message.path.length)) + message.path = [] + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos + while (reader.pos < end2) + message.path.push(reader.int32()) + } else message.path.push(reader.int32()) + break + case 2: + if (!(message.span && message.span.length)) + message.span = [] + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos + while (reader.pos < end2) + message.span.push(reader.int32()) + } else message.span.push(reader.int32()) + break + case 3: + message.leadingComments = reader.string() + break + case 4: + message.trailingComments = reader.string() + break + case 6: + if ( + !( + message.leadingDetachedComments && + message.leadingDetachedComments.length + ) + ) + message.leadingDetachedComments = [] + message.leadingDetachedComments.push(reader.string()) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a Location message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.SourceCodeInfo.Location} Location + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Location.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a Location message. + * @function verify + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Location.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.path != null && message.hasOwnProperty('path')) { + if (!Array.isArray(message.path)) + return 'path: array expected' + for (var i = 0; i < message.path.length; ++i) + if (!$util.isInteger(message.path[i])) + return 'path: integer[] expected' + } + if (message.span != null && message.hasOwnProperty('span')) { + if (!Array.isArray(message.span)) + return 'span: array expected' + for (var i = 0; i < message.span.length; ++i) + if (!$util.isInteger(message.span[i])) + return 'span: integer[] expected' + } + if ( + message.leadingComments != null && + message.hasOwnProperty('leadingComments') + ) + if (!$util.isString(message.leadingComments)) + return 'leadingComments: string expected' + if ( + message.trailingComments != null && + message.hasOwnProperty('trailingComments') + ) + if (!$util.isString(message.trailingComments)) + return 'trailingComments: string expected' + if ( + message.leadingDetachedComments != null && + message.hasOwnProperty('leadingDetachedComments') + ) { + if (!Array.isArray(message.leadingDetachedComments)) + return 'leadingDetachedComments: array expected' + for ( + var i = 0; + i < message.leadingDetachedComments.length; + ++i + ) + if (!$util.isString(message.leadingDetachedComments[i])) + return 'leadingDetachedComments: string[] expected' + } + return null + } + + /** + * Creates a Location message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.SourceCodeInfo.Location} Location + */ + Location.fromObject = function fromObject(object) { + if ( + object instanceof + $root.google.protobuf.SourceCodeInfo.Location + ) + return object + var message = new $root.google.protobuf.SourceCodeInfo.Location() + if (object.path) { + if (!Array.isArray(object.path)) + throw TypeError( + '.google.protobuf.SourceCodeInfo.Location.path: array expected' + ) + message.path = [] + for (var i = 0; i < object.path.length; ++i) + message.path[i] = object.path[i] | 0 + } + if (object.span) { + if (!Array.isArray(object.span)) + throw TypeError( + '.google.protobuf.SourceCodeInfo.Location.span: array expected' + ) + message.span = [] + for (var i = 0; i < object.span.length; ++i) + message.span[i] = object.span[i] | 0 + } + if (object.leadingComments != null) + message.leadingComments = String(object.leadingComments) + if (object.trailingComments != null) + message.trailingComments = String(object.trailingComments) + if (object.leadingDetachedComments) { + if (!Array.isArray(object.leadingDetachedComments)) + throw TypeError( + '.google.protobuf.SourceCodeInfo.Location.leadingDetachedComments: array expected' + ) + message.leadingDetachedComments = [] + for ( + var i = 0; + i < object.leadingDetachedComments.length; + ++i + ) + message.leadingDetachedComments[i] = String( + object.leadingDetachedComments[i] + ) + } + return message + } + + /** + * Creates a plain object from a Location message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {google.protobuf.SourceCodeInfo.Location} message Location + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Location.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) { + object.path = [] + object.span = [] + object.leadingDetachedComments = [] + } + if (options.defaults) { + object.leadingComments = '' + object.trailingComments = '' + } + if (message.path && message.path.length) { + object.path = [] + for (var j = 0; j < message.path.length; ++j) + object.path[j] = message.path[j] + } + if (message.span && message.span.length) { + object.span = [] + for (var j = 0; j < message.span.length; ++j) + object.span[j] = message.span[j] + } + if ( + message.leadingComments != null && + message.hasOwnProperty('leadingComments') + ) + object.leadingComments = message.leadingComments + if ( + message.trailingComments != null && + message.hasOwnProperty('trailingComments') + ) + object.trailingComments = message.trailingComments + if ( + message.leadingDetachedComments && + message.leadingDetachedComments.length + ) { + object.leadingDetachedComments = [] + for ( + var j = 0; + j < message.leadingDetachedComments.length; + ++j + ) + object.leadingDetachedComments[j] = + message.leadingDetachedComments[j] + } + return object + } + + /** + * Converts this Location to JSON. + * @function toJSON + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + * @returns {Object.} JSON object + */ + Location.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return Location + })() + + return SourceCodeInfo + })() + + protobuf.GeneratedCodeInfo = (function () { + /** + * Properties of a GeneratedCodeInfo. + * @memberof google.protobuf + * @interface IGeneratedCodeInfo + * @property {Array.|null} [annotation] GeneratedCodeInfo annotation + */ + + /** + * Constructs a new GeneratedCodeInfo. + * @memberof google.protobuf + * @classdesc Represents a GeneratedCodeInfo. + * @implements IGeneratedCodeInfo + * @constructor + * @param {google.protobuf.IGeneratedCodeInfo=} [properties] Properties to set + */ + function GeneratedCodeInfo(properties) { + this.annotation = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * GeneratedCodeInfo annotation. + * @member {Array.} annotation + * @memberof google.protobuf.GeneratedCodeInfo + * @instance + */ + GeneratedCodeInfo.prototype.annotation = $util.emptyArray + + /** + * Creates a new GeneratedCodeInfo instance using the specified properties. + * @function create + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {google.protobuf.IGeneratedCodeInfo=} [properties] Properties to set + * @returns {google.protobuf.GeneratedCodeInfo} GeneratedCodeInfo instance + */ + GeneratedCodeInfo.create = function create(properties) { + return new GeneratedCodeInfo(properties) + } + + /** + * Encodes the specified GeneratedCodeInfo message. Does not implicitly {@link google.protobuf.GeneratedCodeInfo.verify|verify} messages. + * @function encode + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {google.protobuf.IGeneratedCodeInfo} message GeneratedCodeInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GeneratedCodeInfo.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.annotation != null && message.annotation.length) + for (var i = 0; i < message.annotation.length; ++i) + $root.google.protobuf.GeneratedCodeInfo.Annotation.encode( + message.annotation[i], + writer.uint32(/* id 1, wireType 2 =*/ 10).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified GeneratedCodeInfo message, length delimited. Does not implicitly {@link google.protobuf.GeneratedCodeInfo.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {google.protobuf.IGeneratedCodeInfo} message GeneratedCodeInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GeneratedCodeInfo.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a GeneratedCodeInfo message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.GeneratedCodeInfo} GeneratedCodeInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GeneratedCodeInfo.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.GeneratedCodeInfo() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + if (!(message.annotation && message.annotation.length)) + message.annotation = [] + message.annotation.push( + $root.google.protobuf.GeneratedCodeInfo.Annotation.decode( + reader, + reader.uint32() + ) + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a GeneratedCodeInfo message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.GeneratedCodeInfo} GeneratedCodeInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GeneratedCodeInfo.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a GeneratedCodeInfo message. + * @function verify + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GeneratedCodeInfo.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.annotation != null && + message.hasOwnProperty('annotation') + ) { + if (!Array.isArray(message.annotation)) + return 'annotation: array expected' + for (var i = 0; i < message.annotation.length; ++i) { + var error = $root.google.protobuf.GeneratedCodeInfo.Annotation.verify( + message.annotation[i] + ) + if (error) return 'annotation.' + error + } + } + return null + } + + /** + * Creates a GeneratedCodeInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.GeneratedCodeInfo} GeneratedCodeInfo + */ + GeneratedCodeInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.GeneratedCodeInfo) + return object + var message = new $root.google.protobuf.GeneratedCodeInfo() + if (object.annotation) { + if (!Array.isArray(object.annotation)) + throw TypeError( + '.google.protobuf.GeneratedCodeInfo.annotation: array expected' + ) + message.annotation = [] + for (var i = 0; i < object.annotation.length; ++i) { + if (typeof object.annotation[i] !== 'object') + throw TypeError( + '.google.protobuf.GeneratedCodeInfo.annotation: object expected' + ) + message.annotation[ + i + ] = $root.google.protobuf.GeneratedCodeInfo.Annotation.fromObject( + object.annotation[i] + ) + } + } + return message + } + + /** + * Creates a plain object from a GeneratedCodeInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {google.protobuf.GeneratedCodeInfo} message GeneratedCodeInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GeneratedCodeInfo.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) object.annotation = [] + if (message.annotation && message.annotation.length) { + object.annotation = [] + for (var j = 0; j < message.annotation.length; ++j) + object.annotation[ + j + ] = $root.google.protobuf.GeneratedCodeInfo.Annotation.toObject( + message.annotation[j], + options + ) + } + return object + } + + /** + * Converts this GeneratedCodeInfo to JSON. + * @function toJSON + * @memberof google.protobuf.GeneratedCodeInfo + * @instance + * @returns {Object.} JSON object + */ + GeneratedCodeInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + GeneratedCodeInfo.Annotation = (function () { + /** + * Properties of an Annotation. + * @memberof google.protobuf.GeneratedCodeInfo + * @interface IAnnotation + * @property {Array.|null} [path] Annotation path + * @property {string|null} [sourceFile] Annotation sourceFile + * @property {number|null} [begin] Annotation begin + * @property {number|null} [end] Annotation end + */ + + /** + * Constructs a new Annotation. + * @memberof google.protobuf.GeneratedCodeInfo + * @classdesc Represents an Annotation. + * @implements IAnnotation + * @constructor + * @param {google.protobuf.GeneratedCodeInfo.IAnnotation=} [properties] Properties to set + */ + function Annotation(properties) { + this.path = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * Annotation path. + * @member {Array.} path + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + */ + Annotation.prototype.path = $util.emptyArray + + /** + * Annotation sourceFile. + * @member {string} sourceFile + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + */ + Annotation.prototype.sourceFile = '' + + /** + * Annotation begin. + * @member {number} begin + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + */ + Annotation.prototype.begin = 0 + + /** + * Annotation end. + * @member {number} end + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + */ + Annotation.prototype.end = 0 + + /** + * Creates a new Annotation instance using the specified properties. + * @function create + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {google.protobuf.GeneratedCodeInfo.IAnnotation=} [properties] Properties to set + * @returns {google.protobuf.GeneratedCodeInfo.Annotation} Annotation instance + */ + Annotation.create = function create(properties) { + return new Annotation(properties) + } + + /** + * Encodes the specified Annotation message. Does not implicitly {@link google.protobuf.GeneratedCodeInfo.Annotation.verify|verify} messages. + * @function encode + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {google.protobuf.GeneratedCodeInfo.IAnnotation} message Annotation message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Annotation.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.path != null && message.path.length) { + writer.uint32(/* id 1, wireType 2 =*/ 10).fork() + for (var i = 0; i < message.path.length; ++i) + writer.int32(message.path[i]) + writer.ldelim() + } + if ( + message.sourceFile != null && + Object.hasOwnProperty.call(message, 'sourceFile') + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.sourceFile) + if ( + message.begin != null && + Object.hasOwnProperty.call(message, 'begin') + ) + writer + .uint32(/* id 3, wireType 0 =*/ 24) + .int32(message.begin) + if ( + message.end != null && + Object.hasOwnProperty.call(message, 'end') + ) + writer.uint32(/* id 4, wireType 0 =*/ 32).int32(message.end) + return writer + } + + /** + * Encodes the specified Annotation message, length delimited. Does not implicitly {@link google.protobuf.GeneratedCodeInfo.Annotation.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {google.protobuf.GeneratedCodeInfo.IAnnotation} message Annotation message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Annotation.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an Annotation message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.GeneratedCodeInfo.Annotation} Annotation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Annotation.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.GeneratedCodeInfo.Annotation() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + if (!(message.path && message.path.length)) + message.path = [] + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos + while (reader.pos < end2) + message.path.push(reader.int32()) + } else message.path.push(reader.int32()) + break + case 2: + message.sourceFile = reader.string() + break + case 3: + message.begin = reader.int32() + break + case 4: + message.end = reader.int32() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an Annotation message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.GeneratedCodeInfo.Annotation} Annotation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Annotation.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an Annotation message. + * @function verify + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Annotation.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.path != null && message.hasOwnProperty('path')) { + if (!Array.isArray(message.path)) + return 'path: array expected' + for (var i = 0; i < message.path.length; ++i) + if (!$util.isInteger(message.path[i])) + return 'path: integer[] expected' + } + if ( + message.sourceFile != null && + message.hasOwnProperty('sourceFile') + ) + if (!$util.isString(message.sourceFile)) + return 'sourceFile: string expected' + if (message.begin != null && message.hasOwnProperty('begin')) + if (!$util.isInteger(message.begin)) + return 'begin: integer expected' + if (message.end != null && message.hasOwnProperty('end')) + if (!$util.isInteger(message.end)) + return 'end: integer expected' + return null + } + + /** + * Creates an Annotation message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.GeneratedCodeInfo.Annotation} Annotation + */ + Annotation.fromObject = function fromObject(object) { + if ( + object instanceof + $root.google.protobuf.GeneratedCodeInfo.Annotation + ) + return object + var message = new $root.google.protobuf.GeneratedCodeInfo.Annotation() + if (object.path) { + if (!Array.isArray(object.path)) + throw TypeError( + '.google.protobuf.GeneratedCodeInfo.Annotation.path: array expected' + ) + message.path = [] + for (var i = 0; i < object.path.length; ++i) + message.path[i] = object.path[i] | 0 + } + if (object.sourceFile != null) + message.sourceFile = String(object.sourceFile) + if (object.begin != null) message.begin = object.begin | 0 + if (object.end != null) message.end = object.end | 0 + return message + } + + /** + * Creates a plain object from an Annotation message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {google.protobuf.GeneratedCodeInfo.Annotation} message Annotation + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Annotation.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) object.path = [] + if (options.defaults) { + object.sourceFile = '' + object.begin = 0 + object.end = 0 + } + if (message.path && message.path.length) { + object.path = [] + for (var j = 0; j < message.path.length; ++j) + object.path[j] = message.path[j] + } + if ( + message.sourceFile != null && + message.hasOwnProperty('sourceFile') + ) + object.sourceFile = message.sourceFile + if (message.begin != null && message.hasOwnProperty('begin')) + object.begin = message.begin + if (message.end != null && message.hasOwnProperty('end')) + object.end = message.end + return object + } + + /** + * Converts this Annotation to JSON. + * @function toJSON + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + * @returns {Object.} JSON object + */ + Annotation.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return Annotation + })() + + return GeneratedCodeInfo + })() + + protobuf.Struct = (function () { + /** + * Properties of a Struct. + * @memberof google.protobuf + * @interface IStruct + * @property {Object.|null} [fields] Struct fields + */ + + /** + * Constructs a new Struct. + * @memberof google.protobuf + * @classdesc Represents a Struct. + * @implements IStruct + * @constructor + * @param {google.protobuf.IStruct=} [properties] Properties to set + */ + function Struct(properties) { + this.fields = {} + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * Struct fields. + * @member {Object.} fields + * @memberof google.protobuf.Struct + * @instance + */ + Struct.prototype.fields = $util.emptyObject + + /** + * Creates a new Struct instance using the specified properties. + * @function create + * @memberof google.protobuf.Struct + * @static + * @param {google.protobuf.IStruct=} [properties] Properties to set + * @returns {google.protobuf.Struct} Struct instance + */ + Struct.create = function create(properties) { + return new Struct(properties) + } + + /** + * Encodes the specified Struct message. Does not implicitly {@link google.protobuf.Struct.verify|verify} messages. + * @function encode + * @memberof google.protobuf.Struct + * @static + * @param {google.protobuf.IStruct} message Struct message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Struct.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.fields != null && + Object.hasOwnProperty.call(message, 'fields') + ) + for ( + var keys = Object.keys(message.fields), i = 0; + i < keys.length; + ++i + ) { + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .fork() + .uint32(/* id 1, wireType 2 =*/ 10) + .string(keys[i]) + $root.google.protobuf.Value.encode( + message.fields[keys[i]], + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + ) + .ldelim() + .ldelim() + } + return writer + } + + /** + * Encodes the specified Struct message, length delimited. Does not implicitly {@link google.protobuf.Struct.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.Struct + * @static + * @param {google.protobuf.IStruct} message Struct message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Struct.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a Struct message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.Struct + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.Struct} Struct + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Struct.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.Struct(), + key, + value + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + if (message.fields === $util.emptyObject) + message.fields = {} + var end2 = reader.uint32() + reader.pos + key = '' + value = null + while (reader.pos < end2) { + var tag2 = reader.uint32() + switch (tag2 >>> 3) { + case 1: + key = reader.string() + break + case 2: + value = $root.google.protobuf.Value.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag2 & 7) + break + } + } + message.fields[key] = value + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a Struct message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.Struct + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.Struct} Struct + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Struct.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a Struct message. + * @function verify + * @memberof google.protobuf.Struct + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Struct.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.fields != null && + message.hasOwnProperty('fields') + ) { + if (!$util.isObject(message.fields)) + return 'fields: object expected' + var key = Object.keys(message.fields) + for (var i = 0; i < key.length; ++i) { + var error = $root.google.protobuf.Value.verify( + message.fields[key[i]] + ) + if (error) return 'fields.' + error + } + } + return null + } + + /** + * Creates a Struct message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Struct + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Struct} Struct + */ + Struct.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Struct) + return object + var message = new $root.google.protobuf.Struct() + if (object.fields) { + if (typeof object.fields !== 'object') + throw TypeError( + '.google.protobuf.Struct.fields: object expected' + ) + message.fields = {} + for ( + var keys = Object.keys(object.fields), i = 0; + i < keys.length; + ++i + ) { + if (typeof object.fields[keys[i]] !== 'object') + throw TypeError( + '.google.protobuf.Struct.fields: object expected' + ) + message.fields[ + keys[i] + ] = $root.google.protobuf.Value.fromObject( + object.fields[keys[i]] + ) + } + } + return message + } + + /** + * Creates a plain object from a Struct message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Struct + * @static + * @param {google.protobuf.Struct} message Struct + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Struct.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.objects || options.defaults) object.fields = {} + var keys2 + if ( + message.fields && + (keys2 = Object.keys(message.fields)).length + ) { + object.fields = {} + for (var j = 0; j < keys2.length; ++j) + object.fields[ + keys2[j] + ] = $root.google.protobuf.Value.toObject( + message.fields[keys2[j]], + options + ) + } + return object + } + + /** + * Converts this Struct to JSON. + * @function toJSON + * @memberof google.protobuf.Struct + * @instance + * @returns {Object.} JSON object + */ + Struct.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return Struct + })() + + protobuf.Value = (function () { + /** + * Properties of a Value. + * @memberof google.protobuf + * @interface IValue + * @property {google.protobuf.NullValue|null} [nullValue] Value nullValue + * @property {number|null} [numberValue] Value numberValue + * @property {string|null} [stringValue] Value stringValue + * @property {boolean|null} [boolValue] Value boolValue + * @property {google.protobuf.IStruct|null} [structValue] Value structValue + * @property {google.protobuf.IListValue|null} [listValue] Value listValue + */ + + /** + * Constructs a new Value. + * @memberof google.protobuf + * @classdesc Represents a Value. + * @implements IValue + * @constructor + * @param {google.protobuf.IValue=} [properties] Properties to set + */ + function Value(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * Value nullValue. + * @member {google.protobuf.NullValue} nullValue + * @memberof google.protobuf.Value + * @instance + */ + Value.prototype.nullValue = 0 + + /** + * Value numberValue. + * @member {number} numberValue + * @memberof google.protobuf.Value + * @instance + */ + Value.prototype.numberValue = 0 + + /** + * Value stringValue. + * @member {string} stringValue + * @memberof google.protobuf.Value + * @instance + */ + Value.prototype.stringValue = '' + + /** + * Value boolValue. + * @member {boolean} boolValue + * @memberof google.protobuf.Value + * @instance + */ + Value.prototype.boolValue = false + + /** + * Value structValue. + * @member {google.protobuf.IStruct|null|undefined} structValue + * @memberof google.protobuf.Value + * @instance + */ + Value.prototype.structValue = null + + /** + * Value listValue. + * @member {google.protobuf.IListValue|null|undefined} listValue + * @memberof google.protobuf.Value + * @instance + */ + Value.prototype.listValue = null + + // OneOf field names bound to virtual getters and setters + var $oneOfFields + + /** + * Value kind. + * @member {"nullValue"|"numberValue"|"stringValue"|"boolValue"|"structValue"|"listValue"|undefined} kind + * @memberof google.protobuf.Value + * @instance + */ + Object.defineProperty(Value.prototype, 'kind', { + get: $util.oneOfGetter( + ($oneOfFields = [ + 'nullValue', + 'numberValue', + 'stringValue', + 'boolValue', + 'structValue', + 'listValue' + ]) + ), + set: $util.oneOfSetter($oneOfFields) + }) + + /** + * Creates a new Value instance using the specified properties. + * @function create + * @memberof google.protobuf.Value + * @static + * @param {google.protobuf.IValue=} [properties] Properties to set + * @returns {google.protobuf.Value} Value instance + */ + Value.create = function create(properties) { + return new Value(properties) + } + + /** + * Encodes the specified Value message. Does not implicitly {@link google.protobuf.Value.verify|verify} messages. + * @function encode + * @memberof google.protobuf.Value + * @static + * @param {google.protobuf.IValue} message Value message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Value.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.nullValue != null && + Object.hasOwnProperty.call(message, 'nullValue') + ) + writer + .uint32(/* id 1, wireType 0 =*/ 8) + .int32(message.nullValue) + if ( + message.numberValue != null && + Object.hasOwnProperty.call(message, 'numberValue') + ) + writer + .uint32(/* id 2, wireType 1 =*/ 17) + .double(message.numberValue) + if ( + message.stringValue != null && + Object.hasOwnProperty.call(message, 'stringValue') + ) + writer + .uint32(/* id 3, wireType 2 =*/ 26) + .string(message.stringValue) + if ( + message.boolValue != null && + Object.hasOwnProperty.call(message, 'boolValue') + ) + writer + .uint32(/* id 4, wireType 0 =*/ 32) + .bool(message.boolValue) + if ( + message.structValue != null && + Object.hasOwnProperty.call(message, 'structValue') + ) + $root.google.protobuf.Struct.encode( + message.structValue, + writer.uint32(/* id 5, wireType 2 =*/ 42).fork() + ).ldelim() + if ( + message.listValue != null && + Object.hasOwnProperty.call(message, 'listValue') + ) + $root.google.protobuf.ListValue.encode( + message.listValue, + writer.uint32(/* id 6, wireType 2 =*/ 50).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified Value message, length delimited. Does not implicitly {@link google.protobuf.Value.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.Value + * @static + * @param {google.protobuf.IValue} message Value message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Value.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a Value message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.Value + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.Value} Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Value.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.Value() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.nullValue = reader.int32() + break + case 2: + message.numberValue = reader.double() + break + case 3: + message.stringValue = reader.string() + break + case 4: + message.boolValue = reader.bool() + break + case 5: + message.structValue = $root.google.protobuf.Struct.decode( + reader, + reader.uint32() + ) + break + case 6: + message.listValue = $root.google.protobuf.ListValue.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a Value message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.Value + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.Value} Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Value.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a Value message. + * @function verify + * @memberof google.protobuf.Value + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Value.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + var properties = {} + if ( + message.nullValue != null && + message.hasOwnProperty('nullValue') + ) { + properties.kind = 1 + switch (message.nullValue) { + default: + return 'nullValue: enum value expected' + case 0: + break + } + } + if ( + message.numberValue != null && + message.hasOwnProperty('numberValue') + ) { + if (properties.kind === 1) return 'kind: multiple values' + properties.kind = 1 + if (typeof message.numberValue !== 'number') + return 'numberValue: number expected' + } + if ( + message.stringValue != null && + message.hasOwnProperty('stringValue') + ) { + if (properties.kind === 1) return 'kind: multiple values' + properties.kind = 1 + if (!$util.isString(message.stringValue)) + return 'stringValue: string expected' + } + if ( + message.boolValue != null && + message.hasOwnProperty('boolValue') + ) { + if (properties.kind === 1) return 'kind: multiple values' + properties.kind = 1 + if (typeof message.boolValue !== 'boolean') + return 'boolValue: boolean expected' + } + if ( + message.structValue != null && + message.hasOwnProperty('structValue') + ) { + if (properties.kind === 1) return 'kind: multiple values' + properties.kind = 1 + { + var error = $root.google.protobuf.Struct.verify( + message.structValue + ) + if (error) return 'structValue.' + error + } + } + if ( + message.listValue != null && + message.hasOwnProperty('listValue') + ) { + if (properties.kind === 1) return 'kind: multiple values' + properties.kind = 1 + { + var error = $root.google.protobuf.ListValue.verify( + message.listValue + ) + if (error) return 'listValue.' + error + } + } + return null + } + + /** + * Creates a Value message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Value + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Value} Value + */ + Value.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Value) return object + var message = new $root.google.protobuf.Value() + switch (object.nullValue) { + case 'NULL_VALUE': + case 0: + message.nullValue = 0 + break + } + if (object.numberValue != null) + message.numberValue = Number(object.numberValue) + if (object.stringValue != null) + message.stringValue = String(object.stringValue) + if (object.boolValue != null) + message.boolValue = Boolean(object.boolValue) + if (object.structValue != null) { + if (typeof object.structValue !== 'object') + throw TypeError( + '.google.protobuf.Value.structValue: object expected' + ) + message.structValue = $root.google.protobuf.Struct.fromObject( + object.structValue + ) + } + if (object.listValue != null) { + if (typeof object.listValue !== 'object') + throw TypeError( + '.google.protobuf.Value.listValue: object expected' + ) + message.listValue = $root.google.protobuf.ListValue.fromObject( + object.listValue + ) + } + return message + } + + /** + * Creates a plain object from a Value message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Value + * @static + * @param {google.protobuf.Value} message Value + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Value.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if ( + message.nullValue != null && + message.hasOwnProperty('nullValue') + ) { + object.nullValue = + options.enums === String + ? $root.google.protobuf.NullValue[message.nullValue] + : message.nullValue + if (options.oneofs) object.kind = 'nullValue' + } + if ( + message.numberValue != null && + message.hasOwnProperty('numberValue') + ) { + object.numberValue = + options.json && !isFinite(message.numberValue) + ? String(message.numberValue) + : message.numberValue + if (options.oneofs) object.kind = 'numberValue' + } + if ( + message.stringValue != null && + message.hasOwnProperty('stringValue') + ) { + object.stringValue = message.stringValue + if (options.oneofs) object.kind = 'stringValue' + } + if ( + message.boolValue != null && + message.hasOwnProperty('boolValue') + ) { + object.boolValue = message.boolValue + if (options.oneofs) object.kind = 'boolValue' + } + if ( + message.structValue != null && + message.hasOwnProperty('structValue') + ) { + object.structValue = $root.google.protobuf.Struct.toObject( + message.structValue, + options + ) + if (options.oneofs) object.kind = 'structValue' + } + if ( + message.listValue != null && + message.hasOwnProperty('listValue') + ) { + object.listValue = $root.google.protobuf.ListValue.toObject( + message.listValue, + options + ) + if (options.oneofs) object.kind = 'listValue' + } + return object + } + + /** + * Converts this Value to JSON. + * @function toJSON + * @memberof google.protobuf.Value + * @instance + * @returns {Object.} JSON object + */ + Value.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return Value + })() + + /** + * NullValue enum. + * @name google.protobuf.NullValue + * @enum {number} + * @property {number} NULL_VALUE=0 NULL_VALUE value + */ + protobuf.NullValue = (function () { + var valuesById = {}, + values = Object.create(valuesById) + values[(valuesById[0] = 'NULL_VALUE')] = 0 + return values + })() + + protobuf.ListValue = (function () { + /** + * Properties of a ListValue. + * @memberof google.protobuf + * @interface IListValue + * @property {Array.|null} [values] ListValue values + */ + + /** + * Constructs a new ListValue. + * @memberof google.protobuf + * @classdesc Represents a ListValue. + * @implements IListValue + * @constructor + * @param {google.protobuf.IListValue=} [properties] Properties to set + */ + function ListValue(properties) { + this.values = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * ListValue values. + * @member {Array.} values + * @memberof google.protobuf.ListValue + * @instance + */ + ListValue.prototype.values = $util.emptyArray + + /** + * Creates a new ListValue instance using the specified properties. + * @function create + * @memberof google.protobuf.ListValue + * @static + * @param {google.protobuf.IListValue=} [properties] Properties to set + * @returns {google.protobuf.ListValue} ListValue instance + */ + ListValue.create = function create(properties) { + return new ListValue(properties) + } + + /** + * Encodes the specified ListValue message. Does not implicitly {@link google.protobuf.ListValue.verify|verify} messages. + * @function encode + * @memberof google.protobuf.ListValue + * @static + * @param {google.protobuf.IListValue} message ListValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListValue.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.values != null && message.values.length) + for (var i = 0; i < message.values.length; ++i) + $root.google.protobuf.Value.encode( + message.values[i], + writer.uint32(/* id 1, wireType 2 =*/ 10).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified ListValue message, length delimited. Does not implicitly {@link google.protobuf.ListValue.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.ListValue + * @static + * @param {google.protobuf.IListValue} message ListValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListValue.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a ListValue message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.ListValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.ListValue} ListValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListValue.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.ListValue() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + if (!(message.values && message.values.length)) + message.values = [] + message.values.push( + $root.google.protobuf.Value.decode( + reader, + reader.uint32() + ) + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a ListValue message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.ListValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.ListValue} ListValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListValue.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a ListValue message. + * @function verify + * @memberof google.protobuf.ListValue + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListValue.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.values != null && + message.hasOwnProperty('values') + ) { + if (!Array.isArray(message.values)) + return 'values: array expected' + for (var i = 0; i < message.values.length; ++i) { + var error = $root.google.protobuf.Value.verify( + message.values[i] + ) + if (error) return 'values.' + error + } + } + return null + } + + /** + * Creates a ListValue message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.ListValue + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.ListValue} ListValue + */ + ListValue.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.ListValue) + return object + var message = new $root.google.protobuf.ListValue() + if (object.values) { + if (!Array.isArray(object.values)) + throw TypeError( + '.google.protobuf.ListValue.values: array expected' + ) + message.values = [] + for (var i = 0; i < object.values.length; ++i) { + if (typeof object.values[i] !== 'object') + throw TypeError( + '.google.protobuf.ListValue.values: object expected' + ) + message.values[i] = $root.google.protobuf.Value.fromObject( + object.values[i] + ) + } + } + return message + } + + /** + * Creates a plain object from a ListValue message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.ListValue + * @static + * @param {google.protobuf.ListValue} message ListValue + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListValue.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) object.values = [] + if (message.values && message.values.length) { + object.values = [] + for (var j = 0; j < message.values.length; ++j) + object.values[j] = $root.google.protobuf.Value.toObject( + message.values[j], + options + ) + } + return object + } + + /** + * Converts this ListValue to JSON. + * @function toJSON + * @memberof google.protobuf.ListValue + * @instance + * @returns {Object.} JSON object + */ + ListValue.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return ListValue + })() + + protobuf.Duration = (function () { + /** + * Properties of a Duration. + * @memberof google.protobuf + * @interface IDuration + * @property {number|Long|null} [seconds] Duration seconds + * @property {number|null} [nanos] Duration nanos + */ + + /** + * Constructs a new Duration. + * @memberof google.protobuf + * @classdesc Represents a Duration. + * @implements IDuration + * @constructor + * @param {google.protobuf.IDuration=} [properties] Properties to set + */ + function Duration(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * Duration seconds. + * @member {number|Long} seconds + * @memberof google.protobuf.Duration + * @instance + */ + Duration.prototype.seconds = $util.Long + ? $util.Long.fromBits(0, 0, false) + : 0 + + /** + * Duration nanos. + * @member {number} nanos + * @memberof google.protobuf.Duration + * @instance + */ + Duration.prototype.nanos = 0 + + /** + * Creates a new Duration instance using the specified properties. + * @function create + * @memberof google.protobuf.Duration + * @static + * @param {google.protobuf.IDuration=} [properties] Properties to set + * @returns {google.protobuf.Duration} Duration instance + */ + Duration.create = function create(properties) { + return new Duration(properties) + } + + /** + * Encodes the specified Duration message. Does not implicitly {@link google.protobuf.Duration.verify|verify} messages. + * @function encode + * @memberof google.protobuf.Duration + * @static + * @param {google.protobuf.IDuration} message Duration message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Duration.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.seconds != null && + Object.hasOwnProperty.call(message, 'seconds') + ) + writer + .uint32(/* id 1, wireType 0 =*/ 8) + .int64(message.seconds) + if ( + message.nanos != null && + Object.hasOwnProperty.call(message, 'nanos') + ) + writer.uint32(/* id 2, wireType 0 =*/ 16).int32(message.nanos) + return writer + } + + /** + * Encodes the specified Duration message, length delimited. Does not implicitly {@link google.protobuf.Duration.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.Duration + * @static + * @param {google.protobuf.IDuration} message Duration message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Duration.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a Duration message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.Duration + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.Duration} Duration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Duration.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.Duration() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.seconds = reader.int64() + break + case 2: + message.nanos = reader.int32() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a Duration message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.Duration + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.Duration} Duration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Duration.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a Duration message. + * @function verify + * @memberof google.protobuf.Duration + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Duration.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.seconds != null && + message.hasOwnProperty('seconds') + ) + if ( + !$util.isInteger(message.seconds) && + !( + message.seconds && + $util.isInteger(message.seconds.low) && + $util.isInteger(message.seconds.high) + ) + ) + return 'seconds: integer|Long expected' + if (message.nanos != null && message.hasOwnProperty('nanos')) + if (!$util.isInteger(message.nanos)) + return 'nanos: integer expected' + return null + } + + /** + * Creates a Duration message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Duration + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Duration} Duration + */ + Duration.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Duration) + return object + var message = new $root.google.protobuf.Duration() + if (object.seconds != null) + if ($util.Long) + (message.seconds = $util.Long.fromValue( + object.seconds + )).unsigned = false + else if (typeof object.seconds === 'string') + message.seconds = parseInt(object.seconds, 10) + else if (typeof object.seconds === 'number') + message.seconds = object.seconds + else if (typeof object.seconds === 'object') + message.seconds = new $util.LongBits( + object.seconds.low >>> 0, + object.seconds.high >>> 0 + ).toNumber() + if (object.nanos != null) message.nanos = object.nanos | 0 + return message + } + + /** + * Creates a plain object from a Duration message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Duration + * @static + * @param {google.protobuf.Duration} message Duration + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Duration.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.defaults) { + if ($util.Long) { + var long = new $util.Long(0, 0, false) + object.seconds = + options.longs === String + ? long.toString() + : options.longs === Number + ? long.toNumber() + : long + } else object.seconds = options.longs === String ? '0' : 0 + object.nanos = 0 + } + if ( + message.seconds != null && + message.hasOwnProperty('seconds') + ) + if (typeof message.seconds === 'number') + object.seconds = + options.longs === String + ? String(message.seconds) + : message.seconds + else + object.seconds = + options.longs === String + ? $util.Long.prototype.toString.call(message.seconds) + : options.longs === Number + ? new $util.LongBits( + message.seconds.low >>> 0, + message.seconds.high >>> 0 + ).toNumber() + : message.seconds + if (message.nanos != null && message.hasOwnProperty('nanos')) + object.nanos = message.nanos + return object + } + + /** + * Converts this Duration to JSON. + * @function toJSON + * @memberof google.protobuf.Duration + * @instance + * @returns {Object.} JSON object + */ + Duration.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return Duration + })() + + protobuf.Any = (function () { + /** + * Properties of an Any. + * @memberof google.protobuf + * @interface IAny + * @property {string|null} [type_url] Any type_url + * @property {Uint8Array|null} [value] Any value + */ + + /** + * Constructs a new Any. + * @memberof google.protobuf + * @classdesc Represents an Any. + * @implements IAny + * @constructor + * @param {google.protobuf.IAny=} [properties] Properties to set + */ + function Any(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * Any type_url. + * @member {string} type_url + * @memberof google.protobuf.Any + * @instance + */ + Any.prototype.type_url = '' + + /** + * Any value. + * @member {Uint8Array} value + * @memberof google.protobuf.Any + * @instance + */ + Any.prototype.value = $util.newBuffer([]) + + /** + * Creates a new Any instance using the specified properties. + * @function create + * @memberof google.protobuf.Any + * @static + * @param {google.protobuf.IAny=} [properties] Properties to set + * @returns {google.protobuf.Any} Any instance + */ + Any.create = function create(properties) { + return new Any(properties) + } + + /** + * Encodes the specified Any message. Does not implicitly {@link google.protobuf.Any.verify|verify} messages. + * @function encode + * @memberof google.protobuf.Any + * @static + * @param {google.protobuf.IAny} message Any message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Any.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.type_url != null && + Object.hasOwnProperty.call(message, 'type_url') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.type_url) + if ( + message.value != null && + Object.hasOwnProperty.call(message, 'value') + ) + writer.uint32(/* id 2, wireType 2 =*/ 18).bytes(message.value) + return writer + } + + /** + * Encodes the specified Any message, length delimited. Does not implicitly {@link google.protobuf.Any.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.Any + * @static + * @param {google.protobuf.IAny} message Any message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Any.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an Any message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.Any + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.Any} Any + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Any.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.Any() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.type_url = reader.string() + break + case 2: + message.value = reader.bytes() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an Any message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.Any + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.Any} Any + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Any.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an Any message. + * @function verify + * @memberof google.protobuf.Any + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Any.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.type_url != null && + message.hasOwnProperty('type_url') + ) + if (!$util.isString(message.type_url)) + return 'type_url: string expected' + if (message.value != null && message.hasOwnProperty('value')) + if ( + !( + (message.value && + typeof message.value.length === 'number') || + $util.isString(message.value) + ) + ) + return 'value: buffer expected' + return null + } + + /** + * Creates an Any message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Any + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Any} Any + */ + Any.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Any) return object + var message = new $root.google.protobuf.Any() + if (object.type_url != null) + message.type_url = String(object.type_url) + if (object.value != null) + if (typeof object.value === 'string') + $util.base64.decode( + object.value, + (message.value = $util.newBuffer( + $util.base64.length(object.value) + )), + 0 + ) + else if (object.value.length) message.value = object.value + return message + } + + /** + * Creates a plain object from an Any message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Any + * @static + * @param {google.protobuf.Any} message Any + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Any.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.type_url = '' + if (options.bytes === String) object.value = '' + else { + object.value = [] + if (options.bytes !== Array) + object.value = $util.newBuffer(object.value) + } + } + if ( + message.type_url != null && + message.hasOwnProperty('type_url') + ) + object.type_url = message.type_url + if (message.value != null && message.hasOwnProperty('value')) + object.value = + options.bytes === String + ? $util.base64.encode( + message.value, + 0, + message.value.length + ) + : options.bytes === Array + ? Array.prototype.slice.call(message.value) + : message.value + return object + } + + /** + * Converts this Any to JSON. + * @function toJSON + * @memberof google.protobuf.Any + * @instance + * @returns {Object.} JSON object + */ + Any.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return Any + })() + + protobuf.Timestamp = (function () { + /** + * Properties of a Timestamp. + * @memberof google.protobuf + * @interface ITimestamp + * @property {number|Long|null} [seconds] Timestamp seconds + * @property {number|null} [nanos] Timestamp nanos + */ + + /** + * Constructs a new Timestamp. + * @memberof google.protobuf + * @classdesc Represents a Timestamp. + * @implements ITimestamp + * @constructor + * @param {google.protobuf.ITimestamp=} [properties] Properties to set + */ + function Timestamp(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * Timestamp seconds. + * @member {number|Long} seconds + * @memberof google.protobuf.Timestamp + * @instance + */ + Timestamp.prototype.seconds = $util.Long + ? $util.Long.fromBits(0, 0, false) + : 0 + + /** + * Timestamp nanos. + * @member {number} nanos + * @memberof google.protobuf.Timestamp + * @instance + */ + Timestamp.prototype.nanos = 0 + + /** + * Creates a new Timestamp instance using the specified properties. + * @function create + * @memberof google.protobuf.Timestamp + * @static + * @param {google.protobuf.ITimestamp=} [properties] Properties to set + * @returns {google.protobuf.Timestamp} Timestamp instance + */ + Timestamp.create = function create(properties) { + return new Timestamp(properties) + } + + /** + * Encodes the specified Timestamp message. Does not implicitly {@link google.protobuf.Timestamp.verify|verify} messages. + * @function encode + * @memberof google.protobuf.Timestamp + * @static + * @param {google.protobuf.ITimestamp} message Timestamp message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Timestamp.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.seconds != null && + Object.hasOwnProperty.call(message, 'seconds') + ) + writer + .uint32(/* id 1, wireType 0 =*/ 8) + .int64(message.seconds) + if ( + message.nanos != null && + Object.hasOwnProperty.call(message, 'nanos') + ) + writer.uint32(/* id 2, wireType 0 =*/ 16).int32(message.nanos) + return writer + } + + /** + * Encodes the specified Timestamp message, length delimited. Does not implicitly {@link google.protobuf.Timestamp.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.Timestamp + * @static + * @param {google.protobuf.ITimestamp} message Timestamp message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Timestamp.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a Timestamp message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.Timestamp + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.Timestamp} Timestamp + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Timestamp.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.Timestamp() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.seconds = reader.int64() + break + case 2: + message.nanos = reader.int32() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a Timestamp message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.Timestamp + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.Timestamp} Timestamp + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Timestamp.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a Timestamp message. + * @function verify + * @memberof google.protobuf.Timestamp + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Timestamp.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.seconds != null && + message.hasOwnProperty('seconds') + ) + if ( + !$util.isInteger(message.seconds) && + !( + message.seconds && + $util.isInteger(message.seconds.low) && + $util.isInteger(message.seconds.high) + ) + ) + return 'seconds: integer|Long expected' + if (message.nanos != null && message.hasOwnProperty('nanos')) + if (!$util.isInteger(message.nanos)) + return 'nanos: integer expected' + return null + } + + /** + * Creates a Timestamp message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Timestamp + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Timestamp} Timestamp + */ + Timestamp.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Timestamp) + return object + var message = new $root.google.protobuf.Timestamp() + if (object.seconds != null) + if ($util.Long) + (message.seconds = $util.Long.fromValue( + object.seconds + )).unsigned = false + else if (typeof object.seconds === 'string') + message.seconds = parseInt(object.seconds, 10) + else if (typeof object.seconds === 'number') + message.seconds = object.seconds + else if (typeof object.seconds === 'object') + message.seconds = new $util.LongBits( + object.seconds.low >>> 0, + object.seconds.high >>> 0 + ).toNumber() + if (object.nanos != null) message.nanos = object.nanos | 0 + return message + } + + /** + * Creates a plain object from a Timestamp message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Timestamp + * @static + * @param {google.protobuf.Timestamp} message Timestamp + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Timestamp.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.defaults) { + if ($util.Long) { + var long = new $util.Long(0, 0, false) + object.seconds = + options.longs === String + ? long.toString() + : options.longs === Number + ? long.toNumber() + : long + } else object.seconds = options.longs === String ? '0' : 0 + object.nanos = 0 + } + if ( + message.seconds != null && + message.hasOwnProperty('seconds') + ) + if (typeof message.seconds === 'number') + object.seconds = + options.longs === String + ? String(message.seconds) + : message.seconds + else + object.seconds = + options.longs === String + ? $util.Long.prototype.toString.call(message.seconds) + : options.longs === Number + ? new $util.LongBits( + message.seconds.low >>> 0, + message.seconds.high >>> 0 + ).toNumber() + : message.seconds + if (message.nanos != null && message.hasOwnProperty('nanos')) + object.nanos = message.nanos + return object + } + + /** + * Converts this Timestamp to JSON. + * @function toJSON + * @memberof google.protobuf.Timestamp + * @instance + * @returns {Object.} JSON object + */ + Timestamp.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return Timestamp + })() + + protobuf.Empty = (function () { + /** + * Properties of an Empty. + * @memberof google.protobuf + * @interface IEmpty + */ + + /** + * Constructs a new Empty. + * @memberof google.protobuf + * @classdesc Represents an Empty. + * @implements IEmpty + * @constructor + * @param {google.protobuf.IEmpty=} [properties] Properties to set + */ + function Empty(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * Creates a new Empty instance using the specified properties. + * @function create + * @memberof google.protobuf.Empty + * @static + * @param {google.protobuf.IEmpty=} [properties] Properties to set + * @returns {google.protobuf.Empty} Empty instance + */ + Empty.create = function create(properties) { + return new Empty(properties) + } + + /** + * Encodes the specified Empty message. Does not implicitly {@link google.protobuf.Empty.verify|verify} messages. + * @function encode + * @memberof google.protobuf.Empty + * @static + * @param {google.protobuf.IEmpty} message Empty message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Empty.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + return writer + } + + /** + * Encodes the specified Empty message, length delimited. Does not implicitly {@link google.protobuf.Empty.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.Empty + * @static + * @param {google.protobuf.IEmpty} message Empty message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Empty.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an Empty message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.Empty + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.Empty} Empty + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Empty.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.Empty() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an Empty message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.Empty + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.Empty} Empty + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Empty.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an Empty message. + * @function verify + * @memberof google.protobuf.Empty + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Empty.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + return null + } + + /** + * Creates an Empty message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Empty + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Empty} Empty + */ + Empty.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Empty) return object + return new $root.google.protobuf.Empty() + } + + /** + * Creates a plain object from an Empty message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Empty + * @static + * @param {google.protobuf.Empty} message Empty + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Empty.toObject = function toObject() { + return {} + } + + /** + * Converts this Empty to JSON. + * @function toJSON + * @memberof google.protobuf.Empty + * @instance + * @returns {Object.} JSON object + */ + Empty.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return Empty + })() + + protobuf.FieldMask = (function () { + /** + * Properties of a FieldMask. + * @memberof google.protobuf + * @interface IFieldMask + * @property {Array.|null} [paths] FieldMask paths + */ + + /** + * Constructs a new FieldMask. + * @memberof google.protobuf + * @classdesc Represents a FieldMask. + * @implements IFieldMask + * @constructor + * @param {google.protobuf.IFieldMask=} [properties] Properties to set + */ + function FieldMask(properties) { + this.paths = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * FieldMask paths. + * @member {Array.} paths + * @memberof google.protobuf.FieldMask + * @instance + */ + FieldMask.prototype.paths = $util.emptyArray + + /** + * Creates a new FieldMask instance using the specified properties. + * @function create + * @memberof google.protobuf.FieldMask + * @static + * @param {google.protobuf.IFieldMask=} [properties] Properties to set + * @returns {google.protobuf.FieldMask} FieldMask instance + */ + FieldMask.create = function create(properties) { + return new FieldMask(properties) + } + + /** + * Encodes the specified FieldMask message. Does not implicitly {@link google.protobuf.FieldMask.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FieldMask + * @static + * @param {google.protobuf.IFieldMask} message FieldMask message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FieldMask.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.paths != null && message.paths.length) + for (var i = 0; i < message.paths.length; ++i) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.paths[i]) + return writer + } + + /** + * Encodes the specified FieldMask message, length delimited. Does not implicitly {@link google.protobuf.FieldMask.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FieldMask + * @static + * @param {google.protobuf.IFieldMask} message FieldMask message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FieldMask.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a FieldMask message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FieldMask + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FieldMask} FieldMask + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FieldMask.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.FieldMask() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + if (!(message.paths && message.paths.length)) + message.paths = [] + message.paths.push(reader.string()) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a FieldMask message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FieldMask + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FieldMask} FieldMask + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FieldMask.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a FieldMask message. + * @function verify + * @memberof google.protobuf.FieldMask + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FieldMask.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.paths != null && message.hasOwnProperty('paths')) { + if (!Array.isArray(message.paths)) + return 'paths: array expected' + for (var i = 0; i < message.paths.length; ++i) + if (!$util.isString(message.paths[i])) + return 'paths: string[] expected' + } + return null + } + + /** + * Creates a FieldMask message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FieldMask + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FieldMask} FieldMask + */ + FieldMask.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FieldMask) + return object + var message = new $root.google.protobuf.FieldMask() + if (object.paths) { + if (!Array.isArray(object.paths)) + throw TypeError( + '.google.protobuf.FieldMask.paths: array expected' + ) + message.paths = [] + for (var i = 0; i < object.paths.length; ++i) + message.paths[i] = String(object.paths[i]) + } + return message + } + + /** + * Creates a plain object from a FieldMask message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FieldMask + * @static + * @param {google.protobuf.FieldMask} message FieldMask + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FieldMask.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) object.paths = [] + if (message.paths && message.paths.length) { + object.paths = [] + for (var j = 0; j < message.paths.length; ++j) + object.paths[j] = message.paths[j] + } + return object + } + + /** + * Converts this FieldMask to JSON. + * @function toJSON + * @memberof google.protobuf.FieldMask + * @instance + * @returns {Object.} JSON object + */ + FieldMask.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return FieldMask + })() + + return protobuf + })() + + google.rpc = (function () { + /** + * Namespace rpc. + * @memberof google + * @namespace + */ + var rpc = {} + + rpc.Status = (function () { + /** + * Properties of a Status. + * @memberof google.rpc + * @interface IStatus + * @property {number|null} [code] Status code + * @property {string|null} [message] Status message + * @property {Array.|null} [details] Status details + */ + + /** + * Constructs a new Status. + * @memberof google.rpc + * @classdesc Represents a Status. + * @implements IStatus + * @constructor + * @param {google.rpc.IStatus=} [properties] Properties to set + */ + function Status(properties) { + this.details = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * Status code. + * @member {number} code + * @memberof google.rpc.Status + * @instance + */ + Status.prototype.code = 0 + + /** + * Status message. + * @member {string} message + * @memberof google.rpc.Status + * @instance + */ + Status.prototype.message = '' + + /** + * Status details. + * @member {Array.} details + * @memberof google.rpc.Status + * @instance + */ + Status.prototype.details = $util.emptyArray + + /** + * Creates a new Status instance using the specified properties. + * @function create + * @memberof google.rpc.Status + * @static + * @param {google.rpc.IStatus=} [properties] Properties to set + * @returns {google.rpc.Status} Status instance + */ + Status.create = function create(properties) { + return new Status(properties) + } + + /** + * Encodes the specified Status message. Does not implicitly {@link google.rpc.Status.verify|verify} messages. + * @function encode + * @memberof google.rpc.Status + * @static + * @param {google.rpc.IStatus} message Status message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Status.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.code != null && + Object.hasOwnProperty.call(message, 'code') + ) + writer.uint32(/* id 1, wireType 0 =*/ 8).int32(message.code) + if ( + message.message != null && + Object.hasOwnProperty.call(message, 'message') + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.message) + if (message.details != null && message.details.length) + for (var i = 0; i < message.details.length; ++i) + $root.google.protobuf.Any.encode( + message.details[i], + writer.uint32(/* id 3, wireType 2 =*/ 26).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified Status message, length delimited. Does not implicitly {@link google.rpc.Status.verify|verify} messages. + * @function encodeDelimited + * @memberof google.rpc.Status + * @static + * @param {google.rpc.IStatus} message Status message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Status.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a Status message from the specified reader or buffer. + * @function decode + * @memberof google.rpc.Status + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.rpc.Status} Status + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Status.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.rpc.Status() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.code = reader.int32() + break + case 2: + message.message = reader.string() + break + case 3: + if (!(message.details && message.details.length)) + message.details = [] + message.details.push( + $root.google.protobuf.Any.decode( + reader, + reader.uint32() + ) + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a Status message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.rpc.Status + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.rpc.Status} Status + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Status.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a Status message. + * @function verify + * @memberof google.rpc.Status + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Status.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.code != null && message.hasOwnProperty('code')) + if (!$util.isInteger(message.code)) + return 'code: integer expected' + if ( + message.message != null && + message.hasOwnProperty('message') + ) + if (!$util.isString(message.message)) + return 'message: string expected' + if ( + message.details != null && + message.hasOwnProperty('details') + ) { + if (!Array.isArray(message.details)) + return 'details: array expected' + for (var i = 0; i < message.details.length; ++i) { + var error = $root.google.protobuf.Any.verify( + message.details[i] + ) + if (error) return 'details.' + error + } + } + return null + } + + /** + * Creates a Status message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.rpc.Status + * @static + * @param {Object.} object Plain object + * @returns {google.rpc.Status} Status + */ + Status.fromObject = function fromObject(object) { + if (object instanceof $root.google.rpc.Status) return object + var message = new $root.google.rpc.Status() + if (object.code != null) message.code = object.code | 0 + if (object.message != null) + message.message = String(object.message) + if (object.details) { + if (!Array.isArray(object.details)) + throw TypeError( + '.google.rpc.Status.details: array expected' + ) + message.details = [] + for (var i = 0; i < object.details.length; ++i) { + if (typeof object.details[i] !== 'object') + throw TypeError( + '.google.rpc.Status.details: object expected' + ) + message.details[i] = $root.google.protobuf.Any.fromObject( + object.details[i] + ) + } + } + return message + } + + /** + * Creates a plain object from a Status message. Also converts values to other types if specified. + * @function toObject + * @memberof google.rpc.Status + * @static + * @param {google.rpc.Status} message Status + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Status.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) object.details = [] + if (options.defaults) { + object.code = 0 + object.message = '' + } + if (message.code != null && message.hasOwnProperty('code')) + object.code = message.code + if ( + message.message != null && + message.hasOwnProperty('message') + ) + object.message = message.message + if (message.details && message.details.length) { + object.details = [] + for (var j = 0; j < message.details.length; ++j) + object.details[j] = $root.google.protobuf.Any.toObject( + message.details[j], + options + ) + } + return object + } + + /** + * Converts this Status to JSON. + * @function toJSON + * @memberof google.rpc.Status + * @instance + * @returns {Object.} JSON object + */ + Status.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return Status + })() + + return rpc + })() + + return google + })() + + return $root + }) + + /***/ + }, + + /***/ 97774: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /*! + * Copyright 2015 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.decodeValue = exports.structToObj = exports.ObjectToStructConverter = exports.objToStruct = void 0 + const is = __webpack_require__(98941) + function objToStruct(obj, options) { + return new ObjectToStructConverter(options).convert(obj) + } + exports.objToStruct = objToStruct + class ObjectToStructConverter { + /** + * A class that can be used to convert an object to a struct. Optionally this + * class can be used to erase/throw on circular references during conversion. + * + * @private + * + * @param {object=} options - Configuration object. + * @param {boolean} options.removeCircular - Remove circular references in the + * object with a placeholder string. (Default: `false`) + * @param {boolean} options.stringify - Stringify un-recognized types. (Default: + * `false`) + */ + constructor(options) { + options = options || {} + this.seenObjects = new Set() + this.removeCircular = options.removeCircular === true + this.stringify = options.stringify === true + } + /** + * Begin the conversion process from a JS object to an encoded gRPC Value + * message. + * + * @param {*} value - The input value. + * @return {object} - The encoded value. + * + * @example + * ObjectToStructConverter.convert({ + * aString: 'Hi' + * }); + * // { + * // fields: { + * // aString: { + * // stringValue: 'Hello!' + * // } + * // } + * // } + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + convert(obj) { + const convertedObject = { + fields: {} + } + this.seenObjects.add(obj) + for (const prop in obj) { + if (Object.prototype.hasOwnProperty.call(obj, prop)) { + const value = obj[prop] + if (is.undefined(value)) { + continue + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + convertedObject.fields[prop] = this.encodeValue_(value) + } + } + this.seenObjects.delete(obj) + return convertedObject + } + /** + * Convert a raw value to a type-denoted protobuf message-friendly object. + * + * @private + * + * @param {*} value - The input value. + * @return {*} - The encoded value. + * + * @example + * ObjectToStructConverter.encodeValue('Hi'); + * // { + * // stringValue: 'Hello!' + * // } + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + encodeValue_(value) { + let convertedValue + if (is.null(value)) { + convertedValue = { + nullValue: 0 + } + } else if (is.number(value)) { + convertedValue = { + numberValue: value + } + } else if (is.string(value)) { + convertedValue = { + stringValue: value + } + } else if (is.boolean(value)) { + convertedValue = { + boolValue: value + } + } else if (Buffer.isBuffer(value)) { + convertedValue = { + blobValue: value + } + } else if (is.object(value)) { + if (this.seenObjects.has(value)) { + // Circular reference. + if (!this.removeCircular) { + throw new Error( + [ + 'This object contains a circular reference. To automatically', + 'remove it, set the `removeCircular` option to true.' + ].join(' ') + ) + } + convertedValue = { + stringValue: '[Circular]' + } + } else { + convertedValue = { + structValue: this.convert(value) + } + } + } else if (is.array(value)) { + convertedValue = { + listValue: { + values: value.map(this.encodeValue_.bind(this)) + } + } + } else { + if (!this.stringify) { + throw new Error( + 'Value of type ' + typeof value + ' not recognized.' + ) + } + convertedValue = { + stringValue: String(value) + } + } + return convertedValue + } + } + exports.ObjectToStructConverter = ObjectToStructConverter + /** + * Condense a protobuf Struct into an object of only its values. + * + * @private + * + * @param {object} struct - A protobuf Struct message. + * @return {object} - The simplified object. + * + * @example + * GrpcService.structToObj_({ + * fields: { + * name: { + * kind: 'stringValue', + * stringValue: 'Stephen' + * } + * } + * }); + * // { + * // name: 'Stephen' + * // } + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function structToObj(struct) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const convertedObject = {} + for (const prop in struct.fields) { + // eslint-disable-next-line no-prototype-builtins + if (struct.fields.hasOwnProperty(prop)) { + const value = struct.fields[prop] + convertedObject[prop] = decodeValue(value) + } + } + return convertedObject + } + exports.structToObj = structToObj + /** + * Decode a protobuf Struct's value. + * + * @param {object} value - A Struct's Field message. + * @return {*} - The decoded value. + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function decodeValue(value) { + switch (value.kind) { + case 'structValue': { + return structToObj(value.structValue) + } + case 'nullValue': { + return null + } + case 'listValue': { + return value.listValue.values.map(decodeValue) + } + default: { + return value[value.kind] + } + } + } + exports.decodeValue = decodeValue + //# sourceMappingURL=common.js.map + + /***/ + }, + + /***/ 4710: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /*! + * Copyright 2015 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.Entry = void 0 + // eslint-disable-next-line @typescript-eslint/no-var-requires + const EventId = __webpack_require__(97271) + const extend = __webpack_require__(38171) + const is = __webpack_require__(98941) + const common_1 = __webpack_require__(97774) + const eventId = new EventId() + /** + * Create an entry object to define new data to insert into a log. + * + * Note, [Cloud Logging Quotas and limits]{@link https://cloud.google.com/logging/quotas} + * dictates that the maximum log entry size, including all + * [LogEntry Resource properties]{@link https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry}, + * cannot exceed _approximately_ 256 KB. + * + * @see [LogEntry JSON representation]{@link https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry} + * + * @class + * + * @param {?object} [metadata] See a + * [LogEntry + * Resource](https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry). + * @param {object|string} data The data to use as the value for this log + * entry. + * + * If providing an object, these value types are supported: + * - `String` + * - `Number` + * - `Boolean` + * - `Buffer` + * - `Object` + * - `Array` + * + * Any other types are stringified with `String(value)`. + * + * @example + * const {Logging} = require('@google-cloud/logging'); + * const logging = new Logging(); + * const syslog = logging.log('syslog'); + * + * const metadata = { + * resource: { + * type: 'gce_instance', + * labels: { + * zone: 'global', + * instance_id: '3' + * } + * } + * }; + * + * const entry = syslog.entry(metadata, { + * delegate: 'my_username' + * }); + * + * syslog.alert(entry, (err, apiResponse) => { + * if (!err) { + * // Log entry inserted successfully. + * } + * }); + * + * //- + * // You will also receive `Entry` objects when using + * // Logging#getEntries() and Log#getEntries(). + * //- + * logging.getEntries((err, entries) => { + * if (!err) { + * // entries[0].data = The data value from the log entry. + * } + * }); + */ + class Entry { + constructor(metadata, data) { + /** + * @name Entry#metadata + * @type {object} + * @property {Date} timestamp + * @property {number} insertId + */ + this.metadata = extend( + { + timestamp: new Date() + }, + metadata + ) + // JavaScript date has a very coarse granularity (millisecond), which makes + // it quite likely that multiple log entries would have the same timestamp. + // The Logging API doesn't guarantee to preserve insertion order for entries + // with the same timestamp. The service does use `insertId` as a secondary + // ordering for entries with the same timestamp. `insertId` needs to be + // globally unique (within the project) however. + // + // We use a globally unique monotonically increasing EventId as the + // insertId. + this.metadata.insertId = this.metadata.insertId || eventId.new() + /** + * @name Entry#data + * @type {object} + */ + this.data = data + } + /** + * Serialize an entry to the format the API expects. + * + * @param {object} [options] Configuration object. + * @param {boolean} [options.removeCircular] Replace circular references in an + * object with a string value, `[Circular]`. + */ + toJSON(options = {}) { + var _a + const entry = extend(true, {}, this.metadata) + // Format log message + if (is.object(this.data)) { + entry.jsonPayload = common_1.objToStruct(this.data, { + removeCircular: !!options.removeCircular, + stringify: true + }) + } else if (is.string(this.data)) { + entry.textPayload = this.data + } + // Format log timestamp + if (is.date(entry.timestamp)) { + const seconds = entry.timestamp.getTime() / 1000 + const secondsRounded = Math.floor(seconds) + entry.timestamp = { + seconds: secondsRounded, + nanos: Math.floor((seconds - secondsRounded) * 1e9) + } + } else if (is.string(entry.timestamp)) { + // Convert RFC3339 "Zulu" timestamp into a format that can be parsed to Date + const zuluTime = entry.timestamp + const ms = Date.parse(zuluTime.split(/[.,Z]/)[0] + 'Z') + const reNano = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.(\d{0,9})Z$/ + const nanoSecs = + (_a = zuluTime.match(reNano)) === null || _a === void 0 + ? void 0 + : _a[1] + entry.timestamp = { + seconds: ms ? Math.floor(ms / 1000) : 0, + nanos: nanoSecs ? Number(nanoSecs.padEnd(9, '0')) : 0 + } + } + return entry + } + /** + * Create an Entry object from an API response, such as `entries:list`. + * + * @private + * + * @param {object} entry An API representation of an entry. See a + * [LogEntry](https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry). + * @returns {Entry} + */ + static fromApiResponse_(entry) { + let data = entry[entry.payload] + if (entry.payload === 'jsonPayload') { + data = common_1.structToObj(data) + } + const serializedEntry = new Entry(entry, data) + if (entry.timestamp) { + let ms = Number(entry.timestamp.seconds) * 1000 + ms += Number(entry.timestamp.nanos) / 1e6 + serializedEntry.metadata.timestamp = new Date(ms) + } + return serializedEntry + } + } + exports.Entry = Entry + //# sourceMappingURL=entry.js.map + + /***/ + }, + + /***/ 9341: /***/ (module, exports, __webpack_require__) => { + 'use strict' + + /*! + * Copyright 2015 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.v2 = exports.protos = exports.Logging = exports.Sink = exports.Severity = exports.Log = exports.Entry = exports.detectServiceContext = exports.middleware = void 0 + const common_1 = __webpack_require__(54777) + const paginator_1 = __webpack_require__(46412) + const projectify_1 = __webpack_require__(3497) + const promisify_1 = __webpack_require__(19203) + const arrify = __webpack_require__(61546) + const extend = __webpack_require__(38171) + const gax = __webpack_require__(12263) + // eslint-disable-next-line @typescript-eslint/no-var-requires + const pumpify = __webpack_require__(40212) + const streamEvents = __webpack_require__(79626) + const through = __webpack_require__(18180) + const middleware = __webpack_require__(83870) + exports.middleware = middleware + const metadata_1 = __webpack_require__(19373) + Object.defineProperty(exports, 'detectServiceContext', { + enumerable: true, + get: function () { + return metadata_1.detectServiceContext + } + }) + const version = __webpack_require__(87989) /* .version */.i8 + // eslint-disable-next-line @typescript-eslint/no-var-requires + const v2 = __webpack_require__(5863) + exports.v2 = v2 + const entry_1 = __webpack_require__(4710) + Object.defineProperty(exports, 'Entry', { + enumerable: true, + get: function () { + return entry_1.Entry + } + }) + const log_1 = __webpack_require__(33259) + Object.defineProperty(exports, 'Log', { + enumerable: true, + get: function () { + return log_1.Log + } + }) + Object.defineProperty(exports, 'Severity', { + enumerable: true, + get: function () { + return log_1.Severity + } + }) + const sink_1 = __webpack_require__(5764) + Object.defineProperty(exports, 'Sink', { + enumerable: true, + get: function () { + return sink_1.Sink + } + }) + /** + * @typedef {object} ClientConfig + * @property {string} [projectId] The project ID from the Google Developer's + * Console, e.g. 'grape-spaceship-123'. We will also check the environment + * variable `GCLOUD_PROJECT` for your project ID. If your app is running in + * an environment which supports {@link + * https://cloud.google.com/docs/authentication/production#providing_credentials_to_your_application + * Application Default Credentials}, your project ID will be detected + * automatically. + * @property {string} [keyFilename] Full path to the a .json, .pem, or .p12 key + * downloaded from the Google Developers Console. If you provide a path to a + * JSON file, the `projectId` option above is not necessary. NOTE: .pem and + * .p12 require you to specify the `email` option as well. + * @property {string} [email] Account email address. Required when using a .pem + * or .p12 keyFilename. + * @property {object} [credentials] Credentials object. + * @property {string} [credentials.client_email] + * @property {string} [credentials.private_key] + * @property {boolean} [autoRetry=true] Automatically retry requests if the + * response is related to rate limits or certain intermittent server errors. + * We will exponentially backoff subsequent requests by default. + * @property {number} [maxRetries=3] Maximum number of automatic retries + * attempted before returning the error. + * @property {Constructor} [promise] Custom promise module to use instead of + * native Promises. + */ + /** + * [Stackdriver Logging](https://cloud.google.com/logging/docs) allows you to + * store, search, analyze, monitor, and alert on log data and events from Google + * Cloud Platform and Amazon Web Services (AWS). + * + * @class + * + * @see [What is Stackdriver Logging?](https://cloud.google.com/logging/docs) + * @see [Introduction to the Stackdriver Logging API](https://cloud.google.com/logging/docs/api) + * @see [Logging to Stackdriver from Bunyan](https://www.npmjs.com/package/@google-cloud/logging-bunyan) + * @see [Logging to Stackdriver from Winston](https://www.npmjs.com/package/@google-cloud/logging-winston) + * + * @param {ClientConfig} [options] Configuration options. + * + * @example Import the client library + * const {Logging} = require('@google-cloud/logging'); + * + * @example Create a client that uses Application Default Credentials (ADC): + * const logging = new Logging(); + * + * @example Create a client with explicitcredentials: + * const logging = new Logging({ projectId: + * 'your-project-id', keyFilename: '/path/to/keyfile.json' + * }); + * + * @example include:samples/quickstart.js + * region_tag:logging_quickstart + * Full quickstart example: + */ + class Logging { + constructor(options) { + // Determine what scopes are needed. + // It is the union of the scopes on all three clients. + const scopes = [] + const clientClasses = [ + v2.ConfigServiceV2Client, + v2.LoggingServiceV2Client, + v2.MetricsServiceV2Client + ] + for (const clientClass of clientClasses) { + for (const scope of clientClass.scopes) { + if (scopes.indexOf(scope) === -1) { + scopes.push(scope) + } + } + } + const options_ = extend( + { + libName: 'gccl', + libVersion: version, + scopes + }, + options + ) + this.api = {} + this.auth = new gax.GoogleAuth(options_) + this.options = options_ + this.projectId = this.options.projectId || '{{projectId}}' + this.configService = new v2.ConfigServiceV2Client(this.options) + this.loggingService = new v2.LoggingServiceV2Client(this.options) + } + /** + * Config to set for the sink. Not all available options are listed here, see + * the [Sink + * resource](https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks#LogSink) + * definition for full details. + * + * @typedef {object} CreateSinkRequest + * @property {object} [gaxOptions] Request configuration options, outlined + * here: https://googleapis.github.io/gax-nodejs/global.html#CallOptions. + * @property {Bucket|Dataset|Topic} [destination] The destination. The proper ACL + * scopes will be granted to the provided destination. Can be one of: + * {@link + * https://cloud.google.com/nodejs/docs/reference/storage/latest/Bucket + * Bucket}, + * {@link + * https://cloud.google.com/nodejs/docs/reference/bigquery/latest/Dataset + * Dataset}, or {@link + * https://cloud.google.com/nodejs/docs/reference/pubsub/latest/Topic Topic} + * @property {string} [filter] An advanced logs filter. Only log entries + * matching the filter are written. + * @property {string} [uniqueWriterIdentity] Determines the kind of IAM + * identity returned as `writerIdentity` in the new sink. See {@link https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/create#query-parameters}. + */ + /** + * @typedef {array} CreateSinkResponse + * @property {Sink} 0 The new {@link Sink}. + * @property {object} 1 The full API response. + */ + /** + * @callback CreateSinkCallback + * @param {?Error} err Request error, if any. + * @param {Sink} sink The new {@link Sink}. + * @param {object} apiResponse The full API response. + */ + // jscs:disable maximumLineLength + /** + * Create a sink. + * + * @see [Sink Overview]{@link https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks} + * @see [Advanced Logs Filters]{@link https://cloud.google.com/logging/docs/view/advanced_filters} + * @see [projects.sinks.create API Documentation]{@link https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/create} + * + * @param {string} name Name of the sink. + * @param {CreateSinkRequest} config Config to set for the sink. + * @param {CreateSinkCallback} [callback] Callback function. + * @returns {Promise} + * @throws {Error} If a name is not provided. + * @throws {Error} if a config object is not provided. + * @see Sink#create + * + * @example + * const {Storage} = require('@google-cloud/storage'); + * const storage = new Storage({ + * projectId: 'grape-spaceship-123' + * }); + * const {Logging} = require('@google-cloud/logging'); + * const logging = new Logging(); + * + * const config = { + * destination: storage.bucket('logging-bucket'), + * filter: 'severity = ALERT' + * }; + * + * function callback(err, sink, apiResponse) { + * // `sink` is a Sink object. + * } + * + * logging.createSink('new-sink-name', config, callback); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * logging.createSink('new-sink-name', config).then(data => { + * const sink = data[0]; + * const apiResponse = data[1]; + * }); + * + * @example include:samples/sinks.js + * region_tag:logging_create_sink + * Another example: + */ + async createSink(name, config) { + if (typeof name !== 'string') { + throw new Error('A sink name must be provided.') + } + if (typeof config !== 'object') { + throw new Error('A sink configuration object must be provided.') + } + if ( + common_1.util.isCustomType(config.destination, 'bigquery/dataset') + ) { + await this.setAclForDataset_(config) + } + if (common_1.util.isCustomType(config.destination, 'pubsub/topic')) { + await this.setAclForTopic_(config) + } + if ( + common_1.util.isCustomType(config.destination, 'storage/bucket') + ) { + await this.setAclForBucket_(config) + } + const reqOpts = { + parent: 'projects/' + this.projectId, + sink: extend({}, config, { name }), + uniqueWriterIdentity: config.uniqueWriterIdentity + } + delete reqOpts.sink.gaxOptions + delete reqOpts.sink.uniqueWriterIdentity + await this.setProjectId(reqOpts) + const [resp] = await this.configService.createSink( + reqOpts, + config.gaxOptions + ) + const sink = this.sink(resp.name) + sink.metadata = resp + return [sink, resp] + } + /** + * Create an entry object. + * + * Using this method will not itself make any API requests. You will use + * the object returned in other API calls, such as + * {@link Log#write}. + * + * Note, [Cloud Logging Quotas and limits]{@link https://cloud.google.com/logging/quotas} + * dictates that the maximum log entry size, including all + * [LogEntry Resource properties]{@link https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry}, + * cannot exceed _approximately_ 256 KB. + * + * @see [LogEntry JSON representation]{@link https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry} + * + * @param {?object|?string} [resource] See a + * [Monitored + * Resource](https://cloud.google.com/logging/docs/reference/v2/rest/v2/MonitoredResource). + * @param {object|string} data The data to use as the value for this log + * entry. + * @returns {Entry} + * + * @example + * const {Logging} = require('@google-cloud/logging'); + * const logging = new Logging(); + * + * const resource = { + * type: 'gce_instance', + * labels: { + * zone: 'global', + * instance_id: '3' + * } + * }; + * + * const entry = logging.entry(resource, { + * delegate: 'my_username' + * }); + * + * entry.toJSON(); + * // { + * // resource: { + * // type: 'gce_instance', + * // labels: { + * // zone: 'global', + * // instance_id: '3' + * // } + * // }, + * // jsonPayload: { + * // delegate: 'my_username' + * // } + * // } + */ + entry(resource, data) { + return new entry_1.Entry(resource, data) + } + /** + * Query object for listing entries. + * + * @typedef {object} GetEntriesRequest + * @property {boolean} [autoPaginate=true] Have pagination handled + * automatically. + * @property {string} [filter] An + * [advanced logs + * filter](https://cloud.google.com/logging/docs/view/advanced_filters). An + * empty filter matches all log entries. + * @property {object} [gaxOptions] Request configuration options, outlined + * here: https://googleapis.github.io/gax-nodejs/global.html#CallOptions. + * @property {string} [log] A name of the log specifying to pnly return + * entries from this log. + * @property {number} [maxApiCalls] Maximum number of API calls to make. + * @property {number} [maxResults] Maximum number of items plus prefixes to + * return. + * @property {string} [orderBy] How the results should be sorted, + * `timestamp asc` (oldest first) and `timestamp desc` (newest first, + * **default**). + * @property {number} [pageSize] Maximum number of logs to return. + * @property {string} [pageToken] A previously-returned page token + * representing part of the larger set of results to view. + */ + /** + * @typedef {array} GetEntriesResponse + * @property {Entry[]} 0 Array of {@link Entry} instances. + * @property {object} 1 The full API response. + */ + /** + * @callback GetEntriesCallback + * @param {?Error} err Request error, if any. + * @param {Entry[]} entries Array of {@link Entry} instances. + * @param {object} apiResponse The full API response. + */ + /** + * List the entries in your logs. + * + * @see [entries.list API Documentation]{@link https://cloud.google.com/logging/docs/reference/v2/rest/v2/entries/list} + * + * @param {GetEntriesRequest} [query] Query object for listing entries. + * @param {GetEntriesCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const {Logging} = require('@google-cloud/logging'); + * const logging = new Logging(); + * + * logging.getEntries((err, entries) => { + * // `entries` is an array of Stackdriver Logging entry objects. + * // See the `data` property to read the data from the entry. + * }); + * + * //- + * // To control how many API requests are made and page through the results + * // manually, set `autoPaginate` to `false`. + * //- + * function callback(err, entries, nextQuery, apiResponse) { + * if (nextQuery) { + * // More results exist. + * logging.getEntries(nextQuery, callback); + * } + * } + * + * logging.getEntries({ + * autoPaginate: false + * }, callback); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * logging.getEntries().then(data => { + * const entries = data[0]; + * }); + * + * @example include:samples/logs.js + * region_tag:logging_list_log_entries + * Another example: + * + * @example include:samples/logs.js + * region_tag:logging_list_log_entries_advanced + * Another example: + */ + async getEntries(opts) { + const options = opts ? opts : {} + const reqOpts = extend( + { + orderBy: 'timestamp desc' + }, + options + ) + reqOpts.resourceNames = arrify(reqOpts.resourceNames) + this.projectId = await this.auth.getProjectId() + const resourceName = 'projects/' + this.projectId + if (reqOpts.resourceNames.indexOf(resourceName) === -1) { + reqOpts.resourceNames.push(resourceName) + } + delete reqOpts.autoPaginate + delete reqOpts.gaxOptions + const gaxOptions = extend( + { + autoPaginate: options.autoPaginate + }, + options.gaxOptions + ) + const resp = await this.loggingService.listLogEntries( + reqOpts, + gaxOptions + ) + const [entries] = resp + if (entries) { + resp[0] = entries.map(entry_1.Entry.fromApiResponse_) + } + return resp + } + /** + * List the {@link Entry} objects in your logs as a readable object + * stream. + * + * @method Logging#getEntriesStream + * @param {GetEntriesRequest} [query] Query object for listing entries. + * @returns {ReadableStream} A readable stream that emits {@link Entry} + * instances. + * + * @example + * const {Logging} = require('@google-cloud/logging'); + * const logging = new Logging(); + * + * logging.getEntriesStream() + * .on('error', console.error) + * .on('data', entry => { + * // `entry` is a Stackdriver Logging entry object. + * // See the `data` property to read the data from the entry. + * }) + * .on('end', function() { + * // All entries retrieved. + * }); + * + * //- + * // If you anticipate many results, you can end a stream early to prevent + * // unnecessary processing and API requests. + * //- + * logging.getEntriesStream() + * .on('data', function(entry) { + * this.end(); + * }); + */ + getEntriesStream(options = {}) { + let requestStream + const userStream = streamEvents(pumpify.obj()) + userStream.abort = () => { + if (requestStream) { + requestStream.abort() + } + } + const toEntryStream = through.obj((entry, _, next) => { + next(null, entry_1.Entry.fromApiResponse_(entry)) + }) + userStream.once('reading', () => { + this.auth.getProjectId().then(projectId => { + this.projectId = projectId + if (options.log) { + if (options.filter) { + options.filter = `(${ + options.filter + }) AND logName="${log_1.Log.formatName_( + this.projectId, + options.log + )}"` + } else { + options.filter = `logName="${log_1.Log.formatName_( + this.projectId, + options.log + )}"` + } + delete options.log + } + const reqOpts = extend( + { + orderBy: 'timestamp desc' + }, + options + ) + reqOpts.resourceNames = arrify(reqOpts.resourceNames) + reqOpts.resourceNames.push(`projects/${this.projectId}`) + delete reqOpts.autoPaginate + delete reqOpts.gaxOptions + const gaxOptions = extend( + { + autoPaginate: options.autoPaginate + }, + options.gaxOptions + ) + let gaxStream + requestStream = streamEvents(through.obj()) + requestStream.abort = () => { + if (gaxStream && gaxStream.cancel) { + gaxStream.cancel() + } + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + if (!global.GCLOUD_SANDBOX_ENV) { + requestStream.once('reading', () => { + try { + gaxStream = this.loggingService.listLogEntriesStream( + reqOpts, + gaxOptions + ) + } catch (error) { + requestStream.destroy(error) + return + } + gaxStream + .on('error', err => { + requestStream.destroy(err) + }) + .pipe(requestStream) + return + }) + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + userStream.setPipeline(requestStream, toEntryStream) + }) + }) + return userStream + } + /** + * Query object for listing entries. + * + * @typedef {object} GetLogsRequest + * @property {boolean} [autoPaginate=true] Have pagination handled + * automatically. + * @property {object} [gaxOptions] Request configuration options, outlined + * here: https://googleapis.github.io/gax-nodejs/global.html#CallOptions. + * @property {number} [maxApiCalls] Maximum number of API calls to make. + * @property {number} [maxResults] Maximum number of items plus prefixes to + * return. + * @property {number} [pageSize] Maximum number of logs to return. + * @property {string} [pageToken] A previously-returned page token + * representing part of the larger set of results to view. + */ + /** + * @typedef {array} GetLogsResponse + * @property {Log[]} 0 Array of {@link Log} instances. + * @property {object} 1 The full API response. + */ + /** + * @callback GetLogsCallback + * @param {?Error} err Request error, if any. + * @param {Log[]} logs Array of {@link Log} instances. + * @param {object} apiResponse The full API response. + */ + /** + * List the entries in your logs. + * + * @see [logs.list API Documentation]{@link https://cloud.google.com/logging/docs/reference/v2/rest/v2/logs/list} + * + * @param {GetLogsRequest} [query] Query object for listing entries. + * @param {GetLogsCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const {Logging} = require('@google-cloud/logging'); + * const logging = new Logging(); + * + * logging.getLogs((err, logs) => { + * // `logs` is an array of Stackdriver Logging log objects. + * }); + * + * //- + * // To control how many API requests are made and page through the results + * // manually, set `autoPaginate` to `false`. + * //- + * function callback(err, entries, nextQuery, apiResponse) { + * if (nextQuery) { + * // More results exist. + * logging.getLogs(nextQuery, callback); + * } + * } + * + * logging.getLogs({ + * autoPaginate: false + * }, callback); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * logging.getLogs().then(data => { + * const entries = data[0]; + * }); + * + * @example include:samples/logs.js + * region_tag:logging_list_logs + * Another example: + */ + async getLogs(opts) { + const options = opts ? opts : {} + this.projectId = await this.auth.getProjectId() + const reqOpts = extend({}, options, { + parent: 'projects/' + this.projectId + }) + delete reqOpts.autoPaginate + delete reqOpts.gaxOptions + const gaxOptions = extend( + { + autoPaginate: options.autoPaginate + }, + options.gaxOptions + ) + const resp = await this.loggingService.listLogs(reqOpts, gaxOptions) + const [logs] = resp + if (logs) { + resp[0] = logs.map(logName => this.log(logName)) + } + return resp + } + /** + * List the {@link Log} objects in your project as a readable object stream. + * + * @method Logging#getLogsStream + * @param {GetLogsRequest} [query] Query object for listing entries. + * @returns {ReadableStream} A readable stream that emits {@link Log} + * instances. + * + * @example + * const {Logging} = require('@google-cloud/logging'); + * const logging = new Logging(); + * + * logging.getLogsStream() + * .on('error', console.error) + * .on('data', log => { + * // `log` is a Stackdriver Logging log object. + * }) + * .on('end', function() { + * // All logs retrieved. + * }); + * + * //- + * // If you anticipate many results, you can end a stream early to prevent + * // unnecessary processing and API requests. + * //- + * logging.getLogsStream() + * .on('data', log => { + * this.end(); + * }); + */ + getLogsStream(options = {}) { + options = options || {} + let requestStream + const userStream = streamEvents(pumpify.obj()) + userStream.abort = () => { + if (requestStream) { + requestStream.abort() + } + } + const toLogStream = through.obj((logName, _, next) => { + next(null, this.log(logName)) + }) + userStream.once('reading', () => { + this.auth.getProjectId().then(projectId => { + this.projectId = projectId + const reqOpts = extend({}, options, { + parent: 'projects/' + this.projectId + }) + delete reqOpts.gaxOptions + const gaxOptions = extend( + { + autoPaginate: options.autoPaginate + }, + options.gaxOptions + ) + let gaxStream + requestStream = streamEvents(through.obj()) + requestStream.abort = () => { + if (gaxStream && gaxStream.cancel) { + gaxStream.cancel() + } + } + requestStream.once('reading', () => { + try { + gaxStream = this.loggingService.listLogsStream( + reqOpts, + gaxOptions + ) + } catch (error) { + requestStream.destroy(error) + return + } + gaxStream + .on('error', err => { + requestStream.destroy(err) + }) + .pipe(requestStream) + return + }) + // eslint-disable-next-line @typescript-eslint/no-explicit-any + userStream.setPipeline(requestStream, toLogStream) + }) + }) + return userStream + } + /** + * Query object for listing sinks. + * + * @typedef {object} GetSinksRequest + * @property {boolean} [autoPaginate=true] Have pagination handled + * automatically. + * @property {object} [gaxOptions] Request configuration options, outlined + * here: https://googleapis.github.io/gax-nodejs/global.html#CallOptions. + * @property {number} [maxApiCalls] Maximum number of API calls to make. + * @property {number} [maxResults] Maximum number of items plus prefixes to + * return. + * @property {number} [pageSize] Maximum number of logs to return. + * @property {string} [pageToken] A previously-returned page token + * representing part of the larger set of results to view. + */ + /** + * @typedef {array} GetSinksResponse + * @property {Sink[]} 0 Array of {@link Sink} instances. + * @property {object} 1 The full API response. + */ + /** + * @callback GetSinksCallback + * @param {?Error} err Request error, if any. + * @param {Sink[]} sinks Array of {@link Sink} instances. + * @param {object} apiResponse The full API response. + */ + /** + * Get the sinks associated with this project. + * + * @see [projects.sinks.list API Documentation]{@link https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/list} + * + * @param {GetSinksRequest} [query] Query object for listing sinks. + * @param {GetSinksCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const {Logging} = require('@google-cloud/logging'); + * const logging = new Logging(); + * + * logging.getSinks((err, sinks) => { + * // sinks is an array of Sink objects. + * }); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * logging.getSinks().then(data => { + * const sinks = data[0]; + * }); + * + * @example include:samples/sinks.js + * region_tag:logging_list_sinks + * Another example: + */ + async getSinks(opts) { + const options = opts ? opts : {} + this.projectId = await this.auth.getProjectId() + const reqOpts = extend({}, options, { + parent: 'projects/' + this.projectId + }) + delete reqOpts.autoPaginate + delete reqOpts.gaxOptions + const gaxOptions = extend( + { + autoPaginate: options.autoPaginate + }, + options.gaxOptions + ) + const resp = await this.configService.listSinks(reqOpts, gaxOptions) + const [sinks] = resp + if (sinks) { + resp[0] = sinks.map(sink => { + const sinkInstance = this.sink(sink.name) + sinkInstance.metadata = sink + return sinkInstance + }) + } + return resp + } + /** + * Get the {@link Sink} objects associated with this project as a + * readable object stream. + * + * @method Logging#getSinksStream + * @param {GetSinksRequest} [query] Query object for listing sinks. + * @returns {ReadableStream} A readable stream that emits {@link Sink} + * instances. + * + * @example + * const {Logging} = require('@google-cloud/logging'); + * const logging = new Logging(); + * + * logging.getSinksStream() + * .on('error', console.error) + * .on('data', sink => { + * // `sink` is a Sink object. + * }) + * .on('end', function() { + * // All sinks retrieved. + * }); + * + * //- + * // If you anticipate many results, you can end a stream early to prevent + * // unnecessary processing and API requests. + * //- + * logging.getSinksStream() + * .on('data', function(sink) { + * this.end(); + * }); + */ + getSinksStream(options) { + // eslint-disable-next-line @typescript-eslint/no-this-alias + const self = this + options = options || {} + let requestStream + const userStream = streamEvents(pumpify.obj()) + userStream.abort = () => { + if (requestStream) { + requestStream.abort() + } + } + const toSinkStream = through.obj((sink, _, next) => { + const sinkInstance = self.sink(sink.name) + sinkInstance.metadata = sink + next(null, sinkInstance) + }) + userStream.once('reading', () => { + this.auth.getProjectId().then(projectId => { + this.projectId = projectId + const reqOpts = extend({}, options, { + parent: 'projects/' + self.projectId + }) + delete reqOpts.gaxOptions + const gaxOptions = extend( + { + autoPaginate: options.autoPaginate + }, + options.gaxOptions + ) + let gaxStream + requestStream = streamEvents(through.obj()) + requestStream.abort = () => { + if (gaxStream && gaxStream.cancel) { + gaxStream.cancel() + } + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + if (!global.GCLOUD_SANDBOX_ENV) { + requestStream.once('reading', () => { + try { + gaxStream = this.configService.listSinksStream( + reqOpts, + gaxOptions + ) + } catch (error) { + requestStream.destroy(error) + return + } + gaxStream + .on('error', err => { + requestStream.destroy(err) + }) + .pipe(requestStream) + return + }) + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + userStream.setPipeline(requestStream, toSinkStream) + }) + }) + return userStream + } + /** + * Get a reference to a Stackdriver Logging log. + * + * @see [Log Overview]{@link https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.logs} + * + * @param {string} name Name of the existing log. + * @param {object} [options] Configuration object. + * @param {boolean} [options.removeCircular] Replace circular references in + * logged objects with a string value, `[Circular]`. (Default: false) + * @returns {Log} + * + * @example + * const {Logging} = require('@google-cloud/logging'); + * const logging = new Logging(); + * const log = logging.log('my-log'); + */ + log(name, options) { + return new log_1.Log(this, name, options) + } + /** + * Get a reference to a Stackdriver Logging sink. + * + * @see [Sink Overview]{@link https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks} + * + * @param {string} name Name of the existing sink. + * @returns {Sink} + * + * @example + * const {Logging} = require('@google-cloud/logging'); + * const logging = new Logging(); + * const sink = logging.sink('my-sink'); + */ + sink(name) { + return new sink_1.Sink(this, name) + } + /** + * Funnel all API requests through this method, to be sure we have a project + * ID. + * + * @param {object} config Configuration object. + * @param {object} config.gaxOpts GAX options. + * @param {function} config.method The gax method to call. + * @param {object} config.reqOpts Request options. + * @param {function} [callback] Callback function. + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + request(config, callback) { + // eslint-disable-next-line @typescript-eslint/no-this-alias + const self = this + const isStreamMode = !callback + let gaxStream + let stream + if (isStreamMode) { + stream = streamEvents(through.obj()) + stream.abort = () => { + if (gaxStream && gaxStream.cancel) { + gaxStream.cancel() + } + } + stream.once('reading', makeRequestStream) + } else { + makeRequestCallback() + } + function prepareGaxRequest(callback) { + self.auth.getProjectId((err, projectId) => { + if (err) { + callback(err) + return + } + self.projectId = projectId + let gaxClient = self.api[config.client] + if (!gaxClient) { + // Lazily instantiate client. + gaxClient = new v2[config.client](self.options) + self.api[config.client] = gaxClient + } + let reqOpts = extend(true, {}, config.reqOpts) + reqOpts = projectify_1.replaceProjectIdToken(reqOpts, projectId) + const requestFn = gaxClient[config.method].bind( + gaxClient, + reqOpts, + config.gaxOpts + ) + callback(null, requestFn) + }) + } + function makeRequestCallback() { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + if (global.GCLOUD_SANDBOX_ENV) { + return + } + prepareGaxRequest((err, requestFn) => { + if (err) { + callback(err) + return + } + requestFn(callback) + }) + } + function makeRequestStream() { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + if (global.GCLOUD_SANDBOX_ENV) { + return through.obj() + } + prepareGaxRequest((err, requestFn) => { + if (err) { + stream.destroy(err) + return + } + gaxStream = requestFn() + gaxStream + .on('error', err => { + stream.destroy(err) + }) + .pipe(stream) + }) + return + } + return stream + } + /** + * This method is called when creating a sink with a Bucket destination. The + * bucket must first grant proper ACL access to the Stackdriver Logging + * account. + * + * The parameters are the same as what {@link Logging#createSink} accepts. + * + * @private + */ + async setAclForBucket_(config) { + const bucket = config.destination + // eslint-disable-next-line @typescript-eslint/no-explicit-any + await bucket.acl.owners.addGroup('cloud-logs@google.com') + config.destination = 'storage.googleapis.com/' + bucket.name + } + /** + * This method is called when creating a sink with a Dataset destination. The + * dataset must first grant proper ACL access to the Stackdriver Logging + * account. + * + * The parameters are the same as what {@link Logging#createSink} accepts. + * + * @private + */ + async setAclForDataset_(config) { + const dataset = config.destination + const [metadata] = await dataset.getMetadata() + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const access = [].slice.call(arrify(metadata.access)) + access.push({ + role: 'WRITER', + groupByEmail: 'cloud-logs@google.com' + }) + await dataset.setMetadata({ + access + }) + const baseUrl = 'bigquery.googleapis.com' + const pId = dataset.parent.projectId + const dId = dataset.id + config.destination = `${baseUrl}/projects/${pId}/datasets/${dId}` + } + /** + * This method is called when creating a sink with a Topic destination. The + * topic must first grant proper ACL access to the Stackdriver Logging + * account. + * + * The parameters are the same as what {@link Logging#createSink} accepts. + * + * @private + */ + async setAclForTopic_(config) { + const topic = config.destination + const [policy] = await topic.iam.getPolicy() + policy.bindings = arrify(policy.bindings) + policy.bindings.push({ + role: 'roles/pubsub.publisher', + members: ['serviceAccount:cloud-logs@system.gserviceaccount.com'] + }) + await topic.iam.setPolicy(policy) + const baseUrl = 'pubsub.googleapis.com' + const topicName = topic.name + config.destination = `${baseUrl}/${topicName}` + } + // eslint-disable-next-line @typescript-eslint/no-unused-vars + async setProjectId(reqOpts) { + if (this.projectId === '{{projectId}}') { + this.projectId = await this.auth.getProjectId() + } + reqOpts = projectify_1.replaceProjectIdToken(reqOpts, this.projectId) + } + } + exports.Logging = Logging + /*! Developer Documentation + * All async methods (except for streams) will execute a callback in the event + * that a callback is provided. + */ + promisify_1.callbackifyAll(Logging, { + exclude: ['request'] + }) + /*! Developer Documentation + * + * These methods can be auto-paginated. + */ + paginator_1.paginator.extend(Logging, [ + 'getEntries', + 'getLogs', + 'getSinks' + ]) + /** + * Reference to the low-level auto-generated clients for the V2 Logging service. + * + * @type {object} + * @property {constructor} LoggingServiceV2Client + * Reference to {@link v2.LoggingServiceV2Client} + * @property {constructor} ConfigServiceV2Client + * Reference to {@link v2.ConfigServiceV2Client} + * @property {constructor} MetricsServiceV2Client + * Reference to {@link v2.MetricsServiceV2Client} + */ + module.exports.v2 = v2 + const protos = __webpack_require__(86114) + exports.protos = protos + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 33259: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /*! + * Copyright 2015 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.Log = exports.Severity = void 0 + const arrify = __webpack_require__(61546) + const promisify_1 = __webpack_require__(19203) + const dotProp = __webpack_require__(82042) + const extend = __webpack_require__(38171) + const entry_1 = __webpack_require__(4710) + const metadata_1 = __webpack_require__(19373) + // eslint-disable-next-line @typescript-eslint/no-var-requires + const snakeCaseKeys = __webpack_require__(99160) + var Severity + ;(function (Severity) { + Severity[(Severity['emergency'] = 0)] = 'emergency' + Severity[(Severity['alert'] = 1)] = 'alert' + Severity[(Severity['critical'] = 2)] = 'critical' + Severity[(Severity['error'] = 3)] = 'error' + Severity[(Severity['warning'] = 4)] = 'warning' + Severity[(Severity['notice'] = 5)] = 'notice' + Severity[(Severity['info'] = 6)] = 'info' + Severity[(Severity['debug'] = 7)] = 'debug' + })((Severity = exports.Severity || (exports.Severity = {}))) + /** + * A log is a named collection of entries, each entry representing a timestamped + * event. Logs can be produced by Google Cloud Platform services, by third-party + * services, or by your applications. For example, the log `apache-access` is + * produced by the Apache Web Server, but the log + * `compute.googleapis.com/activity_log` is produced by Google Compute Engine. + * + * @see [Introduction to Logs]{@link https://cloud.google.com/logging/docs/basic-concepts#logs} + * + * @class + * + * @param {Logging} logging {@link Logging} instance. + * @param {string} name Name of the log. + * @param {object} [options] Configuration object. + * @param {boolean} [options.removeCircular] Replace circular references in + * logged objects with a string value, `[Circular]`. (Default: false) + * + * @example + * const {Logging} = require('@google-cloud/logging'); + * const logging = new Logging(); + * const log = logging.log('syslog'); + */ + class Log { + constructor(logging, name, options) { + options = options || {} + this.formattedName_ = Log.formatName_(logging.projectId, name) + this.removeCircular_ = options.removeCircular === true + this.maxEntrySize = options.maxEntrySize + this.logging = logging + /** + * @name Log#name + * @type {string} + */ + this.name = this.formattedName_.split('/').pop() + } + /** + * Write a log entry with a severity of "ALERT". + * + * This is a simple wrapper around {@link Log#write}. All arguments are + * the same as documented there. + * + * @param {Entry|Entry[]} entry A log entry, or array of entries, to write. + * @param {?WriteOptions} [options] Write options + * @param {LogWriteCallback} [callback] Callback function. + * @returns {Promise} + * @example + * const {Logging} = require('@google-cloud/logging'); + * const logging = new Logging(); + * const log = logging.log('my-log'); + * + * const entry = log.entry('gce_instance', { + * instance: 'my_instance' + * }); + * + * log.alert(entry, (err, apiResponse) => {}); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * log.alert(entry).then(data => { + * const apiResponse = data[0]; + * }); + */ + alert(entry, options) { + return this.write( + Log.assignSeverityToEntries_(entry, 'ALERT'), + options + ) + } + /** + * Write a log entry with a severity of "CRITICAL". + * + * This is a simple wrapper around {@link Log#write}. All arguments are + * the same as documented there. + * + * @param {Entry|Entry[]} entry A log entry, or array of entries, to write. + * @param {?WriteOptions} [options] Write options + * @param {LogWriteCallback} [callback] Callback function. + * @returns {Promise} + * @example + * const {Logging} = require('@google-cloud/logging'); + * const logging = new Logging(); + * const log = logging.log('my-log'); + * + * const entry = log.entry('gce_instance', { + * instance: 'my_instance' + * }); + * + * log.critical(entry, (err, apiResponse) => {}); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * log.critical(entry).then(data => { + * const apiResponse = data[0]; + * }); + */ + critical(entry, options) { + return this.write( + Log.assignSeverityToEntries_(entry, 'CRITICAL'), + options + ) + } + /** + * Write a log entry with a severity of "DEBUG". + * + * This is a simple wrapper around {@link Log#write}. All arguments are + * the same as documented there. + * + * @param {Entry|Entry[]} entry A log entry, or array of entries, to write. + * @param {?WriteOptions} [options] Write options + * @param {LogWriteCallback} [callback] Callback function. + * @returns {Promise} + * @example + * const {Logging} = require('@google-cloud/logging'); + * const logging = new Logging(); + * const log = logging.log('my-log'); + * + * const entry = log.entry('gce_instance', { + * instance: 'my_instance' + * }); + * + * log.debug(entry, (err, apiResponse) => {}); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * log.debug(entry).then(data => { + * const apiResponse = data[0]; + * }); + */ + debug(entry, options) { + return this.write( + Log.assignSeverityToEntries_(entry, 'DEBUG'), + options + ) + } + /** + * @typedef {array} DeleteLogResponse + * @property {object} 0 The full API response. + */ + /** + * @callback DeleteLogCallback + * @param {?Error} err Request error, if any. + * @param {object} apiResponse The full API response. + */ + /** + * Delete the log. + * + * @see [projects.logs.delete API Documentation]{@link https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.logs/delete} + * + * @param {object} [gaxOptions] Request configuration options, outlined + * here: https://googleapis.github.io/gax-nodejs/global.html#CallOptions. + * @param {DeleteLogCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const {Logging} = require('@google-cloud/logging'); + * const logging = new Logging(); + * const log = logging.log('my-log'); + * + * log.delete((err, apiResponse) => { + * if (!err) { + * // The log was deleted. + * } + * }); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * log.delete().then(data => { + * const apiResponse = data[0]; + * }); + * + * @example include:samples/logs.js + * region_tag:logging_delete_log + * Another example: + */ + async delete(gaxOptions) { + const projectId = await this.logging.auth.getProjectId() + this.formattedName_ = Log.formatName_(projectId, this.name) + const reqOpts = { + logName: this.formattedName_ + } + return this.logging.loggingService.deleteLog(reqOpts, gaxOptions) + } + /** + * Write a log entry with a severity of "EMERGENCY". + * + * This is a simple wrapper around {@link Log#write}. All arguments are + * the same as documented there. + * + * @param {Entry|Entry[]} entry A log entry, or array of entries, to write. + * @param {?WriteOptions} [options] Write options + * @param {LogWriteCallback} [callback] Callback function. + * @returns {Promise} + * @example + * const {Logging} = require('@google-cloud/logging'); + * const logging = new Logging(); + * const log = logging.log('my-log'); + * + * const entry = log.entry('gce_instance', { + * instance: 'my_instance' + * }); + * + * log.emergency(entry, (err, apiResponse) => {}); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * log.emergency(entry).then(data => { + * const apiResponse = data[0]; + * }); + */ + emergency(entry, options) { + return this.write( + Log.assignSeverityToEntries_(entry, 'EMERGENCY'), + options + ) + } + /** + * Create an entry object for this log. + * + * Using this method will not itself make any API requests. You will use + * the object returned in other API calls, such as + * {@link Log#write}. + * + * Note, [Cloud Logging Quotas and limits]{@link https://cloud.google.com/logging/quotas} + * dictates that the maximum log entry size, including all + * [LogEntry Resource properties]{@link https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry}, + * cannot exceed _approximately_ 256 KB. + * + * @see [LogEntry JSON representation]{@link https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry} + * + * @param {?object} metadata See a + * [LogEntry + * Resource](https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry). + * @param {object|string} data The data to use as the value for this log + * entry. + * @returns {Entry} + * + * @example + * const {Logging} = require('@google-cloud/logging'); + * const logging = new Logging(); + * const log = logging.log('my-log'); + * + * const metadata = { + * resource: { + * type: 'gce_instance', + * labels: { + * zone: 'global', + * instance_id: '3' + * } + * } + * }; + * + * const entry = log.entry(metadata, { + * delegate: 'my_username' + * }); + * + * entry.toJSON(); + * // { + * // logName: 'projects/grape-spaceship-123/logs/syslog', + * // resource: { + * // type: 'gce_instance', + * // labels: { + * // zone: 'global', + * // instance_id: '3' + * // } + * // }, + * // jsonPayload: { + * // delegate: 'my_username' + * // } + * // } + */ + entry(metadataOrData, data) { + let metadata + if (!data) { + data = metadataOrData + metadata = {} + } else { + metadata = metadataOrData + } + return this.logging.entry(metadata, data) + } + /** + * Write a log entry with a severity of "ERROR". + * + * This is a simple wrapper around {@link Log#write}. All arguments are + * the same as documented there. + * + * @param {Entry|Entry[]} entry A log entry, or array of entries, to write. + * @param {?WriteOptions} [options] Write options + * @param {LogWriteCallback} [callback] Callback function. + * @returns {Promise} + * @example + * const {Logging} = require('@google-cloud/logging'); + * const logging = new Logging(); + * const log = logging.log('my-log'); + * + * const entry = log.entry('gce_instance', { + * instance: 'my_instance' + * }); + * + * log.error(entry, (err, apiResponse) => {}); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * log.error(entry).then(data => { + * const apiResponse = data[0]; + * }); + */ + error(entry, options) { + return this.write( + Log.assignSeverityToEntries_(entry, 'ERROR'), + options + ) + } + /** + * This method is a wrapper around {module:logging#getEntries}, but with a + * filter specified to only return entries from this log. + * + * @see [entries.list API Documentation]{@link https://cloud.google.com/logging/docs/reference/v2/rest/v2/entries/list} + * + * @param {GetEntriesRequest} [query] Query object for listing entries. + * @param {GetEntriesCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const {Logging} = require('@google-cloud/logging'); + * const logging = new Logging(); + * const log = logging.log('my-log'); + * + * log.getEntries((err, entries) => { + * // `entries` is an array of Stackdriver Logging entry objects. + * // See the `data` property to read the data from the entry. + * }); + * + * //- + * // To control how many API requests are made and page through the results + * // manually, set `autoPaginate` to `false`. + * //- + * function callback(err, entries, nextQuery, apiResponse) { + * if (nextQuery) { + * // More results exist. + * log.getEntries(nextQuery, callback); + * } + * } + * + * log.getEntries({ + * autoPaginate: false + * }, callback); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * log.getEntries().then(data => { + * const entries = data[0]; + * }); + */ + async getEntries(opts) { + const options = extend({}, opts) + const projectId = await this.logging.auth.getProjectId() + this.formattedName_ = Log.formatName_(projectId, this.name) + if (options.filter) { + options.filter = `(${options.filter}) AND logName="${this.formattedName_}"` + } else { + options.filter = `logName="${this.formattedName_}"` + } + return this.logging.getEntries(options) + } + /** + * This method is a wrapper around {module:logging#getEntriesStream}, but with + * a filter specified to only return {module:logging/entry} objects from this + * log. + * + * @method Log#getEntriesStream + * @param {GetEntriesRequest} [query] Query object for listing entries. + * @returns {ReadableStream} A readable stream that emits {@link Entry} + * instances. + * + * @example + * const {Logging} = require('@google-cloud/logging'); + * const logging = new Logging(); + * const log = logging.log('my-log'); + * + * log.getEntriesStream() + * .on('error', console.error) + * .on('data', entry => { + * // `entry` is a Stackdriver Logging entry object. + * // See the `data` property to read the data from the entry. + * }) + * .on('end', function() { + * // All entries retrieved. + * }); + * + * //- + * // If you anticipate many results, you can end a stream early to prevent + * // unnecessary processing and API requests. + * //- + * log.getEntriesStream() + * .on('data', function(entry) { + * this.end(); + * }); + */ + getEntriesStream(options) { + options = extend( + { + log: this.name + }, + options + ) + return this.logging.getEntriesStream(options) + } + /** + * Write a log entry with a severity of "INFO". + * + * This is a simple wrapper around {@link Log#write}. All arguments are + * the same as documented there. + * + * @param {Entry|Entry[]} entry A log entry, or array of entries, to write. + * @param {?WriteOptions} [options] Write options + * @param {LogWriteCallback} [callback] Callback function. + * @returns {Promise} + * @example + * const {Logging} = require('@google-cloud/logging'); + * const logging = new Logging(); + * const log = logging.log('my-log'); + * + * const entry = log.entry('gce_instance', { + * instance: 'my_instance' + * }); + * + * log.info(entry, (err, apiResponse) => {}); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * log.info(entry).then(data => { + * const apiResponse = data[0]; + * }); + */ + info(entry, options) { + return this.write( + Log.assignSeverityToEntries_(entry, 'INFO'), + options + ) + } + /** + * Write a log entry with a severity of "NOTICE". + * + * This is a simple wrapper around {@link Log#write}. All arguments are + * the same as documented there. + * + * @param {Entry|Entry[]} entry A log entry, or array of entries, to write. + * @param {?WriteOptions} [options] Write options + * @param {LogWriteCallback} [callback] Callback function. + * @returns {Promise} + * @example + * const {Logging} = require('@google-cloud/logging'); + * const logging = new Logging(); + * const log = logging.log('my-log'); + * + * const entry = log.entry('gce_instance', { + * instance: 'my_instance' + * }); + * + * log.notice(entry, (err, apiResponse) => {}); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * log.notice(entry).then(data => { + * const apiResponse = data[0]; + * }); + */ + notice(entry, options) { + return this.write( + Log.assignSeverityToEntries_(entry, 'NOTICE'), + options + ) + } + /** + * Write a log entry with a severity of "WARNING". + * + * This is a simple wrapper around {@link Log#write}. All arguments are + * the same as documented there. + * + * @param {Entry|Entry[]} entry A log entry, or array of entries, to write. + * @param {?WriteOptions} [options] Write options + * @param {LogWriteCallback} [callback] Callback function. + * @returns {Promise} + * @example + * const {Logging} = require('@google-cloud/logging'); + * const logging = new Logging(); + * const log = logging.log('my-log'); + * + * const entry = log.entry('gce_instance', { + * instance: 'my_instance' + * }); + * + * log.warning(entry, (err, apiResponse) => {}); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * log.warning(entry).then(data => { + * const apiResponse = data[0]; + * }); + */ + warning(entry, options) { + return this.write( + Log.assignSeverityToEntries_(entry, 'WARNING'), + options + ) + } + /** + * @typedef {array} LogWriteResponse + * @property {object} 0 The full API response. + */ + /** + * @callback LogWriteCallback + * @param {?Error} err Request error, if any. + * @param {object} apiResponse The full API response. + */ + /** + * Write options. + * + * @typedef {object} WriteOptions + * @property {boolean} [dryRun] If true, the request should expect normal + * response, but the entries won't be persisted nor exported. + * @property {object} gaxOptions Request configuration options, outlined here: + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions. + * @property {object[]} labels Labels to set on the log. + * @property {boolean} [partialSuccess] Whether valid entries should be + * written even if some other entries fail due to INVALID_ARGUMENT + * or PERMISSION_DENIED errors. + * @property {object} resource A default monitored resource for entries where + * one isn't specified. + */ + /** + * Write log entries to Stackdriver Logging. + * + * Note, [Cloud Logging Quotas and limits]{@link https://cloud.google.com/logging/quotas} + * dictates that the maximum cumulative size of all entries per write, + * including all [LogEntry Resource properties]{@link https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry}, + * cannot exceed _approximately_ 10 MB. + * + * @see [entries.write API Documentation]{@link https://cloud.google.com/logging/docs/reference/v2/rest/v2/entries/write} + * + * @param {Entry|Entry[]} entry A log entry, or array of entries, to write. + * @param {?WriteOptions} [options] Write options + * @param {LogWriteCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const entry = log.entry('gce_instance', { + * instance: 'my_instance' + * }); + * + * log.write(entry, (err, apiResponse) => { + * if (!err) { + * // The log entry was written. + * } + * }); + * + * //- + * // You may also pass multiple log entries to write. + * //- + * const secondEntry = log.entry('compute.googleapis.com', { + * user: 'my_username' + * }); + * + * log.write([ + * entry, + * secondEntry + * ], (err, apiResponse) => { + * if (!err) { + * // The log entries were written. + * } + * }); + * + * //- + * // To save some steps, you can also pass in plain values as your entries. + * // Note, however, that you must provide a configuration object to specify + * // the resource. + * //- + * const entries = [ + * { + * user: 'my_username' + * }, + * { + * home: process.env.HOME + * } + * ]; + * + * const options = { + * resource: 'compute.googleapis.com' + * }; + * + * log.write(entries, options, (err, apiResponse) => {}); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * log.write(entries).then(data => { + * const apiResponse = data[0]; + * }); + * + * @example include:samples/logs.js + * region_tag:logging_write_log_entry + * Another example: + * + * @example include:samples/logs.js + * region_tag:logging_write_log_entry_advanced + * Another example: + */ + async write(entry, opts) { + const options = opts ? opts : {} + // eslint-disable-next-line @typescript-eslint/no-this-alias + const self = this + if (options.resource) { + if (options.resource.labels) { + options.resource.labels = snakeCaseKeys(options.resource.labels) + } + return writeWithResource(options.resource) + } else if (this.logging.detectedResource) { + return writeWithResource(this.logging.detectedResource) + } else { + const resource = await metadata_1.getDefaultResource( + this.logging.auth + ) + this.logging.detectedResource = resource + return writeWithResource(resource) + } + async function writeWithResource(resource) { + let decoratedEntries + try { + decoratedEntries = self.decorateEntries_(arrify(entry)) + } catch (err) { + // Ignore errors (the API will speak up if it has an issue). + } + self.truncateEntries(decoratedEntries) + const projectId = await self.logging.auth.getProjectId() + self.formattedName_ = Log.formatName_(projectId, self.name) + const reqOpts = extend( + { + logName: self.formattedName_, + entries: decoratedEntries, + resource + }, + options + ) + delete reqOpts.gaxOptions + return self.logging.loggingService.writeLogEntries( + reqOpts, + options.gaxOptions + ) + } + } + // TODO proper signature of `private decorateEntries` (sans underscore suffix) + /** + * All entries are passed through here in order to get them serialized. + * + * @private + * + * @param {object[]} entries - Entry objects. + * @returns {object[]} Serialized entries. + * @throws if there is an error during serialization. + */ + decorateEntries_(entries) { + return entries.map(entry => { + if (!(entry instanceof entry_1.Entry)) { + entry = this.entry(entry) + } + return entry.toJSON({ + removeCircular: this.removeCircular_ + }) + }) + } + // TODO consider refactoring `truncateEntries` so that it does not mutate + /** + * Truncate log entries at maxEntrySize, so that error is not thrown, see: + * https://cloud.google.com/logging/quotas + * + * @private + * + * @param {object|string} the JSON log entry. + * @returns {object|string} truncated JSON log entry. + */ + truncateEntries(entries) { + return entries.forEach(entry => { + if (this.maxEntrySize === undefined) return + const payloadSize = JSON.stringify(entry).length + if (payloadSize < this.maxEntrySize) return + let delta = payloadSize - this.maxEntrySize + if (entry.textPayload) { + entry.textPayload = entry.textPayload.slice( + 0, + Math.max(entry.textPayload.length - delta, 0) + ) + } else { + const fieldsToTruncate = [ + // Winston: + 'jsonPayload.fields.metadata.structValue.fields.stack.stringValue', + // Bunyan: + 'jsonPayload.fields.msg.stringValue', + 'jsonPayload.fields.err.structValue.fields.stack.stringValue', + 'jsonPayload.fields.err.structValue.fields.message.stringValue', + // All: + 'jsonPayload.fields.message.stringValue' + ] + for (const field of fieldsToTruncate) { + const msg = dotProp.get(entry, field, '') + if (msg !== '') { + dotProp.set( + entry, + field, + msg.slice(0, Math.max(msg.length - delta, 0)) + ) + delta -= Math.min(msg.length, delta) + } + } + } + }) + } + /** + * Return an array of log entries with the desired severity assigned. + * + * @private + * + * @param {object|object[]} entries - Log entries. + * @param {string} severity - The desired severity level. + */ + static assignSeverityToEntries_(entries, severity) { + return arrify(entries).map(entry => { + const metadata = extend(true, {}, entry.metadata, { + severity + }) + return extend(new entry_1.Entry(), entry, { + metadata + }) + }) + } + /** + * Format the name of a log. A log's full name is in the format of + * 'projects/{projectId}/logs/{logName}'. + * + * @private + * + * @returns {string} + */ + static formatName_(projectId, name) { + const path = 'projects/' + projectId + '/logs/' + name = name.replace(path, '') + if (decodeURIComponent(name) === name) { + // The name has not been encoded yet. + name = encodeURIComponent(name) + } + return path + name + } + } + exports.Log = Log + /*! Developer Documentation + * + * All async methods (except for streams) will call a callback in the event + * that a callback is provided . + */ + promisify_1.callbackifyAll(Log, { + exclude: ['entry', 'getEntriesStream'] + }) + //# sourceMappingURL=log.js.map + + /***/ + }, + + /***/ 19373: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /*! + * Copyright 2016 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.detectServiceContext = exports.getDefaultResource = exports.getGlobalDescriptor = exports.getGKEDescriptor = exports.KUBERNETES_NAMESPACE_ID_PATH = exports.getGCEDescriptor = exports.getGAEDescriptor = exports.getCloudFunctionDescriptor = void 0 + const fs = __webpack_require__(35747) + const gcpMetadata = __webpack_require__(3563) + const google_auth_library_1 = __webpack_require__(20810) + const util_1 = __webpack_require__(31669) + const readFile = util_1.promisify(fs.readFile) + function zoneFromQualifiedZone(qualified) { + // Some parsing is necessary. Metadata service returns a fully + // qualified zone name: 'projects/{projectId}/zones/{zone}'. Logging + // wants just the zone part. + // + return qualified.split('/').pop() + } + /** + * Create a descriptor for Cloud Functions. + * + * @returns {object} + */ + function getCloudFunctionDescriptor() { + /** + * In GCF versions after Node 8, K_SERVICE is the preferred way to + * get the function name and GOOGLE_CLOUD_REGION is the preferred way + * to get the region. + */ + return { + type: 'cloud_function', + labels: { + function_name: process.env.K_SERVICE || process.env.FUNCTION_NAME, + region: + process.env.GOOGLE_CLOUD_REGION || process.env.FUNCTION_REGION + } + } + } + exports.getCloudFunctionDescriptor = getCloudFunctionDescriptor + /** + * Create a descriptor for Google App Engine. + * + * @returns {object} + */ + async function getGAEDescriptor() { + const qualifiedZone = await gcpMetadata.instance('zone') + const zone = zoneFromQualifiedZone(qualifiedZone) + return { + type: 'gae_app', + labels: { + module_id: process.env.GAE_SERVICE || process.env.GAE_MODULE_NAME, + version_id: process.env.GAE_VERSION, + zone + } + } + } + exports.getGAEDescriptor = getGAEDescriptor + /** + * Create a descriptor for Google Compute Engine. + * @return {object} + */ + async function getGCEDescriptor() { + const idResponse = await gcpMetadata.instance('id') + const zoneResponse = await gcpMetadata.instance('zone') + // Some parsing is necessary. Metadata service returns a fully + // qualified zone name: 'projects/{projectId}/zones/{zone}'. Logging + // wants just the zone part. + // + const zone = zoneFromQualifiedZone(zoneResponse) + return { + type: 'gce_instance', + labels: { + // idResponse can be BigNumber when the id too large for JavaScript + // numbers. Use a toString() to uniformly convert to a string. + instance_id: idResponse.toString(), + zone + } + } + } + exports.getGCEDescriptor = getGCEDescriptor + exports.KUBERNETES_NAMESPACE_ID_PATH = + '/var/run/secrets/kubernetes.io/serviceaccount/namespace' + /** + * Create a descriptor for Google Container Engine. + * + * @return {object} + */ + async function getGKEDescriptor() { + // Stackdriver Logging Monitored Resource for 'container' requires + // cluster_name and namespace_id fields. Note that these *need* to be + // snake_case. The namespace_id is not easily available from inside the + // container, but we can get the namespace_name. Logging has been using the + // namespace_name in place of namespace_id for a while now. Log correlation + // with metrics may not necessarily work however. + // + const resp = await gcpMetadata.instance('attributes/cluster-name') + let namespace + try { + namespace = await readFile( + exports.KUBERNETES_NAMESPACE_ID_PATH, + 'utf8' + ) + } catch (err) { + throw new Error( + `Error reading ${exports.KUBERNETES_NAMESPACE_ID_PATH}: ${err.message}` + ) + } + return { + type: 'k8s_container', + labels: { + cluster_name: resp, + namespace_name: namespace + } + } + } + exports.getGKEDescriptor = getGKEDescriptor + /** + * Create a global descriptor. + * + * @returns {object} + */ + function getGlobalDescriptor() { + return { + type: 'global' + } + } + exports.getGlobalDescriptor = getGlobalDescriptor + /** + * Attempt to contact the metadata service and determine, + * based on request success and environment variables, what type of resource + * the library is operating on. + */ + async function getDefaultResource(auth) { + const env = await auth.getEnv() + switch (env) { + case google_auth_library_1.GCPEnv.KUBERNETES_ENGINE: + return getGKEDescriptor().catch(() => getGlobalDescriptor()) + case google_auth_library_1.GCPEnv.APP_ENGINE: + return getGAEDescriptor().catch(() => getGlobalDescriptor()) + case google_auth_library_1.GCPEnv.CLOUD_FUNCTIONS: + return getCloudFunctionDescriptor() + case google_auth_library_1.GCPEnv.COMPUTE_ENGINE: + // Test for compute engine should be done after all the rest - + // everything runs on top of compute engine. + return getGCEDescriptor().catch(() => getGlobalDescriptor()) + default: + return getGlobalDescriptor() + } + } + exports.getDefaultResource = getDefaultResource + /** + * For logged errors, users can provide a service context. This enables errors + * to be picked up Stackdriver Error Reporting. For more information see + * [this guide]{@link + * https://cloud.google.com/error-reporting/docs/formatting-error-messages} and + * the [official documentation]{@link + * https://cloud.google.com/error-reporting/reference/rest/v1beta1/ServiceContext}. + */ + async function detectServiceContext(auth) { + const env = await auth.getEnv() + switch (env) { + case google_auth_library_1.GCPEnv.APP_ENGINE: + return { + service: process.env.GAE_SERVICE || process.env.GAE_MODULE_NAME, + version: process.env.GAE_VERSION || process.env.GAE_MODULE_VERSION + } + case google_auth_library_1.GCPEnv.CLOUD_FUNCTIONS: + return { + service: process.env.FUNCTION_NAME + } + // One Kubernetes we probably need to use the pod-name to describe the + // service. Currently there isn't a universal way to acquire the pod + // name from within the pod. + case google_auth_library_1.GCPEnv.KUBERNETES_ENGINE: + case google_auth_library_1.GCPEnv.COMPUTE_ENGINE: + default: + return null + } + } + exports.detectServiceContext = detectServiceContext + //# sourceMappingURL=metadata.js.map + + /***/ + }, + + /***/ 57097: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /*! + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.getOrInjectContext = exports.makeHeaderWrapper = void 0 + const context = __webpack_require__(94469) + function makeHeaderWrapper(req) { + const wrapper = { + setHeader(name, value) { + req.headers[name] = value + }, + getHeader(name) { + return req.headers[name] + } + } + return wrapper + } + exports.makeHeaderWrapper = makeHeaderWrapper + function getOrInjectContext(headerWrapper) { + let spanContext = context.extract(headerWrapper) + if (spanContext) { + return spanContext + } + // We were the first actor to detect lack of context. Establish context. + spanContext = context.generate() + context.inject(headerWrapper, spanContext) + return spanContext + } + exports.getOrInjectContext = getOrInjectContext + //# sourceMappingURL=context.js.map + + /***/ + }, + + /***/ 27474: /***/ function ( + __unused_webpack_module, + exports, + __webpack_require__ + ) { + 'use strict' + + /*! + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + var __createBinding = + (this && this.__createBinding) || + (Object.create + ? function (o, m, k, k2) { + if (k2 === undefined) k2 = k + Object.defineProperty(o, k2, { + enumerable: true, + get: function () { + return m[k] + } + }) + } + : function (o, m, k, k2) { + if (k2 === undefined) k2 = k + o[k2] = m[k] + }) + var __exportStar = + (this && this.__exportStar) || + function (m, exports) { + for (var p in m) + if (p !== 'default' && !exports.hasOwnProperty(p)) + __createBinding(exports, m, p) + } + Object.defineProperty(exports, '__esModule', { value: true }) + __exportStar(__webpack_require__(81321), exports) + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 19928: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + /*! + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.makeHttpRequestData = void 0 + function makeHttpRequestData(req, res, latencyMilliseconds) { + return { + status: res.statusCode, + requestUrl: req.originalUrl, + requestMethod: req.method, + userAgent: req.headers['user-agent'], + responseSize: + (res.getHeader && Number(res.getHeader('Content-Length'))) || 0, + latency: { + seconds: Math.floor(latencyMilliseconds / 1e3), + nanos: Math.floor((latencyMilliseconds % 1e3) * 1e6) + } + } + } + exports.makeHttpRequestData = makeHttpRequestData + //# sourceMappingURL=make-http-request.js.map + + /***/ + }, + + /***/ 81321: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /*! + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.makeMiddleware = void 0 + const onFinished = __webpack_require__(24694) + const context_1 = __webpack_require__(57097) + const make_http_request_1 = __webpack_require__(19928) + /** + * Generates an express middleware that installs a request-specific logger on + * the `request` object. It optionally can do HttpRequest timing that can be + * used for generating request logs. This can be used to integrate with logging + * libraries such as winston and bunyan. + * + * @param projectId Generated traceIds will be associated with this project. + * @param makeChildLogger A function that generates logger instances that will + * be installed onto `req` as `req.log`. The logger should include the trace in + * each log entry's metadata (associated with the LOGGING_TRACE_KEY property. + * @param emitRequestLog Optional. A function that will emit a parent request + * log. While some environments like GAE and GCF emit parent request logs + * automatically, other environments do not. When provided this function will be + * called with a populated `StackdriverHttpRequest` which can be emitted as + * request log. + */ + function makeMiddleware(projectId, makeChildLogger, emitRequestLog) { + return (req, res, next) => { + // TODO(ofrobots): use high-resolution timer. + const requestStartMs = Date.now() + const wrapper = context_1.makeHeaderWrapper(req) + const spanContext = context_1.getOrInjectContext(wrapper) + const trace = `projects/${projectId}/traces/${spanContext.traceId}` + // Install a child logger on the request object. + req.log = makeChildLogger(trace) + if (emitRequestLog) { + // Emit a 'Request Log' on the parent logger. + onFinished(res, () => { + const latencyMs = Date.now() - requestStartMs + const httpRequest = make_http_request_1.makeHttpRequestData( + req, + res, + latencyMs + ) + emitRequestLog(httpRequest, trace) + }) + } + next() + } + } + exports.makeMiddleware = makeMiddleware + //# sourceMappingURL=make-middleware.js.map + + /***/ + }, + + /***/ 83870: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /*! + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.express = void 0 + const express = __webpack_require__(27474) + exports.express = express + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 5764: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /*! + * Copyright 2015 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.Sink = void 0 + const promisify_1 = __webpack_require__(19203) + const extend = __webpack_require__(38171) + /** + * A sink is an object that lets you to specify a set of log entries to export + * to a particular destination. Stackdriver Logging lets you export log entries + * to destinations including Cloud Storage buckets (for long term log + * storage), Google BigQuery datasets (for log analysis), Google Pub/Sub (for + * streaming to other applications). + * + * @see [Introduction to Sinks]{@link https://cloud.google.com/logging/docs/basic-concepts#sinks} + * + * @class + * + * @param {Logging} logging {@link Logging} instance. + * @param {string} name Name of the sink. + * + * @example + * const {Logging} = require('@google-cloud/logging'); + * const logging = new Logging(); + * const sink = logging.sink('my-sink'); + */ + class Sink { + constructor(logging, name) { + this.logging = logging + /** + * @name Sink#name + * @type {string} + */ + this.name = name + this.formattedName_ = + 'projects/' + logging.projectId + '/sinks/' + name + } + /** + * Create a sink. + * + * @param {CreateSinkRequest} config Config to set for the sink. + * @param {CreateSinkCallback} [callback] Callback function. + * @returns {Promise} + * @throws {Error} if a config object is not provided. + * @see Logging#createSink + * + * @example + * const {Logging} = require('@google-cloud/logging'); + * const logging = new Logging(); + * const sink = logging.sink('my-sink'); + * + * const config = { + * destination: { + * // ... + * } + * }; + * + * sink.create(config, (err, sink, apiResponse) => { + * if (!err) { + * // The sink was created successfully. + * } + * }); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * sink.create(config).then(data => { + * const sink = data[0]; + * const apiResponse = data[1]; + * }); + * + * @example include:samples/sinks.js + * region_tag:logging_create_sink + * Another example: + */ + create(config) { + return this.logging.createSink(this.name, config) + } + /** + * @typedef {array} DeleteSinkResponse + * @property {object} 0 The full API response. + */ + /** + * @callback DeleteSinkCallback + * @param {?Error} err Request error, if any. + * @param {object} apiResponse The full API response. + */ + /** + * Delete the sink. + * + * @see [projects.sink.delete API Documentation]{@link https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/delete} + * + * @param {object} [gaxOptions] Request configuration options, outlined + * here: https://googleapis.github.io/gax-nodejs/global.html#CallOptions. + * @param {DeleteSinkCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const {Logging} = require('@google-cloud/logging'); + * const logging = new Logging(); + * const sink = logging.sink('my-sink'); + * + * sink.delete((err, apiResponse) => { + * if (!err) { + * // The log was deleted. + * } + * }); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * sink.delete().then(data => { + * const apiResponse = data[0]; + * }); + * + * @example include:samples/sinks.js + * region_tag:logging_delete_sink + * Another example: + */ + async delete(gaxOptions) { + const projectId = await this.logging.auth.getProjectId() + this.formattedName_ = 'projects/' + projectId + '/sinks/' + this.name + const reqOpts = { + sinkName: this.formattedName_ + } + return this.logging.configService.deleteSink(reqOpts, gaxOptions) + } + /** + * @typedef {array} GetSinkMetadataResponse + * @property {object} 0 The {@link Sink} metadata. + * @property {object} 1 The full API response. + */ + /** + * @callback GetSinkMetadataCallback + * @param {?Error} err Request error, if any. + * @param {object} metadata The {@link Sink} metadata. + * @param {object} apiResponse The full API response. + */ + /** + * Get the sink's metadata. + * + * @see [Sink Resource]{@link https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks#LogSink} + * @see [projects.sink.get API Documentation]{@link https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/get} + * + * @param {object} [gaxOptions] Request configuration options, outlined + * here: https://googleapis.github.io/gax-nodejs/global.html#CallOptions. + * @param {SinkMetadataCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const {Logging} = require('@google-cloud/logging'); + * const logging = new Logging(); + * const sink = logging.sink('my-sink'); + * + * sink.getMetadata((err, metadata, apiResponse) => {}); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * sink.getMetadata().then(data => { + * const metadata = data[0]; + * }); + * + * @example include:samples/sinks.js + * region_tag:logging_get_sink + * Another example: + */ + async getMetadata(gaxOptions) { + const projectId = await this.logging.auth.getProjectId() + this.formattedName_ = 'projects/' + projectId + '/sinks/' + this.name + const reqOpts = { + sinkName: this.formattedName_ + } + ;[this.metadata] = await this.logging.configService.getSink( + reqOpts, + gaxOptions + ) + return [this.metadata] + } + /** + * @typedef {array} SetSinkFilterResponse + * @property {object} 0 The full API response. + */ + /** + * @callback SetSinkFilterCallback + * @param {?Error} err Request error, if any. + * @param {object} apiResponse The full API response. + */ + /** + * Set the sink's filter. + * + * This will override any filter that was previously set. + * + * @see [Advanced Logs Filters]{@link https://cloud.google.com/logging/docs/view/advanced_filters} + * + * @param {string} filter The new filter. + * @param {SetSinkFilterCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const {Logging} = require('@google-cloud/logging'); + * const logging = new Logging(); + * const sink = logging.sink('my-sink'); + * + * const filter = 'metadata.severity = ALERT'; + * + * sink.setFilter(filter, (err, apiResponse) => {}); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * sink.setFilter(filter).then(data => { + * const apiResponse = data[0]; + * }); + */ + setFilter(filter) { + return this.setMetadata({ + filter + }) + } + /** + * @typedef {array} SetSinkMetadataResponse + * @property {object} 0 The full API response. + */ + /** + * @callback SetSinkMetadataCallback + * @param {?Error} err Request error, if any. + * @param {object} apiResponse The full API response. + */ + /** + * Set the sink's metadata. + * + * @see [Sink Resource]{@link https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks#LogSink} + * @see [projects.sink.update API Documentation]{@link https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/update} + * + * @param {object} metadata See a + * [Sink + * resource](https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks#LogSink). + * @param {object} [metadata.gaxOptions] Request configuration options, + * outlined here: + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions. + * @param {SetSinkMetadataCallback} [callback] Callback function. + * @returns {Promise} + * + * @example + * const {Logging} = require('@google-cloud/logging'); + * const logging = new Logging(); + * const sink = logging.sink('my-sink'); + * + * const metadata = { + * filter: 'metadata.severity = ALERT' + * }; + * + * sink.setMetadata(metadata, (err, apiResponse) => {}); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * sink.setMetadata(metadata).then(data => { + * const apiResponse = data[0]; + * }); + * + * @example include:samples/sinks.js + * region_tag:logging_update_sink + * Another example: + */ + async setMetadata(metadata) { + const [currentMetadata] = await this.getMetadata() + const reqOpts = { + sinkName: this.formattedName_, + sink: extend({}, currentMetadata, metadata) + } + delete reqOpts.sink.gaxOptions + ;[this.metadata] = await this.logging.configService.updateSink( + reqOpts, + metadata.gaxOptions + ) + return [this.metadata] + } + } + exports.Sink = Sink + /*! Developer Documentation + * + * All async methods (except for streams) will call a callbakc in the event + * that a callback is provided. + */ + promisify_1.callbackifyAll(Sink) + //# sourceMappingURL=sink.js.map + + /***/ + }, + + /***/ 37965: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + // Copyright 2020 Google LLC + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + // + // ** This file is automatically generated by gapic-generator-typescript. ** + // ** https://github.com/googleapis/gapic-generator-typescript ** + // ** All changes to this file may be overwritten. ** + Object.defineProperty(exports, '__esModule', { value: true }) + exports.ConfigServiceV2Client = void 0 + const gax = __webpack_require__(12263) + const path = __webpack_require__(85622) + const gapicConfig = __webpack_require__(75821) + const version = __webpack_require__(87989) /* .version */.i8 + /** + * Service for configuring sinks used to route log entries. + * @class + * @memberof v2 + */ + class ConfigServiceV2Client { + /** + * Construct an instance of ConfigServiceV2Client. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - client configuration override. + * TODO(@alexander-fenster): link to gax documentation. + * @param {boolean} fallback - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts) { + var _a, _b + this._terminated = false + this.descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {} + } + // Ensure that options include all the required fields. + const staticMembers = this.constructor + const servicePath = + (opts === null || opts === void 0 ? void 0 : opts.servicePath) || + (opts === null || opts === void 0 ? void 0 : opts.apiEndpoint) || + staticMembers.servicePath + const port = + (opts === null || opts === void 0 ? void 0 : opts.port) || + staticMembers.port + const clientConfig = + (_a = + opts === null || opts === void 0 ? void 0 : opts.clientConfig) !== + null && _a !== void 0 + ? _a + : {} + const fallback = + (_b = opts === null || opts === void 0 ? void 0 : opts.fallback) !== + null && _b !== void 0 + ? _b + : typeof window !== 'undefined' + opts = Object.assign( + { servicePath, port, clientConfig, fallback }, + opts + ) + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if ( + servicePath !== staticMembers.servicePath && + !('scopes' in opts) + ) { + opts['scopes'] = staticMembers.scopes + } + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts) + // Save options to use in initialize() method. + this._opts = opts + // Save the auth object to the client, for use by other methods. + this.auth = this._gaxGrpc.auth + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes + } + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}` + ] + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`) + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`) + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`) + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`) + } + // Load the applicable protos. + // For Node.js, pass the path to JSON proto file. + // For browsers, pass the JSON content. + const nodejsProtoPath = __webpack_require__.ab + 'protos.json' + this._protos = this._gaxGrpc.loadProto( + opts.fallback + ? // eslint-disable-next-line @typescript-eslint/no-var-requires + __webpack_require__(54479) + : __webpack_require__.ab + 'protos.json' + ) + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + billingAccountCmekSettingsPathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}/cmekSettings' + ), + billingAccountExclusionPathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}/exclusions/{exclusion}' + ), + billingAccountLocationBucketPathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}/locations/{location}/buckets/{bucket}' + ), + billingAccountLogPathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}/logs/{log}' + ), + billingAccountSinkPathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}/sinks/{sink}' + ), + folderCmekSettingsPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/cmekSettings' + ), + folderExclusionPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/exclusions/{exclusion}' + ), + folderLocationBucketPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/locations/{location}/buckets/{bucket}' + ), + folderLogPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/logs/{log}' + ), + folderSinkPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/sinks/{sink}' + ), + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + logMetricPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/metrics/{metric}' + ), + organizationCmekSettingsPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/cmekSettings' + ), + organizationExclusionPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/exclusions/{exclusion}' + ), + organizationLocationBucketPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/locations/{location}/buckets/{bucket}' + ), + organizationLogPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/logs/{log}' + ), + organizationSinkPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/sinks/{sink}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + projectCmekSettingsPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/cmekSettings' + ), + projectExclusionPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/exclusions/{exclusion}' + ), + projectLocationBucketPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/buckets/{bucket}' + ), + projectLogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/logs/{log}' + ), + projectSinkPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/sinks/{sink}' + ) + } + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listBuckets: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'buckets' + ), + listSinks: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'sinks' + ), + listExclusions: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'exclusions' + ) + } + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.logging.v2.ConfigServiceV2', + gapicConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') } + ) + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {} + } + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.configServiceV2Stub) { + return this.configServiceV2Stub + } + // Put together the "service stub" for + // google.logging.v2.ConfigServiceV2. + this.configServiceV2Stub = this._gaxGrpc.createStub( + this._opts.fallback + ? this._protos.lookupService('google.logging.v2.ConfigServiceV2') + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._protos.google.logging.v2.ConfigServiceV2, + this._opts + ) + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const configServiceV2StubMethods = [ + 'listBuckets', + 'getBucket', + 'updateBucket', + 'listSinks', + 'getSink', + 'createSink', + 'updateSink', + 'deleteSink', + 'listExclusions', + 'getExclusion', + 'createExclusion', + 'updateExclusion', + 'deleteExclusion', + 'getCmekSettings', + 'updateCmekSettings' + ] + for (const methodName of configServiceV2StubMethods) { + const callPromise = this.configServiceV2Stub.then( + stub => (...args) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.') + } + const func = stub[methodName] + return func.apply(stub, args) + }, + err => () => { + throw err + } + ) + const descriptor = this.descriptors.page[methodName] || undefined + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ) + this.innerApiCalls[methodName] = apiCall + } + return this.configServiceV2Stub + } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'logging.googleapis.com' + } + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'logging.googleapis.com' + } + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443 + } + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + 'https://www.googleapis.com/auth/logging.admin', + 'https://www.googleapis.com/auth/logging.read' + ] + } + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback) { + if (callback) { + this.auth.getProjectId(callback) + return + } + return this.auth.getProjectId() + } + /** + * Gets a bucket (Beta). + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the bucket: + * + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * + * Example: + * `"projects/my-project-id/locations/my-location/buckets/my-bucket-id"`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [LogBucket]{@link google.logging.v2.LogBucket}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.getBucket(request); + */ + getBucket(request, optionsOrCallback, callback) { + request = request || {} + let options + if ( + typeof optionsOrCallback === 'function' && + callback === undefined + ) { + callback = optionsOrCallback + options = {} + } else { + options = optionsOrCallback + } + options = options || {} + options.otherArgs = options.otherArgs || {} + options.otherArgs.headers = options.otherArgs.headers || {} + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + name: request.name || '' + }) + this.initialize() + return this.innerApiCalls.getBucket(request, options, callback) + } + /** + * Updates a bucket. This method replaces the following fields in the + * existing bucket with values from the new bucket: `retention_period` + * + * If the retention period is decreased and the bucket is locked, + * FAILED_PRECONDITION will be returned. + * + * If the bucket has a LifecycleState of DELETE_REQUESTED, FAILED_PRECONDITION + * will be returned. + * + * A buckets region may not be modified after it is created. + * This method is in Beta. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The full resource name of the bucket to update. + * + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" + * + * Example: + * `"projects/my-project-id/locations/my-location/buckets/my-bucket-id"`. Also + * requires permission "resourcemanager.projects.updateLiens" to set the + * locked property + * @param {google.logging.v2.LogBucket} request.bucket + * Required. The updated bucket. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Field mask that specifies the fields in `bucket` that need an update. A + * bucket field will be overwritten if, and only if, it is in the update + * mask. `name` and output only fields cannot be updated. + * + * For a detailed `FieldMask` definition, see + * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.FieldMask + * + * Example: `updateMask=retention_days`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [LogBucket]{@link google.logging.v2.LogBucket}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.updateBucket(request); + */ + updateBucket(request, optionsOrCallback, callback) { + request = request || {} + let options + if ( + typeof optionsOrCallback === 'function' && + callback === undefined + ) { + callback = optionsOrCallback + options = {} + } else { + options = optionsOrCallback + } + options = options || {} + options.otherArgs = options.otherArgs || {} + options.otherArgs.headers = options.otherArgs.headers || {} + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + name: request.name || '' + }) + this.initialize() + return this.innerApiCalls.updateBucket(request, options, callback) + } + /** + * Gets a sink. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.sinkName + * Required. The resource name of the sink: + * + * "projects/[PROJECT_ID]/sinks/[SINK_ID]" + * "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]" + * "folders/[FOLDER_ID]/sinks/[SINK_ID]" + * + * Example: `"projects/my-project-id/sinks/my-sink-id"`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [LogSink]{@link google.logging.v2.LogSink}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.getSink(request); + */ + getSink(request, optionsOrCallback, callback) { + request = request || {} + let options + if ( + typeof optionsOrCallback === 'function' && + callback === undefined + ) { + callback = optionsOrCallback + options = {} + } else { + options = optionsOrCallback + } + options = options || {} + options.otherArgs = options.otherArgs || {} + options.otherArgs.headers = options.otherArgs.headers || {} + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + sink_name: request.sinkName || '' + }) + this.initialize() + return this.innerApiCalls.getSink(request, options, callback) + } + /** + * Creates a sink that exports specified log entries to a destination. The + * export of newly-ingested log entries begins immediately, unless the sink's + * `writer_identity` is not permitted to write to the destination. A sink can + * export log entries only from the resource owning the sink. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource in which to create the sink: + * + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * + * Examples: `"projects/my-logging-project"`, `"organizations/123456789"`. + * @param {google.logging.v2.LogSink} request.sink + * Required. The new sink, whose `name` parameter is a sink identifier that + * is not already in use. + * @param {boolean} [request.uniqueWriterIdentity] + * Optional. Determines the kind of IAM identity returned as `writer_identity` + * in the new sink. If this value is omitted or set to false, and if the + * sink's parent is a project, then the value returned as `writer_identity` is + * the same group or service account used by Logging before the addition of + * writer identities to this API. The sink's destination must be in the same + * project as the sink itself. + * + * If this field is set to true, or if the sink is owned by a non-project + * resource such as an organization, then the value of `writer_identity` will + * be a unique service account used only for exports from the new sink. For + * more information, see `writer_identity` in {@link google.logging.v2.LogSink|LogSink}. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [LogSink]{@link google.logging.v2.LogSink}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.createSink(request); + */ + createSink(request, optionsOrCallback, callback) { + request = request || {} + let options + if ( + typeof optionsOrCallback === 'function' && + callback === undefined + ) { + callback = optionsOrCallback + options = {} + } else { + options = optionsOrCallback + } + options = options || {} + options.otherArgs = options.otherArgs || {} + options.otherArgs.headers = options.otherArgs.headers || {} + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + parent: request.parent || '' + }) + this.initialize() + return this.innerApiCalls.createSink(request, options, callback) + } + /** + * Updates a sink. This method replaces the following fields in the existing + * sink with values from the new sink: `destination`, and `filter`. + * + * The updated sink might also have a new `writer_identity`; see the + * `unique_writer_identity` field. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.sinkName + * Required. The full resource name of the sink to update, including the parent + * resource and the sink identifier: + * + * "projects/[PROJECT_ID]/sinks/[SINK_ID]" + * "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]" + * "folders/[FOLDER_ID]/sinks/[SINK_ID]" + * + * Example: `"projects/my-project-id/sinks/my-sink-id"`. + * @param {google.logging.v2.LogSink} request.sink + * Required. The updated sink, whose name is the same identifier that appears as part + * of `sink_name`. + * @param {boolean} [request.uniqueWriterIdentity] + * Optional. See {@link google.logging.v2.ConfigServiceV2.CreateSink|sinks.create} + * for a description of this field. When updating a sink, the effect of this + * field on the value of `writer_identity` in the updated sink depends on both + * the old and new values of this field: + * + * + If the old and new values of this field are both false or both true, + * then there is no change to the sink's `writer_identity`. + * + If the old value is false and the new value is true, then + * `writer_identity` is changed to a unique service account. + * + It is an error if the old value is true and the new value is + * set to false or defaulted to false. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Field mask that specifies the fields in `sink` that need + * an update. A sink field will be overwritten if, and only if, it is + * in the update mask. `name` and output only fields cannot be updated. + * + * An empty updateMask is temporarily treated as using the following mask + * for backwards compatibility purposes: + * destination,filter,includeChildren + * At some point in the future, behavior will be removed and specifying an + * empty updateMask will be an error. + * + * For a detailed `FieldMask` definition, see + * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.FieldMask + * + * Example: `updateMask=filter`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [LogSink]{@link google.logging.v2.LogSink}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.updateSink(request); + */ + updateSink(request, optionsOrCallback, callback) { + request = request || {} + let options + if ( + typeof optionsOrCallback === 'function' && + callback === undefined + ) { + callback = optionsOrCallback + options = {} + } else { + options = optionsOrCallback + } + options = options || {} + options.otherArgs = options.otherArgs || {} + options.otherArgs.headers = options.otherArgs.headers || {} + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + sink_name: request.sinkName || '' + }) + this.initialize() + return this.innerApiCalls.updateSink(request, options, callback) + } + /** + * Deletes a sink. If the sink has a unique `writer_identity`, then that + * service account is also deleted. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.sinkName + * Required. The full resource name of the sink to delete, including the parent + * resource and the sink identifier: + * + * "projects/[PROJECT_ID]/sinks/[SINK_ID]" + * "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]" + * "folders/[FOLDER_ID]/sinks/[SINK_ID]" + * + * Example: `"projects/my-project-id/sinks/my-sink-id"`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.deleteSink(request); + */ + deleteSink(request, optionsOrCallback, callback) { + request = request || {} + let options + if ( + typeof optionsOrCallback === 'function' && + callback === undefined + ) { + callback = optionsOrCallback + options = {} + } else { + options = optionsOrCallback + } + options = options || {} + options.otherArgs = options.otherArgs || {} + options.otherArgs.headers = options.otherArgs.headers || {} + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + sink_name: request.sinkName || '' + }) + this.initialize() + return this.innerApiCalls.deleteSink(request, options, callback) + } + /** + * Gets the description of an exclusion. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of an existing exclusion: + * + * "projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]" + * "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/exclusions/[EXCLUSION_ID]" + * "folders/[FOLDER_ID]/exclusions/[EXCLUSION_ID]" + * + * Example: `"projects/my-project-id/exclusions/my-exclusion-id"`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [LogExclusion]{@link google.logging.v2.LogExclusion}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.getExclusion(request); + */ + getExclusion(request, optionsOrCallback, callback) { + request = request || {} + let options + if ( + typeof optionsOrCallback === 'function' && + callback === undefined + ) { + callback = optionsOrCallback + options = {} + } else { + options = optionsOrCallback + } + options = options || {} + options.otherArgs = options.otherArgs || {} + options.otherArgs.headers = options.otherArgs.headers || {} + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + name: request.name || '' + }) + this.initialize() + return this.innerApiCalls.getExclusion(request, options, callback) + } + /** + * Creates a new exclusion in a specified parent resource. + * Only log entries belonging to that resource can be excluded. + * You can have up to 10 exclusions in a resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource in which to create the exclusion: + * + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * + * Examples: `"projects/my-logging-project"`, `"organizations/123456789"`. + * @param {google.logging.v2.LogExclusion} request.exclusion + * Required. The new exclusion, whose `name` parameter is an exclusion name + * that is not already used in the parent resource. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [LogExclusion]{@link google.logging.v2.LogExclusion}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.createExclusion(request); + */ + createExclusion(request, optionsOrCallback, callback) { + request = request || {} + let options + if ( + typeof optionsOrCallback === 'function' && + callback === undefined + ) { + callback = optionsOrCallback + options = {} + } else { + options = optionsOrCallback + } + options = options || {} + options.otherArgs = options.otherArgs || {} + options.otherArgs.headers = options.otherArgs.headers || {} + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + parent: request.parent || '' + }) + this.initialize() + return this.innerApiCalls.createExclusion(request, options, callback) + } + /** + * Changes one or more properties of an existing exclusion. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the exclusion to update: + * + * "projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]" + * "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/exclusions/[EXCLUSION_ID]" + * "folders/[FOLDER_ID]/exclusions/[EXCLUSION_ID]" + * + * Example: `"projects/my-project-id/exclusions/my-exclusion-id"`. + * @param {google.logging.v2.LogExclusion} request.exclusion + * Required. New values for the existing exclusion. Only the fields specified in + * `update_mask` are relevant. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. A non-empty list of fields to change in the existing exclusion. New values + * for the fields are taken from the corresponding fields in the + * {@link google.logging.v2.LogExclusion|LogExclusion} included in this request. Fields not mentioned in + * `update_mask` are not changed and are ignored in the request. + * + * For example, to change the filter and description of an exclusion, + * specify an `update_mask` of `"filter,description"`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [LogExclusion]{@link google.logging.v2.LogExclusion}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.updateExclusion(request); + */ + updateExclusion(request, optionsOrCallback, callback) { + request = request || {} + let options + if ( + typeof optionsOrCallback === 'function' && + callback === undefined + ) { + callback = optionsOrCallback + options = {} + } else { + options = optionsOrCallback + } + options = options || {} + options.otherArgs = options.otherArgs || {} + options.otherArgs.headers = options.otherArgs.headers || {} + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + name: request.name || '' + }) + this.initialize() + return this.innerApiCalls.updateExclusion(request, options, callback) + } + /** + * Deletes an exclusion. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of an existing exclusion to delete: + * + * "projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]" + * "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/exclusions/[EXCLUSION_ID]" + * "folders/[FOLDER_ID]/exclusions/[EXCLUSION_ID]" + * + * Example: `"projects/my-project-id/exclusions/my-exclusion-id"`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.deleteExclusion(request); + */ + deleteExclusion(request, optionsOrCallback, callback) { + request = request || {} + let options + if ( + typeof optionsOrCallback === 'function' && + callback === undefined + ) { + callback = optionsOrCallback + options = {} + } else { + options = optionsOrCallback + } + options = options || {} + options.otherArgs = options.otherArgs || {} + options.otherArgs.headers = options.otherArgs.headers || {} + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + name: request.name || '' + }) + this.initialize() + return this.innerApiCalls.deleteExclusion(request, options, callback) + } + /** + * Gets the Logs Router CMEK settings for the given resource. + * + * Note: CMEK for the Logs Router can currently only be configured for GCP + * organizations. Once configured, it applies to all projects and folders in + * the GCP organization. + * + * See [Enabling CMEK for Logs + * Router](https://cloud.google.com/logging/docs/routing/managed-encryption) + * for more information. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource for which to retrieve CMEK settings. + * + * "projects/[PROJECT_ID]/cmekSettings" + * "organizations/[ORGANIZATION_ID]/cmekSettings" + * "billingAccounts/[BILLING_ACCOUNT_ID]/cmekSettings" + * "folders/[FOLDER_ID]/cmekSettings" + * + * Example: `"organizations/12345/cmekSettings"`. + * + * Note: CMEK for the Logs Router can currently only be configured for GCP + * organizations. Once configured, it applies to all projects and folders in + * the GCP organization. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [CmekSettings]{@link google.logging.v2.CmekSettings}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.getCmekSettings(request); + */ + getCmekSettings(request, optionsOrCallback, callback) { + request = request || {} + let options + if ( + typeof optionsOrCallback === 'function' && + callback === undefined + ) { + callback = optionsOrCallback + options = {} + } else { + options = optionsOrCallback + } + options = options || {} + options.otherArgs = options.otherArgs || {} + options.otherArgs.headers = options.otherArgs.headers || {} + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + name: request.name || '' + }) + this.initialize() + return this.innerApiCalls.getCmekSettings(request, options, callback) + } + /** + * Updates the Logs Router CMEK settings for the given resource. + * + * Note: CMEK for the Logs Router can currently only be configured for GCP + * organizations. Once configured, it applies to all projects and folders in + * the GCP organization. + * + * {@link google.logging.v2.ConfigServiceV2.UpdateCmekSettings|UpdateCmekSettings} + * will fail if 1) `kms_key_name` is invalid, or 2) the associated service + * account does not have the required + * `roles/cloudkms.cryptoKeyEncrypterDecrypter` role assigned for the key, or + * 3) access to the key is disabled. + * + * See [Enabling CMEK for Logs + * Router](https://cloud.google.com/logging/docs/routing/managed-encryption) + * for more information. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name for the CMEK settings to update. + * + * "projects/[PROJECT_ID]/cmekSettings" + * "organizations/[ORGANIZATION_ID]/cmekSettings" + * "billingAccounts/[BILLING_ACCOUNT_ID]/cmekSettings" + * "folders/[FOLDER_ID]/cmekSettings" + * + * Example: `"organizations/12345/cmekSettings"`. + * + * Note: CMEK for the Logs Router can currently only be configured for GCP + * organizations. Once configured, it applies to all projects and folders in + * the GCP organization. + * @param {google.logging.v2.CmekSettings} request.cmekSettings + * Required. The CMEK settings to update. + * + * See [Enabling CMEK for Logs + * Router](https://cloud.google.com/logging/docs/routing/managed-encryption) + * for more information. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Field mask identifying which fields from `cmek_settings` should + * be updated. A field will be overwritten if and only if it is in the update + * mask. Output only fields cannot be updated. + * + * See {@link google.protobuf.FieldMask|FieldMask} for more information. + * + * Example: `"updateMask=kmsKeyName"` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [CmekSettings]{@link google.logging.v2.CmekSettings}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.updateCmekSettings(request); + */ + updateCmekSettings(request, optionsOrCallback, callback) { + request = request || {} + let options + if ( + typeof optionsOrCallback === 'function' && + callback === undefined + ) { + callback = optionsOrCallback + options = {} + } else { + options = optionsOrCallback + } + options = options || {} + options.otherArgs = options.otherArgs || {} + options.otherArgs.headers = options.otherArgs.headers || {} + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + name: request.name || '' + }) + this.initialize() + return this.innerApiCalls.updateCmekSettings( + request, + options, + callback + ) + } + /** + * Lists buckets (Beta). + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource whose buckets are to be listed: + * + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]" + * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]" + * "folders/[FOLDER_ID]/locations/[LOCATION_ID]" + * + * Note: The locations portion of the resource must be specified, but + * supplying the character `-` in place of [LOCATION_ID] will return all + * buckets. + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [LogBucket]{@link google.logging.v2.LogBucket}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listBucketsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listBuckets(request, optionsOrCallback, callback) { + request = request || {} + let options + if ( + typeof optionsOrCallback === 'function' && + callback === undefined + ) { + callback = optionsOrCallback + options = {} + } else { + options = optionsOrCallback + } + options = options || {} + options.otherArgs = options.otherArgs || {} + options.otherArgs.headers = options.otherArgs.headers || {} + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + parent: request.parent || '' + }) + this.initialize() + return this.innerApiCalls.listBuckets(request, options, callback) + } + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource whose buckets are to be listed: + * + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]" + * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]" + * "folders/[FOLDER_ID]/locations/[LOCATION_ID]" + * + * Note: The locations portion of the resource must be specified, but + * supplying the character `-` in place of [LOCATION_ID] will return all + * buckets. + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [LogBucket]{@link google.logging.v2.LogBucket} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listBucketsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listBucketsStream(request, options) { + request = request || {} + options = options || {} + options.otherArgs = options.otherArgs || {} + options.otherArgs.headers = options.otherArgs.headers || {} + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + parent: request.parent || '' + }) + const callSettings = new gax.CallSettings(options) + this.initialize() + return this.descriptors.page.listBuckets.createStream( + this.innerApiCalls.listBuckets, + request, + callSettings + ) + } + /** + * Equivalent to `listBuckets`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource whose buckets are to be listed: + * + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]" + * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]" + * "folders/[FOLDER_ID]/locations/[LOCATION_ID]" + * + * Note: The locations portion of the resource must be specified, but + * supplying the character `-` in place of [LOCATION_ID] will return all + * buckets. + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [LogBucket]{@link google.logging.v2.LogBucket}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listBucketsAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listBucketsAsync(request, options) { + request = request || {} + options = options || {} + options.otherArgs = options.otherArgs || {} + options.otherArgs.headers = options.otherArgs.headers || {} + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + parent: request.parent || '' + }) + options = options || {} + const callSettings = new gax.CallSettings(options) + this.initialize() + return this.descriptors.page.listBuckets.asyncIterate( + this.innerApiCalls['listBuckets'], + request, + callSettings + ) + } + /** + * Lists sinks. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource whose sinks are to be listed: + * + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [LogSink]{@link google.logging.v2.LogSink}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listSinksAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listSinks(request, optionsOrCallback, callback) { + request = request || {} + let options + if ( + typeof optionsOrCallback === 'function' && + callback === undefined + ) { + callback = optionsOrCallback + options = {} + } else { + options = optionsOrCallback + } + options = options || {} + options.otherArgs = options.otherArgs || {} + options.otherArgs.headers = options.otherArgs.headers || {} + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + parent: request.parent || '' + }) + this.initialize() + return this.innerApiCalls.listSinks(request, options, callback) + } + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource whose sinks are to be listed: + * + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [LogSink]{@link google.logging.v2.LogSink} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listSinksAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listSinksStream(request, options) { + request = request || {} + options = options || {} + options.otherArgs = options.otherArgs || {} + options.otherArgs.headers = options.otherArgs.headers || {} + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + parent: request.parent || '' + }) + const callSettings = new gax.CallSettings(options) + this.initialize() + return this.descriptors.page.listSinks.createStream( + this.innerApiCalls.listSinks, + request, + callSettings + ) + } + /** + * Equivalent to `listSinks`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource whose sinks are to be listed: + * + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [LogSink]{@link google.logging.v2.LogSink}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listSinksAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listSinksAsync(request, options) { + request = request || {} + options = options || {} + options.otherArgs = options.otherArgs || {} + options.otherArgs.headers = options.otherArgs.headers || {} + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + parent: request.parent || '' + }) + options = options || {} + const callSettings = new gax.CallSettings(options) + this.initialize() + return this.descriptors.page.listSinks.asyncIterate( + this.innerApiCalls['listSinks'], + request, + callSettings + ) + } + /** + * Lists all the exclusions in a parent resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource whose exclusions are to be listed. + * + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [LogExclusion]{@link google.logging.v2.LogExclusion}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listExclusionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listExclusions(request, optionsOrCallback, callback) { + request = request || {} + let options + if ( + typeof optionsOrCallback === 'function' && + callback === undefined + ) { + callback = optionsOrCallback + options = {} + } else { + options = optionsOrCallback + } + options = options || {} + options.otherArgs = options.otherArgs || {} + options.otherArgs.headers = options.otherArgs.headers || {} + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + parent: request.parent || '' + }) + this.initialize() + return this.innerApiCalls.listExclusions(request, options, callback) + } + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource whose exclusions are to be listed. + * + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [LogExclusion]{@link google.logging.v2.LogExclusion} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listExclusionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listExclusionsStream(request, options) { + request = request || {} + options = options || {} + options.otherArgs = options.otherArgs || {} + options.otherArgs.headers = options.otherArgs.headers || {} + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + parent: request.parent || '' + }) + const callSettings = new gax.CallSettings(options) + this.initialize() + return this.descriptors.page.listExclusions.createStream( + this.innerApiCalls.listExclusions, + request, + callSettings + ) + } + /** + * Equivalent to `listExclusions`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource whose exclusions are to be listed. + * + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [LogExclusion]{@link google.logging.v2.LogExclusion}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listExclusionsAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listExclusionsAsync(request, options) { + request = request || {} + options = options || {} + options.otherArgs = options.otherArgs || {} + options.otherArgs.headers = options.otherArgs.headers || {} + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + parent: request.parent || '' + }) + options = options || {} + const callSettings = new gax.CallSettings(options) + this.initialize() + return this.descriptors.page.listExclusions.asyncIterate( + this.innerApiCalls['listExclusions'], + request, + callSettings + ) + } + // -------------------- + // -- Path templates -- + // -------------------- + /** + * Return a fully-qualified billingAccountCmekSettings resource name string. + * + * @param {string} billing_account + * @returns {string} Resource name string. + */ + billingAccountCmekSettingsPath(billingAccount) { + return this.pathTemplates.billingAccountCmekSettingsPathTemplate.render( + { + billing_account: billingAccount + } + ) + } + /** + * Parse the billing_account from BillingAccountCmekSettings resource. + * + * @param {string} billingAccountCmekSettingsName + * A fully-qualified path representing billing_account_cmekSettings resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountCmekSettingsName( + billingAccountCmekSettingsName + ) { + return this.pathTemplates.billingAccountCmekSettingsPathTemplate.match( + billingAccountCmekSettingsName + ).billing_account + } + /** + * Return a fully-qualified billingAccountExclusion resource name string. + * + * @param {string} billing_account + * @param {string} exclusion + * @returns {string} Resource name string. + */ + billingAccountExclusionPath(billingAccount, exclusion) { + return this.pathTemplates.billingAccountExclusionPathTemplate.render({ + billing_account: billingAccount, + exclusion: exclusion + }) + } + /** + * Parse the billing_account from BillingAccountExclusion resource. + * + * @param {string} billingAccountExclusionName + * A fully-qualified path representing billing_account_exclusion resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountExclusionName( + billingAccountExclusionName + ) { + return this.pathTemplates.billingAccountExclusionPathTemplate.match( + billingAccountExclusionName + ).billing_account + } + /** + * Parse the exclusion from BillingAccountExclusion resource. + * + * @param {string} billingAccountExclusionName + * A fully-qualified path representing billing_account_exclusion resource. + * @returns {string} A string representing the exclusion. + */ + matchExclusionFromBillingAccountExclusionName( + billingAccountExclusionName + ) { + return this.pathTemplates.billingAccountExclusionPathTemplate.match( + billingAccountExclusionName + ).exclusion + } + /** + * Return a fully-qualified billingAccountLocationBucket resource name string. + * + * @param {string} billing_account + * @param {string} location + * @param {string} bucket + * @returns {string} Resource name string. + */ + billingAccountLocationBucketPath(billingAccount, location, bucket) { + return this.pathTemplates.billingAccountLocationBucketPathTemplate.render( + { + billing_account: billingAccount, + location: location, + bucket: bucket + } + ) + } + /** + * Parse the billing_account from BillingAccountLocationBucket resource. + * + * @param {string} billingAccountLocationBucketName + * A fully-qualified path representing billing_account_location_bucket resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountLocationBucketName( + billingAccountLocationBucketName + ) { + return this.pathTemplates.billingAccountLocationBucketPathTemplate.match( + billingAccountLocationBucketName + ).billing_account + } + /** + * Parse the location from BillingAccountLocationBucket resource. + * + * @param {string} billingAccountLocationBucketName + * A fully-qualified path representing billing_account_location_bucket resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBillingAccountLocationBucketName( + billingAccountLocationBucketName + ) { + return this.pathTemplates.billingAccountLocationBucketPathTemplate.match( + billingAccountLocationBucketName + ).location + } + /** + * Parse the bucket from BillingAccountLocationBucket resource. + * + * @param {string} billingAccountLocationBucketName + * A fully-qualified path representing billing_account_location_bucket resource. + * @returns {string} A string representing the bucket. + */ + matchBucketFromBillingAccountLocationBucketName( + billingAccountLocationBucketName + ) { + return this.pathTemplates.billingAccountLocationBucketPathTemplate.match( + billingAccountLocationBucketName + ).bucket + } + /** + * Return a fully-qualified billingAccountLog resource name string. + * + * @param {string} billing_account + * @param {string} log + * @returns {string} Resource name string. + */ + billingAccountLogPath(billingAccount, log) { + return this.pathTemplates.billingAccountLogPathTemplate.render({ + billing_account: billingAccount, + log: log + }) + } + /** + * Parse the billing_account from BillingAccountLog resource. + * + * @param {string} billingAccountLogName + * A fully-qualified path representing billing_account_log resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountLogName(billingAccountLogName) { + return this.pathTemplates.billingAccountLogPathTemplate.match( + billingAccountLogName + ).billing_account + } + /** + * Parse the log from BillingAccountLog resource. + * + * @param {string} billingAccountLogName + * A fully-qualified path representing billing_account_log resource. + * @returns {string} A string representing the log. + */ + matchLogFromBillingAccountLogName(billingAccountLogName) { + return this.pathTemplates.billingAccountLogPathTemplate.match( + billingAccountLogName + ).log + } + /** + * Return a fully-qualified billingAccountSink resource name string. + * + * @param {string} billing_account + * @param {string} sink + * @returns {string} Resource name string. + */ + billingAccountSinkPath(billingAccount, sink) { + return this.pathTemplates.billingAccountSinkPathTemplate.render({ + billing_account: billingAccount, + sink: sink + }) + } + /** + * Parse the billing_account from BillingAccountSink resource. + * + * @param {string} billingAccountSinkName + * A fully-qualified path representing billing_account_sink resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountSinkName(billingAccountSinkName) { + return this.pathTemplates.billingAccountSinkPathTemplate.match( + billingAccountSinkName + ).billing_account + } + /** + * Parse the sink from BillingAccountSink resource. + * + * @param {string} billingAccountSinkName + * A fully-qualified path representing billing_account_sink resource. + * @returns {string} A string representing the sink. + */ + matchSinkFromBillingAccountSinkName(billingAccountSinkName) { + return this.pathTemplates.billingAccountSinkPathTemplate.match( + billingAccountSinkName + ).sink + } + /** + * Return a fully-qualified folderCmekSettings resource name string. + * + * @param {string} folder + * @returns {string} Resource name string. + */ + folderCmekSettingsPath(folder) { + return this.pathTemplates.folderCmekSettingsPathTemplate.render({ + folder: folder + }) + } + /** + * Parse the folder from FolderCmekSettings resource. + * + * @param {string} folderCmekSettingsName + * A fully-qualified path representing folder_cmekSettings resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderCmekSettingsName(folderCmekSettingsName) { + return this.pathTemplates.folderCmekSettingsPathTemplate.match( + folderCmekSettingsName + ).folder + } + /** + * Return a fully-qualified folderExclusion resource name string. + * + * @param {string} folder + * @param {string} exclusion + * @returns {string} Resource name string. + */ + folderExclusionPath(folder, exclusion) { + return this.pathTemplates.folderExclusionPathTemplate.render({ + folder: folder, + exclusion: exclusion + }) + } + /** + * Parse the folder from FolderExclusion resource. + * + * @param {string} folderExclusionName + * A fully-qualified path representing folder_exclusion resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderExclusionName(folderExclusionName) { + return this.pathTemplates.folderExclusionPathTemplate.match( + folderExclusionName + ).folder + } + /** + * Parse the exclusion from FolderExclusion resource. + * + * @param {string} folderExclusionName + * A fully-qualified path representing folder_exclusion resource. + * @returns {string} A string representing the exclusion. + */ + matchExclusionFromFolderExclusionName(folderExclusionName) { + return this.pathTemplates.folderExclusionPathTemplate.match( + folderExclusionName + ).exclusion + } + /** + * Return a fully-qualified folderLocationBucket resource name string. + * + * @param {string} folder + * @param {string} location + * @param {string} bucket + * @returns {string} Resource name string. + */ + folderLocationBucketPath(folder, location, bucket) { + return this.pathTemplates.folderLocationBucketPathTemplate.render({ + folder: folder, + location: location, + bucket: bucket + }) + } + /** + * Parse the folder from FolderLocationBucket resource. + * + * @param {string} folderLocationBucketName + * A fully-qualified path representing folder_location_bucket resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderLocationBucketName(folderLocationBucketName) { + return this.pathTemplates.folderLocationBucketPathTemplate.match( + folderLocationBucketName + ).folder + } + /** + * Parse the location from FolderLocationBucket resource. + * + * @param {string} folderLocationBucketName + * A fully-qualified path representing folder_location_bucket resource. + * @returns {string} A string representing the location. + */ + matchLocationFromFolderLocationBucketName(folderLocationBucketName) { + return this.pathTemplates.folderLocationBucketPathTemplate.match( + folderLocationBucketName + ).location + } + /** + * Parse the bucket from FolderLocationBucket resource. + * + * @param {string} folderLocationBucketName + * A fully-qualified path representing folder_location_bucket resource. + * @returns {string} A string representing the bucket. + */ + matchBucketFromFolderLocationBucketName(folderLocationBucketName) { + return this.pathTemplates.folderLocationBucketPathTemplate.match( + folderLocationBucketName + ).bucket + } + /** + * Return a fully-qualified folderLog resource name string. + * + * @param {string} folder + * @param {string} log + * @returns {string} Resource name string. + */ + folderLogPath(folder, log) { + return this.pathTemplates.folderLogPathTemplate.render({ + folder: folder, + log: log + }) + } + /** + * Parse the folder from FolderLog resource. + * + * @param {string} folderLogName + * A fully-qualified path representing folder_log resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderLogName(folderLogName) { + return this.pathTemplates.folderLogPathTemplate.match(folderLogName) + .folder + } + /** + * Parse the log from FolderLog resource. + * + * @param {string} folderLogName + * A fully-qualified path representing folder_log resource. + * @returns {string} A string representing the log. + */ + matchLogFromFolderLogName(folderLogName) { + return this.pathTemplates.folderLogPathTemplate.match(folderLogName) + .log + } + /** + * Return a fully-qualified folderSink resource name string. + * + * @param {string} folder + * @param {string} sink + * @returns {string} Resource name string. + */ + folderSinkPath(folder, sink) { + return this.pathTemplates.folderSinkPathTemplate.render({ + folder: folder, + sink: sink + }) + } + /** + * Parse the folder from FolderSink resource. + * + * @param {string} folderSinkName + * A fully-qualified path representing folder_sink resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderSinkName(folderSinkName) { + return this.pathTemplates.folderSinkPathTemplate.match(folderSinkName) + .folder + } + /** + * Parse the sink from FolderSink resource. + * + * @param {string} folderSinkName + * A fully-qualified path representing folder_sink resource. + * @returns {string} A string representing the sink. + */ + matchSinkFromFolderSinkName(folderSinkName) { + return this.pathTemplates.folderSinkPathTemplate.match(folderSinkName) + .sink + } + /** + * Return a fully-qualified location resource name string. + * + * @param {string} project + * @param {string} location + * @returns {string} Resource name string. + */ + locationPath(project, location) { + return this.pathTemplates.locationPathTemplate.render({ + project: project, + location: location + }) + } + /** + * Parse the project from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLocationName(locationName) { + return this.pathTemplates.locationPathTemplate.match(locationName) + .project + } + /** + * Parse the location from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the location. + */ + matchLocationFromLocationName(locationName) { + return this.pathTemplates.locationPathTemplate.match(locationName) + .location + } + /** + * Return a fully-qualified logMetric resource name string. + * + * @param {string} project + * @param {string} metric + * @returns {string} Resource name string. + */ + logMetricPath(project, metric) { + return this.pathTemplates.logMetricPathTemplate.render({ + project: project, + metric: metric + }) + } + /** + * Parse the project from LogMetric resource. + * + * @param {string} logMetricName + * A fully-qualified path representing LogMetric resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLogMetricName(logMetricName) { + return this.pathTemplates.logMetricPathTemplate.match(logMetricName) + .project + } + /** + * Parse the metric from LogMetric resource. + * + * @param {string} logMetricName + * A fully-qualified path representing LogMetric resource. + * @returns {string} A string representing the metric. + */ + matchMetricFromLogMetricName(logMetricName) { + return this.pathTemplates.logMetricPathTemplate.match(logMetricName) + .metric + } + /** + * Return a fully-qualified organizationCmekSettings resource name string. + * + * @param {string} organization + * @returns {string} Resource name string. + */ + organizationCmekSettingsPath(organization) { + return this.pathTemplates.organizationCmekSettingsPathTemplate.render( + { + organization: organization + } + ) + } + /** + * Parse the organization from OrganizationCmekSettings resource. + * + * @param {string} organizationCmekSettingsName + * A fully-qualified path representing organization_cmekSettings resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationCmekSettingsName( + organizationCmekSettingsName + ) { + return this.pathTemplates.organizationCmekSettingsPathTemplate.match( + organizationCmekSettingsName + ).organization + } + /** + * Return a fully-qualified organizationExclusion resource name string. + * + * @param {string} organization + * @param {string} exclusion + * @returns {string} Resource name string. + */ + organizationExclusionPath(organization, exclusion) { + return this.pathTemplates.organizationExclusionPathTemplate.render({ + organization: organization, + exclusion: exclusion + }) + } + /** + * Parse the organization from OrganizationExclusion resource. + * + * @param {string} organizationExclusionName + * A fully-qualified path representing organization_exclusion resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationExclusionName( + organizationExclusionName + ) { + return this.pathTemplates.organizationExclusionPathTemplate.match( + organizationExclusionName + ).organization + } + /** + * Parse the exclusion from OrganizationExclusion resource. + * + * @param {string} organizationExclusionName + * A fully-qualified path representing organization_exclusion resource. + * @returns {string} A string representing the exclusion. + */ + matchExclusionFromOrganizationExclusionName(organizationExclusionName) { + return this.pathTemplates.organizationExclusionPathTemplate.match( + organizationExclusionName + ).exclusion + } + /** + * Return a fully-qualified organizationLocationBucket resource name string. + * + * @param {string} organization + * @param {string} location + * @param {string} bucket + * @returns {string} Resource name string. + */ + organizationLocationBucketPath(organization, location, bucket) { + return this.pathTemplates.organizationLocationBucketPathTemplate.render( + { + organization: organization, + location: location, + bucket: bucket + } + ) + } + /** + * Parse the organization from OrganizationLocationBucket resource. + * + * @param {string} organizationLocationBucketName + * A fully-qualified path representing organization_location_bucket resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationLocationBucketName( + organizationLocationBucketName + ) { + return this.pathTemplates.organizationLocationBucketPathTemplate.match( + organizationLocationBucketName + ).organization + } + /** + * Parse the location from OrganizationLocationBucket resource. + * + * @param {string} organizationLocationBucketName + * A fully-qualified path representing organization_location_bucket resource. + * @returns {string} A string representing the location. + */ + matchLocationFromOrganizationLocationBucketName( + organizationLocationBucketName + ) { + return this.pathTemplates.organizationLocationBucketPathTemplate.match( + organizationLocationBucketName + ).location + } + /** + * Parse the bucket from OrganizationLocationBucket resource. + * + * @param {string} organizationLocationBucketName + * A fully-qualified path representing organization_location_bucket resource. + * @returns {string} A string representing the bucket. + */ + matchBucketFromOrganizationLocationBucketName( + organizationLocationBucketName + ) { + return this.pathTemplates.organizationLocationBucketPathTemplate.match( + organizationLocationBucketName + ).bucket + } + /** + * Return a fully-qualified organizationLog resource name string. + * + * @param {string} organization + * @param {string} log + * @returns {string} Resource name string. + */ + organizationLogPath(organization, log) { + return this.pathTemplates.organizationLogPathTemplate.render({ + organization: organization, + log: log + }) + } + /** + * Parse the organization from OrganizationLog resource. + * + * @param {string} organizationLogName + * A fully-qualified path representing organization_log resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationLogName(organizationLogName) { + return this.pathTemplates.organizationLogPathTemplate.match( + organizationLogName + ).organization + } + /** + * Parse the log from OrganizationLog resource. + * + * @param {string} organizationLogName + * A fully-qualified path representing organization_log resource. + * @returns {string} A string representing the log. + */ + matchLogFromOrganizationLogName(organizationLogName) { + return this.pathTemplates.organizationLogPathTemplate.match( + organizationLogName + ).log + } + /** + * Return a fully-qualified organizationSink resource name string. + * + * @param {string} organization + * @param {string} sink + * @returns {string} Resource name string. + */ + organizationSinkPath(organization, sink) { + return this.pathTemplates.organizationSinkPathTemplate.render({ + organization: organization, + sink: sink + }) + } + /** + * Parse the organization from OrganizationSink resource. + * + * @param {string} organizationSinkName + * A fully-qualified path representing organization_sink resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationSinkName(organizationSinkName) { + return this.pathTemplates.organizationSinkPathTemplate.match( + organizationSinkName + ).organization + } + /** + * Parse the sink from OrganizationSink resource. + * + * @param {string} organizationSinkName + * A fully-qualified path representing organization_sink resource. + * @returns {string} A string representing the sink. + */ + matchSinkFromOrganizationSinkName(organizationSinkName) { + return this.pathTemplates.organizationSinkPathTemplate.match( + organizationSinkName + ).sink + } + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project) { + return this.pathTemplates.projectPathTemplate.render({ + project: project + }) + } + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName) { + return this.pathTemplates.projectPathTemplate.match(projectName) + .project + } + /** + * Return a fully-qualified projectCmekSettings resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectCmekSettingsPath(project) { + return this.pathTemplates.projectCmekSettingsPathTemplate.render({ + project: project + }) + } + /** + * Parse the project from ProjectCmekSettings resource. + * + * @param {string} projectCmekSettingsName + * A fully-qualified path representing project_cmekSettings resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectCmekSettingsName(projectCmekSettingsName) { + return this.pathTemplates.projectCmekSettingsPathTemplate.match( + projectCmekSettingsName + ).project + } + /** + * Return a fully-qualified projectExclusion resource name string. + * + * @param {string} project + * @param {string} exclusion + * @returns {string} Resource name string. + */ + projectExclusionPath(project, exclusion) { + return this.pathTemplates.projectExclusionPathTemplate.render({ + project: project, + exclusion: exclusion + }) + } + /** + * Parse the project from ProjectExclusion resource. + * + * @param {string} projectExclusionName + * A fully-qualified path representing project_exclusion resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectExclusionName(projectExclusionName) { + return this.pathTemplates.projectExclusionPathTemplate.match( + projectExclusionName + ).project + } + /** + * Parse the exclusion from ProjectExclusion resource. + * + * @param {string} projectExclusionName + * A fully-qualified path representing project_exclusion resource. + * @returns {string} A string representing the exclusion. + */ + matchExclusionFromProjectExclusionName(projectExclusionName) { + return this.pathTemplates.projectExclusionPathTemplate.match( + projectExclusionName + ).exclusion + } + /** + * Return a fully-qualified projectLocationBucket resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} bucket + * @returns {string} Resource name string. + */ + projectLocationBucketPath(project, location, bucket) { + return this.pathTemplates.projectLocationBucketPathTemplate.render({ + project: project, + location: location, + bucket: bucket + }) + } + /** + * Parse the project from ProjectLocationBucket resource. + * + * @param {string} projectLocationBucketName + * A fully-qualified path representing project_location_bucket resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationBucketName(projectLocationBucketName) { + return this.pathTemplates.projectLocationBucketPathTemplate.match( + projectLocationBucketName + ).project + } + /** + * Parse the location from ProjectLocationBucket resource. + * + * @param {string} projectLocationBucketName + * A fully-qualified path representing project_location_bucket resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationBucketName(projectLocationBucketName) { + return this.pathTemplates.projectLocationBucketPathTemplate.match( + projectLocationBucketName + ).location + } + /** + * Parse the bucket from ProjectLocationBucket resource. + * + * @param {string} projectLocationBucketName + * A fully-qualified path representing project_location_bucket resource. + * @returns {string} A string representing the bucket. + */ + matchBucketFromProjectLocationBucketName(projectLocationBucketName) { + return this.pathTemplates.projectLocationBucketPathTemplate.match( + projectLocationBucketName + ).bucket + } + /** + * Return a fully-qualified projectLog resource name string. + * + * @param {string} project + * @param {string} log + * @returns {string} Resource name string. + */ + projectLogPath(project, log) { + return this.pathTemplates.projectLogPathTemplate.render({ + project: project, + log: log + }) + } + /** + * Parse the project from ProjectLog resource. + * + * @param {string} projectLogName + * A fully-qualified path representing project_log resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLogName(projectLogName) { + return this.pathTemplates.projectLogPathTemplate.match(projectLogName) + .project + } + /** + * Parse the log from ProjectLog resource. + * + * @param {string} projectLogName + * A fully-qualified path representing project_log resource. + * @returns {string} A string representing the log. + */ + matchLogFromProjectLogName(projectLogName) { + return this.pathTemplates.projectLogPathTemplate.match(projectLogName) + .log + } + /** + * Return a fully-qualified projectSink resource name string. + * + * @param {string} project + * @param {string} sink + * @returns {string} Resource name string. + */ + projectSinkPath(project, sink) { + return this.pathTemplates.projectSinkPathTemplate.render({ + project: project, + sink: sink + }) + } + /** + * Parse the project from ProjectSink resource. + * + * @param {string} projectSinkName + * A fully-qualified path representing project_sink resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectSinkName(projectSinkName) { + return this.pathTemplates.projectSinkPathTemplate.match( + projectSinkName + ).project + } + /** + * Parse the sink from ProjectSink resource. + * + * @param {string} projectSinkName + * A fully-qualified path representing project_sink resource. + * @returns {string} A string representing the sink. + */ + matchSinkFromProjectSinkName(projectSinkName) { + return this.pathTemplates.projectSinkPathTemplate.match( + projectSinkName + ).sink + } + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close() { + this.initialize() + if (!this._terminated) { + return this.configServiceV2Stub.then(stub => { + this._terminated = true + stub.close() + }) + } + return Promise.resolve() + } + } + exports.ConfigServiceV2Client = ConfigServiceV2Client + //# sourceMappingURL=config_service_v2_client.js.map + + /***/ + }, + + /***/ 5863: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + // Copyright 2020 Google LLC + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + // + // ** This file is automatically generated by gapic-generator-typescript. ** + // ** https://github.com/googleapis/gapic-generator-typescript ** + // ** All changes to this file may be overwritten. ** + Object.defineProperty(exports, '__esModule', { value: true }) + var config_service_v2_client_1 = __webpack_require__(37965) + Object.defineProperty(exports, 'ConfigServiceV2Client', { + enumerable: true, + get: function () { + return config_service_v2_client_1.ConfigServiceV2Client + } + }) + var logging_service_v2_client_1 = __webpack_require__(814) + Object.defineProperty(exports, 'LoggingServiceV2Client', { + enumerable: true, + get: function () { + return logging_service_v2_client_1.LoggingServiceV2Client + } + }) + var metrics_service_v2_client_1 = __webpack_require__(47516) + Object.defineProperty(exports, 'MetricsServiceV2Client', { + enumerable: true, + get: function () { + return metrics_service_v2_client_1.MetricsServiceV2Client + } + }) + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 814: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + // Copyright 2020 Google LLC + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + // + // ** This file is automatically generated by gapic-generator-typescript. ** + // ** https://github.com/googleapis/gapic-generator-typescript ** + // ** All changes to this file may be overwritten. ** + Object.defineProperty(exports, '__esModule', { value: true }) + exports.LoggingServiceV2Client = void 0 + const gax = __webpack_require__(12263) + const path = __webpack_require__(85622) + const gapicConfig = __webpack_require__(34742) + const version = __webpack_require__(87989) /* .version */.i8 + /** + * Service for ingesting and querying logs. + * @class + * @memberof v2 + */ + class LoggingServiceV2Client { + /** + * Construct an instance of LoggingServiceV2Client. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - client configuration override. + * TODO(@alexander-fenster): link to gax documentation. + * @param {boolean} fallback - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts) { + var _a, _b + this._terminated = false + this.descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {} + } + // Ensure that options include all the required fields. + const staticMembers = this.constructor + const servicePath = + (opts === null || opts === void 0 ? void 0 : opts.servicePath) || + (opts === null || opts === void 0 ? void 0 : opts.apiEndpoint) || + staticMembers.servicePath + const port = + (opts === null || opts === void 0 ? void 0 : opts.port) || + staticMembers.port + const clientConfig = + (_a = + opts === null || opts === void 0 ? void 0 : opts.clientConfig) !== + null && _a !== void 0 + ? _a + : {} + const fallback = + (_b = opts === null || opts === void 0 ? void 0 : opts.fallback) !== + null && _b !== void 0 + ? _b + : typeof window !== 'undefined' + opts = Object.assign( + { servicePath, port, clientConfig, fallback }, + opts + ) + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if ( + servicePath !== staticMembers.servicePath && + !('scopes' in opts) + ) { + opts['scopes'] = staticMembers.scopes + } + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts) + // Save options to use in initialize() method. + this._opts = opts + // Save the auth object to the client, for use by other methods. + this.auth = this._gaxGrpc.auth + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes + } + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}` + ] + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`) + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`) + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`) + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`) + } + // Load the applicable protos. + // For Node.js, pass the path to JSON proto file. + // For browsers, pass the JSON content. + const nodejsProtoPath = __webpack_require__.ab + 'protos.json' + this._protos = this._gaxGrpc.loadProto( + opts.fallback + ? // eslint-disable-next-line @typescript-eslint/no-var-requires + __webpack_require__(54479) + : __webpack_require__.ab + 'protos.json' + ) + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + billingAccountCmekSettingsPathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}/cmekSettings' + ), + billingAccountExclusionPathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}/exclusions/{exclusion}' + ), + billingAccountLocationBucketPathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}/locations/{location}/buckets/{bucket}' + ), + billingAccountLogPathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}/logs/{log}' + ), + billingAccountSinkPathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}/sinks/{sink}' + ), + folderCmekSettingsPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/cmekSettings' + ), + folderExclusionPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/exclusions/{exclusion}' + ), + folderLocationBucketPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/locations/{location}/buckets/{bucket}' + ), + folderLogPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/logs/{log}' + ), + folderSinkPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/sinks/{sink}' + ), + logMetricPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/metrics/{metric}' + ), + organizationCmekSettingsPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/cmekSettings' + ), + organizationExclusionPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/exclusions/{exclusion}' + ), + organizationLocationBucketPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/locations/{location}/buckets/{bucket}' + ), + organizationLogPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/logs/{log}' + ), + organizationSinkPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/sinks/{sink}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + projectCmekSettingsPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/cmekSettings' + ), + projectExclusionPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/exclusions/{exclusion}' + ), + projectLocationBucketPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/buckets/{bucket}' + ), + projectLogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/logs/{log}' + ), + projectSinkPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/sinks/{sink}' + ) + } + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listLogEntries: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'entries' + ), + listMonitoredResourceDescriptors: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'resourceDescriptors' + ), + listLogs: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'logNames' + ) + } + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + const protoFilesRoot = opts.fallback + ? this._gaxModule.protobuf.Root.fromJSON( + // eslint-disable-next-line @typescript-eslint/no-var-requires + __webpack_require__(54479) + ) + : this._gaxModule.protobuf.loadSync( + __webpack_require__.ab + 'protos.json' + ) + // Some methods on this API support automatically batching + // requests; denote this. + this.descriptors.batching = { + writeLogEntries: new this._gaxModule.BundleDescriptor( + 'entries', + ['log_name', 'resource', 'labels'], + null, + gax.createByteLengthFunction( + // eslint-disable-next-line @typescript-eslint/no-explicit-any + protoFilesRoot.lookupType('google.logging.v2.LogEntry') + ) + ) + } + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.logging.v2.LoggingServiceV2', + gapicConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') } + ) + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {} + } + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + var _a + // If the client stub promise is already initialized, return immediately. + if (this.loggingServiceV2Stub) { + return this.loggingServiceV2Stub + } + // Put together the "service stub" for + // google.logging.v2.LoggingServiceV2. + this.loggingServiceV2Stub = this._gaxGrpc.createStub( + this._opts.fallback + ? this._protos.lookupService('google.logging.v2.LoggingServiceV2') + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._protos.google.logging.v2.LoggingServiceV2, + this._opts + ) + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const loggingServiceV2StubMethods = [ + 'deleteLog', + 'writeLogEntries', + 'listLogEntries', + 'listMonitoredResourceDescriptors', + 'listLogs' + ] + for (const methodName of loggingServiceV2StubMethods) { + const callPromise = this.loggingServiceV2Stub.then( + stub => (...args) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.') + } + const func = stub[methodName] + return func.apply(stub, args) + }, + err => () => { + throw err + } + ) + const descriptor = + this.descriptors.page[methodName] || + ((_a = this.descriptors.batching) === null || _a === void 0 + ? void 0 + : _a[methodName]) || + undefined + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ) + this.innerApiCalls[methodName] = apiCall + } + return this.loggingServiceV2Stub + } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'logging.googleapis.com' + } + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'logging.googleapis.com' + } + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443 + } + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + 'https://www.googleapis.com/auth/logging.admin', + 'https://www.googleapis.com/auth/logging.read', + 'https://www.googleapis.com/auth/logging.write' + ] + } + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback) { + if (callback) { + this.auth.getProjectId(callback) + return + } + return this.auth.getProjectId() + } + /** + * Deletes all the log entries in a log. The log reappears if it receives new + * entries. Log entries written shortly before the delete operation might not + * be deleted. Entries received after the delete operation with a timestamp + * before the operation will be deleted. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.logName + * Required. The resource name of the log to delete: + * + * "projects/[PROJECT_ID]/logs/[LOG_ID]" + * "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]" + * "folders/[FOLDER_ID]/logs/[LOG_ID]" + * + * `[LOG_ID]` must be URL-encoded. For example, + * `"projects/my-project-id/logs/syslog"`, + * `"organizations/1234567890/logs/cloudresourcemanager.googleapis.com%2Factivity"`. + * For more information about log names, see + * {@link google.logging.v2.LogEntry|LogEntry}. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.deleteLog(request); + */ + deleteLog(request, optionsOrCallback, callback) { + request = request || {} + let options + if ( + typeof optionsOrCallback === 'function' && + callback === undefined + ) { + callback = optionsOrCallback + options = {} + } else { + options = optionsOrCallback + } + options = options || {} + options.otherArgs = options.otherArgs || {} + options.otherArgs.headers = options.otherArgs.headers || {} + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + log_name: request.logName || '' + }) + this.initialize() + return this.innerApiCalls.deleteLog(request, options, callback) + } + /** + * Writes log entries to Logging. This API method is the + * only way to send log entries to Logging. This method + * is used, directly or indirectly, by the Logging agent + * (fluentd) and all logging libraries configured to use Logging. + * A single request may contain log entries for a maximum of 1000 + * different resources (projects, organizations, billing accounts or + * folders) + * + * @param {Object} request + * The request object that will be sent. + * @param {string} [request.logName] + * Optional. A default log resource name that is assigned to all log entries + * in `entries` that do not specify a value for `log_name`: + * + * "projects/[PROJECT_ID]/logs/[LOG_ID]" + * "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]" + * "folders/[FOLDER_ID]/logs/[LOG_ID]" + * + * `[LOG_ID]` must be URL-encoded. For example: + * + * "projects/my-project-id/logs/syslog" + * "organizations/1234567890/logs/cloudresourcemanager.googleapis.com%2Factivity" + * + * The permission `logging.logEntries.create` is needed on each project, + * organization, billing account, or folder that is receiving new log + * entries, whether the resource is specified in `logName` or in an + * individual log entry. + * @param {google.api.MonitoredResource} [request.resource] + * Optional. A default monitored resource object that is assigned to all log + * entries in `entries` that do not specify a value for `resource`. Example: + * + * { "type": "gce_instance", + * "labels": { + * "zone": "us-central1-a", "instance_id": "00000000000000000000" }} + * + * See {@link google.logging.v2.LogEntry|LogEntry}. + * @param {number[]} [request.labels] + * Optional. Default labels that are added to the `labels` field of all log + * entries in `entries`. If a log entry already has a label with the same key + * as a label in this parameter, then the log entry's label is not changed. + * See {@link google.logging.v2.LogEntry|LogEntry}. + * @param {number[]} request.entries + * Required. The log entries to send to Logging. The order of log + * entries in this list does not matter. Values supplied in this method's + * `log_name`, `resource`, and `labels` fields are copied into those log + * entries in this list that do not include values for their corresponding + * fields. For more information, see the + * {@link google.logging.v2.LogEntry|LogEntry} type. + * + * If the `timestamp` or `insert_id` fields are missing in log entries, then + * this method supplies the current time or a unique identifier, respectively. + * The supplied values are chosen so that, among the log entries that did not + * supply their own values, the entries earlier in the list will sort before + * the entries later in the list. See the `entries.list` method. + * + * Log entries with timestamps that are more than the + * [logs retention period](https://cloud.google.com/logging/quota-policy) in + * the past or more than 24 hours in the future will not be available when + * calling `entries.list`. However, those log entries can still be [exported + * with + * LogSinks](https://cloud.google.com/logging/docs/api/tasks/exporting-logs). + * + * To improve throughput and to avoid exceeding the + * [quota limit](https://cloud.google.com/logging/quota-policy) for calls to + * `entries.write`, you should try to include several log entries in this + * list, rather than calling this method for each individual log entry. + * @param {boolean} [request.partialSuccess] + * Optional. Whether valid entries should be written even if some other + * entries fail due to INVALID_ARGUMENT or PERMISSION_DENIED errors. If any + * entry is not written, then the response status is the error associated + * with one of the failed entries and the response includes error details + * keyed by the entries' zero-based index in the `entries.write` method. + * @param {boolean} [request.dryRun] + * Optional. If true, the request should expect normal response, but the + * entries won't be persisted nor exported. Useful for checking whether the + * logging API endpoints are working properly before sending valuable data. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [WriteLogEntriesResponse]{@link google.logging.v2.WriteLogEntriesResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.writeLogEntries(request); + */ + writeLogEntries(request, optionsOrCallback, callback) { + request = request || {} + let options + if ( + typeof optionsOrCallback === 'function' && + callback === undefined + ) { + callback = optionsOrCallback + options = {} + } else { + options = optionsOrCallback + } + options = options || {} + this.initialize() + return this.innerApiCalls.writeLogEntries(request, options, callback) + } + /** + * Lists log entries. Use this method to retrieve log entries that originated + * from a project/folder/organization/billing account. For ways to export log + * entries, see [Exporting + * Logs](https://cloud.google.com/logging/docs/export). + * + * @param {Object} request + * The request object that will be sent. + * @param {string[]} request.resourceNames + * Required. Names of one or more parent resources from which to + * retrieve log entries: + * + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * + * + * Projects listed in the `project_ids` field are added to this list. + * @param {string} [request.filter] + * Optional. A filter that chooses which log entries to return. See [Advanced + * Logs Queries](https://cloud.google.com/logging/docs/view/advanced-queries). + * Only log entries that match the filter are returned. An empty filter + * matches all log entries in the resources listed in `resource_names`. + * Referencing a parent resource that is not listed in `resource_names` will + * cause the filter to return no results. The maximum length of the filter is + * 20000 characters. + * @param {string} [request.orderBy] + * Optional. How the results should be sorted. Presently, the only permitted + * values are `"timestamp asc"` (default) and `"timestamp desc"`. The first + * option returns entries in order of increasing values of + * `LogEntry.timestamp` (oldest first), and the second option returns entries + * in order of decreasing timestamps (newest first). Entries with equal + * timestamps are returned in order of their `insert_id` values. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Default is 50. If the value is negative or exceeds 1000, + * the request is rejected. The presence of `next_page_token` in the + * response indicates that more results might be available. + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `page_token` must be the value of + * `next_page_token` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [LogEntry]{@link google.logging.v2.LogEntry}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listLogEntriesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listLogEntries(request, optionsOrCallback, callback) { + request = request || {} + let options + if ( + typeof optionsOrCallback === 'function' && + callback === undefined + ) { + callback = optionsOrCallback + options = {} + } else { + options = optionsOrCallback + } + options = options || {} + this.initialize() + return this.innerApiCalls.listLogEntries(request, options, callback) + } + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string[]} request.resourceNames + * Required. Names of one or more parent resources from which to + * retrieve log entries: + * + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * + * + * Projects listed in the `project_ids` field are added to this list. + * @param {string} [request.filter] + * Optional. A filter that chooses which log entries to return. See [Advanced + * Logs Queries](https://cloud.google.com/logging/docs/view/advanced-queries). + * Only log entries that match the filter are returned. An empty filter + * matches all log entries in the resources listed in `resource_names`. + * Referencing a parent resource that is not listed in `resource_names` will + * cause the filter to return no results. The maximum length of the filter is + * 20000 characters. + * @param {string} [request.orderBy] + * Optional. How the results should be sorted. Presently, the only permitted + * values are `"timestamp asc"` (default) and `"timestamp desc"`. The first + * option returns entries in order of increasing values of + * `LogEntry.timestamp` (oldest first), and the second option returns entries + * in order of decreasing timestamps (newest first). Entries with equal + * timestamps are returned in order of their `insert_id` values. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Default is 50. If the value is negative or exceeds 1000, + * the request is rejected. The presence of `next_page_token` in the + * response indicates that more results might be available. + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `page_token` must be the value of + * `next_page_token` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [LogEntry]{@link google.logging.v2.LogEntry} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listLogEntriesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listLogEntriesStream(request, options) { + request = request || {} + options = options || {} + const callSettings = new gax.CallSettings(options) + this.initialize() + return this.descriptors.page.listLogEntries.createStream( + this.innerApiCalls.listLogEntries, + request, + callSettings + ) + } + /** + * Equivalent to `listLogEntries`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string[]} request.resourceNames + * Required. Names of one or more parent resources from which to + * retrieve log entries: + * + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * + * + * Projects listed in the `project_ids` field are added to this list. + * @param {string} [request.filter] + * Optional. A filter that chooses which log entries to return. See [Advanced + * Logs Queries](https://cloud.google.com/logging/docs/view/advanced-queries). + * Only log entries that match the filter are returned. An empty filter + * matches all log entries in the resources listed in `resource_names`. + * Referencing a parent resource that is not listed in `resource_names` will + * cause the filter to return no results. The maximum length of the filter is + * 20000 characters. + * @param {string} [request.orderBy] + * Optional. How the results should be sorted. Presently, the only permitted + * values are `"timestamp asc"` (default) and `"timestamp desc"`. The first + * option returns entries in order of increasing values of + * `LogEntry.timestamp` (oldest first), and the second option returns entries + * in order of decreasing timestamps (newest first). Entries with equal + * timestamps are returned in order of their `insert_id` values. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Default is 50. If the value is negative or exceeds 1000, + * the request is rejected. The presence of `next_page_token` in the + * response indicates that more results might be available. + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `page_token` must be the value of + * `next_page_token` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [LogEntry]{@link google.logging.v2.LogEntry}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listLogEntriesAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listLogEntriesAsync(request, options) { + request = request || {} + options = options || {} + options = options || {} + const callSettings = new gax.CallSettings(options) + this.initialize() + return this.descriptors.page.listLogEntries.asyncIterate( + this.innerApiCalls['listLogEntries'], + request, + callSettings + ) + } + /** + * Lists the descriptors for monitored resource types used by Logging. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [MonitoredResourceDescriptor]{@link google.api.MonitoredResourceDescriptor}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listMonitoredResourceDescriptorsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listMonitoredResourceDescriptors(request, optionsOrCallback, callback) { + request = request || {} + let options + if ( + typeof optionsOrCallback === 'function' && + callback === undefined + ) { + callback = optionsOrCallback + options = {} + } else { + options = optionsOrCallback + } + options = options || {} + this.initialize() + return this.innerApiCalls.listMonitoredResourceDescriptors( + request, + options, + callback + ) + } + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [MonitoredResourceDescriptor]{@link google.api.MonitoredResourceDescriptor} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listMonitoredResourceDescriptorsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listMonitoredResourceDescriptorsStream(request, options) { + request = request || {} + options = options || {} + const callSettings = new gax.CallSettings(options) + this.initialize() + return this.descriptors.page.listMonitoredResourceDescriptors.createStream( + this.innerApiCalls.listMonitoredResourceDescriptors, + request, + callSettings + ) + } + /** + * Equivalent to `listMonitoredResourceDescriptors`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [MonitoredResourceDescriptor]{@link google.api.MonitoredResourceDescriptor}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listMonitoredResourceDescriptorsAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listMonitoredResourceDescriptorsAsync(request, options) { + request = request || {} + options = options || {} + options = options || {} + const callSettings = new gax.CallSettings(options) + this.initialize() + return this.descriptors.page.listMonitoredResourceDescriptors.asyncIterate( + this.innerApiCalls['listMonitoredResourceDescriptors'], + request, + callSettings + ) + } + /** + * Lists the logs in projects, organizations, folders, or billing accounts. + * Only logs that have entries are listed. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name that owns the logs: + * + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of string. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listLogsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listLogs(request, optionsOrCallback, callback) { + request = request || {} + let options + if ( + typeof optionsOrCallback === 'function' && + callback === undefined + ) { + callback = optionsOrCallback + options = {} + } else { + options = optionsOrCallback + } + options = options || {} + options.otherArgs = options.otherArgs || {} + options.otherArgs.headers = options.otherArgs.headers || {} + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + parent: request.parent || '' + }) + this.initialize() + return this.innerApiCalls.listLogs(request, options, callback) + } + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name that owns the logs: + * + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing string on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listLogsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listLogsStream(request, options) { + request = request || {} + options = options || {} + options.otherArgs = options.otherArgs || {} + options.otherArgs.headers = options.otherArgs.headers || {} + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + parent: request.parent || '' + }) + const callSettings = new gax.CallSettings(options) + this.initialize() + return this.descriptors.page.listLogs.createStream( + this.innerApiCalls.listLogs, + request, + callSettings + ) + } + /** + * Equivalent to `listLogs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name that owns the logs: + * + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * string. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listLogsAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listLogsAsync(request, options) { + request = request || {} + options = options || {} + options.otherArgs = options.otherArgs || {} + options.otherArgs.headers = options.otherArgs.headers || {} + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + parent: request.parent || '' + }) + options = options || {} + const callSettings = new gax.CallSettings(options) + this.initialize() + return this.descriptors.page.listLogs.asyncIterate( + this.innerApiCalls['listLogs'], + request, + callSettings + ) + } + // -------------------- + // -- Path templates -- + // -------------------- + /** + * Return a fully-qualified billingAccountCmekSettings resource name string. + * + * @param {string} billing_account + * @returns {string} Resource name string. + */ + billingAccountCmekSettingsPath(billingAccount) { + return this.pathTemplates.billingAccountCmekSettingsPathTemplate.render( + { + billing_account: billingAccount + } + ) + } + /** + * Parse the billing_account from BillingAccountCmekSettings resource. + * + * @param {string} billingAccountCmekSettingsName + * A fully-qualified path representing billing_account_cmekSettings resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountCmekSettingsName( + billingAccountCmekSettingsName + ) { + return this.pathTemplates.billingAccountCmekSettingsPathTemplate.match( + billingAccountCmekSettingsName + ).billing_account + } + /** + * Return a fully-qualified billingAccountExclusion resource name string. + * + * @param {string} billing_account + * @param {string} exclusion + * @returns {string} Resource name string. + */ + billingAccountExclusionPath(billingAccount, exclusion) { + return this.pathTemplates.billingAccountExclusionPathTemplate.render({ + billing_account: billingAccount, + exclusion: exclusion + }) + } + /** + * Parse the billing_account from BillingAccountExclusion resource. + * + * @param {string} billingAccountExclusionName + * A fully-qualified path representing billing_account_exclusion resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountExclusionName( + billingAccountExclusionName + ) { + return this.pathTemplates.billingAccountExclusionPathTemplate.match( + billingAccountExclusionName + ).billing_account + } + /** + * Parse the exclusion from BillingAccountExclusion resource. + * + * @param {string} billingAccountExclusionName + * A fully-qualified path representing billing_account_exclusion resource. + * @returns {string} A string representing the exclusion. + */ + matchExclusionFromBillingAccountExclusionName( + billingAccountExclusionName + ) { + return this.pathTemplates.billingAccountExclusionPathTemplate.match( + billingAccountExclusionName + ).exclusion + } + /** + * Return a fully-qualified billingAccountLocationBucket resource name string. + * + * @param {string} billing_account + * @param {string} location + * @param {string} bucket + * @returns {string} Resource name string. + */ + billingAccountLocationBucketPath(billingAccount, location, bucket) { + return this.pathTemplates.billingAccountLocationBucketPathTemplate.render( + { + billing_account: billingAccount, + location: location, + bucket: bucket + } + ) + } + /** + * Parse the billing_account from BillingAccountLocationBucket resource. + * + * @param {string} billingAccountLocationBucketName + * A fully-qualified path representing billing_account_location_bucket resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountLocationBucketName( + billingAccountLocationBucketName + ) { + return this.pathTemplates.billingAccountLocationBucketPathTemplate.match( + billingAccountLocationBucketName + ).billing_account + } + /** + * Parse the location from BillingAccountLocationBucket resource. + * + * @param {string} billingAccountLocationBucketName + * A fully-qualified path representing billing_account_location_bucket resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBillingAccountLocationBucketName( + billingAccountLocationBucketName + ) { + return this.pathTemplates.billingAccountLocationBucketPathTemplate.match( + billingAccountLocationBucketName + ).location + } + /** + * Parse the bucket from BillingAccountLocationBucket resource. + * + * @param {string} billingAccountLocationBucketName + * A fully-qualified path representing billing_account_location_bucket resource. + * @returns {string} A string representing the bucket. + */ + matchBucketFromBillingAccountLocationBucketName( + billingAccountLocationBucketName + ) { + return this.pathTemplates.billingAccountLocationBucketPathTemplate.match( + billingAccountLocationBucketName + ).bucket + } + /** + * Return a fully-qualified billingAccountLog resource name string. + * + * @param {string} billing_account + * @param {string} log + * @returns {string} Resource name string. + */ + billingAccountLogPath(billingAccount, log) { + return this.pathTemplates.billingAccountLogPathTemplate.render({ + billing_account: billingAccount, + log: log + }) + } + /** + * Parse the billing_account from BillingAccountLog resource. + * + * @param {string} billingAccountLogName + * A fully-qualified path representing billing_account_log resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountLogName(billingAccountLogName) { + return this.pathTemplates.billingAccountLogPathTemplate.match( + billingAccountLogName + ).billing_account + } + /** + * Parse the log from BillingAccountLog resource. + * + * @param {string} billingAccountLogName + * A fully-qualified path representing billing_account_log resource. + * @returns {string} A string representing the log. + */ + matchLogFromBillingAccountLogName(billingAccountLogName) { + return this.pathTemplates.billingAccountLogPathTemplate.match( + billingAccountLogName + ).log + } + /** + * Return a fully-qualified billingAccountSink resource name string. + * + * @param {string} billing_account + * @param {string} sink + * @returns {string} Resource name string. + */ + billingAccountSinkPath(billingAccount, sink) { + return this.pathTemplates.billingAccountSinkPathTemplate.render({ + billing_account: billingAccount, + sink: sink + }) + } + /** + * Parse the billing_account from BillingAccountSink resource. + * + * @param {string} billingAccountSinkName + * A fully-qualified path representing billing_account_sink resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountSinkName(billingAccountSinkName) { + return this.pathTemplates.billingAccountSinkPathTemplate.match( + billingAccountSinkName + ).billing_account + } + /** + * Parse the sink from BillingAccountSink resource. + * + * @param {string} billingAccountSinkName + * A fully-qualified path representing billing_account_sink resource. + * @returns {string} A string representing the sink. + */ + matchSinkFromBillingAccountSinkName(billingAccountSinkName) { + return this.pathTemplates.billingAccountSinkPathTemplate.match( + billingAccountSinkName + ).sink + } + /** + * Return a fully-qualified folderCmekSettings resource name string. + * + * @param {string} folder + * @returns {string} Resource name string. + */ + folderCmekSettingsPath(folder) { + return this.pathTemplates.folderCmekSettingsPathTemplate.render({ + folder: folder + }) + } + /** + * Parse the folder from FolderCmekSettings resource. + * + * @param {string} folderCmekSettingsName + * A fully-qualified path representing folder_cmekSettings resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderCmekSettingsName(folderCmekSettingsName) { + return this.pathTemplates.folderCmekSettingsPathTemplate.match( + folderCmekSettingsName + ).folder + } + /** + * Return a fully-qualified folderExclusion resource name string. + * + * @param {string} folder + * @param {string} exclusion + * @returns {string} Resource name string. + */ + folderExclusionPath(folder, exclusion) { + return this.pathTemplates.folderExclusionPathTemplate.render({ + folder: folder, + exclusion: exclusion + }) + } + /** + * Parse the folder from FolderExclusion resource. + * + * @param {string} folderExclusionName + * A fully-qualified path representing folder_exclusion resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderExclusionName(folderExclusionName) { + return this.pathTemplates.folderExclusionPathTemplate.match( + folderExclusionName + ).folder + } + /** + * Parse the exclusion from FolderExclusion resource. + * + * @param {string} folderExclusionName + * A fully-qualified path representing folder_exclusion resource. + * @returns {string} A string representing the exclusion. + */ + matchExclusionFromFolderExclusionName(folderExclusionName) { + return this.pathTemplates.folderExclusionPathTemplate.match( + folderExclusionName + ).exclusion + } + /** + * Return a fully-qualified folderLocationBucket resource name string. + * + * @param {string} folder + * @param {string} location + * @param {string} bucket + * @returns {string} Resource name string. + */ + folderLocationBucketPath(folder, location, bucket) { + return this.pathTemplates.folderLocationBucketPathTemplate.render({ + folder: folder, + location: location, + bucket: bucket + }) + } + /** + * Parse the folder from FolderLocationBucket resource. + * + * @param {string} folderLocationBucketName + * A fully-qualified path representing folder_location_bucket resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderLocationBucketName(folderLocationBucketName) { + return this.pathTemplates.folderLocationBucketPathTemplate.match( + folderLocationBucketName + ).folder + } + /** + * Parse the location from FolderLocationBucket resource. + * + * @param {string} folderLocationBucketName + * A fully-qualified path representing folder_location_bucket resource. + * @returns {string} A string representing the location. + */ + matchLocationFromFolderLocationBucketName(folderLocationBucketName) { + return this.pathTemplates.folderLocationBucketPathTemplate.match( + folderLocationBucketName + ).location + } + /** + * Parse the bucket from FolderLocationBucket resource. + * + * @param {string} folderLocationBucketName + * A fully-qualified path representing folder_location_bucket resource. + * @returns {string} A string representing the bucket. + */ + matchBucketFromFolderLocationBucketName(folderLocationBucketName) { + return this.pathTemplates.folderLocationBucketPathTemplate.match( + folderLocationBucketName + ).bucket + } + /** + * Return a fully-qualified folderLog resource name string. + * + * @param {string} folder + * @param {string} log + * @returns {string} Resource name string. + */ + folderLogPath(folder, log) { + return this.pathTemplates.folderLogPathTemplate.render({ + folder: folder, + log: log + }) + } + /** + * Parse the folder from FolderLog resource. + * + * @param {string} folderLogName + * A fully-qualified path representing folder_log resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderLogName(folderLogName) { + return this.pathTemplates.folderLogPathTemplate.match(folderLogName) + .folder + } + /** + * Parse the log from FolderLog resource. + * + * @param {string} folderLogName + * A fully-qualified path representing folder_log resource. + * @returns {string} A string representing the log. + */ + matchLogFromFolderLogName(folderLogName) { + return this.pathTemplates.folderLogPathTemplate.match(folderLogName) + .log + } + /** + * Return a fully-qualified folderSink resource name string. + * + * @param {string} folder + * @param {string} sink + * @returns {string} Resource name string. + */ + folderSinkPath(folder, sink) { + return this.pathTemplates.folderSinkPathTemplate.render({ + folder: folder, + sink: sink + }) + } + /** + * Parse the folder from FolderSink resource. + * + * @param {string} folderSinkName + * A fully-qualified path representing folder_sink resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderSinkName(folderSinkName) { + return this.pathTemplates.folderSinkPathTemplate.match(folderSinkName) + .folder + } + /** + * Parse the sink from FolderSink resource. + * + * @param {string} folderSinkName + * A fully-qualified path representing folder_sink resource. + * @returns {string} A string representing the sink. + */ + matchSinkFromFolderSinkName(folderSinkName) { + return this.pathTemplates.folderSinkPathTemplate.match(folderSinkName) + .sink + } + /** + * Return a fully-qualified logMetric resource name string. + * + * @param {string} project + * @param {string} metric + * @returns {string} Resource name string. + */ + logMetricPath(project, metric) { + return this.pathTemplates.logMetricPathTemplate.render({ + project: project, + metric: metric + }) + } + /** + * Parse the project from LogMetric resource. + * + * @param {string} logMetricName + * A fully-qualified path representing LogMetric resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLogMetricName(logMetricName) { + return this.pathTemplates.logMetricPathTemplate.match(logMetricName) + .project + } + /** + * Parse the metric from LogMetric resource. + * + * @param {string} logMetricName + * A fully-qualified path representing LogMetric resource. + * @returns {string} A string representing the metric. + */ + matchMetricFromLogMetricName(logMetricName) { + return this.pathTemplates.logMetricPathTemplate.match(logMetricName) + .metric + } + /** + * Return a fully-qualified organizationCmekSettings resource name string. + * + * @param {string} organization + * @returns {string} Resource name string. + */ + organizationCmekSettingsPath(organization) { + return this.pathTemplates.organizationCmekSettingsPathTemplate.render( + { + organization: organization + } + ) + } + /** + * Parse the organization from OrganizationCmekSettings resource. + * + * @param {string} organizationCmekSettingsName + * A fully-qualified path representing organization_cmekSettings resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationCmekSettingsName( + organizationCmekSettingsName + ) { + return this.pathTemplates.organizationCmekSettingsPathTemplate.match( + organizationCmekSettingsName + ).organization + } + /** + * Return a fully-qualified organizationExclusion resource name string. + * + * @param {string} organization + * @param {string} exclusion + * @returns {string} Resource name string. + */ + organizationExclusionPath(organization, exclusion) { + return this.pathTemplates.organizationExclusionPathTemplate.render({ + organization: organization, + exclusion: exclusion + }) + } + /** + * Parse the organization from OrganizationExclusion resource. + * + * @param {string} organizationExclusionName + * A fully-qualified path representing organization_exclusion resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationExclusionName( + organizationExclusionName + ) { + return this.pathTemplates.organizationExclusionPathTemplate.match( + organizationExclusionName + ).organization + } + /** + * Parse the exclusion from OrganizationExclusion resource. + * + * @param {string} organizationExclusionName + * A fully-qualified path representing organization_exclusion resource. + * @returns {string} A string representing the exclusion. + */ + matchExclusionFromOrganizationExclusionName(organizationExclusionName) { + return this.pathTemplates.organizationExclusionPathTemplate.match( + organizationExclusionName + ).exclusion + } + /** + * Return a fully-qualified organizationLocationBucket resource name string. + * + * @param {string} organization + * @param {string} location + * @param {string} bucket + * @returns {string} Resource name string. + */ + organizationLocationBucketPath(organization, location, bucket) { + return this.pathTemplates.organizationLocationBucketPathTemplate.render( + { + organization: organization, + location: location, + bucket: bucket + } + ) + } + /** + * Parse the organization from OrganizationLocationBucket resource. + * + * @param {string} organizationLocationBucketName + * A fully-qualified path representing organization_location_bucket resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationLocationBucketName( + organizationLocationBucketName + ) { + return this.pathTemplates.organizationLocationBucketPathTemplate.match( + organizationLocationBucketName + ).organization + } + /** + * Parse the location from OrganizationLocationBucket resource. + * + * @param {string} organizationLocationBucketName + * A fully-qualified path representing organization_location_bucket resource. + * @returns {string} A string representing the location. + */ + matchLocationFromOrganizationLocationBucketName( + organizationLocationBucketName + ) { + return this.pathTemplates.organizationLocationBucketPathTemplate.match( + organizationLocationBucketName + ).location + } + /** + * Parse the bucket from OrganizationLocationBucket resource. + * + * @param {string} organizationLocationBucketName + * A fully-qualified path representing organization_location_bucket resource. + * @returns {string} A string representing the bucket. + */ + matchBucketFromOrganizationLocationBucketName( + organizationLocationBucketName + ) { + return this.pathTemplates.organizationLocationBucketPathTemplate.match( + organizationLocationBucketName + ).bucket + } + /** + * Return a fully-qualified organizationLog resource name string. + * + * @param {string} organization + * @param {string} log + * @returns {string} Resource name string. + */ + organizationLogPath(organization, log) { + return this.pathTemplates.organizationLogPathTemplate.render({ + organization: organization, + log: log + }) + } + /** + * Parse the organization from OrganizationLog resource. + * + * @param {string} organizationLogName + * A fully-qualified path representing organization_log resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationLogName(organizationLogName) { + return this.pathTemplates.organizationLogPathTemplate.match( + organizationLogName + ).organization + } + /** + * Parse the log from OrganizationLog resource. + * + * @param {string} organizationLogName + * A fully-qualified path representing organization_log resource. + * @returns {string} A string representing the log. + */ + matchLogFromOrganizationLogName(organizationLogName) { + return this.pathTemplates.organizationLogPathTemplate.match( + organizationLogName + ).log + } + /** + * Return a fully-qualified organizationSink resource name string. + * + * @param {string} organization + * @param {string} sink + * @returns {string} Resource name string. + */ + organizationSinkPath(organization, sink) { + return this.pathTemplates.organizationSinkPathTemplate.render({ + organization: organization, + sink: sink + }) + } + /** + * Parse the organization from OrganizationSink resource. + * + * @param {string} organizationSinkName + * A fully-qualified path representing organization_sink resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationSinkName(organizationSinkName) { + return this.pathTemplates.organizationSinkPathTemplate.match( + organizationSinkName + ).organization + } + /** + * Parse the sink from OrganizationSink resource. + * + * @param {string} organizationSinkName + * A fully-qualified path representing organization_sink resource. + * @returns {string} A string representing the sink. + */ + matchSinkFromOrganizationSinkName(organizationSinkName) { + return this.pathTemplates.organizationSinkPathTemplate.match( + organizationSinkName + ).sink + } + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project) { + return this.pathTemplates.projectPathTemplate.render({ + project: project + }) + } + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName) { + return this.pathTemplates.projectPathTemplate.match(projectName) + .project + } + /** + * Return a fully-qualified projectCmekSettings resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectCmekSettingsPath(project) { + return this.pathTemplates.projectCmekSettingsPathTemplate.render({ + project: project + }) + } + /** + * Parse the project from ProjectCmekSettings resource. + * + * @param {string} projectCmekSettingsName + * A fully-qualified path representing project_cmekSettings resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectCmekSettingsName(projectCmekSettingsName) { + return this.pathTemplates.projectCmekSettingsPathTemplate.match( + projectCmekSettingsName + ).project + } + /** + * Return a fully-qualified projectExclusion resource name string. + * + * @param {string} project + * @param {string} exclusion + * @returns {string} Resource name string. + */ + projectExclusionPath(project, exclusion) { + return this.pathTemplates.projectExclusionPathTemplate.render({ + project: project, + exclusion: exclusion + }) + } + /** + * Parse the project from ProjectExclusion resource. + * + * @param {string} projectExclusionName + * A fully-qualified path representing project_exclusion resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectExclusionName(projectExclusionName) { + return this.pathTemplates.projectExclusionPathTemplate.match( + projectExclusionName + ).project + } + /** + * Parse the exclusion from ProjectExclusion resource. + * + * @param {string} projectExclusionName + * A fully-qualified path representing project_exclusion resource. + * @returns {string} A string representing the exclusion. + */ + matchExclusionFromProjectExclusionName(projectExclusionName) { + return this.pathTemplates.projectExclusionPathTemplate.match( + projectExclusionName + ).exclusion + } + /** + * Return a fully-qualified projectLocationBucket resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} bucket + * @returns {string} Resource name string. + */ + projectLocationBucketPath(project, location, bucket) { + return this.pathTemplates.projectLocationBucketPathTemplate.render({ + project: project, + location: location, + bucket: bucket + }) + } + /** + * Parse the project from ProjectLocationBucket resource. + * + * @param {string} projectLocationBucketName + * A fully-qualified path representing project_location_bucket resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationBucketName(projectLocationBucketName) { + return this.pathTemplates.projectLocationBucketPathTemplate.match( + projectLocationBucketName + ).project + } + /** + * Parse the location from ProjectLocationBucket resource. + * + * @param {string} projectLocationBucketName + * A fully-qualified path representing project_location_bucket resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationBucketName(projectLocationBucketName) { + return this.pathTemplates.projectLocationBucketPathTemplate.match( + projectLocationBucketName + ).location + } + /** + * Parse the bucket from ProjectLocationBucket resource. + * + * @param {string} projectLocationBucketName + * A fully-qualified path representing project_location_bucket resource. + * @returns {string} A string representing the bucket. + */ + matchBucketFromProjectLocationBucketName(projectLocationBucketName) { + return this.pathTemplates.projectLocationBucketPathTemplate.match( + projectLocationBucketName + ).bucket + } + /** + * Return a fully-qualified projectLog resource name string. + * + * @param {string} project + * @param {string} log + * @returns {string} Resource name string. + */ + projectLogPath(project, log) { + return this.pathTemplates.projectLogPathTemplate.render({ + project: project, + log: log + }) + } + /** + * Parse the project from ProjectLog resource. + * + * @param {string} projectLogName + * A fully-qualified path representing project_log resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLogName(projectLogName) { + return this.pathTemplates.projectLogPathTemplate.match(projectLogName) + .project + } + /** + * Parse the log from ProjectLog resource. + * + * @param {string} projectLogName + * A fully-qualified path representing project_log resource. + * @returns {string} A string representing the log. + */ + matchLogFromProjectLogName(projectLogName) { + return this.pathTemplates.projectLogPathTemplate.match(projectLogName) + .log + } + /** + * Return a fully-qualified projectSink resource name string. + * + * @param {string} project + * @param {string} sink + * @returns {string} Resource name string. + */ + projectSinkPath(project, sink) { + return this.pathTemplates.projectSinkPathTemplate.render({ + project: project, + sink: sink + }) + } + /** + * Parse the project from ProjectSink resource. + * + * @param {string} projectSinkName + * A fully-qualified path representing project_sink resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectSinkName(projectSinkName) { + return this.pathTemplates.projectSinkPathTemplate.match( + projectSinkName + ).project + } + /** + * Parse the sink from ProjectSink resource. + * + * @param {string} projectSinkName + * A fully-qualified path representing project_sink resource. + * @returns {string} A string representing the sink. + */ + matchSinkFromProjectSinkName(projectSinkName) { + return this.pathTemplates.projectSinkPathTemplate.match( + projectSinkName + ).sink + } + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close() { + this.initialize() + if (!this._terminated) { + return this.loggingServiceV2Stub.then(stub => { + this._terminated = true + stub.close() + }) + } + return Promise.resolve() + } + } + exports.LoggingServiceV2Client = LoggingServiceV2Client + //# sourceMappingURL=logging_service_v2_client.js.map + + /***/ + }, + + /***/ 47516: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + // Copyright 2020 Google LLC + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + // + // ** This file is automatically generated by gapic-generator-typescript. ** + // ** https://github.com/googleapis/gapic-generator-typescript ** + // ** All changes to this file may be overwritten. ** + Object.defineProperty(exports, '__esModule', { value: true }) + exports.MetricsServiceV2Client = void 0 + const gax = __webpack_require__(12263) + const path = __webpack_require__(85622) + const gapicConfig = __webpack_require__(95739) + const version = __webpack_require__(87989) /* .version */.i8 + /** + * Service for configuring logs-based metrics. + * @class + * @memberof v2 + */ + class MetricsServiceV2Client { + /** + * Construct an instance of MetricsServiceV2Client. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - client configuration override. + * TODO(@alexander-fenster): link to gax documentation. + * @param {boolean} fallback - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts) { + var _a, _b + this._terminated = false + this.descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {} + } + // Ensure that options include all the required fields. + const staticMembers = this.constructor + const servicePath = + (opts === null || opts === void 0 ? void 0 : opts.servicePath) || + (opts === null || opts === void 0 ? void 0 : opts.apiEndpoint) || + staticMembers.servicePath + const port = + (opts === null || opts === void 0 ? void 0 : opts.port) || + staticMembers.port + const clientConfig = + (_a = + opts === null || opts === void 0 ? void 0 : opts.clientConfig) !== + null && _a !== void 0 + ? _a + : {} + const fallback = + (_b = opts === null || opts === void 0 ? void 0 : opts.fallback) !== + null && _b !== void 0 + ? _b + : typeof window !== 'undefined' + opts = Object.assign( + { servicePath, port, clientConfig, fallback }, + opts + ) + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if ( + servicePath !== staticMembers.servicePath && + !('scopes' in opts) + ) { + opts['scopes'] = staticMembers.scopes + } + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts) + // Save options to use in initialize() method. + this._opts = opts + // Save the auth object to the client, for use by other methods. + this.auth = this._gaxGrpc.auth + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes + } + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}` + ] + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`) + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`) + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`) + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`) + } + // Load the applicable protos. + // For Node.js, pass the path to JSON proto file. + // For browsers, pass the JSON content. + const nodejsProtoPath = __webpack_require__.ab + 'protos.json' + this._protos = this._gaxGrpc.loadProto( + opts.fallback + ? // eslint-disable-next-line @typescript-eslint/no-var-requires + __webpack_require__(54479) + : __webpack_require__.ab + 'protos.json' + ) + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + billingAccountCmekSettingsPathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}/cmekSettings' + ), + billingAccountExclusionPathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}/exclusions/{exclusion}' + ), + billingAccountLocationBucketPathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}/locations/{location}/buckets/{bucket}' + ), + billingAccountLogPathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}/logs/{log}' + ), + billingAccountSinkPathTemplate: new this._gaxModule.PathTemplate( + 'billingAccounts/{billing_account}/sinks/{sink}' + ), + folderCmekSettingsPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/cmekSettings' + ), + folderExclusionPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/exclusions/{exclusion}' + ), + folderLocationBucketPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/locations/{location}/buckets/{bucket}' + ), + folderLogPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/logs/{log}' + ), + folderSinkPathTemplate: new this._gaxModule.PathTemplate( + 'folders/{folder}/sinks/{sink}' + ), + logMetricPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/metrics/{metric}' + ), + organizationCmekSettingsPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/cmekSettings' + ), + organizationExclusionPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/exclusions/{exclusion}' + ), + organizationLocationBucketPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/locations/{location}/buckets/{bucket}' + ), + organizationLogPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/logs/{log}' + ), + organizationSinkPathTemplate: new this._gaxModule.PathTemplate( + 'organizations/{organization}/sinks/{sink}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + projectCmekSettingsPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/cmekSettings' + ), + projectExclusionPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/exclusions/{exclusion}' + ), + projectLocationBucketPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/buckets/{bucket}' + ), + projectLogPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/logs/{log}' + ), + projectSinkPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/sinks/{sink}' + ) + } + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listLogMetrics: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'metrics' + ) + } + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.logging.v2.MetricsServiceV2', + gapicConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') } + ) + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {} + } + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.metricsServiceV2Stub) { + return this.metricsServiceV2Stub + } + // Put together the "service stub" for + // google.logging.v2.MetricsServiceV2. + this.metricsServiceV2Stub = this._gaxGrpc.createStub( + this._opts.fallback + ? this._protos.lookupService('google.logging.v2.MetricsServiceV2') + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._protos.google.logging.v2.MetricsServiceV2, + this._opts + ) + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const metricsServiceV2StubMethods = [ + 'listLogMetrics', + 'getLogMetric', + 'createLogMetric', + 'updateLogMetric', + 'deleteLogMetric' + ] + for (const methodName of metricsServiceV2StubMethods) { + const callPromise = this.metricsServiceV2Stub.then( + stub => (...args) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.') + } + const func = stub[methodName] + return func.apply(stub, args) + }, + err => () => { + throw err + } + ) + const descriptor = this.descriptors.page[methodName] || undefined + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ) + this.innerApiCalls[methodName] = apiCall + } + return this.metricsServiceV2Stub + } + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'logging.googleapis.com' + } + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'logging.googleapis.com' + } + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443 + } + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', + 'https://www.googleapis.com/auth/logging.admin', + 'https://www.googleapis.com/auth/logging.read', + 'https://www.googleapis.com/auth/logging.write' + ] + } + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback) { + if (callback) { + this.auth.getProjectId(callback) + return + } + return this.auth.getProjectId() + } + /** + * Gets a logs-based metric. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.metricName + * Required. The resource name of the desired metric: + * + * "projects/[PROJECT_ID]/metrics/[METRIC_ID]" + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [LogMetric]{@link google.logging.v2.LogMetric}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.getLogMetric(request); + */ + getLogMetric(request, optionsOrCallback, callback) { + request = request || {} + let options + if ( + typeof optionsOrCallback === 'function' && + callback === undefined + ) { + callback = optionsOrCallback + options = {} + } else { + options = optionsOrCallback + } + options = options || {} + options.otherArgs = options.otherArgs || {} + options.otherArgs.headers = options.otherArgs.headers || {} + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + metric_name: request.metricName || '' + }) + this.initialize() + return this.innerApiCalls.getLogMetric(request, options, callback) + } + /** + * Creates a logs-based metric. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the project in which to create the metric: + * + * "projects/[PROJECT_ID]" + * + * The new metric must be provided in the request. + * @param {google.logging.v2.LogMetric} request.metric + * Required. The new logs-based metric, which must not have an identifier that + * already exists. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [LogMetric]{@link google.logging.v2.LogMetric}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.createLogMetric(request); + */ + createLogMetric(request, optionsOrCallback, callback) { + request = request || {} + let options + if ( + typeof optionsOrCallback === 'function' && + callback === undefined + ) { + callback = optionsOrCallback + options = {} + } else { + options = optionsOrCallback + } + options = options || {} + options.otherArgs = options.otherArgs || {} + options.otherArgs.headers = options.otherArgs.headers || {} + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + parent: request.parent || '' + }) + this.initialize() + return this.innerApiCalls.createLogMetric(request, options, callback) + } + /** + * Creates or updates a logs-based metric. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.metricName + * Required. The resource name of the metric to update: + * + * "projects/[PROJECT_ID]/metrics/[METRIC_ID]" + * + * The updated metric must be provided in the request and it's + * `name` field must be the same as `[METRIC_ID]` If the metric + * does not exist in `[PROJECT_ID]`, then a new metric is created. + * @param {google.logging.v2.LogMetric} request.metric + * Required. The updated metric. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [LogMetric]{@link google.logging.v2.LogMetric}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.updateLogMetric(request); + */ + updateLogMetric(request, optionsOrCallback, callback) { + request = request || {} + let options + if ( + typeof optionsOrCallback === 'function' && + callback === undefined + ) { + callback = optionsOrCallback + options = {} + } else { + options = optionsOrCallback + } + options = options || {} + options.otherArgs = options.otherArgs || {} + options.otherArgs.headers = options.otherArgs.headers || {} + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + metric_name: request.metricName || '' + }) + this.initialize() + return this.innerApiCalls.updateLogMetric(request, options, callback) + } + /** + * Deletes a logs-based metric. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.metricName + * Required. The resource name of the metric to delete: + * + * "projects/[PROJECT_ID]/metrics/[METRIC_ID]" + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.deleteLogMetric(request); + */ + deleteLogMetric(request, optionsOrCallback, callback) { + request = request || {} + let options + if ( + typeof optionsOrCallback === 'function' && + callback === undefined + ) { + callback = optionsOrCallback + options = {} + } else { + options = optionsOrCallback + } + options = options || {} + options.otherArgs = options.otherArgs || {} + options.otherArgs.headers = options.otherArgs.headers || {} + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + metric_name: request.metricName || '' + }) + this.initialize() + return this.innerApiCalls.deleteLogMetric(request, options, callback) + } + /** + * Lists logs-based metrics. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project containing the metrics: + * + * "projects/[PROJECT_ID]" + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [LogMetric]{@link google.logging.v2.LogMetric}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listLogMetricsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listLogMetrics(request, optionsOrCallback, callback) { + request = request || {} + let options + if ( + typeof optionsOrCallback === 'function' && + callback === undefined + ) { + callback = optionsOrCallback + options = {} + } else { + options = optionsOrCallback + } + options = options || {} + options.otherArgs = options.otherArgs || {} + options.otherArgs.headers = options.otherArgs.headers || {} + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + parent: request.parent || '' + }) + this.initialize() + return this.innerApiCalls.listLogMetrics(request, options, callback) + } + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project containing the metrics: + * + * "projects/[PROJECT_ID]" + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [LogMetric]{@link google.logging.v2.LogMetric} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listLogMetricsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listLogMetricsStream(request, options) { + request = request || {} + options = options || {} + options.otherArgs = options.otherArgs || {} + options.otherArgs.headers = options.otherArgs.headers || {} + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + parent: request.parent || '' + }) + const callSettings = new gax.CallSettings(options) + this.initialize() + return this.descriptors.page.listLogMetrics.createStream( + this.innerApiCalls.listLogMetrics, + request, + callSettings + ) + } + /** + * Equivalent to `listLogMetrics`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project containing the metrics: + * + * "projects/[PROJECT_ID]" + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [LogMetric]{@link google.logging.v2.LogMetric}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listLogMetricsAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listLogMetricsAsync(request, options) { + request = request || {} + options = options || {} + options.otherArgs = options.otherArgs || {} + options.otherArgs.headers = options.otherArgs.headers || {} + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + parent: request.parent || '' + }) + options = options || {} + const callSettings = new gax.CallSettings(options) + this.initialize() + return this.descriptors.page.listLogMetrics.asyncIterate( + this.innerApiCalls['listLogMetrics'], + request, + callSettings + ) + } + // -------------------- + // -- Path templates -- + // -------------------- + /** + * Return a fully-qualified billingAccountCmekSettings resource name string. + * + * @param {string} billing_account + * @returns {string} Resource name string. + */ + billingAccountCmekSettingsPath(billingAccount) { + return this.pathTemplates.billingAccountCmekSettingsPathTemplate.render( + { + billing_account: billingAccount + } + ) + } + /** + * Parse the billing_account from BillingAccountCmekSettings resource. + * + * @param {string} billingAccountCmekSettingsName + * A fully-qualified path representing billing_account_cmekSettings resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountCmekSettingsName( + billingAccountCmekSettingsName + ) { + return this.pathTemplates.billingAccountCmekSettingsPathTemplate.match( + billingAccountCmekSettingsName + ).billing_account + } + /** + * Return a fully-qualified billingAccountExclusion resource name string. + * + * @param {string} billing_account + * @param {string} exclusion + * @returns {string} Resource name string. + */ + billingAccountExclusionPath(billingAccount, exclusion) { + return this.pathTemplates.billingAccountExclusionPathTemplate.render({ + billing_account: billingAccount, + exclusion: exclusion + }) + } + /** + * Parse the billing_account from BillingAccountExclusion resource. + * + * @param {string} billingAccountExclusionName + * A fully-qualified path representing billing_account_exclusion resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountExclusionName( + billingAccountExclusionName + ) { + return this.pathTemplates.billingAccountExclusionPathTemplate.match( + billingAccountExclusionName + ).billing_account + } + /** + * Parse the exclusion from BillingAccountExclusion resource. + * + * @param {string} billingAccountExclusionName + * A fully-qualified path representing billing_account_exclusion resource. + * @returns {string} A string representing the exclusion. + */ + matchExclusionFromBillingAccountExclusionName( + billingAccountExclusionName + ) { + return this.pathTemplates.billingAccountExclusionPathTemplate.match( + billingAccountExclusionName + ).exclusion + } + /** + * Return a fully-qualified billingAccountLocationBucket resource name string. + * + * @param {string} billing_account + * @param {string} location + * @param {string} bucket + * @returns {string} Resource name string. + */ + billingAccountLocationBucketPath(billingAccount, location, bucket) { + return this.pathTemplates.billingAccountLocationBucketPathTemplate.render( + { + billing_account: billingAccount, + location: location, + bucket: bucket + } + ) + } + /** + * Parse the billing_account from BillingAccountLocationBucket resource. + * + * @param {string} billingAccountLocationBucketName + * A fully-qualified path representing billing_account_location_bucket resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountLocationBucketName( + billingAccountLocationBucketName + ) { + return this.pathTemplates.billingAccountLocationBucketPathTemplate.match( + billingAccountLocationBucketName + ).billing_account + } + /** + * Parse the location from BillingAccountLocationBucket resource. + * + * @param {string} billingAccountLocationBucketName + * A fully-qualified path representing billing_account_location_bucket resource. + * @returns {string} A string representing the location. + */ + matchLocationFromBillingAccountLocationBucketName( + billingAccountLocationBucketName + ) { + return this.pathTemplates.billingAccountLocationBucketPathTemplate.match( + billingAccountLocationBucketName + ).location + } + /** + * Parse the bucket from BillingAccountLocationBucket resource. + * + * @param {string} billingAccountLocationBucketName + * A fully-qualified path representing billing_account_location_bucket resource. + * @returns {string} A string representing the bucket. + */ + matchBucketFromBillingAccountLocationBucketName( + billingAccountLocationBucketName + ) { + return this.pathTemplates.billingAccountLocationBucketPathTemplate.match( + billingAccountLocationBucketName + ).bucket + } + /** + * Return a fully-qualified billingAccountLog resource name string. + * + * @param {string} billing_account + * @param {string} log + * @returns {string} Resource name string. + */ + billingAccountLogPath(billingAccount, log) { + return this.pathTemplates.billingAccountLogPathTemplate.render({ + billing_account: billingAccount, + log: log + }) + } + /** + * Parse the billing_account from BillingAccountLog resource. + * + * @param {string} billingAccountLogName + * A fully-qualified path representing billing_account_log resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountLogName(billingAccountLogName) { + return this.pathTemplates.billingAccountLogPathTemplate.match( + billingAccountLogName + ).billing_account + } + /** + * Parse the log from BillingAccountLog resource. + * + * @param {string} billingAccountLogName + * A fully-qualified path representing billing_account_log resource. + * @returns {string} A string representing the log. + */ + matchLogFromBillingAccountLogName(billingAccountLogName) { + return this.pathTemplates.billingAccountLogPathTemplate.match( + billingAccountLogName + ).log + } + /** + * Return a fully-qualified billingAccountSink resource name string. + * + * @param {string} billing_account + * @param {string} sink + * @returns {string} Resource name string. + */ + billingAccountSinkPath(billingAccount, sink) { + return this.pathTemplates.billingAccountSinkPathTemplate.render({ + billing_account: billingAccount, + sink: sink + }) + } + /** + * Parse the billing_account from BillingAccountSink resource. + * + * @param {string} billingAccountSinkName + * A fully-qualified path representing billing_account_sink resource. + * @returns {string} A string representing the billing_account. + */ + matchBillingAccountFromBillingAccountSinkName(billingAccountSinkName) { + return this.pathTemplates.billingAccountSinkPathTemplate.match( + billingAccountSinkName + ).billing_account + } + /** + * Parse the sink from BillingAccountSink resource. + * + * @param {string} billingAccountSinkName + * A fully-qualified path representing billing_account_sink resource. + * @returns {string} A string representing the sink. + */ + matchSinkFromBillingAccountSinkName(billingAccountSinkName) { + return this.pathTemplates.billingAccountSinkPathTemplate.match( + billingAccountSinkName + ).sink + } + /** + * Return a fully-qualified folderCmekSettings resource name string. + * + * @param {string} folder + * @returns {string} Resource name string. + */ + folderCmekSettingsPath(folder) { + return this.pathTemplates.folderCmekSettingsPathTemplate.render({ + folder: folder + }) + } + /** + * Parse the folder from FolderCmekSettings resource. + * + * @param {string} folderCmekSettingsName + * A fully-qualified path representing folder_cmekSettings resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderCmekSettingsName(folderCmekSettingsName) { + return this.pathTemplates.folderCmekSettingsPathTemplate.match( + folderCmekSettingsName + ).folder + } + /** + * Return a fully-qualified folderExclusion resource name string. + * + * @param {string} folder + * @param {string} exclusion + * @returns {string} Resource name string. + */ + folderExclusionPath(folder, exclusion) { + return this.pathTemplates.folderExclusionPathTemplate.render({ + folder: folder, + exclusion: exclusion + }) + } + /** + * Parse the folder from FolderExclusion resource. + * + * @param {string} folderExclusionName + * A fully-qualified path representing folder_exclusion resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderExclusionName(folderExclusionName) { + return this.pathTemplates.folderExclusionPathTemplate.match( + folderExclusionName + ).folder + } + /** + * Parse the exclusion from FolderExclusion resource. + * + * @param {string} folderExclusionName + * A fully-qualified path representing folder_exclusion resource. + * @returns {string} A string representing the exclusion. + */ + matchExclusionFromFolderExclusionName(folderExclusionName) { + return this.pathTemplates.folderExclusionPathTemplate.match( + folderExclusionName + ).exclusion + } + /** + * Return a fully-qualified folderLocationBucket resource name string. + * + * @param {string} folder + * @param {string} location + * @param {string} bucket + * @returns {string} Resource name string. + */ + folderLocationBucketPath(folder, location, bucket) { + return this.pathTemplates.folderLocationBucketPathTemplate.render({ + folder: folder, + location: location, + bucket: bucket + }) + } + /** + * Parse the folder from FolderLocationBucket resource. + * + * @param {string} folderLocationBucketName + * A fully-qualified path representing folder_location_bucket resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderLocationBucketName(folderLocationBucketName) { + return this.pathTemplates.folderLocationBucketPathTemplate.match( + folderLocationBucketName + ).folder + } + /** + * Parse the location from FolderLocationBucket resource. + * + * @param {string} folderLocationBucketName + * A fully-qualified path representing folder_location_bucket resource. + * @returns {string} A string representing the location. + */ + matchLocationFromFolderLocationBucketName(folderLocationBucketName) { + return this.pathTemplates.folderLocationBucketPathTemplate.match( + folderLocationBucketName + ).location + } + /** + * Parse the bucket from FolderLocationBucket resource. + * + * @param {string} folderLocationBucketName + * A fully-qualified path representing folder_location_bucket resource. + * @returns {string} A string representing the bucket. + */ + matchBucketFromFolderLocationBucketName(folderLocationBucketName) { + return this.pathTemplates.folderLocationBucketPathTemplate.match( + folderLocationBucketName + ).bucket + } + /** + * Return a fully-qualified folderLog resource name string. + * + * @param {string} folder + * @param {string} log + * @returns {string} Resource name string. + */ + folderLogPath(folder, log) { + return this.pathTemplates.folderLogPathTemplate.render({ + folder: folder, + log: log + }) + } + /** + * Parse the folder from FolderLog resource. + * + * @param {string} folderLogName + * A fully-qualified path representing folder_log resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderLogName(folderLogName) { + return this.pathTemplates.folderLogPathTemplate.match(folderLogName) + .folder + } + /** + * Parse the log from FolderLog resource. + * + * @param {string} folderLogName + * A fully-qualified path representing folder_log resource. + * @returns {string} A string representing the log. + */ + matchLogFromFolderLogName(folderLogName) { + return this.pathTemplates.folderLogPathTemplate.match(folderLogName) + .log + } + /** + * Return a fully-qualified folderSink resource name string. + * + * @param {string} folder + * @param {string} sink + * @returns {string} Resource name string. + */ + folderSinkPath(folder, sink) { + return this.pathTemplates.folderSinkPathTemplate.render({ + folder: folder, + sink: sink + }) + } + /** + * Parse the folder from FolderSink resource. + * + * @param {string} folderSinkName + * A fully-qualified path representing folder_sink resource. + * @returns {string} A string representing the folder. + */ + matchFolderFromFolderSinkName(folderSinkName) { + return this.pathTemplates.folderSinkPathTemplate.match(folderSinkName) + .folder + } + /** + * Parse the sink from FolderSink resource. + * + * @param {string} folderSinkName + * A fully-qualified path representing folder_sink resource. + * @returns {string} A string representing the sink. + */ + matchSinkFromFolderSinkName(folderSinkName) { + return this.pathTemplates.folderSinkPathTemplate.match(folderSinkName) + .sink + } + /** + * Return a fully-qualified logMetric resource name string. + * + * @param {string} project + * @param {string} metric + * @returns {string} Resource name string. + */ + logMetricPath(project, metric) { + return this.pathTemplates.logMetricPathTemplate.render({ + project: project, + metric: metric + }) + } + /** + * Parse the project from LogMetric resource. + * + * @param {string} logMetricName + * A fully-qualified path representing LogMetric resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLogMetricName(logMetricName) { + return this.pathTemplates.logMetricPathTemplate.match(logMetricName) + .project + } + /** + * Parse the metric from LogMetric resource. + * + * @param {string} logMetricName + * A fully-qualified path representing LogMetric resource. + * @returns {string} A string representing the metric. + */ + matchMetricFromLogMetricName(logMetricName) { + return this.pathTemplates.logMetricPathTemplate.match(logMetricName) + .metric + } + /** + * Return a fully-qualified organizationCmekSettings resource name string. + * + * @param {string} organization + * @returns {string} Resource name string. + */ + organizationCmekSettingsPath(organization) { + return this.pathTemplates.organizationCmekSettingsPathTemplate.render( + { + organization: organization + } + ) + } + /** + * Parse the organization from OrganizationCmekSettings resource. + * + * @param {string} organizationCmekSettingsName + * A fully-qualified path representing organization_cmekSettings resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationCmekSettingsName( + organizationCmekSettingsName + ) { + return this.pathTemplates.organizationCmekSettingsPathTemplate.match( + organizationCmekSettingsName + ).organization + } + /** + * Return a fully-qualified organizationExclusion resource name string. + * + * @param {string} organization + * @param {string} exclusion + * @returns {string} Resource name string. + */ + organizationExclusionPath(organization, exclusion) { + return this.pathTemplates.organizationExclusionPathTemplate.render({ + organization: organization, + exclusion: exclusion + }) + } + /** + * Parse the organization from OrganizationExclusion resource. + * + * @param {string} organizationExclusionName + * A fully-qualified path representing organization_exclusion resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationExclusionName( + organizationExclusionName + ) { + return this.pathTemplates.organizationExclusionPathTemplate.match( + organizationExclusionName + ).organization + } + /** + * Parse the exclusion from OrganizationExclusion resource. + * + * @param {string} organizationExclusionName + * A fully-qualified path representing organization_exclusion resource. + * @returns {string} A string representing the exclusion. + */ + matchExclusionFromOrganizationExclusionName(organizationExclusionName) { + return this.pathTemplates.organizationExclusionPathTemplate.match( + organizationExclusionName + ).exclusion + } + /** + * Return a fully-qualified organizationLocationBucket resource name string. + * + * @param {string} organization + * @param {string} location + * @param {string} bucket + * @returns {string} Resource name string. + */ + organizationLocationBucketPath(organization, location, bucket) { + return this.pathTemplates.organizationLocationBucketPathTemplate.render( + { + organization: organization, + location: location, + bucket: bucket + } + ) + } + /** + * Parse the organization from OrganizationLocationBucket resource. + * + * @param {string} organizationLocationBucketName + * A fully-qualified path representing organization_location_bucket resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationLocationBucketName( + organizationLocationBucketName + ) { + return this.pathTemplates.organizationLocationBucketPathTemplate.match( + organizationLocationBucketName + ).organization + } + /** + * Parse the location from OrganizationLocationBucket resource. + * + * @param {string} organizationLocationBucketName + * A fully-qualified path representing organization_location_bucket resource. + * @returns {string} A string representing the location. + */ + matchLocationFromOrganizationLocationBucketName( + organizationLocationBucketName + ) { + return this.pathTemplates.organizationLocationBucketPathTemplate.match( + organizationLocationBucketName + ).location + } + /** + * Parse the bucket from OrganizationLocationBucket resource. + * + * @param {string} organizationLocationBucketName + * A fully-qualified path representing organization_location_bucket resource. + * @returns {string} A string representing the bucket. + */ + matchBucketFromOrganizationLocationBucketName( + organizationLocationBucketName + ) { + return this.pathTemplates.organizationLocationBucketPathTemplate.match( + organizationLocationBucketName + ).bucket + } + /** + * Return a fully-qualified organizationLog resource name string. + * + * @param {string} organization + * @param {string} log + * @returns {string} Resource name string. + */ + organizationLogPath(organization, log) { + return this.pathTemplates.organizationLogPathTemplate.render({ + organization: organization, + log: log + }) + } + /** + * Parse the organization from OrganizationLog resource. + * + * @param {string} organizationLogName + * A fully-qualified path representing organization_log resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationLogName(organizationLogName) { + return this.pathTemplates.organizationLogPathTemplate.match( + organizationLogName + ).organization + } + /** + * Parse the log from OrganizationLog resource. + * + * @param {string} organizationLogName + * A fully-qualified path representing organization_log resource. + * @returns {string} A string representing the log. + */ + matchLogFromOrganizationLogName(organizationLogName) { + return this.pathTemplates.organizationLogPathTemplate.match( + organizationLogName + ).log + } + /** + * Return a fully-qualified organizationSink resource name string. + * + * @param {string} organization + * @param {string} sink + * @returns {string} Resource name string. + */ + organizationSinkPath(organization, sink) { + return this.pathTemplates.organizationSinkPathTemplate.render({ + organization: organization, + sink: sink + }) + } + /** + * Parse the organization from OrganizationSink resource. + * + * @param {string} organizationSinkName + * A fully-qualified path representing organization_sink resource. + * @returns {string} A string representing the organization. + */ + matchOrganizationFromOrganizationSinkName(organizationSinkName) { + return this.pathTemplates.organizationSinkPathTemplate.match( + organizationSinkName + ).organization + } + /** + * Parse the sink from OrganizationSink resource. + * + * @param {string} organizationSinkName + * A fully-qualified path representing organization_sink resource. + * @returns {string} A string representing the sink. + */ + matchSinkFromOrganizationSinkName(organizationSinkName) { + return this.pathTemplates.organizationSinkPathTemplate.match( + organizationSinkName + ).sink + } + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project) { + return this.pathTemplates.projectPathTemplate.render({ + project: project + }) + } + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName) { + return this.pathTemplates.projectPathTemplate.match(projectName) + .project + } + /** + * Return a fully-qualified projectCmekSettings resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectCmekSettingsPath(project) { + return this.pathTemplates.projectCmekSettingsPathTemplate.render({ + project: project + }) + } + /** + * Parse the project from ProjectCmekSettings resource. + * + * @param {string} projectCmekSettingsName + * A fully-qualified path representing project_cmekSettings resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectCmekSettingsName(projectCmekSettingsName) { + return this.pathTemplates.projectCmekSettingsPathTemplate.match( + projectCmekSettingsName + ).project + } + /** + * Return a fully-qualified projectExclusion resource name string. + * + * @param {string} project + * @param {string} exclusion + * @returns {string} Resource name string. + */ + projectExclusionPath(project, exclusion) { + return this.pathTemplates.projectExclusionPathTemplate.render({ + project: project, + exclusion: exclusion + }) + } + /** + * Parse the project from ProjectExclusion resource. + * + * @param {string} projectExclusionName + * A fully-qualified path representing project_exclusion resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectExclusionName(projectExclusionName) { + return this.pathTemplates.projectExclusionPathTemplate.match( + projectExclusionName + ).project + } + /** + * Parse the exclusion from ProjectExclusion resource. + * + * @param {string} projectExclusionName + * A fully-qualified path representing project_exclusion resource. + * @returns {string} A string representing the exclusion. + */ + matchExclusionFromProjectExclusionName(projectExclusionName) { + return this.pathTemplates.projectExclusionPathTemplate.match( + projectExclusionName + ).exclusion + } + /** + * Return a fully-qualified projectLocationBucket resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} bucket + * @returns {string} Resource name string. + */ + projectLocationBucketPath(project, location, bucket) { + return this.pathTemplates.projectLocationBucketPathTemplate.render({ + project: project, + location: location, + bucket: bucket + }) + } + /** + * Parse the project from ProjectLocationBucket resource. + * + * @param {string} projectLocationBucketName + * A fully-qualified path representing project_location_bucket resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLocationBucketName(projectLocationBucketName) { + return this.pathTemplates.projectLocationBucketPathTemplate.match( + projectLocationBucketName + ).project + } + /** + * Parse the location from ProjectLocationBucket resource. + * + * @param {string} projectLocationBucketName + * A fully-qualified path representing project_location_bucket resource. + * @returns {string} A string representing the location. + */ + matchLocationFromProjectLocationBucketName(projectLocationBucketName) { + return this.pathTemplates.projectLocationBucketPathTemplate.match( + projectLocationBucketName + ).location + } + /** + * Parse the bucket from ProjectLocationBucket resource. + * + * @param {string} projectLocationBucketName + * A fully-qualified path representing project_location_bucket resource. + * @returns {string} A string representing the bucket. + */ + matchBucketFromProjectLocationBucketName(projectLocationBucketName) { + return this.pathTemplates.projectLocationBucketPathTemplate.match( + projectLocationBucketName + ).bucket + } + /** + * Return a fully-qualified projectLog resource name string. + * + * @param {string} project + * @param {string} log + * @returns {string} Resource name string. + */ + projectLogPath(project, log) { + return this.pathTemplates.projectLogPathTemplate.render({ + project: project, + log: log + }) + } + /** + * Parse the project from ProjectLog resource. + * + * @param {string} projectLogName + * A fully-qualified path representing project_log resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectLogName(projectLogName) { + return this.pathTemplates.projectLogPathTemplate.match(projectLogName) + .project + } + /** + * Parse the log from ProjectLog resource. + * + * @param {string} projectLogName + * A fully-qualified path representing project_log resource. + * @returns {string} A string representing the log. + */ + matchLogFromProjectLogName(projectLogName) { + return this.pathTemplates.projectLogPathTemplate.match(projectLogName) + .log + } + /** + * Return a fully-qualified projectSink resource name string. + * + * @param {string} project + * @param {string} sink + * @returns {string} Resource name string. + */ + projectSinkPath(project, sink) { + return this.pathTemplates.projectSinkPathTemplate.render({ + project: project, + sink: sink + }) + } + /** + * Parse the project from ProjectSink resource. + * + * @param {string} projectSinkName + * A fully-qualified path representing project_sink resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectSinkName(projectSinkName) { + return this.pathTemplates.projectSinkPathTemplate.match( + projectSinkName + ).project + } + /** + * Parse the sink from ProjectSink resource. + * + * @param {string} projectSinkName + * A fully-qualified path representing project_sink resource. + * @returns {string} A string representing the sink. + */ + matchSinkFromProjectSinkName(projectSinkName) { + return this.pathTemplates.projectSinkPathTemplate.match( + projectSinkName + ).sink + } + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close() { + this.initialize() + if (!this._terminated) { + return this.metricsServiceV2Stub.then(stub => { + this._terminated = true + stub.close() + }) + } + return Promise.resolve() + } + } + exports.MetricsServiceV2Client = MetricsServiceV2Client + //# sourceMappingURL=metrics_service_v2_client.js.map + + /***/ + }, + + /***/ 46412: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /*! + * Copyright 2015 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.ResourceStream = exports.paginator = exports.Paginator = void 0 + /*! + * @module common/paginator + */ + const arrify = __webpack_require__(61546) + const extend = __webpack_require__(38171) + const resource_stream_1 = __webpack_require__(72199) + Object.defineProperty(exports, 'ResourceStream', { + enumerable: true, + get: function () { + return resource_stream_1.ResourceStream + } + }) + /*! Developer Documentation + * + * paginator is used to auto-paginate `nextQuery` methods as well as + * streamifying them. + * + * Before: + * + * search.query('done=true', function(err, results, nextQuery) { + * search.query(nextQuery, function(err, results, nextQuery) {}); + * }); + * + * After: + * + * search.query('done=true', function(err, results) {}); + * + * Methods to extend should be written to accept callbacks and return a + * `nextQuery`. + */ + class Paginator { + /** + * Cache the original method, then overwrite it on the Class's prototype. + * + * @param {function} Class - The parent class of the methods to extend. + * @param {string|string[]} methodNames - Name(s) of the methods to extend. + */ + // tslint:disable-next-line:variable-name + extend(Class, methodNames) { + methodNames = arrify(methodNames) + methodNames.forEach(methodName => { + const originalMethod = Class.prototype[methodName] + // map the original method to a private member + Class.prototype[methodName + '_'] = originalMethod + // overwrite the original to auto-paginate + /* eslint-disable @typescript-eslint/no-explicit-any */ + Class.prototype[methodName] = function (...args) { + const parsedArguments = paginator.parseArguments_(args) + return paginator.run_(parsedArguments, originalMethod.bind(this)) + } + }) + } + /** + * Wraps paginated API calls in a readable object stream. + * + * This method simply calls the nextQuery recursively, emitting results to a + * stream. The stream ends when `nextQuery` is null. + * + * `maxResults` will act as a cap for how many results are fetched and emitted + * to the stream. + * + * @param {string} methodName - Name of the method to streamify. + * @return {function} - Wrapped function. + */ + /* eslint-disable @typescript-eslint/no-explicit-any */ + streamify(methodName) { + return function ( + /* eslint-disable @typescript-eslint/no-explicit-any */ + ...args + ) { + const parsedArguments = paginator.parseArguments_(args) + const originalMethod = this[methodName + '_'] || this[methodName] + return paginator.runAsStream_( + parsedArguments, + originalMethod.bind(this) + ) + } + } + /** + * Parse a pseudo-array `arguments` for a query and callback. + * + * @param {array} args - The original `arguments` pseduo-array that the original + * method received. + */ + /* eslint-disable @typescript-eslint/no-explicit-any */ + parseArguments_(args) { + let query + let autoPaginate = true + let maxApiCalls = -1 + let maxResults = -1 + let callback + const firstArgument = args[0] + const lastArgument = args[args.length - 1] + if (typeof firstArgument === 'function') { + callback = firstArgument + } else { + query = firstArgument + } + if (typeof lastArgument === 'function') { + callback = lastArgument + } + if (typeof query === 'object') { + query = extend(true, {}, query) + // Check if the user only asked for a certain amount of results. + if (query.maxResults && typeof query.maxResults === 'number') { + // `maxResults` is used API-wide. + maxResults = query.maxResults + } else if (typeof query.pageSize === 'number') { + // `pageSize` is Pub/Sub's `maxResults`. + maxResults = query.pageSize + } + if (query.maxApiCalls && typeof query.maxApiCalls === 'number') { + maxApiCalls = query.maxApiCalls + delete query.maxApiCalls + } + // maxResults is the user specified limit. + if (maxResults !== -1 || query.autoPaginate === false) { + autoPaginate = false + } + } + const parsedArguments = { + query: query || {}, + autoPaginate, + maxApiCalls, + maxResults, + callback + } + parsedArguments.streamOptions = extend( + true, + {}, + parsedArguments.query + ) + delete parsedArguments.streamOptions.autoPaginate + delete parsedArguments.streamOptions.maxResults + delete parsedArguments.streamOptions.pageSize + return parsedArguments + } + /** + * This simply checks to see if `autoPaginate` is set or not, if it's true + * then we buffer all results, otherwise simply call the original method. + * + * @param {array} parsedArguments - Parsed arguments from the original method + * call. + * @param {object=|string=} parsedArguments.query - Query object. This is most + * commonly an object, but to make the API more simple, it can also be a + * string in some places. + * @param {function=} parsedArguments.callback - Callback function. + * @param {boolean} parsedArguments.autoPaginate - Auto-pagination enabled. + * @param {boolean} parsedArguments.maxApiCalls - Maximum API calls to make. + * @param {number} parsedArguments.maxResults - Maximum results to return. + * @param {function} originalMethod - The cached method that accepts a callback + * and returns `nextQuery` to receive more results. + */ + run_(parsedArguments, originalMethod) { + const query = parsedArguments.query + const callback = parsedArguments.callback + if (!parsedArguments.autoPaginate) { + return originalMethod(query, callback) + } + const results = new Array() + const promise = new Promise((resolve, reject) => { + paginator + .runAsStream_(parsedArguments, originalMethod) + .on('error', reject) + .on('data', data => results.push(data)) + .on('end', () => resolve(results)) + }) + if (!callback) { + return promise.then(results => [results]) + } + promise.then( + results => callback(null, results), + err => callback(err) + ) + } + /** + * This method simply calls the nextQuery recursively, emitting results to a + * stream. The stream ends when `nextQuery` is null. + * + * `maxResults` will act as a cap for how many results are fetched and emitted + * to the stream. + * + * @param {object=|string=} parsedArguments.query - Query object. This is most + * commonly an object, but to make the API more simple, it can also be a + * string in some places. + * @param {function=} parsedArguments.callback - Callback function. + * @param {boolean} parsedArguments.autoPaginate - Auto-pagination enabled. + * @param {boolean} parsedArguments.maxApiCalls - Maximum API calls to make. + * @param {number} parsedArguments.maxResults - Maximum results to return. + * @param {function} originalMethod - The cached method that accepts a callback + * and returns `nextQuery` to receive more results. + * @return {stream} - Readable object stream. + */ + /* eslint-disable @typescript-eslint/no-explicit-any */ + runAsStream_(parsedArguments, originalMethod) { + return new resource_stream_1.ResourceStream( + parsedArguments, + originalMethod + ) + } + } + exports.Paginator = Paginator + const paginator = new Paginator() + exports.paginator = paginator + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 72199: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /*! + * Copyright 2019 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.ResourceStream = void 0 + const stream_1 = __webpack_require__(92413) + class ResourceStream extends stream_1.Transform { + constructor(args, requestFn) { + const options = Object.assign( + { objectMode: true }, + args.streamOptions + ) + super(options) + this._ended = false + this._maxApiCalls = + args.maxApiCalls === -1 ? Infinity : args.maxApiCalls + this._nextQuery = args.query + this._reading = false + this._requestFn = requestFn + this._requestsMade = 0 + this._resultsToSend = + args.maxResults === -1 ? Infinity : args.maxResults + } + /* eslint-disable @typescript-eslint/no-explicit-any */ + end(...args) { + this._ended = true + return super.end(...args) + } + _read() { + if (this._reading) { + return + } + this._reading = true + // Wrap in a try/catch to catch input linting errors, e.g. + // an invalid BigQuery query. These errors are thrown in an + // async fashion, which makes them un-catchable by the user. + try { + this._requestFn(this._nextQuery, (err, results, nextQuery) => { + if (err) { + this.destroy(err) + return + } + this._nextQuery = nextQuery + if (this._resultsToSend !== Infinity) { + results = results.splice(0, this._resultsToSend) + this._resultsToSend -= results.length + } + let more = true + for (const result of results) { + if (this._ended) { + break + } + more = this.push(result) + } + const isFinished = !this._nextQuery || this._resultsToSend < 1 + const madeMaxCalls = ++this._requestsMade >= this._maxApiCalls + if (isFinished || madeMaxCalls) { + this.end() + } + if (more && !this._ended) { + setImmediate(() => this._read()) + } + this._reading = false + }) + } catch (e) { + this.destroy(e) + } + } + } + exports.ResourceStream = ResourceStream + //# sourceMappingURL=resource-stream.js.map + + /***/ + }, + + /***/ 3497: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + Object.defineProperty(exports, '__esModule', { value: true }) + const stream_1 = __webpack_require__(92413) + // Copyright 2014 Google LLC + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + /** + * Populate the `{{projectId}}` placeholder. + * + * @throws {Error} If a projectId is required, but one is not provided. + * + * @param {*} - Any input value that may contain a placeholder. Arrays and objects will be looped. + * @param {string} projectId - A projectId. If not provided + * @return {*} - The original argument with all placeholders populated. + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function replaceProjectIdToken(value, projectId) { + if (Array.isArray(value)) { + value = value.map(v => replaceProjectIdToken(v, projectId)) + } + if ( + value !== null && + typeof value === 'object' && + !(value instanceof Buffer) && + !(value instanceof stream_1.Stream) && + typeof value.hasOwnProperty === 'function' + ) { + for (const opt in value) { + // eslint-disable-next-line no-prototype-builtins + if (value.hasOwnProperty(opt)) { + value[opt] = replaceProjectIdToken(value[opt], projectId) + } + } + } + if (typeof value === 'string' && value.indexOf('{{projectId}}') > -1) { + if (!projectId || projectId === '{{projectId}}') { + throw new MissingProjectIdError() + } + value = value.replace(/{{projectId}}/g, projectId) + } + return value + } + exports.replaceProjectIdToken = replaceProjectIdToken + /** + * Custom error type for missing project ID errors. + */ + class MissingProjectIdError extends Error { + constructor() { + super(...arguments) + this.message = `Sorry, we cannot connect to Cloud Services without a project + ID. You may specify one with an environment variable named + "GOOGLE_CLOUD_PROJECT".`.replace(/ +/g, ' ') + } + } + exports.MissingProjectIdError = MissingProjectIdError + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 19203: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + /* eslint-disable prefer-rest-params */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.callbackifyAll = exports.callbackify = exports.promisifyAll = exports.promisify = void 0 + /** + * Wraps a callback style function to conditionally return a promise. + * + * @param {function} originalMethod - The method to promisify. + * @param {object=} options - Promise options. + * @param {boolean} options.singular - Resolve the promise with single arg instead of an array. + * @return {function} wrapped + */ + function promisify(originalMethod, options) { + if (originalMethod.promisified_) { + return originalMethod + } + options = options || {} + const slice = Array.prototype.slice + // tslint:disable-next-line:no-any + const wrapper = function () { + let last + for (last = arguments.length - 1; last >= 0; last--) { + const arg = arguments[last] + if (typeof arg === 'undefined') { + continue // skip trailing undefined. + } + if (typeof arg !== 'function') { + break // non-callback last argument found. + } + return originalMethod.apply(this, arguments) + } + // peel trailing undefined. + const args = slice.call(arguments, 0, last + 1) + // tslint:disable-next-line:variable-name + let PromiseCtor = Promise + // Because dedupe will likely create a single install of + // @google-cloud/common to be shared amongst all modules, we need to + // localize it at the Service level. + if (this && this.Promise) { + PromiseCtor = this.Promise + } + return new PromiseCtor((resolve, reject) => { + // tslint:disable-next-line:no-any + args.push((...args) => { + const callbackArgs = slice.call(args) + const err = callbackArgs.shift() + if (err) { + return reject(err) + } + if (options.singular && callbackArgs.length === 1) { + resolve(callbackArgs[0]) + } else { + resolve(callbackArgs) + } + }) + originalMethod.apply(this, args) + }) + } + wrapper.promisified_ = true + return wrapper + } + exports.promisify = promisify + /** + * Promisifies certain Class methods. This will not promisify private or + * streaming methods. + * + * @param {module:common/service} Class - Service class. + * @param {object=} options - Configuration object. + */ + // tslint:disable-next-line:variable-name + function promisifyAll(Class, options) { + const exclude = (options && options.exclude) || [] + const ownPropertyNames = Object.getOwnPropertyNames(Class.prototype) + const methods = ownPropertyNames.filter(methodName => { + // clang-format off + return ( + !exclude.includes(methodName) && + typeof Class.prototype[methodName] === 'function' && // is it a function? + !/(^_|(Stream|_)|promise$)|^constructor$/.test(methodName) // is it promisable? + ) + // clang-format on + }) + methods.forEach(methodName => { + const originalMethod = Class.prototype[methodName] + if (!originalMethod.promisified_) { + Class.prototype[methodName] = exports.promisify( + originalMethod, + options + ) + } + }) + } + exports.promisifyAll = promisifyAll + /** + * Wraps a promisy type function to conditionally call a callback function. + * + * @param {function} originalMethod - The method to callbackify. + * @param {object=} options - Callback options. + * @param {boolean} options.singular - Pass to the callback a single arg instead of an array. + * @return {function} wrapped + */ + function callbackify(originalMethod) { + if (originalMethod.callbackified_) { + return originalMethod + } + // tslint:disable-next-line:no-any + const wrapper = function () { + if (typeof arguments[arguments.length - 1] !== 'function') { + return originalMethod.apply(this, arguments) + } + const cb = Array.prototype.pop.call(arguments) + originalMethod.apply(this, arguments).then( + // tslint:disable-next-line:no-any + res => { + res = Array.isArray(res) ? res : [res] + cb(null, ...res) + }, + err => cb(err) + ) + } + wrapper.callbackified_ = true + return wrapper + } + exports.callbackify = callbackify + /** + * Callbackifies certain Class methods. This will not callbackify private or + * streaming methods. + * + * @param {module:common/service} Class - Service class. + * @param {object=} options - Configuration object. + */ + function callbackifyAll( + // tslint:disable-next-line:variable-name + Class, + options + ) { + const exclude = (options && options.exclude) || [] + const ownPropertyNames = Object.getOwnPropertyNames(Class.prototype) + const methods = ownPropertyNames.filter(methodName => { + // clang-format off + return ( + !exclude.includes(methodName) && + typeof Class.prototype[methodName] === 'function' && // is it a function? + !/^_|(Stream|_)|^constructor$/.test(methodName) // is it callbackifyable? + ) + // clang-format on + }) + methods.forEach(methodName => { + const originalMethod = Class.prototype[methodName] + if (!originalMethod.callbackified_) { + Class.prototype[methodName] = exports.callbackify(originalMethod) + } + }) + } + exports.callbackifyAll = callbackifyAll + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 34186: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + /* + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.BackoffTimeout = void 0 + const INITIAL_BACKOFF_MS = 1000 + const BACKOFF_MULTIPLIER = 1.6 + const MAX_BACKOFF_MS = 120000 + const BACKOFF_JITTER = 0.2 + /** + * Get a number uniformly at random in the range [min, max) + * @param min + * @param max + */ + function uniformRandom(min, max) { + return Math.random() * (max - min) + min + } + class BackoffTimeout { + constructor(callback, options) { + this.callback = callback + this.initialDelay = INITIAL_BACKOFF_MS + this.multiplier = BACKOFF_MULTIPLIER + this.maxDelay = MAX_BACKOFF_MS + this.jitter = BACKOFF_JITTER + this.running = false + if (options) { + if (options.initialDelay) { + this.initialDelay = options.initialDelay + } + if (options.multiplier) { + this.multiplier = options.multiplier + } + if (options.jitter) { + this.jitter = options.jitter + } + if (options.maxDelay) { + this.maxDelay = options.maxDelay + } + } + this.nextDelay = this.initialDelay + this.timerId = setTimeout(() => {}, 0) + clearTimeout(this.timerId) + } + /** + * Call the callback after the current amount of delay time + */ + runOnce() { + this.running = true + this.timerId = setTimeout(() => { + this.callback() + this.running = false + }, this.nextDelay) + const nextBackoff = Math.min( + this.nextDelay * this.multiplier, + this.maxDelay + ) + const jitterMagnitude = nextBackoff * this.jitter + this.nextDelay = + nextBackoff + uniformRandom(-jitterMagnitude, jitterMagnitude) + } + /** + * Stop the timer. The callback will not be called until `runOnce` is called + * again. + */ + stop() { + clearTimeout(this.timerId) + this.running = false + } + /** + * Reset the delay time to its initial value. + */ + reset() { + this.nextDelay = this.initialDelay + } + isRunning() { + return this.running + } + } + exports.BackoffTimeout = BackoffTimeout + //# sourceMappingURL=backoff-timeout.js.map + + /***/ + }, + + /***/ 86380: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /* + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.CallCredentialsFilterFactory = exports.CallCredentialsFilter = void 0 + const filter_1 = __webpack_require__(43392) + const constants_1 = __webpack_require__(90634) + const uri_parser_1 = __webpack_require__(65974) + class CallCredentialsFilter extends filter_1.BaseFilter { + constructor(channel, stream) { + var _a, _b + super() + this.channel = channel + this.stream = stream + this.channel = channel + this.stream = stream + const splitPath = stream.getMethod().split('/') + let serviceName = '' + /* The standard path format is "/{serviceName}/{methodName}", so if we split + * by '/', the first item should be empty and the second should be the + * service name */ + if (splitPath.length >= 2) { + serviceName = splitPath[1] + } + const hostname = + (_b = + (_a = uri_parser_1.splitHostPort(stream.getHost())) === null || + _a === void 0 + ? void 0 + : _a.host) !== null && _b !== void 0 + ? _b + : 'localhost' + /* Currently, call credentials are only allowed on HTTPS connections, so we + * can assume that the scheme is "https" */ + this.serviceUrl = `https://${hostname}/${serviceName}` + } + async sendMetadata(metadata) { + const credentials = this.stream.getCredentials() + const credsMetadata = credentials.generateMetadata({ + service_url: this.serviceUrl + }) + const resultMetadata = await metadata + resultMetadata.merge(await credsMetadata) + if (resultMetadata.get('authorization').length > 1) { + this.stream.cancelWithStatus( + constants_1.Status.INTERNAL, + '"authorization" metadata cannot have multiple values' + ) + } + return resultMetadata + } + } + exports.CallCredentialsFilter = CallCredentialsFilter + class CallCredentialsFilterFactory { + constructor(channel) { + this.channel = channel + this.channel = channel + } + createFilter(callStream) { + return new CallCredentialsFilter(this.channel, callStream) + } + } + exports.CallCredentialsFilterFactory = CallCredentialsFilterFactory + //# sourceMappingURL=call-credentials-filter.js.map + + /***/ + }, + + /***/ 21426: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /* + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.CallCredentials = void 0 + const metadata_1 = __webpack_require__(83665) + function isCurrentOauth2Client(client) { + return ( + 'getRequestHeaders' in client && + typeof client.getRequestHeaders === 'function' + ) + } + /** + * A class that represents a generic method of adding authentication-related + * metadata on a per-request basis. + */ + class CallCredentials { + /** + * Creates a new CallCredentials object from a given function that generates + * Metadata objects. + * @param metadataGenerator A function that accepts a set of options, and + * generates a Metadata object based on these options, which is passed back + * to the caller via a supplied (err, metadata) callback. + */ + static createFromMetadataGenerator(metadataGenerator) { + return new SingleCallCredentials(metadataGenerator) + } + /** + * Create a gRPC credential from a Google credential object. + * @param googleCredentials The authentication client to use. + * @return The resulting CallCredentials object. + */ + static createFromGoogleCredential(googleCredentials) { + return CallCredentials.createFromMetadataGenerator( + (options, callback) => { + let getHeaders + if (isCurrentOauth2Client(googleCredentials)) { + getHeaders = googleCredentials.getRequestHeaders( + options.service_url + ) + } else { + getHeaders = new Promise((resolve, reject) => { + googleCredentials.getRequestMetadata( + options.service_url, + (err, headers) => { + if (err) { + reject(err) + return + } + resolve(headers) + } + ) + }) + } + getHeaders.then( + headers => { + const metadata = new metadata_1.Metadata() + for (const key of Object.keys(headers)) { + metadata.add(key, headers[key]) + } + callback(null, metadata) + }, + err => { + callback(err) + } + ) + } + ) + } + static createEmpty() { + return new EmptyCallCredentials() + } + } + exports.CallCredentials = CallCredentials + class ComposedCallCredentials extends CallCredentials { + constructor(creds) { + super() + this.creds = creds + } + async generateMetadata(options) { + const base = new metadata_1.Metadata() + const generated = await Promise.all( + this.creds.map(cred => cred.generateMetadata(options)) + ) + for (const gen of generated) { + base.merge(gen) + } + return base + } + compose(other) { + return new ComposedCallCredentials(this.creds.concat([other])) + } + _equals(other) { + if (this === other) { + return true + } + if (other instanceof ComposedCallCredentials) { + return this.creds.every((value, index) => + value._equals(other.creds[index]) + ) + } else { + return false + } + } + } + class SingleCallCredentials extends CallCredentials { + constructor(metadataGenerator) { + super() + this.metadataGenerator = metadataGenerator + } + generateMetadata(options) { + return new Promise((resolve, reject) => { + this.metadataGenerator(options, (err, metadata) => { + if (metadata !== undefined) { + resolve(metadata) + } else { + reject(err) + } + }) + }) + } + compose(other) { + return new ComposedCallCredentials([this, other]) + } + _equals(other) { + if (this === other) { + return true + } + if (other instanceof SingleCallCredentials) { + return this.metadataGenerator === other.metadataGenerator + } else { + return false + } + } + } + class EmptyCallCredentials extends CallCredentials { + generateMetadata(options) { + return Promise.resolve(new metadata_1.Metadata()) + } + compose(other) { + return other + } + _equals(other) { + return other instanceof EmptyCallCredentials + } + } + //# sourceMappingURL=call-credentials.js.map + + /***/ + }, + + /***/ 78988: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /* + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.Http2CallStream = exports.InterceptingListenerImpl = exports.isInterceptingListener = void 0 + const http2 = __webpack_require__(97565) + const constants_1 = __webpack_require__(90634) + const filter_stack_1 = __webpack_require__(66450) + const metadata_1 = __webpack_require__(83665) + const stream_decoder_1 = __webpack_require__(16575) + const logging = __webpack_require__(35993) + const constants_2 = __webpack_require__(90634) + const TRACER_NAME = 'call_stream' + const { + HTTP2_HEADER_STATUS, + HTTP2_HEADER_CONTENT_TYPE, + NGHTTP2_CANCEL + } = http2.constants + function isInterceptingListener(listener) { + return ( + listener.onReceiveMetadata !== undefined && + listener.onReceiveMetadata.length === 1 + ) + } + exports.isInterceptingListener = isInterceptingListener + class InterceptingListenerImpl { + constructor(listener, nextListener) { + this.listener = listener + this.nextListener = nextListener + this.processingMessage = false + this.pendingStatus = null + } + onReceiveMetadata(metadata) { + this.listener.onReceiveMetadata(metadata, metadata => { + this.nextListener.onReceiveMetadata(metadata) + }) + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + onReceiveMessage(message) { + /* If this listener processes messages asynchronously, the last message may + * be reordered with respect to the status */ + this.processingMessage = true + this.listener.onReceiveMessage(message, msg => { + this.processingMessage = false + this.nextListener.onReceiveMessage(msg) + if (this.pendingStatus) { + this.nextListener.onReceiveStatus(this.pendingStatus) + } + }) + } + onReceiveStatus(status) { + this.listener.onReceiveStatus(status, processedStatus => { + if (this.processingMessage) { + this.pendingStatus = processedStatus + } else { + this.nextListener.onReceiveStatus(processedStatus) + } + }) + } + } + exports.InterceptingListenerImpl = InterceptingListenerImpl + class Http2CallStream { + constructor( + methodName, + channel, + options, + filterStackFactory, + channelCallCredentials, + callNumber + ) { + this.methodName = methodName + this.channel = channel + this.options = options + this.channelCallCredentials = channelCallCredentials + this.callNumber = callNumber + this.http2Stream = null + this.pendingRead = false + this.isWriteFilterPending = false + this.pendingWrite = null + this.pendingWriteCallback = null + this.writesClosed = false + this.decoder = new stream_decoder_1.StreamDecoder() + this.isReadFilterPending = false + this.canPush = false + /** + * Indicates that an 'end' event has come from the http2 stream, so there + * will be no more data events. + */ + this.readsClosed = false + this.statusOutput = false + this.unpushedReadMessages = [] + this.unfilteredReadMessages = [] + // Status code mapped from :status. To be used if grpc-status is not received + this.mappedStatusCode = constants_1.Status.UNKNOWN + // This is populated (non-null) if and only if the call has ended + this.finalStatus = null + this.subchannel = null + this.listener = null + this.filterStack = filterStackFactory.createFilter(this) + this.credentials = channelCallCredentials + this.disconnectListener = () => { + this.endCall({ + code: constants_1.Status.UNAVAILABLE, + details: 'Connection dropped', + metadata: new metadata_1.Metadata() + }) + } + } + outputStatus() { + /* Precondition: this.finalStatus !== null */ + if (!this.statusOutput) { + this.statusOutput = true + const filteredStatus = this.filterStack.receiveTrailers( + this.finalStatus + ) + /* We delay the actual action of bubbling up the status to insulate the + * cleanup code in this class from any errors that may be thrown in the + * upper layers as a result of bubbling up the status. In particular, + * if the status is not OK, the "error" event may be emitted + * synchronously at the top level, which will result in a thrown error if + * the user does not handle that event. */ + process.nextTick(() => { + var _a + ;(_a = this.listener) === null || _a === void 0 + ? void 0 + : _a.onReceiveStatus(filteredStatus) + }) + if (this.subchannel) { + this.subchannel.callUnref() + this.subchannel.removeDisconnectListener(this.disconnectListener) + } + } + } + trace(text) { + logging.trace( + constants_2.LogVerbosity.DEBUG, + TRACER_NAME, + '[' + this.callNumber + '] ' + text + ) + } + /** + * On first call, emits a 'status' event with the given StatusObject. + * Subsequent calls are no-ops. + * @param status The status of the call. + */ + endCall(status) { + /* If the status is OK and a new status comes in (e.g. from a + * deserialization failure), that new status takes priority */ + if ( + this.finalStatus === null || + this.finalStatus.code === constants_1.Status.OK + ) { + this.trace( + 'ended with status: code=' + + status.code + + ' details="' + + status.details + + '"' + ) + this.finalStatus = status + this.maybeOutputStatus() + } + this.destroyHttp2Stream() + } + maybeOutputStatus() { + if (this.finalStatus !== null) { + /* The combination check of readsClosed and that the two message buffer + * arrays are empty checks that there all incoming data has been fully + * processed */ + if ( + this.finalStatus.code !== constants_1.Status.OK || + (this.readsClosed && + this.unpushedReadMessages.length === 0 && + this.unfilteredReadMessages.length === 0 && + !this.isReadFilterPending) + ) { + this.outputStatus() + } + } + } + push(message) { + this.trace( + 'pushing to reader message of length ' + + (message instanceof Buffer ? message.length : null) + ) + this.canPush = false + process.nextTick(() => { + var _a + /* If we have already output the status any later messages should be + * ignored, and can cause out-of-order operation errors higher up in the + * stack. Checking as late as possible here to avoid any race conditions. + */ + if (this.statusOutput) { + return + } + ;(_a = this.listener) === null || _a === void 0 + ? void 0 + : _a.onReceiveMessage(message) + this.maybeOutputStatus() + }) + } + handleFilterError(error) { + this.cancelWithStatus(constants_1.Status.INTERNAL, error.message) + } + handleFilteredRead(message) { + /* If we the call has already ended with an error, we don't want to do + * anything with this message. Dropping it on the floor is correct + * behavior */ + if ( + this.finalStatus !== null && + this.finalStatus.code !== constants_1.Status.OK + ) { + this.maybeOutputStatus() + return + } + this.isReadFilterPending = false + if (this.canPush) { + this.http2Stream.pause() + this.push(message) + } else { + this.trace( + 'unpushedReadMessages.push message of length ' + message.length + ) + this.unpushedReadMessages.push(message) + } + if (this.unfilteredReadMessages.length > 0) { + /* nextMessage is guaranteed not to be undefined because + unfilteredReadMessages is non-empty */ + const nextMessage = this.unfilteredReadMessages.shift() + this.filterReceivedMessage(nextMessage) + } + } + filterReceivedMessage(framedMessage) { + /* If we the call has already ended with an error, we don't want to do + * anything with this message. Dropping it on the floor is correct + * behavior */ + if ( + this.finalStatus !== null && + this.finalStatus.code !== constants_1.Status.OK + ) { + this.maybeOutputStatus() + return + } + this.trace('filterReceivedMessage of length ' + framedMessage.length) + this.isReadFilterPending = true + this.filterStack + .receiveMessage(Promise.resolve(framedMessage)) + .then( + this.handleFilteredRead.bind(this), + this.handleFilterError.bind(this) + ) + } + tryPush(messageBytes) { + if (this.isReadFilterPending) { + this.trace( + 'unfilteredReadMessages.push message of length ' + + (messageBytes && messageBytes.length) + ) + this.unfilteredReadMessages.push(messageBytes) + } else { + this.filterReceivedMessage(messageBytes) + } + } + handleTrailers(headers) { + let headersString = '' + for (const header of Object.keys(headers)) { + headersString += '\t\t' + header + ': ' + headers[header] + '\n' + } + this.trace('Received server trailers:\n' + headersString) + let metadata + try { + metadata = metadata_1.Metadata.fromHttp2Headers(headers) + } catch (e) { + metadata = new metadata_1.Metadata() + } + const metadataMap = metadata.getMap() + let code = this.mappedStatusCode + if ( + code === constants_1.Status.UNKNOWN && + typeof metadataMap['grpc-status'] === 'string' + ) { + const receivedStatus = Number(metadataMap['grpc-status']) + if (receivedStatus in constants_1.Status) { + code = receivedStatus + this.trace( + 'received status code ' + receivedStatus + ' from server' + ) + } + metadata.remove('grpc-status') + } + let details = '' + if (typeof metadataMap['grpc-message'] === 'string') { + details = decodeURI(metadataMap['grpc-message']) + metadata.remove('grpc-message') + this.trace( + 'received status details string "' + details + '" from server' + ) + } + const status = { code, details, metadata } + let finalStatus + try { + // Attempt to assign final status. + finalStatus = this.filterStack.receiveTrailers(status) + } catch (error) { + // This is a no-op if the call was already ended when handling headers. + this.endCall({ + code: constants_1.Status.INTERNAL, + details: 'Failed to process received status', + metadata: new metadata_1.Metadata() + }) + return + } + // This is a no-op if the call was already ended when handling headers. + this.endCall(finalStatus) + } + attachHttp2Stream(stream, subchannel, extraFilterFactory) { + if (extraFilterFactory !== undefined) { + this.filterStack = new filter_stack_1.FilterStack([ + this.filterStack, + extraFilterFactory.createFilter(this) + ]) + } + if (this.finalStatus !== null) { + stream.close(NGHTTP2_CANCEL) + } else { + this.trace( + 'attachHttp2Stream from subchannel ' + subchannel.getAddress() + ) + this.http2Stream = stream + this.subchannel = subchannel + subchannel.addDisconnectListener(this.disconnectListener) + subchannel.callRef() + stream.on('response', (headers, flags) => { + var _a + let headersString = '' + for (const header of Object.keys(headers)) { + headersString += '\t\t' + header + ': ' + headers[header] + '\n' + } + this.trace('Received server headers:\n' + headersString) + switch (headers[':status']) { + // TODO(murgatroid99): handle 100 and 101 + case 400: + this.mappedStatusCode = constants_1.Status.INTERNAL + break + case 401: + this.mappedStatusCode = constants_1.Status.UNAUTHENTICATED + break + case 403: + this.mappedStatusCode = constants_1.Status.PERMISSION_DENIED + break + case 404: + this.mappedStatusCode = constants_1.Status.UNIMPLEMENTED + break + case 429: + case 502: + case 503: + case 504: + this.mappedStatusCode = constants_1.Status.UNAVAILABLE + break + default: + this.mappedStatusCode = constants_1.Status.UNKNOWN + } + if (flags & http2.constants.NGHTTP2_FLAG_END_STREAM) { + this.handleTrailers(headers) + } else { + let metadata + try { + metadata = metadata_1.Metadata.fromHttp2Headers(headers) + } catch (error) { + this.endCall({ + code: constants_1.Status.UNKNOWN, + details: error.message, + metadata: new metadata_1.Metadata() + }) + return + } + try { + const finalMetadata = this.filterStack.receiveMetadata( + metadata + ) + ;(_a = this.listener) === null || _a === void 0 + ? void 0 + : _a.onReceiveMetadata(finalMetadata) + } catch (error) { + this.endCall({ + code: constants_1.Status.UNKNOWN, + details: error.message, + metadata: new metadata_1.Metadata() + }) + } + } + }) + stream.on('trailers', this.handleTrailers.bind(this)) + stream.on('data', data => { + this.trace('receive HTTP/2 data frame of length ' + data.length) + const messages = this.decoder.write(data) + for (const message of messages) { + this.trace('parsed message of length ' + message.length) + this.tryPush(message) + } + }) + stream.on('end', () => { + this.readsClosed = true + this.maybeOutputStatus() + }) + stream.on('close', () => { + var _a + this.trace('HTTP/2 stream closed with code ' + stream.rstCode) + /* If we have a final status with an OK status code, that means that + * we have received all of the messages and we have processed the + * trailers and the call completed successfully, so it doesn't matter + * how the stream ends after that */ + if ( + ((_a = this.finalStatus) === null || _a === void 0 + ? void 0 + : _a.code) === constants_1.Status.OK + ) { + return + } + let code + let details = '' + switch (stream.rstCode) { + case http2.constants.NGHTTP2_NO_ERROR: + /* If we get a NO_ERROR code and we already have a status, the + * stream completed properly and we just haven't fully processed + * it yet */ + if (this.finalStatus !== null) { + return + } + code = constants_1.Status.INTERNAL + details = `Received RST_STREAM with code ${stream.rstCode}` + break + case http2.constants.NGHTTP2_REFUSED_STREAM: + code = constants_1.Status.UNAVAILABLE + details = 'Stream refused by server' + break + case http2.constants.NGHTTP2_CANCEL: + code = constants_1.Status.CANCELLED + details = 'Call cancelled' + break + case http2.constants.NGHTTP2_ENHANCE_YOUR_CALM: + code = constants_1.Status.RESOURCE_EXHAUSTED + details = 'Bandwidth exhausted' + break + case http2.constants.NGHTTP2_INADEQUATE_SECURITY: + code = constants_1.Status.PERMISSION_DENIED + details = 'Protocol not secure enough' + break + case http2.constants.NGHTTP2_INTERNAL_ERROR: + code = constants_1.Status.INTERNAL + /* This error code was previously handled in the default case, and + * there are several instances of it online, so I wanted to + * preserve the original error message so that people find existing + * information in searches, but also include the more recognizable + * "Internal server error" message. */ + details = `Received RST_STREAM with code ${stream.rstCode} (Internal server error)` + break + default: + code = constants_1.Status.INTERNAL + details = `Received RST_STREAM with code ${stream.rstCode}` + } + // This is a no-op if trailers were received at all. + // This is OK, because status codes emitted here correspond to more + // catastrophic issues that prevent us from receiving trailers in the + // first place. + this.endCall({ + code, + details, + metadata: new metadata_1.Metadata() + }) + }) + stream.on('error', err => { + /* We need an error handler here to stop "Uncaught Error" exceptions + * from bubbling up. However, errors here should all correspond to + * "close" events, where we will handle the error more granularly */ + }) + if (!this.pendingRead) { + stream.pause() + } + if (this.pendingWrite) { + if (!this.pendingWriteCallback) { + throw new Error('Invalid state in write handling code') + } + this.trace( + 'sending data chunk of length ' + + this.pendingWrite.length + + ' (deferred)' + ) + stream.write(this.pendingWrite, this.pendingWriteCallback) + } + this.maybeCloseWrites() + } + } + start(metadata, listener) { + this.trace('Sending metadata') + this.listener = listener + this.channel._startCallStream(this, metadata) + } + destroyHttp2Stream() { + var _a + // The http2 stream could already have been destroyed if cancelWithStatus + // is called in response to an internal http2 error. + if (this.http2Stream !== null && !this.http2Stream.destroyed) { + /* If the call has ended with an OK status, communicate that when closing + * the stream, partly to avoid a situation in which we detect an error + * RST_STREAM as a result after we have the status */ + let code + if ( + ((_a = this.finalStatus) === null || _a === void 0 + ? void 0 + : _a.code) === constants_1.Status.OK + ) { + code = http2.constants.NGHTTP2_NO_ERROR + } else { + code = http2.constants.NGHTTP2_CANCEL + } + this.trace('close http2 stream with code ' + code) + this.http2Stream.close(code) + } + } + cancelWithStatus(status, details) { + this.trace( + 'cancelWithStatus code: ' + status + ' details: "' + details + '"' + ) + this.endCall({ + code: status, + details, + metadata: new metadata_1.Metadata() + }) + } + getDeadline() { + return this.options.deadline + } + getCredentials() { + return this.credentials + } + setCredentials(credentials) { + this.credentials = this.channelCallCredentials.compose(credentials) + } + getStatus() { + return this.finalStatus + } + getPeer() { + var _a, _b + return (_b = + (_a = this.subchannel) === null || _a === void 0 + ? void 0 + : _a.getAddress()) !== null && _b !== void 0 + ? _b + : this.channel.getTarget() + } + getMethod() { + return this.methodName + } + getHost() { + return this.options.host + } + startRead() { + /* If the stream has ended with an error, we should not emit any more + * messages and we should communicate that the stream has ended */ + if ( + this.finalStatus !== null && + this.finalStatus.code !== constants_1.Status.OK + ) { + this.readsClosed = true + this.maybeOutputStatus() + return + } + this.canPush = true + if (this.http2Stream === null) { + this.pendingRead = true + } else { + if (this.unpushedReadMessages.length > 0) { + const nextMessage = this.unpushedReadMessages.shift() + this.push(nextMessage) + return + } + /* Only resume reading from the http2Stream if we don't have any pending + * messages to emit */ + this.http2Stream.resume() + } + } + maybeCloseWrites() { + if ( + this.writesClosed && + !this.isWriteFilterPending && + this.http2Stream !== null + ) { + this.trace('calling end() on HTTP/2 stream') + this.http2Stream.end() + } + } + sendMessageWithContext(context, message) { + var _a + this.trace('write() called with message of length ' + message.length) + const writeObj = { + message, + flags: context.flags + } + const cb = + (_a = context.callback) !== null && _a !== void 0 ? _a : () => {} + this.isWriteFilterPending = true + this.filterStack + .sendMessage(Promise.resolve(writeObj)) + .then(message => { + this.isWriteFilterPending = false + if (this.http2Stream === null) { + this.trace( + 'deferring writing data chunk of length ' + + message.message.length + ) + this.pendingWrite = message.message + this.pendingWriteCallback = cb + } else { + this.trace( + 'sending data chunk of length ' + message.message.length + ) + this.http2Stream.write(message.message, cb) + this.maybeCloseWrites() + } + }, this.handleFilterError.bind(this)) + } + halfClose() { + this.trace('end() called') + this.writesClosed = true + this.maybeCloseWrites() + } + } + exports.Http2CallStream = Http2CallStream + //# sourceMappingURL=call-stream.js.map + + /***/ + }, + + /***/ 97453: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /* + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.ClientDuplexStreamImpl = exports.ClientWritableStreamImpl = exports.ClientReadableStreamImpl = exports.ClientUnaryCallImpl = exports.callErrorFromStatus = void 0 + const events_1 = __webpack_require__(28614) + const stream_1 = __webpack_require__(92413) + const constants_1 = __webpack_require__(90634) + /** + * Construct a ServiceError from a StatusObject. This function exists primarily + * as an attempt to make the error stack trace clearly communicate that the + * error is not necessarily a problem in gRPC itself. + * @param status + */ + function callErrorFromStatus(status) { + const message = `${status.code} ${constants_1.Status[status.code]}: ${ + status.details + }` + return Object.assign(new Error(message), status) + } + exports.callErrorFromStatus = callErrorFromStatus + class ClientUnaryCallImpl extends events_1.EventEmitter { + constructor() { + super() + } + cancel() { + var _a + ;(_a = this.call) === null || _a === void 0 + ? void 0 + : _a.cancelWithStatus( + constants_1.Status.CANCELLED, + 'Cancelled on client' + ) + } + getPeer() { + var _a, _b + return (_b = + (_a = this.call) === null || _a === void 0 + ? void 0 + : _a.getPeer()) !== null && _b !== void 0 + ? _b + : 'unknown' + } + } + exports.ClientUnaryCallImpl = ClientUnaryCallImpl + class ClientReadableStreamImpl extends stream_1.Readable { + constructor(deserialize) { + super({ objectMode: true }) + this.deserialize = deserialize + } + cancel() { + var _a + ;(_a = this.call) === null || _a === void 0 + ? void 0 + : _a.cancelWithStatus( + constants_1.Status.CANCELLED, + 'Cancelled on client' + ) + } + getPeer() { + var _a, _b + return (_b = + (_a = this.call) === null || _a === void 0 + ? void 0 + : _a.getPeer()) !== null && _b !== void 0 + ? _b + : 'unknown' + } + _read(_size) { + var _a + ;(_a = this.call) === null || _a === void 0 ? void 0 : _a.startRead() + } + } + exports.ClientReadableStreamImpl = ClientReadableStreamImpl + class ClientWritableStreamImpl extends stream_1.Writable { + constructor(serialize) { + super({ objectMode: true }) + this.serialize = serialize + } + cancel() { + var _a + ;(_a = this.call) === null || _a === void 0 + ? void 0 + : _a.cancelWithStatus( + constants_1.Status.CANCELLED, + 'Cancelled on client' + ) + } + getPeer() { + var _a, _b + return (_b = + (_a = this.call) === null || _a === void 0 + ? void 0 + : _a.getPeer()) !== null && _b !== void 0 + ? _b + : 'unknown' + } + _write(chunk, encoding, cb) { + var _a + const context = { + callback: cb + } + const flags = Number(encoding) + if (!Number.isNaN(flags)) { + context.flags = flags + } + ;(_a = this.call) === null || _a === void 0 + ? void 0 + : _a.sendMessageWithContext(context, chunk) + } + _final(cb) { + var _a + ;(_a = this.call) === null || _a === void 0 ? void 0 : _a.halfClose() + cb() + } + } + exports.ClientWritableStreamImpl = ClientWritableStreamImpl + class ClientDuplexStreamImpl extends stream_1.Duplex { + constructor(serialize, deserialize) { + super({ objectMode: true }) + this.serialize = serialize + this.deserialize = deserialize + } + cancel() { + var _a + ;(_a = this.call) === null || _a === void 0 + ? void 0 + : _a.cancelWithStatus( + constants_1.Status.CANCELLED, + 'Cancelled on client' + ) + } + getPeer() { + var _a, _b + return (_b = + (_a = this.call) === null || _a === void 0 + ? void 0 + : _a.getPeer()) !== null && _b !== void 0 + ? _b + : 'unknown' + } + _read(_size) { + var _a + ;(_a = this.call) === null || _a === void 0 ? void 0 : _a.startRead() + } + _write(chunk, encoding, cb) { + var _a + const context = { + callback: cb + } + const flags = Number(encoding) + if (!Number.isNaN(flags)) { + context.flags = flags + } + ;(_a = this.call) === null || _a === void 0 + ? void 0 + : _a.sendMessageWithContext(context, chunk) + } + _final(cb) { + var _a + ;(_a = this.call) === null || _a === void 0 ? void 0 : _a.halfClose() + cb() + } + } + exports.ClientDuplexStreamImpl = ClientDuplexStreamImpl + //# sourceMappingURL=call.js.map + + /***/ + }, + + /***/ 44030: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /* + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.createGoogleDefaultCredentials = exports.ChannelCredentials = void 0 + const tls_1 = __webpack_require__(4016) + const call_credentials_1 = __webpack_require__(21426) + const tls_helpers_1 = __webpack_require__(86581) + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function verifyIsBufferOrNull(obj, friendlyName) { + if (obj && !(obj instanceof Buffer)) { + throw new TypeError(`${friendlyName}, if provided, must be a Buffer.`) + } + } + function bufferOrNullEqual(buf1, buf2) { + if (buf1 === null && buf2 === null) { + return true + } else { + return buf1 !== null && buf2 !== null && buf1.equals(buf2) + } + } + /** + * A class that contains credentials for communicating over a channel, as well + * as a set of per-call credentials, which are applied to every method call made + * over a channel initialized with an instance of this class. + */ + class ChannelCredentials { + constructor(callCredentials) { + this.callCredentials = + callCredentials || call_credentials_1.CallCredentials.createEmpty() + } + /** + * Gets the set of per-call credentials associated with this instance. + */ + _getCallCredentials() { + return this.callCredentials + } + /** + * Return a new ChannelCredentials instance with a given set of credentials. + * The resulting instance can be used to construct a Channel that communicates + * over TLS. + * @param rootCerts The root certificate data. + * @param privateKey The client certificate private key, if available. + * @param certChain The client certificate key chain, if available. + */ + static createSsl(rootCerts, privateKey, certChain, verifyOptions) { + verifyIsBufferOrNull(rootCerts, 'Root certificate') + verifyIsBufferOrNull(privateKey, 'Private key') + verifyIsBufferOrNull(certChain, 'Certificate chain') + if (privateKey && !certChain) { + throw new Error( + 'Private key must be given with accompanying certificate chain' + ) + } + if (!privateKey && certChain) { + throw new Error( + 'Certificate chain must be given with accompanying private key' + ) + } + return new SecureChannelCredentialsImpl( + rootCerts || tls_helpers_1.getDefaultRootsData(), + privateKey || null, + certChain || null, + verifyOptions || {} + ) + } + /** + * Return a new ChannelCredentials instance with no credentials. + */ + static createInsecure() { + return new InsecureChannelCredentialsImpl() + } + } + exports.ChannelCredentials = ChannelCredentials + class InsecureChannelCredentialsImpl extends ChannelCredentials { + constructor(callCredentials) { + super(callCredentials) + } + compose(callCredentials) { + throw new Error('Cannot compose insecure credentials') + } + _getConnectionOptions() { + return null + } + _isSecure() { + return false + } + _equals(other) { + return other instanceof InsecureChannelCredentialsImpl + } + } + class SecureChannelCredentialsImpl extends ChannelCredentials { + constructor(rootCerts, privateKey, certChain, verifyOptions) { + super() + this.rootCerts = rootCerts + this.privateKey = privateKey + this.certChain = certChain + this.verifyOptions = verifyOptions + const secureContext = tls_1.createSecureContext({ + ca: rootCerts || undefined, + key: privateKey || undefined, + cert: certChain || undefined, + ciphers: tls_helpers_1.CIPHER_SUITES + }) + this.connectionOptions = { secureContext } + if (verifyOptions && verifyOptions.checkServerIdentity) { + this.connectionOptions.checkServerIdentity = (host, cert) => { + return verifyOptions.checkServerIdentity(host, { raw: cert.raw }) + } + } + } + compose(callCredentials) { + const combinedCallCredentials = this.callCredentials.compose( + callCredentials + ) + return new ComposedChannelCredentialsImpl( + this, + combinedCallCredentials + ) + } + _getConnectionOptions() { + // Copy to prevent callers from mutating this.connectionOptions + return Object.assign({}, this.connectionOptions) + } + _isSecure() { + return true + } + _equals(other) { + if (this === other) { + return true + } + if (other instanceof SecureChannelCredentialsImpl) { + if (!bufferOrNullEqual(this.rootCerts, other.rootCerts)) { + return false + } + if (!bufferOrNullEqual(this.privateKey, other.privateKey)) { + return false + } + if (!bufferOrNullEqual(this.certChain, other.certChain)) { + return false + } + return ( + this.verifyOptions.checkServerIdentity === + other.verifyOptions.checkServerIdentity + ) + } else { + return false + } + } + } + class ComposedChannelCredentialsImpl extends ChannelCredentials { + constructor(channelCredentials, callCreds) { + super(callCreds) + this.channelCredentials = channelCredentials + } + compose(callCredentials) { + const combinedCallCredentials = this.callCredentials.compose( + callCredentials + ) + return new ComposedChannelCredentialsImpl( + this.channelCredentials, + combinedCallCredentials + ) + } + _getConnectionOptions() { + return this.channelCredentials._getConnectionOptions() + } + _isSecure() { + return true + } + _equals(other) { + if (this === other) { + return true + } + if (other instanceof ComposedChannelCredentialsImpl) { + return ( + this.channelCredentials._equals(other.channelCredentials) && + this.callCredentials._equals(other.callCredentials) + ) + } else { + return false + } + } + } + function createGoogleDefaultCredentials() { + const GoogleAuth = __webpack_require__(20810).GoogleAuth + const sslCreds = ChannelCredentials.createSsl() + const googleAuthCreds = call_credentials_1.CallCredentials.createFromGoogleCredential( + new GoogleAuth() + ) + return sslCreds.compose(googleAuthCreds) + } + exports.createGoogleDefaultCredentials = createGoogleDefaultCredentials + //# sourceMappingURL=channel-credentials.js.map + + /***/ + }, + + /***/ 99810: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + /* + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.channelOptionsEqual = exports.recognizedOptions = void 0 + /** + * This is for checking provided options at runtime. This is an object for + * easier membership checking. + */ + exports.recognizedOptions = { + 'grpc.ssl_target_name_override': true, + 'grpc.primary_user_agent': true, + 'grpc.secondary_user_agent': true, + 'grpc.default_authority': true, + 'grpc.keepalive_time_ms': true, + 'grpc.keepalive_timeout_ms': true, + 'grpc.service_config': true, + 'grpc.max_concurrent_streams': true, + 'grpc.initial_reconnect_backoff_ms': true, + 'grpc.max_reconnect_backoff_ms': true, + 'grpc.use_local_subchannel_pool': true, + 'grpc.max_send_message_length': true, + 'grpc.max_receive_message_length': true, + 'grpc.enable_http_proxy': true + } + function channelOptionsEqual(options1, options2) { + const keys1 = Object.keys(options1).sort() + const keys2 = Object.keys(options2).sort() + if (keys1.length !== keys2.length) { + return false + } + for (let i = 0; i < keys1.length; i += 1) { + if (keys1[i] !== keys2[i]) { + return false + } + if (options1[keys1[i]] !== options2[keys2[i]]) { + return false + } + } + return true + } + exports.channelOptionsEqual = channelOptionsEqual + //# sourceMappingURL=channel-options.js.map + + /***/ + }, + + /***/ 13860: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /* + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.ChannelImplementation = exports.ConnectivityState = void 0 + const call_stream_1 = __webpack_require__(78988) + const channel_credentials_1 = __webpack_require__(44030) + const resolving_load_balancer_1 = __webpack_require__(19192) + const subchannel_pool_1 = __webpack_require__(39780) + const picker_1 = __webpack_require__(81611) + const constants_1 = __webpack_require__(90634) + const filter_stack_1 = __webpack_require__(66450) + const call_credentials_filter_1 = __webpack_require__(86380) + const deadline_filter_1 = __webpack_require__(81217) + const compression_filter_1 = __webpack_require__(47616) + const resolver_1 = __webpack_require__(31594) + const logging_1 = __webpack_require__(35993) + const max_message_size_filter_1 = __webpack_require__(30659) + const http_proxy_1 = __webpack_require__(24000) + const uri_parser_1 = __webpack_require__(65974) + var ConnectivityState + ;(function (ConnectivityState) { + ConnectivityState[(ConnectivityState['CONNECTING'] = 0)] = 'CONNECTING' + ConnectivityState[(ConnectivityState['READY'] = 1)] = 'READY' + ConnectivityState[(ConnectivityState['TRANSIENT_FAILURE'] = 2)] = + 'TRANSIENT_FAILURE' + ConnectivityState[(ConnectivityState['IDLE'] = 3)] = 'IDLE' + ConnectivityState[(ConnectivityState['SHUTDOWN'] = 4)] = 'SHUTDOWN' + })( + (ConnectivityState = + exports.ConnectivityState || (exports.ConnectivityState = {})) + ) + /** + * See https://nodejs.org/api/timers.html#timers_setinterval_callback_delay_args + */ + const MAX_TIMEOUT_TIME = 2147483647 + let nextCallNumber = 0 + function getNewCallNumber() { + const callNumber = nextCallNumber + nextCallNumber += 1 + if (nextCallNumber >= Number.MAX_SAFE_INTEGER) { + nextCallNumber = 0 + } + return callNumber + } + class ChannelImplementation { + constructor(target, credentials, options) { + var _a, _b, _c + this.credentials = credentials + this.options = options + this.connectivityState = ConnectivityState.IDLE + this.currentPicker = new picker_1.UnavailablePicker() + this.pickQueue = [] + this.connectivityStateWatchers = [] + if (typeof target !== 'string') { + throw new TypeError('Channel target must be a string') + } + if ( + !(credentials instanceof channel_credentials_1.ChannelCredentials) + ) { + throw new TypeError( + 'Channel credentials must be a ChannelCredentials object' + ) + } + if (options) { + if ( + typeof options !== 'object' || + !Object.values(options).every( + value => + typeof value === 'string' || + typeof value === 'number' || + typeof value === 'undefined' + ) + ) { + throw new TypeError( + 'Channel options must be an object with string or number values' + ) + } + } + const originalTargetUri = uri_parser_1.parseUri(target) + if (originalTargetUri === null) { + throw new Error(`Could not parse target name "${target}"`) + } + /* This ensures that the target has a scheme that is registered with the + * resolver */ + const defaultSchemeMapResult = resolver_1.mapUriDefaultScheme( + originalTargetUri + ) + if (defaultSchemeMapResult === null) { + throw new Error( + `Could not find a default scheme for target name "${target}"` + ) + } + this.callRefTimer = setInterval(() => {}, MAX_TIMEOUT_TIME) + ;(_b = (_a = this.callRefTimer).unref) === null || _b === void 0 + ? void 0 + : _b.call(_a) + if (this.options['grpc.default_authority']) { + this.defaultAuthority = this.options['grpc.default_authority'] + } else { + this.defaultAuthority = resolver_1.getDefaultAuthority( + defaultSchemeMapResult + ) + } + const proxyMapResult = http_proxy_1.mapProxyName( + defaultSchemeMapResult, + options + ) + this.target = proxyMapResult.target + this.options = Object.assign( + {}, + this.options, + proxyMapResult.extraOptions + ) + /* The global boolean parameter to getSubchannelPool has the inverse meaning to what + * the grpc.use_local_subchannel_pool channel option means. */ + this.subchannelPool = subchannel_pool_1.getSubchannelPool( + ((_c = options['grpc.use_local_subchannel_pool']) !== null && + _c !== void 0 + ? _c + : 0) === 0 + ) + const channelControlHelper = { + createSubchannel: (subchannelAddress, subchannelArgs) => { + return this.subchannelPool.getOrCreateSubchannel( + this.target, + subchannelAddress, + Object.assign({}, this.options, subchannelArgs), + this.credentials + ) + }, + updateState: (connectivityState, picker) => { + var _a, _b + this.currentPicker = picker + const queueCopy = this.pickQueue.slice() + ;(_b = (_a = this.callRefTimer).unref) === null || _b === void 0 + ? void 0 + : _b.call(_a) + this.pickQueue = [] + for (const { callStream, callMetadata } of queueCopy) { + this.tryPick(callStream, callMetadata) + } + this.updateState(connectivityState) + }, + requestReresolution: () => { + // This should never be called. + throw new Error( + 'Resolving load balancer should never call requestReresolution' + ) + } + } + this.resolvingLoadBalancer = new resolving_load_balancer_1.ResolvingLoadBalancer( + this.target, + channelControlHelper, + options + ) + this.filterStackFactory = new filter_stack_1.FilterStackFactory([ + new call_credentials_filter_1.CallCredentialsFilterFactory(this), + new deadline_filter_1.DeadlineFilterFactory(this), + new max_message_size_filter_1.MaxMessageSizeFilterFactory( + this.options + ), + new compression_filter_1.CompressionFilterFactory(this) + ]) + } + pushPick(callStream, callMetadata) { + var _a, _b + ;(_b = (_a = this.callRefTimer).ref) === null || _b === void 0 + ? void 0 + : _b.call(_a) + this.pickQueue.push({ callStream, callMetadata }) + } + /** + * Check the picker output for the given call and corresponding metadata, + * and take any relevant actions. Should not be called while iterating + * over pickQueue. + * @param callStream + * @param callMetadata + */ + tryPick(callStream, callMetadata) { + var _a, _b, _c + const pickResult = this.currentPicker.pick({ metadata: callMetadata }) + logging_1.trace( + constants_1.LogVerbosity.DEBUG, + 'channel', + 'Pick result: ' + + picker_1.PickResultType[pickResult.pickResultType] + + ' subchannel: ' + + ((_a = pickResult.subchannel) === null || _a === void 0 + ? void 0 + : _a.getAddress()) + + ' status: ' + + ((_b = pickResult.status) === null || _b === void 0 + ? void 0 + : _b.code) + + ' ' + + ((_c = pickResult.status) === null || _c === void 0 + ? void 0 + : _c.details) + ) + switch (pickResult.pickResultType) { + case picker_1.PickResultType.COMPLETE: + if (pickResult.subchannel === null) { + callStream.cancelWithStatus( + constants_1.Status.UNAVAILABLE, + 'Request dropped by load balancing policy' + ) + // End the call with an error + } else { + /* If the subchannel is not in the READY state, that indicates a bug + * somewhere in the load balancer or picker. So, we log an error and + * queue the pick to be tried again later. */ + if ( + pickResult.subchannel.getConnectivityState() !== + ConnectivityState.READY + ) { + logging_1.log( + constants_1.LogVerbosity.ERROR, + 'Error: COMPLETE pick result subchannel ' + + pickResult.subchannel.getAddress() + + ' has state ' + + ConnectivityState[ + pickResult.subchannel.getConnectivityState() + ] + ) + this.pushPick(callStream, callMetadata) + break + } + /* We need to clone the callMetadata here because the transparent + * retry code in the promise resolution handler use the same + * callMetadata object, so it needs to stay unmodified */ + callStream.filterStack + .sendMetadata(Promise.resolve(callMetadata.clone())) + .then( + finalMetadata => { + var _a, _b + const subchannelState = pickResult.subchannel.getConnectivityState() + if (subchannelState === ConnectivityState.READY) { + try { + pickResult.subchannel.startCallStream( + finalMetadata, + callStream, + (_a = pickResult.extraFilterFactory) !== null && + _a !== void 0 + ? _a + : undefined + ) + /* If we reach this point, the call stream has started + * successfully */ + ;(_b = pickResult.onCallStarted) === null || + _b === void 0 + ? void 0 + : _b.call(pickResult) + } catch (error) { + if (error.code === 'ERR_HTTP2_GOAWAY_SESSION') { + /* An error here indicates that something went wrong with + * the picked subchannel's http2 stream right before we + * tried to start the stream. We are handling a promise + * result here, so this is asynchronous with respect to the + * original tryPick call, so calling it again is not + * recursive. We call tryPick immediately instead of + * queueing this pick again because handling the queue is + * triggered by state changes, and we want to immediately + * check if the state has already changed since the + * previous tryPick call. We do this instead of cancelling + * the stream because the correct behavior may be + * re-queueing instead, based on the logic in the rest of + * tryPick */ + logging_1.trace( + constants_1.LogVerbosity.INFO, + 'channel', + 'Failed to start call on picked subchannel ' + + pickResult.subchannel.getAddress() + + ' with error ' + + error.message + + '. Retrying pick' + ) + this.tryPick(callStream, callMetadata) + } else { + logging_1.trace( + constants_1.LogVerbosity.INFO, + 'channel', + 'Failed to start call on picked subchanel ' + + pickResult.subchannel.getAddress() + + ' with error ' + + error.message + + '. Ending call' + ) + callStream.cancelWithStatus( + constants_1.Status.INTERNAL, + 'Failed to start HTTP/2 stream' + ) + } + } + } else { + /* The logic for doing this here is the same as in the catch + * block above */ + logging_1.trace( + constants_1.LogVerbosity.INFO, + 'channel', + 'Picked subchannel ' + + pickResult.subchannel.getAddress() + + ' has state ' + + ConnectivityState[subchannelState] + + ' after metadata filters. Retrying pick' + ) + this.tryPick(callStream, callMetadata) + } + }, + error => { + // We assume the error code isn't 0 (Status.OK) + callStream.cancelWithStatus( + error.code || constants_1.Status.UNKNOWN, + `Getting metadata from plugin failed with error: ${error.message}` + ) + } + ) + } + break + case picker_1.PickResultType.QUEUE: + this.pushPick(callStream, callMetadata) + break + case picker_1.PickResultType.TRANSIENT_FAILURE: + if (callMetadata.getOptions().waitForReady) { + this.pushPick(callStream, callMetadata) + } else { + callStream.cancelWithStatus( + pickResult.status.code, + pickResult.status.details + ) + } + break + case picker_1.PickResultType.DROP: + callStream.cancelWithStatus( + pickResult.status.code, + pickResult.status.details + ) + break + default: + throw new Error( + `Invalid state: unknown pickResultType ${pickResult.pickResultType}` + ) + } + } + removeConnectivityStateWatcher(watcherObject) { + const watcherIndex = this.connectivityStateWatchers.findIndex( + value => value === watcherObject + ) + if (watcherIndex >= 0) { + this.connectivityStateWatchers.splice(watcherIndex, 1) + } + } + updateState(newState) { + logging_1.trace( + constants_1.LogVerbosity.DEBUG, + 'connectivity_state', + uri_parser_1.uriToString(this.target) + + ' ' + + ConnectivityState[this.connectivityState] + + ' -> ' + + ConnectivityState[newState] + ) + this.connectivityState = newState + const watchersCopy = this.connectivityStateWatchers.slice() + for (const watcherObject of watchersCopy) { + if (newState !== watcherObject.currentState) { + if (watcherObject.timer) { + clearTimeout(watcherObject.timer) + } + this.removeConnectivityStateWatcher(watcherObject) + watcherObject.callback() + } + } + } + _startCallStream(stream, metadata) { + this.tryPick(stream, metadata.clone()) + } + close() { + this.resolvingLoadBalancer.destroy() + this.updateState(ConnectivityState.SHUTDOWN) + clearInterval(this.callRefTimer) + this.subchannelPool.unrefUnusedSubchannels() + } + getTarget() { + return uri_parser_1.uriToString(this.target) + } + getConnectivityState(tryToConnect) { + const connectivityState = this.connectivityState + if (tryToConnect) { + this.resolvingLoadBalancer.exitIdle() + } + return connectivityState + } + watchConnectivityState(currentState, deadline, callback) { + let timer = null + if (deadline !== Infinity) { + const deadlineDate = + deadline instanceof Date ? deadline : new Date(deadline) + const now = new Date() + if (deadline === -Infinity || deadlineDate <= now) { + process.nextTick( + callback, + new Error('Deadline passed without connectivity state change') + ) + return + } + timer = setTimeout(() => { + this.removeConnectivityStateWatcher(watcherObject) + callback( + new Error('Deadline passed without connectivity state change') + ) + }, deadlineDate.getTime() - now.getTime()) + } + const watcherObject = { + currentState, + callback, + timer + } + this.connectivityStateWatchers.push(watcherObject) + } + createCall( + method, + deadline, + host, + parentCall, // eslint-disable-line @typescript-eslint/no-explicit-any + propagateFlags + ) { + if (typeof method !== 'string') { + throw new TypeError('Channel#createCall: method must be a string') + } + if (!(typeof deadline === 'number' || deadline instanceof Date)) { + throw new TypeError( + 'Channel#createCall: deadline must be a number or Date' + ) + } + if (this.connectivityState === ConnectivityState.SHUTDOWN) { + throw new Error('Channel has been shut down') + } + const callNumber = getNewCallNumber() + logging_1.trace( + constants_1.LogVerbosity.DEBUG, + 'channel', + uri_parser_1.uriToString(this.target) + + ' createCall [' + + callNumber + + '] method="' + + method + + '", deadline=' + + deadline + ) + const finalOptions = { + deadline: deadline, + flags: propagateFlags || 0, + host: host || this.defaultAuthority, + parentCall: parentCall || null + } + const stream = new call_stream_1.Http2CallStream( + method, + this, + finalOptions, + this.filterStackFactory, + this.credentials._getCallCredentials(), + callNumber + ) + return stream + } + } + exports.ChannelImplementation = ChannelImplementation + //# sourceMappingURL=channel.js.map + + /***/ + }, + + /***/ 82127: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /* + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.getInterceptingCall = exports.InterceptingCall = exports.RequesterBuilder = exports.ListenerBuilder = exports.InterceptorConfigurationError = void 0 + const metadata_1 = __webpack_require__(83665) + const call_stream_1 = __webpack_require__(78988) + const constants_1 = __webpack_require__(90634) + /** + * Error class associated with passing both interceptors and interceptor + * providers to a client constructor or as call options. + */ + class InterceptorConfigurationError extends Error { + constructor(message) { + super(message) + this.name = 'InterceptorConfigurationError' + Error.captureStackTrace(this, InterceptorConfigurationError) + } + } + exports.InterceptorConfigurationError = InterceptorConfigurationError + class ListenerBuilder { + constructor() { + this.metadata = undefined + this.message = undefined + this.status = undefined + } + withOnReceiveMetadata(onReceiveMetadata) { + this.metadata = onReceiveMetadata + return this + } + withOnReceiveMessage(onReceiveMessage) { + this.message = onReceiveMessage + return this + } + withOnReceiveStatus(onReceiveStatus) { + this.status = onReceiveStatus + return this + } + build() { + return { + onReceiveMetadata: this.metadata, + onReceiveMessage: this.message, + onReceiveStatus: this.status + } + } + } + exports.ListenerBuilder = ListenerBuilder + class RequesterBuilder { + constructor() { + this.start = undefined + this.message = undefined + this.halfClose = undefined + this.cancel = undefined + } + withStart(start) { + this.start = start + return this + } + withSendMessage(sendMessage) { + this.message = sendMessage + return this + } + withHalfClose(halfClose) { + this.halfClose = halfClose + return this + } + withCancel(cancel) { + this.cancel = cancel + return this + } + build() { + return { + start: this.start, + sendMessage: this.message, + halfClose: this.halfClose, + cancel: this.cancel + } + } + } + exports.RequesterBuilder = RequesterBuilder + /** + * A Listener with a default pass-through implementation of each method. Used + * for filling out Listeners with some methods omitted. + */ + const defaultListener = { + onReceiveMetadata: (metadata, next) => { + next(metadata) + }, + onReceiveMessage: (message, next) => { + next(message) + }, + onReceiveStatus: (status, next) => { + next(status) + } + } + /** + * A Requester with a default pass-through implementation of each method. Used + * for filling out Requesters with some methods omitted. + */ + const defaultRequester = { + start: (metadata, listener, next) => { + next(metadata, listener) + }, + sendMessage: (message, next) => { + next(message) + }, + halfClose: next => { + next() + }, + cancel: next => { + next() + } + } + class InterceptingCall { + constructor(nextCall, requester) { + var _a, _b, _c, _d + this.nextCall = nextCall + /** + * Indicates that a message has been passed to the listener's onReceiveMessage + * method it has not been passed to the corresponding next callback + */ + this.processingMessage = false + /** + * Indicates that a status was received but could not be propagated because + * a message was still being processed. + */ + this.pendingHalfClose = false + if (requester) { + this.requester = { + start: + (_a = requester.start) !== null && _a !== void 0 + ? _a + : defaultRequester.start, + sendMessage: + (_b = requester.sendMessage) !== null && _b !== void 0 + ? _b + : defaultRequester.sendMessage, + halfClose: + (_c = requester.halfClose) !== null && _c !== void 0 + ? _c + : defaultRequester.halfClose, + cancel: + (_d = requester.cancel) !== null && _d !== void 0 + ? _d + : defaultRequester.cancel + } + } else { + this.requester = defaultRequester + } + } + cancelWithStatus(status, details) { + this.requester.cancel(() => { + this.nextCall.cancelWithStatus(status, details) + }) + } + getPeer() { + return this.nextCall.getPeer() + } + start(metadata, interceptingListener) { + var _a, _b, _c, _d, _e, _f + const fullInterceptingListener = { + onReceiveMetadata: + (_b = + (_a = + interceptingListener === null || + interceptingListener === void 0 + ? void 0 + : interceptingListener.onReceiveMetadata) === null || + _a === void 0 + ? void 0 + : _a.bind(interceptingListener)) !== null && _b !== void 0 + ? _b + : metadata => {}, + onReceiveMessage: + (_d = + (_c = + interceptingListener === null || + interceptingListener === void 0 + ? void 0 + : interceptingListener.onReceiveMessage) === null || + _c === void 0 + ? void 0 + : _c.bind(interceptingListener)) !== null && _d !== void 0 + ? _d + : message => {}, + onReceiveStatus: + (_f = + (_e = + interceptingListener === null || + interceptingListener === void 0 + ? void 0 + : interceptingListener.onReceiveStatus) === null || + _e === void 0 + ? void 0 + : _e.bind(interceptingListener)) !== null && _f !== void 0 + ? _f + : status => {} + } + this.requester.start( + metadata, + fullInterceptingListener, + (md, listener) => { + var _a, _b, _c + let finalInterceptingListener + if (call_stream_1.isInterceptingListener(listener)) { + finalInterceptingListener = listener + } else { + const fullListener = { + onReceiveMetadata: + (_a = listener.onReceiveMetadata) !== null && _a !== void 0 + ? _a + : defaultListener.onReceiveMetadata, + onReceiveMessage: + (_b = listener.onReceiveMessage) !== null && _b !== void 0 + ? _b + : defaultListener.onReceiveMessage, + onReceiveStatus: + (_c = listener.onReceiveStatus) !== null && _c !== void 0 + ? _c + : defaultListener.onReceiveStatus + } + finalInterceptingListener = new call_stream_1.InterceptingListenerImpl( + fullListener, + fullInterceptingListener + ) + } + this.nextCall.start(md, finalInterceptingListener) + } + ) + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + sendMessageWithContext(context, message) { + this.processingMessage = true + this.requester.sendMessage(message, finalMessage => { + this.processingMessage = false + this.nextCall.sendMessageWithContext(context, finalMessage) + if (this.pendingHalfClose) { + this.nextCall.halfClose() + } + }) + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + sendMessage(message) { + this.sendMessageWithContext({}, message) + } + startRead() { + this.nextCall.startRead() + } + halfClose() { + this.requester.halfClose(() => { + if (this.processingMessage) { + this.pendingHalfClose = true + } else { + this.nextCall.halfClose() + } + }) + } + setCredentials(credentials) { + this.nextCall.setCredentials(credentials) + } + } + exports.InterceptingCall = InterceptingCall + function getCall(channel, path, options) { + let deadline + let host + const parent = null + let propagateFlags + let credentials + if (options) { + deadline = options.deadline + host = options.host + propagateFlags = options.propagate_flags + credentials = options.credentials + } + if (deadline === undefined) { + deadline = Infinity + } + const call = channel.createCall( + path, + deadline, + host, + parent, + propagateFlags + ) + if (credentials) { + call.setCredentials(credentials) + } + return call + } + /** + * InterceptingCall implementation that directly owns the underlying Call + * object and handles serialization and deseraizliation. + */ + class BaseInterceptingCall { + constructor( + call, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + methodDefinition + ) { + this.call = call + this.methodDefinition = methodDefinition + } + cancelWithStatus(status, details) { + this.call.cancelWithStatus(status, details) + } + getPeer() { + return this.call.getPeer() + } + setCredentials(credentials) { + this.call.setCredentials(credentials) + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + sendMessageWithContext(context, message) { + let serialized + try { + serialized = this.methodDefinition.requestSerialize(message) + this.call.sendMessageWithContext(context, serialized) + } catch (e) { + this.call.cancelWithStatus( + constants_1.Status.INTERNAL, + `Request message serialization failure: ${e.message}` + ) + } + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + sendMessage(message) { + this.sendMessageWithContext({}, message) + } + start(metadata, interceptingListener) { + let readError = null + this.call.start(metadata, { + onReceiveMetadata: metadata => { + var _a + ;(_a = + interceptingListener === null || interceptingListener === void 0 + ? void 0 + : interceptingListener.onReceiveMetadata) === null || + _a === void 0 + ? void 0 + : _a.call(interceptingListener, metadata) + }, + onReceiveMessage: message => { + var _a + // eslint-disable-next-line @typescript-eslint/no-explicit-any + let deserialized + try { + deserialized = this.methodDefinition.responseDeserialize( + message + ) + ;(_a = + interceptingListener === null || + interceptingListener === void 0 + ? void 0 + : interceptingListener.onReceiveMessage) === null || + _a === void 0 + ? void 0 + : _a.call(interceptingListener, deserialized) + } catch (e) { + readError = { + code: constants_1.Status.INTERNAL, + details: `Response message parsing error: ${e.message}`, + metadata: new metadata_1.Metadata() + } + this.call.cancelWithStatus(readError.code, readError.details) + } + }, + onReceiveStatus: status => { + var _a, _b + if (readError) { + ;(_a = + interceptingListener === null || + interceptingListener === void 0 + ? void 0 + : interceptingListener.onReceiveStatus) === null || + _a === void 0 + ? void 0 + : _a.call(interceptingListener, readError) + } else { + ;(_b = + interceptingListener === null || + interceptingListener === void 0 + ? void 0 + : interceptingListener.onReceiveStatus) === null || + _b === void 0 + ? void 0 + : _b.call(interceptingListener, status) + } + } + }) + } + startRead() { + this.call.startRead() + } + halfClose() { + this.call.halfClose() + } + } + /** + * BaseInterceptingCall with special-cased behavior for methods with unary + * responses. + */ + class BaseUnaryInterceptingCall extends BaseInterceptingCall { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + constructor(call, methodDefinition) { + super(call, methodDefinition) + } + start(metadata, listener) { + var _a, _b + let receivedMessage = false + const wrapperListener = { + onReceiveMetadata: + (_b = + (_a = + listener === null || listener === void 0 + ? void 0 + : listener.onReceiveMetadata) === null || _a === void 0 + ? void 0 + : _a.bind(listener)) !== null && _b !== void 0 + ? _b + : metadata => {}, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + onReceiveMessage: message => { + var _a + receivedMessage = true + ;(_a = + listener === null || listener === void 0 + ? void 0 + : listener.onReceiveMessage) === null || _a === void 0 + ? void 0 + : _a.call(listener, message) + }, + onReceiveStatus: status => { + var _a, _b + if (!receivedMessage) { + ;(_a = + listener === null || listener === void 0 + ? void 0 + : listener.onReceiveMessage) === null || _a === void 0 + ? void 0 + : _a.call(listener, null) + } + ;(_b = + listener === null || listener === void 0 + ? void 0 + : listener.onReceiveStatus) === null || _b === void 0 + ? void 0 + : _b.call(listener, status) + } + } + super.start(metadata, wrapperListener) + this.call.startRead() + } + } + /** + * BaseInterceptingCall with special-cased behavior for methods with streaming + * responses. + */ + class BaseStreamingInterceptingCall extends BaseInterceptingCall {} + function getBottomInterceptingCall( + channel, + options, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + methodDefinition + ) { + const call = getCall(channel, methodDefinition.path, options) + if (methodDefinition.responseStream) { + return new BaseStreamingInterceptingCall(call, methodDefinition) + } else { + return new BaseUnaryInterceptingCall(call, methodDefinition) + } + } + function getInterceptingCall( + interceptorArgs, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + methodDefinition, + options, + channel + ) { + if ( + interceptorArgs.clientInterceptors.length > 0 && + interceptorArgs.clientInterceptorProviders.length > 0 + ) { + throw new InterceptorConfigurationError( + 'Both interceptors and interceptor_providers were passed as options ' + + 'to the client constructor. Only one of these is allowed.' + ) + } + if ( + interceptorArgs.callInterceptors.length > 0 && + interceptorArgs.callInterceptorProviders.length > 0 + ) { + throw new InterceptorConfigurationError( + 'Both interceptors and interceptor_providers were passed as call ' + + 'options. Only one of these is allowed.' + ) + } + let interceptors = [] + // Interceptors passed to the call override interceptors passed to the client constructor + if ( + interceptorArgs.callInterceptors.length > 0 || + interceptorArgs.callInterceptorProviders.length > 0 + ) { + interceptors = [] + .concat( + interceptorArgs.callInterceptors, + interceptorArgs.callInterceptorProviders.map(provider => + provider(methodDefinition) + ) + ) + .filter(interceptor => interceptor) + // Filter out falsy values when providers return nothing + } else { + interceptors = [] + .concat( + interceptorArgs.clientInterceptors, + interceptorArgs.clientInterceptorProviders.map(provider => + provider(methodDefinition) + ) + ) + .filter(interceptor => interceptor) + // Filter out falsy values when providers return nothing + } + const interceptorOptions = Object.assign({}, options, { + method_definition: methodDefinition + }) + /* For each interceptor in the list, the nextCall function passed to it is + * based on the next interceptor in the list, using a nextCall function + * constructed with the following interceptor in the list, and so on. The + * initialValue, which is effectively at the end of the list, is a nextCall + * function that invokes getBottomInterceptingCall, the result of which + * handles (de)serialization and also gets the underlying call from the + * channel. */ + const getCall = interceptors.reduceRight( + (nextCall, nextInterceptor) => { + return currentOptions => nextInterceptor(currentOptions, nextCall) + }, + finalOptions => + getBottomInterceptingCall(channel, finalOptions, methodDefinition) + ) + return getCall(interceptorOptions) + } + exports.getInterceptingCall = getInterceptingCall + //# sourceMappingURL=client-interceptors.js.map + + /***/ + }, + + /***/ 87172: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /* + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.Client = void 0 + const call_1 = __webpack_require__(97453) + const channel_1 = __webpack_require__(13860) + const constants_1 = __webpack_require__(90634) + const metadata_1 = __webpack_require__(83665) + const client_interceptors_1 = __webpack_require__(82127) + const CHANNEL_SYMBOL = Symbol() + const INTERCEPTOR_SYMBOL = Symbol() + const INTERCEPTOR_PROVIDER_SYMBOL = Symbol() + const CALL_INVOCATION_TRANSFORMER_SYMBOL = Symbol() + /** + * A generic gRPC client. Primarily useful as a base class for all generated + * clients. + */ + class Client { + constructor(address, credentials, options = {}) { + var _a, _b + options = Object.assign({}, options) + this[INTERCEPTOR_SYMBOL] = + (_a = options.interceptors) !== null && _a !== void 0 ? _a : [] + delete options.interceptors + this[INTERCEPTOR_PROVIDER_SYMBOL] = + (_b = options.interceptor_providers) !== null && _b !== void 0 + ? _b + : [] + delete options.interceptor_providers + if ( + this[INTERCEPTOR_SYMBOL].length > 0 && + this[INTERCEPTOR_PROVIDER_SYMBOL].length > 0 + ) { + throw new Error( + 'Both interceptors and interceptor_providers were passed as options ' + + 'to the client constructor. Only one of these is allowed.' + ) + } + this[CALL_INVOCATION_TRANSFORMER_SYMBOL] = + options.callInvocationTransformer + delete options.callInvocationTransformer + if (options.channelOverride) { + this[CHANNEL_SYMBOL] = options.channelOverride + } else if (options.channelFactoryOverride) { + const channelFactoryOverride = options.channelFactoryOverride + delete options.channelFactoryOverride + this[CHANNEL_SYMBOL] = channelFactoryOverride( + address, + credentials, + options + ) + } else { + this[CHANNEL_SYMBOL] = new channel_1.ChannelImplementation( + address, + credentials, + options + ) + } + } + close() { + this[CHANNEL_SYMBOL].close() + } + getChannel() { + return this[CHANNEL_SYMBOL] + } + waitForReady(deadline, callback) { + const checkState = err => { + if (err) { + callback(new Error('Failed to connect before the deadline')) + return + } + let newState + try { + newState = this[CHANNEL_SYMBOL].getConnectivityState(true) + } catch (e) { + callback(new Error('The channel has been closed')) + return + } + if (newState === channel_1.ConnectivityState.READY) { + callback() + } else { + try { + this[CHANNEL_SYMBOL].watchConnectivityState( + newState, + deadline, + checkState + ) + } catch (e) { + callback(new Error('The channel has been closed')) + } + } + } + setImmediate(checkState) + } + checkOptionalUnaryResponseArguments(arg1, arg2, arg3) { + if (arg1 instanceof Function) { + return { + metadata: new metadata_1.Metadata(), + options: {}, + callback: arg1 + } + } else if (arg2 instanceof Function) { + if (arg1 instanceof metadata_1.Metadata) { + return { metadata: arg1, options: {}, callback: arg2 } + } else { + return { + metadata: new metadata_1.Metadata(), + options: arg1, + callback: arg2 + } + } + } else { + if ( + !( + arg1 instanceof metadata_1.Metadata && + arg2 instanceof Object && + arg3 instanceof Function + ) + ) { + throw new Error('Incorrect arguments passed') + } + return { metadata: arg1, options: arg2, callback: arg3 } + } + } + makeUnaryRequest( + method, + serialize, + deserialize, + argument, + metadata, + options, + callback + ) { + var _a, _b + const checkedArguments = this.checkOptionalUnaryResponseArguments( + metadata, + options, + callback + ) + const methodDefinition = { + path: method, + requestStream: false, + responseStream: false, + requestSerialize: serialize, + responseDeserialize: deserialize + } + let callProperties = { + argument: argument, + metadata: checkedArguments.metadata, + call: new call_1.ClientUnaryCallImpl(), + channel: this[CHANNEL_SYMBOL], + methodDefinition: methodDefinition, + callOptions: checkedArguments.options, + callback: checkedArguments.callback + } + if (this[CALL_INVOCATION_TRANSFORMER_SYMBOL]) { + callProperties = this[CALL_INVOCATION_TRANSFORMER_SYMBOL]( + callProperties + ) + } + const emitter = callProperties.call + const interceptorArgs = { + clientInterceptors: this[INTERCEPTOR_SYMBOL], + clientInterceptorProviders: this[INTERCEPTOR_PROVIDER_SYMBOL], + callInterceptors: + (_a = callProperties.callOptions.interceptors) !== null && + _a !== void 0 + ? _a + : [], + callInterceptorProviders: + (_b = callProperties.callOptions.interceptor_providers) !== + null && _b !== void 0 + ? _b + : [] + } + const call = client_interceptors_1.getInterceptingCall( + interceptorArgs, + callProperties.methodDefinition, + callProperties.callOptions, + callProperties.channel + ) + /* This needs to happen before the emitter is used. Unfortunately we can't + * enforce this with the type system. We need to construct this emitter + * before calling the CallInvocationTransformer, and we need to create the + * call after that. */ + emitter.call = call + if (callProperties.callOptions.credentials) { + call.setCredentials(callProperties.callOptions.credentials) + } + let responseMessage = null + let receivedStatus = false + call.start(callProperties.metadata, { + onReceiveMetadata: metadata => { + emitter.emit('metadata', metadata) + }, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + onReceiveMessage(message) { + if (responseMessage !== null) { + call.cancelWithStatus( + constants_1.Status.INTERNAL, + 'Too many responses received' + ) + } + responseMessage = message + }, + onReceiveStatus(status) { + if (receivedStatus) { + return + } + receivedStatus = true + if (status.code === constants_1.Status.OK) { + callProperties.callback(null, responseMessage) + } else { + callProperties.callback(call_1.callErrorFromStatus(status)) + } + emitter.emit('status', status) + } + }) + call.sendMessage(argument) + call.halfClose() + return emitter + } + makeClientStreamRequest( + method, + serialize, + deserialize, + metadata, + options, + callback + ) { + var _a, _b + const checkedArguments = this.checkOptionalUnaryResponseArguments( + metadata, + options, + callback + ) + const methodDefinition = { + path: method, + requestStream: true, + responseStream: false, + requestSerialize: serialize, + responseDeserialize: deserialize + } + let callProperties = { + metadata: checkedArguments.metadata, + call: new call_1.ClientWritableStreamImpl(serialize), + channel: this[CHANNEL_SYMBOL], + methodDefinition: methodDefinition, + callOptions: checkedArguments.options, + callback: checkedArguments.callback + } + if (this[CALL_INVOCATION_TRANSFORMER_SYMBOL]) { + callProperties = this[CALL_INVOCATION_TRANSFORMER_SYMBOL]( + callProperties + ) + } + const emitter = callProperties.call + const interceptorArgs = { + clientInterceptors: this[INTERCEPTOR_SYMBOL], + clientInterceptorProviders: this[INTERCEPTOR_PROVIDER_SYMBOL], + callInterceptors: + (_a = callProperties.callOptions.interceptors) !== null && + _a !== void 0 + ? _a + : [], + callInterceptorProviders: + (_b = callProperties.callOptions.interceptor_providers) !== + null && _b !== void 0 + ? _b + : [] + } + const call = client_interceptors_1.getInterceptingCall( + interceptorArgs, + callProperties.methodDefinition, + callProperties.callOptions, + callProperties.channel + ) + /* This needs to happen before the emitter is used. Unfortunately we can't + * enforce this with the type system. We need to construct this emitter + * before calling the CallInvocationTransformer, and we need to create the + * call after that. */ + emitter.call = call + if (callProperties.callOptions.credentials) { + call.setCredentials(callProperties.callOptions.credentials) + } + let responseMessage = null + let receivedStatus = false + call.start(callProperties.metadata, { + onReceiveMetadata: metadata => { + emitter.emit('metadata', metadata) + }, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + onReceiveMessage(message) { + if (responseMessage !== null) { + call.cancelWithStatus( + constants_1.Status.INTERNAL, + 'Too many responses received' + ) + } + responseMessage = message + }, + onReceiveStatus(status) { + if (receivedStatus) { + return + } + receivedStatus = true + if (status.code === constants_1.Status.OK) { + callProperties.callback(null, responseMessage) + } else { + callProperties.callback(call_1.callErrorFromStatus(status)) + } + emitter.emit('status', status) + } + }) + return emitter + } + checkMetadataAndOptions(arg1, arg2) { + let metadata + let options + if (arg1 instanceof metadata_1.Metadata) { + metadata = arg1 + if (arg2) { + options = arg2 + } else { + options = {} + } + } else { + if (arg1) { + options = arg1 + } else { + options = {} + } + metadata = new metadata_1.Metadata() + } + return { metadata, options } + } + makeServerStreamRequest( + method, + serialize, + deserialize, + argument, + metadata, + options + ) { + var _a, _b + const checkedArguments = this.checkMetadataAndOptions( + metadata, + options + ) + const methodDefinition = { + path: method, + requestStream: false, + responseStream: true, + requestSerialize: serialize, + responseDeserialize: deserialize + } + let callProperties = { + argument: argument, + metadata: checkedArguments.metadata, + call: new call_1.ClientReadableStreamImpl(deserialize), + channel: this[CHANNEL_SYMBOL], + methodDefinition: methodDefinition, + callOptions: checkedArguments.options + } + if (this[CALL_INVOCATION_TRANSFORMER_SYMBOL]) { + callProperties = this[CALL_INVOCATION_TRANSFORMER_SYMBOL]( + callProperties + ) + } + const stream = callProperties.call + const interceptorArgs = { + clientInterceptors: this[INTERCEPTOR_SYMBOL], + clientInterceptorProviders: this[INTERCEPTOR_PROVIDER_SYMBOL], + callInterceptors: + (_a = callProperties.callOptions.interceptors) !== null && + _a !== void 0 + ? _a + : [], + callInterceptorProviders: + (_b = callProperties.callOptions.interceptor_providers) !== + null && _b !== void 0 + ? _b + : [] + } + const call = client_interceptors_1.getInterceptingCall( + interceptorArgs, + callProperties.methodDefinition, + callProperties.callOptions, + callProperties.channel + ) + /* This needs to happen before the emitter is used. Unfortunately we can't + * enforce this with the type system. We need to construct this emitter + * before calling the CallInvocationTransformer, and we need to create the + * call after that. */ + stream.call = call + if (callProperties.callOptions.credentials) { + call.setCredentials(callProperties.callOptions.credentials) + } + let receivedStatus = false + call.start(callProperties.metadata, { + onReceiveMetadata(metadata) { + stream.emit('metadata', metadata) + }, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + onReceiveMessage(message) { + stream.push(message) + }, + onReceiveStatus(status) { + if (receivedStatus) { + return + } + receivedStatus = true + stream.push(null) + if (status.code !== constants_1.Status.OK) { + stream.emit('error', call_1.callErrorFromStatus(status)) + } + stream.emit('status', status) + } + }) + call.sendMessage(argument) + call.halfClose() + return stream + } + makeBidiStreamRequest( + method, + serialize, + deserialize, + metadata, + options + ) { + var _a, _b + const checkedArguments = this.checkMetadataAndOptions( + metadata, + options + ) + const methodDefinition = { + path: method, + requestStream: true, + responseStream: true, + requestSerialize: serialize, + responseDeserialize: deserialize + } + let callProperties = { + metadata: checkedArguments.metadata, + call: new call_1.ClientDuplexStreamImpl(serialize, deserialize), + channel: this[CHANNEL_SYMBOL], + methodDefinition: methodDefinition, + callOptions: checkedArguments.options + } + if (this[CALL_INVOCATION_TRANSFORMER_SYMBOL]) { + callProperties = this[CALL_INVOCATION_TRANSFORMER_SYMBOL]( + callProperties + ) + } + const stream = callProperties.call + const interceptorArgs = { + clientInterceptors: this[INTERCEPTOR_SYMBOL], + clientInterceptorProviders: this[INTERCEPTOR_PROVIDER_SYMBOL], + callInterceptors: + (_a = callProperties.callOptions.interceptors) !== null && + _a !== void 0 + ? _a + : [], + callInterceptorProviders: + (_b = callProperties.callOptions.interceptor_providers) !== + null && _b !== void 0 + ? _b + : [] + } + const call = client_interceptors_1.getInterceptingCall( + interceptorArgs, + callProperties.methodDefinition, + callProperties.callOptions, + callProperties.channel + ) + /* This needs to happen before the emitter is used. Unfortunately we can't + * enforce this with the type system. We need to construct this emitter + * before calling the CallInvocationTransformer, and we need to create the + * call after that. */ + stream.call = call + if (callProperties.callOptions.credentials) { + call.setCredentials(callProperties.callOptions.credentials) + } + let receivedStatus = false + call.start(callProperties.metadata, { + onReceiveMetadata(metadata) { + stream.emit('metadata', metadata) + }, + onReceiveMessage(message) { + stream.push(message) + }, + onReceiveStatus(status) { + if (receivedStatus) { + return + } + receivedStatus = true + stream.push(null) + if (status.code !== constants_1.Status.OK) { + stream.emit('error', call_1.callErrorFromStatus(status)) + } + stream.emit('status', status) + } + }) + return stream + } + } + exports.Client = Client + //# sourceMappingURL=client.js.map + + /***/ + }, + + /***/ 47616: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /* + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.CompressionFilterFactory = exports.CompressionFilter = void 0 + const zlib = __webpack_require__(78761) + const filter_1 = __webpack_require__(43392) + class CompressionHandler { + /** + * @param message Raw uncompressed message bytes + * @param compress Indicates whether the message should be compressed + * @return Framed message, compressed if applicable + */ + async writeMessage(message, compress) { + let messageBuffer = message + if (compress) { + messageBuffer = await this.compressMessage(messageBuffer) + } + const output = Buffer.allocUnsafe(messageBuffer.length + 5) + output.writeUInt8(compress ? 1 : 0, 0) + output.writeUInt32BE(messageBuffer.length, 1) + messageBuffer.copy(output, 5) + return output + } + /** + * @param data Framed message, possibly compressed + * @return Uncompressed message + */ + async readMessage(data) { + const compressed = data.readUInt8(0) === 1 + let messageBuffer = data.slice(5) + if (compressed) { + messageBuffer = await this.decompressMessage(messageBuffer) + } + return messageBuffer + } + } + class IdentityHandler extends CompressionHandler { + async compressMessage(message) { + return message + } + async writeMessage(message, compress) { + const output = Buffer.allocUnsafe(message.length + 5) + /* With "identity" compression, messages should always be marked as + * uncompressed */ + output.writeUInt8(0, 0) + output.writeUInt32BE(message.length, 1) + message.copy(output, 5) + return output + } + decompressMessage(message) { + return Promise.reject( + new Error( + 'Received compressed message but "grpc-encoding" header was identity' + ) + ) + } + } + class DeflateHandler extends CompressionHandler { + compressMessage(message) { + return new Promise((resolve, reject) => { + zlib.deflate(message, (err, output) => { + if (err) { + reject(err) + } else { + resolve(output) + } + }) + }) + } + decompressMessage(message) { + return new Promise((resolve, reject) => { + zlib.inflate(message, (err, output) => { + if (err) { + reject(err) + } else { + resolve(output) + } + }) + }) + } + } + class GzipHandler extends CompressionHandler { + compressMessage(message) { + return new Promise((resolve, reject) => { + zlib.gzip(message, (err, output) => { + if (err) { + reject(err) + } else { + resolve(output) + } + }) + }) + } + decompressMessage(message) { + return new Promise((resolve, reject) => { + zlib.unzip(message, (err, output) => { + if (err) { + reject(err) + } else { + resolve(output) + } + }) + }) + } + } + class UnknownHandler extends CompressionHandler { + constructor(compressionName) { + super() + this.compressionName = compressionName + } + compressMessage(message) { + return Promise.reject( + new Error( + `Received message compressed with unsupported compression method ${this.compressionName}` + ) + ) + } + decompressMessage(message) { + // This should be unreachable + return Promise.reject( + new Error( + `Compression method not supported: ${this.compressionName}` + ) + ) + } + } + function getCompressionHandler(compressionName) { + switch (compressionName) { + case 'identity': + return new IdentityHandler() + case 'deflate': + return new DeflateHandler() + case 'gzip': + return new GzipHandler() + default: + return new UnknownHandler(compressionName) + } + } + class CompressionFilter extends filter_1.BaseFilter { + constructor() { + super(...arguments) + this.sendCompression = new IdentityHandler() + this.receiveCompression = new IdentityHandler() + } + async sendMetadata(metadata) { + const headers = await metadata + headers.set('grpc-accept-encoding', 'identity,deflate,gzip') + headers.set('accept-encoding', 'identity,gzip') + return headers + } + receiveMetadata(metadata) { + const receiveEncoding = metadata.get('grpc-encoding') + if (receiveEncoding.length > 0) { + const encoding = receiveEncoding[0] + if (typeof encoding === 'string') { + this.receiveCompression = getCompressionHandler(encoding) + } + } + metadata.remove('grpc-encoding') + metadata.remove('grpc-accept-encoding') + return metadata + } + async sendMessage(message) { + /* This filter is special. The input message is the bare message bytes, + * and the output is a framed and possibly compressed message. For this + * reason, this filter should be at the bottom of the filter stack */ + const resolvedMessage = await message + const compress = + resolvedMessage.flags === undefined + ? false + : (resolvedMessage.flags & 2) /* NoCompress */ === 0 + return { + message: await this.sendCompression.writeMessage( + resolvedMessage.message, + compress + ), + flags: resolvedMessage.flags + } + } + async receiveMessage(message) { + /* This filter is also special. The input message is framed and possibly + * compressed, and the output message is deframed and uncompressed. So + * this is another reason that this filter should be at the bottom of the + * filter stack. */ + return this.receiveCompression.readMessage(await message) + } + } + exports.CompressionFilter = CompressionFilter + class CompressionFilterFactory { + constructor(channel) { + this.channel = channel + } + createFilter(callStream) { + return new CompressionFilter() + } + } + exports.CompressionFilterFactory = CompressionFilterFactory + //# sourceMappingURL=compression-filter.js.map + + /***/ + }, + + /***/ 90634: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + /* + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.DEFAULT_MAX_RECEIVE_MESSAGE_LENGTH = exports.DEFAULT_MAX_SEND_MESSAGE_LENGTH = exports.Propagate = exports.LogVerbosity = exports.Status = void 0 + var Status + ;(function (Status) { + Status[(Status['OK'] = 0)] = 'OK' + Status[(Status['CANCELLED'] = 1)] = 'CANCELLED' + Status[(Status['UNKNOWN'] = 2)] = 'UNKNOWN' + Status[(Status['INVALID_ARGUMENT'] = 3)] = 'INVALID_ARGUMENT' + Status[(Status['DEADLINE_EXCEEDED'] = 4)] = 'DEADLINE_EXCEEDED' + Status[(Status['NOT_FOUND'] = 5)] = 'NOT_FOUND' + Status[(Status['ALREADY_EXISTS'] = 6)] = 'ALREADY_EXISTS' + Status[(Status['PERMISSION_DENIED'] = 7)] = 'PERMISSION_DENIED' + Status[(Status['RESOURCE_EXHAUSTED'] = 8)] = 'RESOURCE_EXHAUSTED' + Status[(Status['FAILED_PRECONDITION'] = 9)] = 'FAILED_PRECONDITION' + Status[(Status['ABORTED'] = 10)] = 'ABORTED' + Status[(Status['OUT_OF_RANGE'] = 11)] = 'OUT_OF_RANGE' + Status[(Status['UNIMPLEMENTED'] = 12)] = 'UNIMPLEMENTED' + Status[(Status['INTERNAL'] = 13)] = 'INTERNAL' + Status[(Status['UNAVAILABLE'] = 14)] = 'UNAVAILABLE' + Status[(Status['DATA_LOSS'] = 15)] = 'DATA_LOSS' + Status[(Status['UNAUTHENTICATED'] = 16)] = 'UNAUTHENTICATED' + })((Status = exports.Status || (exports.Status = {}))) + var LogVerbosity + ;(function (LogVerbosity) { + LogVerbosity[(LogVerbosity['DEBUG'] = 0)] = 'DEBUG' + LogVerbosity[(LogVerbosity['INFO'] = 1)] = 'INFO' + LogVerbosity[(LogVerbosity['ERROR'] = 2)] = 'ERROR' + })((LogVerbosity = exports.LogVerbosity || (exports.LogVerbosity = {}))) + /** + * NOTE: This enum is not currently used in any implemented API in this + * library. It is included only for type parity with the other implementation. + */ + var Propagate + ;(function (Propagate) { + Propagate[(Propagate['DEADLINE'] = 1)] = 'DEADLINE' + Propagate[(Propagate['CENSUS_STATS_CONTEXT'] = 2)] = + 'CENSUS_STATS_CONTEXT' + Propagate[(Propagate['CENSUS_TRACING_CONTEXT'] = 4)] = + 'CENSUS_TRACING_CONTEXT' + Propagate[(Propagate['CANCELLATION'] = 8)] = 'CANCELLATION' + Propagate[(Propagate['DEFAULTS'] = 65536)] = 'DEFAULTS' + })((Propagate = exports.Propagate || (exports.Propagate = {}))) + // -1 means unlimited + exports.DEFAULT_MAX_SEND_MESSAGE_LENGTH = -1 + // 4 MB default + exports.DEFAULT_MAX_RECEIVE_MESSAGE_LENGTH = 4 * 1024 * 1024 + //# sourceMappingURL=constants.js.map + + /***/ + }, + + /***/ 81217: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /* + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.DeadlineFilterFactory = exports.DeadlineFilter = void 0 + const constants_1 = __webpack_require__(90634) + const filter_1 = __webpack_require__(43392) + const units = [ + ['m', 1], + ['S', 1000], + ['M', 60 * 1000], + ['H', 60 * 60 * 1000] + ] + function getDeadline(deadline) { + const now = new Date().getTime() + const timeoutMs = Math.max(deadline - now, 0) + for (const [unit, factor] of units) { + const amount = timeoutMs / factor + if (amount < 1e8) { + return String(Math.ceil(amount)) + unit + } + } + throw new Error('Deadline is too far in the future') + } + class DeadlineFilter extends filter_1.BaseFilter { + constructor(channel, callStream) { + var _a, _b + super() + this.channel = channel + this.callStream = callStream + this.timer = null + const callDeadline = callStream.getDeadline() + if (callDeadline instanceof Date) { + this.deadline = callDeadline.getTime() + } else { + this.deadline = callDeadline + } + const now = new Date().getTime() + let timeout = this.deadline - now + if (timeout < 0) { + timeout = 0 + } + if (this.deadline !== Infinity) { + this.timer = setTimeout(() => { + callStream.cancelWithStatus( + constants_1.Status.DEADLINE_EXCEEDED, + 'Deadline exceeded' + ) + }, timeout) + ;(_b = (_a = this.timer).unref) === null || _b === void 0 + ? void 0 + : _b.call(_a) + } + } + async sendMetadata(metadata) { + if (this.deadline === Infinity) { + return metadata + } + /* The input metadata promise depends on the original channel.connect() + * promise, so when it is complete that implies that the channel is + * connected */ + const finalMetadata = await metadata + const timeoutString = getDeadline(this.deadline) + finalMetadata.set('grpc-timeout', timeoutString) + return finalMetadata + } + receiveTrailers(status) { + if (this.timer) { + clearTimeout(this.timer) + } + return status + } + } + exports.DeadlineFilter = DeadlineFilter + class DeadlineFilterFactory { + constructor(channel) { + this.channel = channel + } + createFilter(callStream) { + return new DeadlineFilter(this.channel, callStream) + } + } + exports.DeadlineFilterFactory = DeadlineFilterFactory + //# sourceMappingURL=deadline-filter.js.map + + /***/ + }, + + /***/ 66450: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + /* + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.FilterStackFactory = exports.FilterStack = void 0 + class FilterStack { + constructor(filters) { + this.filters = filters + } + sendMetadata(metadata) { + let result = metadata + for (let i = 0; i < this.filters.length; i++) { + result = this.filters[i].sendMetadata(result) + } + return result + } + receiveMetadata(metadata) { + let result = metadata + for (let i = this.filters.length - 1; i >= 0; i--) { + result = this.filters[i].receiveMetadata(result) + } + return result + } + sendMessage(message) { + let result = message + for (let i = 0; i < this.filters.length; i++) { + result = this.filters[i].sendMessage(result) + } + return result + } + receiveMessage(message) { + let result = message + for (let i = this.filters.length - 1; i >= 0; i--) { + result = this.filters[i].receiveMessage(result) + } + return result + } + receiveTrailers(status) { + let result = status + for (let i = this.filters.length - 1; i >= 0; i--) { + result = this.filters[i].receiveTrailers(result) + } + return result + } + } + exports.FilterStack = FilterStack + class FilterStackFactory { + constructor(factories) { + this.factories = factories + } + createFilter(callStream) { + return new FilterStack( + this.factories.map(factory => factory.createFilter(callStream)) + ) + } + } + exports.FilterStackFactory = FilterStackFactory + //# sourceMappingURL=filter-stack.js.map + + /***/ + }, + + /***/ 43392: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + /* + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.BaseFilter = void 0 + class BaseFilter { + async sendMetadata(metadata) { + return metadata + } + receiveMetadata(metadata) { + return metadata + } + async sendMessage(message) { + return message + } + async receiveMessage(message) { + return message + } + receiveTrailers(status) { + return status + } + } + exports.BaseFilter = BaseFilter + //# sourceMappingURL=filter.js.map + + /***/ + }, + + /***/ 24000: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /* + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.getProxiedConnection = exports.mapProxyName = void 0 + const logging_1 = __webpack_require__(35993) + const constants_1 = __webpack_require__(90634) + const resolver_1 = __webpack_require__(31594) + const http = __webpack_require__(98605) + const tls = __webpack_require__(4016) + const logging = __webpack_require__(35993) + const subchannel_1 = __webpack_require__(84764) + const uri_parser_1 = __webpack_require__(65974) + const url_1 = __webpack_require__(78835) + const TRACER_NAME = 'proxy' + function trace(text) { + logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, text) + } + function getProxyInfo() { + let proxyEnv = '' + let envVar = '' + /* Prefer using 'grpc_proxy'. Fallback on 'http_proxy' if it is not set. + * Also prefer using 'https_proxy' with fallback on 'http_proxy'. The + * fallback behavior can be removed if there's a demand for it. + */ + if (process.env.grpc_proxy) { + envVar = 'grpc_proxy' + proxyEnv = process.env.grpc_proxy + } else if (process.env.https_proxy) { + envVar = 'https_proxy' + proxyEnv = process.env.https_proxy + } else if (process.env.http_proxy) { + envVar = 'http_proxy' + proxyEnv = process.env.http_proxy + } else { + return {} + } + let proxyUrl + try { + proxyUrl = new url_1.URL(proxyEnv) + } catch (e) { + logging_1.log( + constants_1.LogVerbosity.ERROR, + `cannot parse value of "${envVar}" env var` + ) + return {} + } + if (proxyUrl.protocol !== 'http:') { + logging_1.log( + constants_1.LogVerbosity.ERROR, + `"${proxyUrl.protocol}" scheme not supported in proxy URI` + ) + return {} + } + let userCred = null + if (proxyUrl.username) { + if (proxyUrl.password) { + logging_1.log( + constants_1.LogVerbosity.INFO, + 'userinfo found in proxy URI' + ) + userCred = `${proxyUrl.username}:${proxyUrl.password}` + } else { + userCred = proxyUrl.username + } + } + const hostname = proxyUrl.hostname + let port = proxyUrl.port + /* The proxy URL uses the scheme "http:", which has a default port number of + * 80. We need to set that explicitly here if it is omitted because otherwise + * it will use gRPC's default port 443. */ + if (port === '') { + port = '80' + } + const result = { + address: `${hostname}:${port}` + } + if (userCred) { + result.creds = userCred + } + trace( + 'Proxy server ' + + result.address + + ' set by environment variable ' + + envVar + ) + return result + } + function getNoProxyHostList() { + /* Prefer using 'no_grpc_proxy'. Fallback on 'no_proxy' if it is not set. */ + let noProxyStr = process.env.no_grpc_proxy + let envVar = 'no_grpc_proxy' + if (!noProxyStr) { + noProxyStr = process.env.no_proxy + envVar = 'no_proxy' + } + if (noProxyStr) { + trace('No proxy server list set by environment variable ' + envVar) + return noProxyStr.split(',') + } else { + return [] + } + } + function mapProxyName(target, options) { + var _a + const noProxyResult = { + target: target, + extraOptions: {} + } + if ( + ((_a = options['grpc.enable_http_proxy']) !== null && _a !== void 0 + ? _a + : 1) === 0 + ) { + return noProxyResult + } + const proxyInfo = getProxyInfo() + if (!proxyInfo.address) { + return noProxyResult + } + const hostPort = uri_parser_1.splitHostPort(target.path) + if (!hostPort) { + return noProxyResult + } + const serverHost = hostPort.host + for (const host of getNoProxyHostList()) { + if (host === serverHost) { + trace( + 'Not using proxy for target in no_proxy list: ' + + uri_parser_1.uriToString(target) + ) + return noProxyResult + } + } + const extraOptions = { + 'grpc.http_connect_target': uri_parser_1.uriToString(target) + } + if (proxyInfo.creds) { + extraOptions['grpc.http_connect_creds'] = proxyInfo.creds + } + return { + target: { + scheme: 'dns', + path: proxyInfo.address + }, + extraOptions: extraOptions + } + } + exports.mapProxyName = mapProxyName + function getProxiedConnection( + address, + channelOptions, + connectionOptions + ) { + if (!('grpc.http_connect_target' in channelOptions)) { + return Promise.resolve({}) + } + const realTarget = channelOptions['grpc.http_connect_target'] + const parsedTarget = uri_parser_1.parseUri(realTarget) + if (parsedTarget === null) { + return Promise.resolve({}) + } + const options = { + method: 'CONNECT', + path: parsedTarget.path + } + // Connect to the subchannel address as a proxy + if (subchannel_1.isTcpSubchannelAddress(address)) { + options.host = address.host + options.port = address.port + } else { + options.socketPath = address.path + } + if ('grpc.http_connect_creds' in channelOptions) { + options.headers = { + 'Proxy-Authorization': + 'Basic ' + + Buffer.from(channelOptions['grpc.http_connect_creds']).toString( + 'base64' + ) + } + } + const proxyAddressString = subchannel_1.subchannelAddressToString( + address + ) + trace( + 'Using proxy ' + proxyAddressString + ' to connect to ' + options.path + ) + return new Promise((resolve, reject) => { + const request = http.request(options) + request.once('connect', (res, socket, head) => { + var _a + request.removeAllListeners() + socket.removeAllListeners() + if (res.statusCode === 200) { + trace( + 'Successfully connected to ' + + options.path + + ' through proxy ' + + proxyAddressString + ) + if ('secureContext' in connectionOptions) { + /* The proxy is connecting to a TLS server, so upgrade this socket + * connection to a TLS connection. + * This is a workaround for https://github.com/nodejs/node/issues/32922 + * See https://github.com/grpc/grpc-node/pull/1369 for more info. */ + const targetPath = resolver_1.getDefaultAuthority(parsedTarget) + const hostPort = uri_parser_1.splitHostPort(targetPath) + const remoteHost = + (_a = + hostPort === null || hostPort === void 0 + ? void 0 + : hostPort.host) !== null && _a !== void 0 + ? _a + : targetPath + const cts = tls.connect( + Object.assign( + { + host: remoteHost, + servername: remoteHost, + socket: socket + }, + connectionOptions + ), + () => { + trace( + 'Successfully established a TLS connection to ' + + options.path + + ' through proxy ' + + proxyAddressString + ) + resolve({ socket: cts, realTarget: parsedTarget }) + } + ) + cts.on('error', () => { + reject() + }) + } else { + resolve({ + socket, + realTarget: parsedTarget + }) + } + } else { + logging_1.log( + constants_1.LogVerbosity.ERROR, + 'Failed to connect to ' + + options.path + + ' through proxy ' + + proxyAddressString + + ' with status ' + + res.statusCode + ) + reject() + } + }) + request.once('error', err => { + request.removeAllListeners() + logging_1.log( + constants_1.LogVerbosity.ERROR, + 'Failed to connect to proxy ' + + proxyAddressString + + ' with error ' + + err.message + ) + reject() + }) + request.end() + }) + } + exports.getProxiedConnection = getProxiedConnection + //# sourceMappingURL=http_proxy.js.map + + /***/ + }, + + /***/ 7025: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /* + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.StatusBuilder = exports.getClientChannel = exports.ServerCredentials = exports.Server = exports.setLogVerbosity = exports.setLogger = exports.load = exports.loadObject = exports.CallCredentials = exports.ChannelCredentials = exports.waitForClientReady = exports.closeClient = exports.Channel = exports.makeGenericClientConstructor = exports.makeClientConstructor = exports.loadPackageDefinition = exports.Client = exports.propagate = exports.connectivityState = exports.status = exports.logVerbosity = exports.Metadata = exports.credentials = void 0 + const semver = __webpack_require__(16627) + const call_credentials_1 = __webpack_require__(21426) + Object.defineProperty(exports, 'CallCredentials', { + enumerable: true, + get: function () { + return call_credentials_1.CallCredentials + } + }) + const channel_1 = __webpack_require__(13860) + Object.defineProperty(exports, 'connectivityState', { + enumerable: true, + get: function () { + return channel_1.ConnectivityState + } + }) + Object.defineProperty(exports, 'Channel', { + enumerable: true, + get: function () { + return channel_1.ChannelImplementation + } + }) + const channel_credentials_1 = __webpack_require__(44030) + Object.defineProperty(exports, 'ChannelCredentials', { + enumerable: true, + get: function () { + return channel_credentials_1.ChannelCredentials + } + }) + const client_1 = __webpack_require__(87172) + Object.defineProperty(exports, 'Client', { + enumerable: true, + get: function () { + return client_1.Client + } + }) + const constants_1 = __webpack_require__(90634) + Object.defineProperty(exports, 'logVerbosity', { + enumerable: true, + get: function () { + return constants_1.LogVerbosity + } + }) + Object.defineProperty(exports, 'status', { + enumerable: true, + get: function () { + return constants_1.Status + } + }) + Object.defineProperty(exports, 'propagate', { + enumerable: true, + get: function () { + return constants_1.Propagate + } + }) + const logging = __webpack_require__(35993) + const make_client_1 = __webpack_require__(38541) + Object.defineProperty(exports, 'loadPackageDefinition', { + enumerable: true, + get: function () { + return make_client_1.loadPackageDefinition + } + }) + Object.defineProperty(exports, 'makeClientConstructor', { + enumerable: true, + get: function () { + return make_client_1.makeClientConstructor + } + }) + Object.defineProperty(exports, 'makeGenericClientConstructor', { + enumerable: true, + get: function () { + return make_client_1.makeClientConstructor + } + }) + const metadata_1 = __webpack_require__(83665) + Object.defineProperty(exports, 'Metadata', { + enumerable: true, + get: function () { + return metadata_1.Metadata + } + }) + const server_1 = __webpack_require__(33389) + Object.defineProperty(exports, 'Server', { + enumerable: true, + get: function () { + return server_1.Server + } + }) + const server_credentials_1 = __webpack_require__(63828) + Object.defineProperty(exports, 'ServerCredentials', { + enumerable: true, + get: function () { + return server_credentials_1.ServerCredentials + } + }) + const status_builder_1 = __webpack_require__(73155) + Object.defineProperty(exports, 'StatusBuilder', { + enumerable: true, + get: function () { + return status_builder_1.StatusBuilder + } + }) + const supportedNodeVersions = __webpack_require__( + 68160 + ) /* .engines.node */.h$.d + if (!semver.satisfies(process.version, supportedNodeVersions)) { + throw new Error( + `@grpc/grpc-js only works on Node ${supportedNodeVersions}` + ) + } + /**** Client Credentials ****/ + // Using assign only copies enumerable properties, which is what we want + exports.credentials = { + /** + * Combine a ChannelCredentials with any number of CallCredentials into a + * single ChannelCredentials object. + * @param channelCredentials The ChannelCredentials object. + * @param callCredentials Any number of CallCredentials objects. + * @return The resulting ChannelCredentials object. + */ + combineChannelCredentials: (channelCredentials, ...callCredentials) => { + return callCredentials.reduce( + (acc, other) => acc.compose(other), + channelCredentials + ) + }, + /** + * Combine any number of CallCredentials into a single CallCredentials + * object. + * @param first The first CallCredentials object. + * @param additional Any number of additional CallCredentials objects. + * @return The resulting CallCredentials object. + */ + combineCallCredentials: (first, ...additional) => { + return additional.reduce((acc, other) => acc.compose(other), first) + }, + // from channel-credentials.ts + createInsecure: channel_credentials_1.ChannelCredentials.createInsecure, + createSsl: channel_credentials_1.ChannelCredentials.createSsl, + // from call-credentials.ts + createFromMetadataGenerator: + call_credentials_1.CallCredentials.createFromMetadataGenerator, + createFromGoogleCredential: + call_credentials_1.CallCredentials.createFromGoogleCredential, + createEmpty: call_credentials_1.CallCredentials.createEmpty + } + /** + * Close a Client object. + * @param client The client to close. + */ + exports.closeClient = client => client.close() + exports.waitForClientReady = (client, deadline, callback) => + client.waitForReady(deadline, callback) + /* eslint-enable @typescript-eslint/no-explicit-any */ + /**** Unimplemented function stubs ****/ + /* eslint-disable @typescript-eslint/no-explicit-any */ + exports.loadObject = (value, options) => { + throw new Error( + 'Not available in this library. Use @grpc/proto-loader and loadPackageDefinition instead' + ) + } + exports.load = (filename, format, options) => { + throw new Error( + 'Not available in this library. Use @grpc/proto-loader and loadPackageDefinition instead' + ) + } + exports.setLogger = logger => { + logging.setLogger(logger) + } + exports.setLogVerbosity = verbosity => { + logging.setLoggerVerbosity(verbosity) + } + exports.getClientChannel = client => { + return client_1.Client.prototype.getChannel.call(client) + } + var client_interceptors_1 = __webpack_require__(82127) + Object.defineProperty(exports, 'ListenerBuilder', { + enumerable: true, + get: function () { + return client_interceptors_1.ListenerBuilder + } + }) + Object.defineProperty(exports, 'RequesterBuilder', { + enumerable: true, + get: function () { + return client_interceptors_1.RequesterBuilder + } + }) + Object.defineProperty(exports, 'InterceptingCall', { + enumerable: true, + get: function () { + return client_interceptors_1.InterceptingCall + } + }) + Object.defineProperty(exports, 'InterceptorConfigurationError', { + enumerable: true, + get: function () { + return client_interceptors_1.InterceptorConfigurationError + } + }) + const resolver = __webpack_require__(31594) + const load_balancer = __webpack_require__(52680) + ;(() => { + resolver.registerAll() + load_balancer.registerAll() + })() + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 88012: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /* + * Copyright 2020 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.setup = exports.CdsLoadBalancer = void 0 + const load_balancer_1 = __webpack_require__(52680) + const load_balancing_config_1 = __webpack_require__(43802) + const xds_client_1 = __webpack_require__(67477) + const load_balancer_child_handler_1 = __webpack_require__(17559) + const channel_1 = __webpack_require__(13860) + const picker_1 = __webpack_require__(81611) + const constants_1 = __webpack_require__(90634) + const metadata_1 = __webpack_require__(83665) + const TYPE_NAME = 'cds' + class CdsLoadBalancer { + constructor(channelControlHelper) { + this.channelControlHelper = channelControlHelper + this.xdsClient = null + this.isWatcherActive = false + this.latestCdsUpdate = null + this.latestConfig = null + this.latestAttributes = {} + this.childBalancer = new load_balancer_child_handler_1.ChildLoadBalancerHandler( + channelControlHelper + ) + this.watcher = { + onValidUpdate: update => { + var _a + this.latestCdsUpdate = update + const edsConfig = { + cluster: update.name, + edsServiceName: + update.eds_cluster_config.service_name === '' + ? undefined + : update.eds_cluster_config.service_name, + localityPickingPolicy: [], + endpointPickingPolicy: [] + } + if ( + (_a = update.lrs_server) === null || _a === void 0 + ? void 0 + : _a.self + ) { + /* the lrs_server.self field indicates that the same server should be + * used for load reporting as for other xDS operations. Setting + * lrsLoadReportingServerName to the empty string sets that behavior. + * Otherwise, if the field is omitted, load reporting is disabled. */ + edsConfig.lrsLoadReportingServerName = '' + } + this.childBalancer.updateAddressList( + [], + { name: 'eds', eds: edsConfig }, + this.latestAttributes + ) + }, + onResourceDoesNotExist: () => { + var _a + ;(_a = this.xdsClient) === null || _a === void 0 + ? void 0 + : _a.removeClusterWatcher( + this.latestConfig.cds.cluster, + this.watcher + ) + this.isWatcherActive = false + }, + onTransientError: status => { + if (this.latestCdsUpdate === null) { + channelControlHelper.updateState( + channel_1.ConnectivityState.TRANSIENT_FAILURE, + new picker_1.UnavailablePicker({ + code: constants_1.Status.UNAVAILABLE, + details: `xDS request failed with error ${status.details}`, + metadata: new metadata_1.Metadata() + }) + ) + } + } + } + } + updateAddressList(addressList, lbConfig, attributes) { + var _a + if (!load_balancing_config_1.isCdsLoadBalancingConfig(lbConfig)) { + return + } + if (!(attributes.xdsClient instanceof xds_client_1.XdsClient)) { + return + } + this.xdsClient = attributes.xdsClient + this.latestAttributes = attributes + /* If the cluster is changing, disable the old watcher before adding the new + * one */ + if ( + this.isWatcherActive && + ((_a = this.latestConfig) === null || _a === void 0 + ? void 0 + : _a.cds.cluster) !== lbConfig.cds.cluster + ) { + this.xdsClient.removeClusterWatcher( + this.latestConfig.cds.cluster, + this.watcher + ) + /* Setting isWatcherActive to false here lets us have one code path for + * calling addClusterWatcher */ + this.isWatcherActive = false + /* If we have a new name, the latestCdsUpdate does not correspond to + * the new config, so it is no longer valid */ + this.latestCdsUpdate = null + } + this.latestConfig = lbConfig + if (!this.isWatcherActive) { + this.xdsClient.addClusterWatcher(lbConfig.cds.cluster, this.watcher) + this.isWatcherActive = true + } + } + exitIdle() { + this.childBalancer.exitIdle() + } + resetBackoff() { + this.childBalancer.resetBackoff() + } + destroy() { + var _a + this.childBalancer.destroy() + if (this.isWatcherActive) { + ;(_a = this.xdsClient) === null || _a === void 0 + ? void 0 + : _a.removeClusterWatcher( + this.latestConfig.cds.cluster, + this.watcher + ) + } + } + getTypeName() { + return TYPE_NAME + } + } + exports.CdsLoadBalancer = CdsLoadBalancer + function setup() { + load_balancer_1.registerLoadBalancerType(TYPE_NAME, CdsLoadBalancer) + } + exports.setup = setup + //# sourceMappingURL=load-balancer-cds.js.map + + /***/ + }, + + /***/ 17559: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /* + * Copyright 2020 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.ChildLoadBalancerHandler = void 0 + const load_balancer_1 = __webpack_require__(52680) + const channel_1 = __webpack_require__(13860) + const TYPE_NAME = 'child_load_balancer_helper' + class ChildLoadBalancerHandler { + constructor(channelControlHelper) { + this.channelControlHelper = channelControlHelper + this.currentChild = null + this.pendingChild = null + this.ChildPolicyHelper = class { + constructor(parent) { + this.parent = parent + this.child = null + } + createSubchannel(subchannelAddress, subchannelArgs) { + return this.parent.channelControlHelper.createSubchannel( + subchannelAddress, + subchannelArgs + ) + } + updateState(connectivityState, picker) { + var _a + if (this.calledByPendingChild()) { + if (connectivityState !== channel_1.ConnectivityState.READY) { + return + } + ;(_a = this.parent.currentChild) === null || _a === void 0 + ? void 0 + : _a.destroy() + this.parent.currentChild = this.parent.pendingChild + this.parent.pendingChild = null + } else if (!this.calledByCurrentChild()) { + return + } + this.parent.channelControlHelper.updateState( + connectivityState, + picker + ) + } + requestReresolution() { + var _a + const latestChild = + (_a = this.parent.pendingChild) !== null && _a !== void 0 + ? _a + : this.parent.currentChild + if (this.child === latestChild) { + this.parent.channelControlHelper.requestReresolution() + } + } + setChild(newChild) { + this.child = newChild + } + calledByPendingChild() { + return this.child === this.parent.pendingChild + } + calledByCurrentChild() { + return this.child === this.parent.currentChild + } + } + } + /** + * Prerequisites: lbConfig !== null and lbConfig.name is registered + * @param addressList + * @param lbConfig + * @param attributes + */ + updateAddressList(addressList, lbConfig, attributes) { + let childToUpdate + if ( + this.currentChild === null || + this.currentChild.getTypeName() !== lbConfig.name + ) { + const newHelper = new this.ChildPolicyHelper(this) + const newChild = load_balancer_1.createLoadBalancer( + lbConfig.name, + newHelper + ) + newHelper.setChild(newChild) + if (this.currentChild === null) { + this.currentChild = newChild + childToUpdate = this.currentChild + } else { + if (this.pendingChild) { + this.pendingChild.destroy() + } + this.pendingChild = newChild + childToUpdate = this.pendingChild + } + } else { + if (this.pendingChild === null) { + childToUpdate = this.currentChild + } else { + childToUpdate = this.pendingChild + } + } + childToUpdate.updateAddressList(addressList, lbConfig, attributes) + } + exitIdle() { + if (this.currentChild) { + this.currentChild.resetBackoff() + if (this.pendingChild) { + this.pendingChild.resetBackoff() + } + } + } + resetBackoff() { + if (this.currentChild) { + this.currentChild.resetBackoff() + if (this.pendingChild) { + this.pendingChild.resetBackoff() + } + } + } + destroy() { + if (this.currentChild) { + this.currentChild.destroy() + } + if (this.pendingChild) { + this.pendingChild.destroy() + } + } + getTypeName() { + return TYPE_NAME + } + } + exports.ChildLoadBalancerHandler = ChildLoadBalancerHandler + //# sourceMappingURL=load-balancer-child-handler.js.map + + /***/ + }, + + /***/ 19299: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /* + * Copyright 2020 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.setup = exports.EdsLoadBalancer = void 0 + const load_balancer_1 = __webpack_require__(52680) + const load_balancing_config_1 = __webpack_require__(43802) + const load_balancer_child_handler_1 = __webpack_require__(17559) + const xds_client_1 = __webpack_require__(67477) + const channel_1 = __webpack_require__(13860) + const picker_1 = __webpack_require__(81611) + const constants_1 = __webpack_require__(90634) + const metadata_1 = __webpack_require__(83665) + const TYPE_NAME = 'eds' + function localityToName(locality) { + return `{region=${locality.region},zone=${locality.zone},sub_zone=${locality.sub_zone}}` + } + /** + * This class load balances over a cluster by making an EDS request and then + * transforming the result into a configuration for another load balancing + * policy. + */ + class EdsLoadBalancer { + constructor(channelControlHelper) { + this.channelControlHelper = channelControlHelper + this.xdsClient = null + this.edsServiceName = null + /** + * Indicates whether the watcher has already been passed to this.xdsClient + * and is getting updates. + */ + this.isWatcherActive = false + this.lastestConfig = null + this.latestAttributes = {} + this.latestEdsUpdate = null + /** + * The priority of each locality the last time we got an update. + */ + this.localityPriorities = new Map() + /** + * The name we assigned to each priority number the last time we got an + * update. + */ + this.priorityNames = [] + this.nextPriorityChildNumber = 0 + this.clusterDropStats = null + this.childBalancer = new load_balancer_child_handler_1.ChildLoadBalancerHandler( + { + createSubchannel: (subchannelAddress, subchannelArgs) => + this.channelControlHelper.createSubchannel( + subchannelAddress, + subchannelArgs + ), + requestReresolution: () => + this.channelControlHelper.requestReresolution(), + updateState: (connectivityState, originalPicker) => { + if (this.latestEdsUpdate === null) { + return + } + const edsPicker = { + pick: pickArgs => { + var _a + const dropCategory = this.checkForDrop() + /* If we drop the call, it ends with an UNAVAILABLE status. + * Otherwise, delegate picking the subchannel to the child + * balancer. */ + if (dropCategory === null) { + return originalPicker.pick(pickArgs) + } else { + ;(_a = this.clusterDropStats) === null || _a === void 0 + ? void 0 + : _a.addCallDropped(dropCategory) + return { + pickResultType: picker_1.PickResultType.DROP, + status: { + code: constants_1.Status.UNAVAILABLE, + details: `Call dropped by load balancing policy. Category: ${dropCategory}`, + metadata: new metadata_1.Metadata() + }, + subchannel: null, + extraFilterFactory: null, + onCallStarted: null + } + } + } + } + this.channelControlHelper.updateState( + connectivityState, + edsPicker + ) + } + } + ) + this.watcher = { + onValidUpdate: update => { + this.latestEdsUpdate = update + this.updateChild() + }, + onResourceDoesNotExist: () => { + var _a + ;(_a = this.xdsClient) === null || _a === void 0 + ? void 0 + : _a.removeEndpointWatcher(this.edsServiceName, this.watcher) + this.isWatcherActive = false + }, + onTransientError: status => { + if (this.latestEdsUpdate === null) { + channelControlHelper.updateState( + channel_1.ConnectivityState.TRANSIENT_FAILURE, + new picker_1.UnavailablePicker({ + code: constants_1.Status.UNAVAILABLE, + details: `xDS request failed with error ${status.details}`, + metadata: new metadata_1.Metadata() + }) + ) + } + } + } + } + /** + * Check whether a single call should be dropped according to the current + * policy, based on randomly chosen numbers. Returns the drop category if + * the call should be dropped, and null otherwise. + */ + checkForDrop() { + var _a + if ( + !((_a = this.latestEdsUpdate) === null || _a === void 0 + ? void 0 + : _a.policy) + ) { + return null + } + /* The drop_overloads policy is a list of pairs of category names and + * probabilities. For each one, if the random number is within that + * probability range, we drop the call citing that category. Otherwise, the + * call proceeds as usual. */ + for (const dropOverload of this.latestEdsUpdate.policy + .drop_overloads) { + if (!dropOverload.drop_percentage) { + continue + } + let randNum + switch (dropOverload.drop_percentage.denominator) { + case 'HUNDRED': + randNum = Math.random() * 100 + break + case 'TEN_THOUSAND': + randNum = Math.random() * 10000 + break + case 'MILLION': + randNum = Math.random() * 1000000 + break + default: + continue + } + if (randNum < dropOverload.drop_percentage.numerator) { + return dropOverload.category + } + } + return null + } + /** + * Should be called when this balancer gets a new config and when the + * XdsClient returns a new ClusterLoadAssignment. + */ + updateChild() { + var _a, _b, _c + if (!(this.lastestConfig && this.latestEdsUpdate)) { + return + } + /** + * Maps each priority number to the list of localities with that priority, + * and the list of addresses associated with each locality. + */ + const priorityList = [] + const newLocalityPriorities = new Map() + /* We are given a list of localities, each of which has a priority. This + * loop consolidates localities into buckets by priority, while also + * simplifying the data structure to make the later steps simpler */ + for (const endpoint of this.latestEdsUpdate.endpoints) { + let localityArray = priorityList[endpoint.priority] + if (localityArray === undefined) { + localityArray = [] + priorityList[endpoint.priority] = localityArray + } + const addresses = endpoint.lb_endpoints.map(lbEndpoint => { + /* The validator in the XdsClient class ensures that each endpoint has + * a socket_address with an IP address and a port_value. */ + const socketAddress = lbEndpoint.endpoint.address.socket_address + return { + host: socketAddress.address, + port: socketAddress.port_value + } + }) + localityArray.push({ + locality: endpoint.locality, + addresses: addresses, + weight: + (_b = + (_a = endpoint.load_balancing_weight) === null || + _a === void 0 + ? void 0 + : _a.value) !== null && _b !== void 0 + ? _b + : 0 + }) + newLocalityPriorities.set( + localityToName(endpoint.locality), + endpoint.priority + ) + } + const newPriorityNames = [] + const addressList = [] + const priorityChildren = new Map() + /* The algorithm here is as follows: for each priority we are given, from + * high to low: + * - If the previous mapping had any of the same localities at the same or + * a lower priority, use the matching name from the highest such + * priority, unless the new mapping has already used that name. + * - Otherwise, construct a new name using this.nextPriorityChildNumber. + */ + for (const [priority, localityArray] of priorityList.entries()) { + if (localityArray === undefined) { + continue + } + /** + * Highest (smallest number) priority value that any of the localities in + * this locality array had a in the previous mapping. + */ + let highestOldPriority = Infinity + for (const localityObj of localityArray) { + const oldPriority = this.localityPriorities.get( + localityToName(localityObj.locality) + ) + if ( + oldPriority !== undefined && + oldPriority >= priority && + oldPriority < highestOldPriority + ) { + highestOldPriority = oldPriority + } + } + let newPriorityName + if (highestOldPriority === Infinity) { + /* No existing priority at or below the same number as the priority we + * are looking at had any of the localities in this priority. So, we + * use a new name. */ + newPriorityName = `child${this.nextPriorityChildNumber++}` + } else { + const newName = this.priorityNames[highestOldPriority] + if (newPriorityNames.indexOf(newName) < 0) { + newPriorityName = newName + } else { + newPriorityName = `child${this.nextPriorityChildNumber++}` + } + } + newPriorityNames[priority] = newPriorityName + const childTargets = new Map() + for (const localityObj of localityArray) { + /* Use the endpoint picking policy from the config, default to + * round_robin. */ + const endpointPickingPolicy = [ + ...this.lastestConfig.eds.endpointPickingPolicy, + { name: 'round_robin', round_robin: {} } + ] + let childPolicy + if (this.lastestConfig.eds.lrsLoadReportingServerName) { + childPolicy = [ + { + name: 'lrs', + lrs: { + cluster_name: this.lastestConfig.eds.cluster, + eds_service_name: + (_c = this.lastestConfig.eds.edsServiceName) !== null && + _c !== void 0 + ? _c + : '', + lrs_load_reporting_server_name: this.lastestConfig.eds + .lrsLoadReportingServerName, + locality: localityObj.locality, + child_policy: endpointPickingPolicy + } + } + ] + } else { + childPolicy = endpointPickingPolicy + } + childTargets.set(localityToName(localityObj.locality), { + weight: localityObj.weight, + child_policy: childPolicy + }) + for (const address of localityObj.addresses) { + addressList.push( + Object.assign( + { + localityPath: [ + newPriorityName, + localityToName(localityObj.locality) + ] + }, + address + ) + ) + } + } + priorityChildren.set(newPriorityName, { + config: [ + { + name: 'weighted_target', + weighted_target: { + targets: childTargets + } + } + ] + }) + } + const childConfig = { + name: 'priority', + priority: { + children: priorityChildren, + /* Contract the priority names array if it is sparse. This config only + * cares about the order of priorities, not their specific numbers */ + priorities: newPriorityNames.filter(value => value !== undefined) + } + } + this.childBalancer.updateAddressList( + addressList, + childConfig, + this.latestAttributes + ) + this.localityPriorities = newLocalityPriorities + this.priorityNames = newPriorityNames + } + updateAddressList(addressList, lbConfig, attributes) { + var _a, _b + if (!load_balancing_config_1.isEdsLoadBalancingConfig(lbConfig)) { + return + } + if (!(attributes.xdsClient instanceof xds_client_1.XdsClient)) { + return + } + this.lastestConfig = lbConfig + this.latestAttributes = attributes + this.xdsClient = attributes.xdsClient + const newEdsServiceName = + (_a = lbConfig.eds.edsServiceName) !== null && _a !== void 0 + ? _a + : lbConfig.eds.cluster + /* If the name is changing, disable the old watcher before adding the new + * one */ + if ( + this.isWatcherActive && + this.edsServiceName !== newEdsServiceName + ) { + this.xdsClient.removeEndpointWatcher( + this.edsServiceName, + this.watcher + ) + /* Setting isWatcherActive to false here lets us have one code path for + * calling addEndpointWatcher */ + this.isWatcherActive = false + /* If we have a new name, the latestEdsUpdate does not correspond to + * the new config, so it is no longer valid */ + this.latestEdsUpdate = null + } + this.edsServiceName = newEdsServiceName + if (!this.isWatcherActive) { + this.xdsClient.addEndpointWatcher(this.edsServiceName, this.watcher) + this.isWatcherActive = true + } + if (lbConfig.eds.lrsLoadReportingServerName) { + this.clusterDropStats = this.xdsClient.addClusterDropStats( + lbConfig.eds.lrsLoadReportingServerName, + lbConfig.eds.cluster, + (_b = lbConfig.eds.edsServiceName) !== null && _b !== void 0 + ? _b + : '' + ) + } + /* If updateAddressList is called after receiving an update and the update + * is still valid, we want to update the child config with the information + * in the new EdsLoadBalancingConfig. */ + this.updateChild() + } + exitIdle() { + this.childBalancer.exitIdle() + } + resetBackoff() { + this.childBalancer.resetBackoff() + } + destroy() { + var _a + if (this.edsServiceName) { + ;(_a = this.xdsClient) === null || _a === void 0 + ? void 0 + : _a.removeEndpointWatcher(this.edsServiceName, this.watcher) + } + this.childBalancer.destroy() + } + getTypeName() { + return TYPE_NAME + } + } + exports.EdsLoadBalancer = EdsLoadBalancer + function setup() { + load_balancer_1.registerLoadBalancerType(TYPE_NAME, EdsLoadBalancer) + } + exports.setup = setup + //# sourceMappingURL=load-balancer-eds.js.map + + /***/ + }, + + /***/ 21819: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /* + * Copyright 2020 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.setup = exports.LrsLoadBalancer = void 0 + const load_balancer_1 = __webpack_require__(52680) + const load_balancing_config_1 = __webpack_require__(43802) + const load_balancer_child_handler_1 = __webpack_require__(17559) + const picker_1 = __webpack_require__(81611) + const xds_client_1 = __webpack_require__(67477) + const filter_1 = __webpack_require__(43392) + const constants_1 = __webpack_require__(90634) + const filter_stack_1 = __webpack_require__(66450) + const TYPE_NAME = 'lrs' + /** + * Filter class that reports when the call ends. + */ + class CallEndTrackingFilter extends filter_1.BaseFilter { + constructor(localityStatsReporter) { + super() + this.localityStatsReporter = localityStatsReporter + } + receiveTrailers(status) { + this.localityStatsReporter.addCallFinished( + status.code !== constants_1.Status.OK + ) + return status + } + } + class CallEndTrackingFilterFactory { + constructor(localityStatsReporter) { + this.localityStatsReporter = localityStatsReporter + } + createFilter(callStream) { + return new CallEndTrackingFilter(this.localityStatsReporter) + } + } + /** + * Picker that delegates picking to another picker, and reports when calls + * created using those picks start and end. + */ + class LoadReportingPicker { + constructor(wrappedPicker, localityStatsReporter) { + this.wrappedPicker = wrappedPicker + this.localityStatsReporter = localityStatsReporter + } + pick(pickArgs) { + const wrappedPick = this.wrappedPicker.pick(pickArgs) + if (wrappedPick.pickResultType === picker_1.PickResultType.COMPLETE) { + const trackingFilterFactory = new CallEndTrackingFilterFactory( + this.localityStatsReporter + ) + /* In the unlikely event that the wrappedPick already has an + * extraFilterFactory, preserve it in a FilterStackFactory. */ + const extraFilterFactory = wrappedPick.extraFilterFactory + ? new filter_stack_1.FilterStackFactory([ + wrappedPick.extraFilterFactory, + trackingFilterFactory + ]) + : trackingFilterFactory + return { + pickResultType: picker_1.PickResultType.COMPLETE, + subchannel: wrappedPick.subchannel, + status: null, + onCallStarted: () => { + var _a + ;(_a = wrappedPick.onCallStarted) === null || _a === void 0 + ? void 0 + : _a.call(wrappedPick) + this.localityStatsReporter.addCallStarted() + }, + extraFilterFactory: extraFilterFactory + } + } else { + return wrappedPick + } + } + } + /** + * "Load balancer" that delegates the actual load balancing logic to another + * LoadBalancer class and adds hooks to track when calls started using that + * LoadBalancer start and end, and uses the XdsClient to report that + * information back to the xDS server. + */ + class LrsLoadBalancer { + constructor(channelControlHelper) { + this.channelControlHelper = channelControlHelper + this.localityStatsReporter = null + this.childBalancer = new load_balancer_child_handler_1.ChildLoadBalancerHandler( + { + createSubchannel: (subchannelAddress, subchannelArgs) => + channelControlHelper.createSubchannel( + subchannelAddress, + subchannelArgs + ), + requestReresolution: () => + channelControlHelper.requestReresolution(), + updateState: (connectivityState, picker) => { + if (this.localityStatsReporter !== null) { + picker = new LoadReportingPicker( + picker, + this.localityStatsReporter + ) + } + channelControlHelper.updateState(connectivityState, picker) + } + } + ) + } + updateAddressList(addressList, lbConfig, attributes) { + var _a + if (!load_balancing_config_1.isLrsLoadBalancingConfig(lbConfig)) { + return + } + if (!(attributes.xdsClient instanceof xds_client_1.XdsClient)) { + return + } + const lrsConfig = lbConfig.lrs + this.localityStatsReporter = attributes.xdsClient.addClusterLocalityStats( + lrsConfig.lrs_load_reporting_server_name, + lrsConfig.cluster_name, + lrsConfig.eds_service_name, + lrsConfig.locality + ) + const childPolicy = + (_a = load_balancer_1.getFirstUsableConfig( + lrsConfig.child_policy + )) !== null && _a !== void 0 + ? _a + : { name: 'pick_first', pick_first: {} } + this.childBalancer.updateAddressList( + addressList, + childPolicy, + attributes + ) + } + exitIdle() { + this.childBalancer.exitIdle() + } + resetBackoff() { + this.childBalancer.resetBackoff() + } + destroy() { + this.childBalancer.destroy() + } + getTypeName() { + return TYPE_NAME + } + } + exports.LrsLoadBalancer = LrsLoadBalancer + function setup() { + load_balancer_1.registerLoadBalancerType(TYPE_NAME, LrsLoadBalancer) + } + exports.setup = setup + //# sourceMappingURL=load-balancer-lrs.js.map + + /***/ + }, + + /***/ 38977: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /* + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.setup = exports.PickFirstLoadBalancer = void 0 + const load_balancer_1 = __webpack_require__(52680) + const channel_1 = __webpack_require__(13860) + const picker_1 = __webpack_require__(81611) + const subchannel_1 = __webpack_require__(84764) + const logging = __webpack_require__(35993) + const constants_1 = __webpack_require__(90634) + const TRACER_NAME = 'pick_first' + function trace(text) { + logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, text) + } + const TYPE_NAME = 'pick_first' + /** + * Delay after starting a connection on a subchannel before starting a + * connection on the next subchannel in the list, for Happy Eyeballs algorithm. + */ + const CONNECTION_DELAY_INTERVAL_MS = 250 + /** + * Picker for a `PickFirstLoadBalancer` in the READY state. Always returns the + * picked subchannel. + */ + class PickFirstPicker { + constructor(subchannel) { + this.subchannel = subchannel + } + pick(pickArgs) { + return { + pickResultType: picker_1.PickResultType.COMPLETE, + subchannel: this.subchannel, + status: null, + extraFilterFactory: null, + onCallStarted: null + } + } + } + class PickFirstLoadBalancer { + /** + * Load balancer that attempts to connect to each backend in the address list + * in order, and picks the first one that connects, using it for every + * request. + * @param channelControlHelper `ChannelControlHelper` instance provided by + * this load balancer's owner. + */ + constructor(channelControlHelper) { + this.channelControlHelper = channelControlHelper + /** + * The list of backend addresses most recently passed to `updateAddressList`. + */ + this.latestAddressList = [] + /** + * The list of subchannels this load balancer is currently attempting to + * connect to. + */ + this.subchannels = [] + /** + * The current connectivity state of the load balancer. + */ + this.currentState = channel_1.ConnectivityState.IDLE + /** + * The index within the `subchannels` array of the subchannel with the most + * recently started connection attempt. + */ + this.currentSubchannelIndex = 0 + /** + * The currently picked subchannel used for making calls. Populated if + * and only if the load balancer's current state is READY. In that case, + * the subchannel's current state is also READY. + */ + this.currentPick = null + this.triedAllSubchannels = false + this.subchannelStateCounts = { + [channel_1.ConnectivityState.CONNECTING]: 0, + [channel_1.ConnectivityState.IDLE]: 0, + [channel_1.ConnectivityState.READY]: 0, + [channel_1.ConnectivityState.SHUTDOWN]: 0, + [channel_1.ConnectivityState.TRANSIENT_FAILURE]: 0 + } + this.subchannelStateListener = ( + subchannel, + previousState, + newState + ) => { + this.subchannelStateCounts[previousState] -= 1 + this.subchannelStateCounts[newState] += 1 + /* If the subchannel we most recently attempted to start connecting + * to goes into TRANSIENT_FAILURE, immediately try to start + * connecting to the next one instead of waiting for the connection + * delay timer. */ + if ( + subchannel === this.subchannels[this.currentSubchannelIndex] && + newState === channel_1.ConnectivityState.TRANSIENT_FAILURE + ) { + this.startNextSubchannelConnecting() + } + if (newState === channel_1.ConnectivityState.READY) { + this.pickSubchannel(subchannel) + return + } else { + if ( + this.triedAllSubchannels && + this.subchannelStateCounts[channel_1.ConnectivityState.IDLE] === + this.subchannels.length + ) { + /* If all of the subchannels are IDLE we should go back to a + * basic IDLE state where there is no subchannel list to avoid + * holding unused resources */ + this.resetSubchannelList() + this.updateState( + channel_1.ConnectivityState.IDLE, + new picker_1.QueuePicker(this) + ) + return + } + if (this.currentPick === null) { + if (this.triedAllSubchannels) { + let newLBState + if ( + this.subchannelStateCounts[ + channel_1.ConnectivityState.CONNECTING + ] > 0 + ) { + newLBState = channel_1.ConnectivityState.CONNECTING + } else if ( + this.subchannelStateCounts[ + channel_1.ConnectivityState.TRANSIENT_FAILURE + ] > 0 + ) { + newLBState = channel_1.ConnectivityState.TRANSIENT_FAILURE + } else { + newLBState = channel_1.ConnectivityState.IDLE + } + if (newLBState !== this.currentState) { + if ( + newLBState === + channel_1.ConnectivityState.TRANSIENT_FAILURE + ) { + this.updateState( + newLBState, + new picker_1.UnavailablePicker() + ) + } else { + this.updateState( + newLBState, + new picker_1.QueuePicker(this) + ) + } + } + } else { + this.updateState( + channel_1.ConnectivityState.CONNECTING, + new picker_1.QueuePicker(this) + ) + } + } + } + } + this.pickedSubchannelStateListener = ( + subchannel, + previousState, + newState + ) => { + if (newState !== channel_1.ConnectivityState.READY) { + this.currentPick = null + subchannel.unref() + subchannel.removeConnectivityStateListener( + this.pickedSubchannelStateListener + ) + if (this.subchannels.length > 0) { + if (this.triedAllSubchannels) { + let newLBState + if ( + this.subchannelStateCounts[ + channel_1.ConnectivityState.CONNECTING + ] > 0 + ) { + newLBState = channel_1.ConnectivityState.CONNECTING + } else if ( + this.subchannelStateCounts[ + channel_1.ConnectivityState.TRANSIENT_FAILURE + ] > 0 + ) { + newLBState = channel_1.ConnectivityState.TRANSIENT_FAILURE + } else { + newLBState = channel_1.ConnectivityState.IDLE + } + if ( + newLBState === channel_1.ConnectivityState.TRANSIENT_FAILURE + ) { + this.updateState( + newLBState, + new picker_1.UnavailablePicker() + ) + } else { + this.updateState(newLBState, new picker_1.QueuePicker(this)) + } + } else { + this.updateState( + channel_1.ConnectivityState.CONNECTING, + new picker_1.QueuePicker(this) + ) + } + } else { + /* We don't need to backoff here because this only happens if a + * subchannel successfully connects then disconnects, so it will not + * create a loop of attempting to connect to an unreachable backend + */ + this.updateState( + channel_1.ConnectivityState.IDLE, + new picker_1.QueuePicker(this) + ) + } + } + } + this.connectionDelayTimeout = setTimeout(() => {}, 0) + clearTimeout(this.connectionDelayTimeout) + } + startNextSubchannelConnecting() { + if (this.triedAllSubchannels) { + return + } + for (const [index, subchannel] of this.subchannels.entries()) { + if (index > this.currentSubchannelIndex) { + const subchannelState = subchannel.getConnectivityState() + if ( + subchannelState === channel_1.ConnectivityState.IDLE || + subchannelState === channel_1.ConnectivityState.CONNECTING + ) { + this.startConnecting(index) + return + } + } + } + this.triedAllSubchannels = true + } + /** + * Have a single subchannel in the `subchannels` list start connecting. + * @param subchannelIndex The index into the `subchannels` list. + */ + startConnecting(subchannelIndex) { + clearTimeout(this.connectionDelayTimeout) + this.currentSubchannelIndex = subchannelIndex + if ( + this.subchannels[subchannelIndex].getConnectivityState() === + channel_1.ConnectivityState.IDLE + ) { + trace( + 'Start connecting to subchannel with address ' + + this.subchannels[subchannelIndex].getAddress() + ) + process.nextTick(() => { + this.subchannels[subchannelIndex].startConnecting() + }) + } + this.connectionDelayTimeout = setTimeout(() => { + this.startNextSubchannelConnecting() + }, CONNECTION_DELAY_INTERVAL_MS) + } + pickSubchannel(subchannel) { + trace('Pick subchannel with address ' + subchannel.getAddress()) + if (this.currentPick !== null) { + this.currentPick.unref() + this.currentPick.removeConnectivityStateListener( + this.pickedSubchannelStateListener + ) + } + this.currentPick = subchannel + this.updateState( + channel_1.ConnectivityState.READY, + new PickFirstPicker(subchannel) + ) + subchannel.addConnectivityStateListener( + this.pickedSubchannelStateListener + ) + subchannel.ref() + this.resetSubchannelList() + clearTimeout(this.connectionDelayTimeout) + } + updateState(newState, picker) { + trace( + channel_1.ConnectivityState[this.currentState] + + ' -> ' + + channel_1.ConnectivityState[newState] + ) + this.currentState = newState + this.channelControlHelper.updateState(newState, picker) + } + resetSubchannelList() { + for (const subchannel of this.subchannels) { + subchannel.removeConnectivityStateListener( + this.subchannelStateListener + ) + subchannel.unref() + } + this.currentSubchannelIndex = 0 + this.subchannelStateCounts = { + [channel_1.ConnectivityState.CONNECTING]: 0, + [channel_1.ConnectivityState.IDLE]: 0, + [channel_1.ConnectivityState.READY]: 0, + [channel_1.ConnectivityState.SHUTDOWN]: 0, + [channel_1.ConnectivityState.TRANSIENT_FAILURE]: 0 + } + this.subchannels = [] + this.triedAllSubchannels = false + } + /** + * Start connecting to the address list most recently passed to + * `updateAddressList`. + */ + connectToAddressList() { + this.resetSubchannelList() + trace( + 'Connect to address list ' + + this.latestAddressList.map(address => + subchannel_1.subchannelAddressToString(address) + ) + ) + this.subchannels = this.latestAddressList.map(address => + this.channelControlHelper.createSubchannel(address, {}) + ) + for (const subchannel of this.subchannels) { + subchannel.ref() + } + for (const subchannel of this.subchannels) { + subchannel.addConnectivityStateListener( + this.subchannelStateListener + ) + this.subchannelStateCounts[subchannel.getConnectivityState()] += 1 + if ( + subchannel.getConnectivityState() === + channel_1.ConnectivityState.READY + ) { + this.pickSubchannel(subchannel) + this.resetSubchannelList() + return + } + } + for (const [index, subchannel] of this.subchannels.entries()) { + const subchannelState = subchannel.getConnectivityState() + if ( + subchannelState === channel_1.ConnectivityState.IDLE || + subchannelState === channel_1.ConnectivityState.CONNECTING + ) { + this.startConnecting(index) + if (this.currentPick === null) { + this.updateState( + channel_1.ConnectivityState.CONNECTING, + new picker_1.QueuePicker(this) + ) + } + return + } + } + // If the code reaches this point, every subchannel must be in TRANSIENT_FAILURE + if (this.currentPick === null) { + this.updateState( + channel_1.ConnectivityState.TRANSIENT_FAILURE, + new picker_1.UnavailablePicker() + ) + } + } + updateAddressList(addressList, lbConfig) { + // lbConfig has no useful information for pick first load balancing + /* To avoid unnecessary churn, we only do something with this address list + * if we're not currently trying to establish a connection, or if the new + * address list is different from the existing one */ + if ( + this.subchannels.length === 0 || + !this.latestAddressList.every( + (value, index) => addressList[index] === value + ) + ) { + this.latestAddressList = addressList + this.connectToAddressList() + } + } + exitIdle() { + for (const subchannel of this.subchannels) { + subchannel.startConnecting() + } + if (this.currentState === channel_1.ConnectivityState.IDLE) { + if (this.latestAddressList.length > 0) { + this.connectToAddressList() + } + } + if ( + this.currentState === channel_1.ConnectivityState.IDLE || + this.triedAllSubchannels + ) { + this.channelControlHelper.requestReresolution() + } + } + resetBackoff() { + /* The pick first load balancer does not have a connection backoff, so this + * does nothing */ + } + destroy() { + this.resetSubchannelList() + if (this.currentPick !== null) { + this.currentPick.unref() + this.currentPick.removeConnectivityStateListener( + this.pickedSubchannelStateListener + ) + } + } + getTypeName() { + return TYPE_NAME + } + } + exports.PickFirstLoadBalancer = PickFirstLoadBalancer + function setup() { + load_balancer_1.registerLoadBalancerType( + TYPE_NAME, + PickFirstLoadBalancer + ) + } + exports.setup = setup + //# sourceMappingURL=load-balancer-pick-first.js.map + + /***/ + }, + + /***/ 92865: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /* + * Copyright 2020 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.setup = exports.PriorityLoadBalancer = exports.isLocalitySubchannelAddress = void 0 + const load_balancer_1 = __webpack_require__(52680) + const load_balancing_config_1 = __webpack_require__(43802) + const channel_1 = __webpack_require__(13860) + const picker_1 = __webpack_require__(81611) + const load_balancer_child_handler_1 = __webpack_require__(17559) + const constants_1 = __webpack_require__(90634) + const metadata_1 = __webpack_require__(83665) + const TYPE_NAME = 'priority' + const DEFAULT_FAILOVER_TIME_MS = 10000 + const DEFAULT_RETENTION_INTERVAL_MS = 15 * 60 * 1000 + function isLocalitySubchannelAddress(address) { + return Array.isArray(address.localityPath) + } + exports.isLocalitySubchannelAddress = isLocalitySubchannelAddress + class PriorityLoadBalancer { + constructor(channelControlHelper) { + this.channelControlHelper = channelControlHelper + /** + * Inner class for holding a child priority and managing associated timers. + */ + this.PriorityChildImpl = class { + constructor(parent, name) { + this.parent = parent + this.name = name + this.connectivityState = channel_1.ConnectivityState.IDLE + this.failoverTimer = null + this.deactivationTimer = null + this.childBalancer = new load_balancer_child_handler_1.ChildLoadBalancerHandler( + { + createSubchannel: (subchannelAddress, subchannelArgs) => { + return this.parent.channelControlHelper.createSubchannel( + subchannelAddress, + subchannelArgs + ) + }, + updateState: (connectivityState, picker) => { + this.updateState(connectivityState, picker) + }, + requestReresolution: () => { + this.parent.channelControlHelper.requestReresolution() + } + } + ) + this.picker = new picker_1.QueuePicker(this.childBalancer) + } + updateState(connectivityState, picker) { + this.connectivityState = connectivityState + this.picker = picker + this.parent.onChildStateChange(this) + } + startFailoverTimer() { + if (this.failoverTimer === null) { + this.failoverTimer = setTimeout(() => { + this.failoverTimer = null + this.updateState( + channel_1.ConnectivityState.TRANSIENT_FAILURE, + new picker_1.UnavailablePicker() + ) + }, DEFAULT_FAILOVER_TIME_MS) + } + } + updateAddressList(addressList, lbConfig, attributes) { + this.childBalancer.updateAddressList( + addressList, + lbConfig, + attributes + ) + this.startFailoverTimer() + } + exitIdle() { + if (this.connectivityState === channel_1.ConnectivityState.IDLE) { + this.startFailoverTimer() + } + this.childBalancer.exitIdle() + } + resetBackoff() { + this.childBalancer.resetBackoff() + } + deactivate() { + if (this.deactivationTimer === null) { + this.deactivationTimer = setTimeout(() => { + this.parent.deleteChild(this) + this.childBalancer.destroy() + }, DEFAULT_RETENTION_INTERVAL_MS) + } + } + maybeReactivate() { + if (this.deactivationTimer !== null) { + clearTimeout(this.deactivationTimer) + this.deactivationTimer = null + } + } + cancelFailoverTimer() { + if (this.failoverTimer !== null) { + clearTimeout(this.failoverTimer) + this.failoverTimer = null + } + } + isFailoverTimerPending() { + return this.failoverTimer !== null + } + getConnectivityState() { + return this.connectivityState + } + getPicker() { + return this.picker + } + getName() { + return this.name + } + destroy() { + this.childBalancer.destroy() + } + } + // End of inner class PriorityChildImpl + this.children = new Map() + /** + * The priority order of child names from the latest config update. + */ + this.priorities = [] + /** + * The attributes object from the latest update, saved to be passed along to + * each new child as they are created + */ + this.latestAttributes = {} + /** + * The latest load balancing policies and address lists for each child from + * the latest update + */ + this.latestUpdates = new Map() + /** + * Current chosen priority that requests are sent to + */ + this.currentPriority = null + /** + * After an update, this preserves the currently selected child from before + * the update. We continue to use that child until it disconnects, or + * another higher-priority child connects, or it is deleted because it is not + * in the new priority list at all and its retention interval has expired, or + * we try and fail to connect to every child in the new priority list. + */ + this.currentChildFromBeforeUpdate = null + } + updateState(state, picker) { + /* If switching to IDLE, use a QueuePicker attached to this load balancer + * so that when the picker calls exitIdle, that in turn calls exitIdle on + * the PriorityChildImpl, which will start the failover timer. */ + if (state === channel_1.ConnectivityState.IDLE) { + picker = new picker_1.QueuePicker(this) + } + this.channelControlHelper.updateState(state, picker) + } + onChildStateChange(child) { + const childState = child.getConnectivityState() + if (child === this.currentChildFromBeforeUpdate) { + if ( + childState === channel_1.ConnectivityState.READY || + childState === channel_1.ConnectivityState.IDLE + ) { + this.updateState(childState, child.getPicker()) + } else { + this.currentChildFromBeforeUpdate = null + this.tryNextPriority(true) + } + return + } + const childPriority = this.priorities.indexOf(child.getName()) + if (childPriority < 0) { + // child is not in the priority list, ignore updates + return + } + if ( + this.currentPriority !== null && + childPriority > this.currentPriority + ) { + // child is lower priority than the currently selected child, ignore updates + return + } + if (childState === channel_1.ConnectivityState.TRANSIENT_FAILURE) { + /* Report connecting if and only if the currently selected child is the + * one entering TRANSIENT_FAILURE */ + this.tryNextPriority(childPriority === this.currentPriority) + return + } + if ( + this.currentPriority === null || + childPriority < this.currentPriority + ) { + /* In this case, either there is no currently selected child or this + * child is higher priority than the currently selected child, so we want + * to switch to it if it is READY or IDLE. */ + if ( + childState === channel_1.ConnectivityState.READY || + childState === channel_1.ConnectivityState.IDLE + ) { + this.selectPriority(childPriority) + } + return + } + /* The currently selected child has updated state to something other than + * TRANSIENT_FAILURE, so we pass that update along */ + this.updateState(childState, child.getPicker()) + } + deleteChild(child) { + if (child === this.currentChildFromBeforeUpdate) { + this.currentChildFromBeforeUpdate = null + /* If we get to this point, the currentChildFromBeforeUpdate was still in + * use, so we are still trying to connect to the specified priorities */ + this.tryNextPriority(true) + } + } + /** + * Select the child at the specified priority, and report that child's state + * as this balancer's state until that child disconnects or a higher-priority + * child connects. + * @param priority + */ + selectPriority(priority) { + var _a + this.currentPriority = priority + const chosenChild = this.children.get(this.priorities[priority]) + this.updateState( + chosenChild.getConnectivityState(), + chosenChild.getPicker() + ) + this.currentChildFromBeforeUpdate = null + // Deactivate each child of lower priority than the chosen child + for (let i = priority + 1; i < this.priorities.length; i++) { + ;(_a = this.children.get(this.priorities[i])) === null || + _a === void 0 + ? void 0 + : _a.deactivate() + } + } + /** + * Check each child in priority order until we find one to use + * @param reportConnecting Whether we should report a CONNECTING state if we + * stop before picking a specific child. This should be true when we have + * not already selected a child. + */ + tryNextPriority(reportConnecting) { + for (const [index, childName] of this.priorities.entries()) { + let child = this.children.get(childName) + /* If the child doesn't already exist, create it and update it. */ + if (child === undefined) { + if (reportConnecting) { + this.updateState( + channel_1.ConnectivityState.CONNECTING, + new picker_1.QueuePicker(this) + ) + } + child = new this.PriorityChildImpl(this, childName) + this.children.set(childName, child) + const childUpdate = this.latestUpdates.get(childName) + if (childUpdate !== undefined) { + child.updateAddressList( + childUpdate.subchannelAddress, + childUpdate.lbConfig, + this.latestAttributes + ) + } + } + /* We're going to try to use this child, so reactivate it if it has been + * deactivated */ + child.maybeReactivate() + if ( + child.getConnectivityState() === + channel_1.ConnectivityState.READY || + child.getConnectivityState() === channel_1.ConnectivityState.IDLE + ) { + this.selectPriority(index) + return + } + if (child.isFailoverTimerPending()) { + /* This child is still trying to connect. Wait until its failover timer + * has ended to continue to the next one */ + if (reportConnecting) { + this.updateState( + channel_1.ConnectivityState.CONNECTING, + new picker_1.QueuePicker(this) + ) + } + return + } + } + this.currentPriority = null + this.currentChildFromBeforeUpdate = null + this.updateState( + channel_1.ConnectivityState.TRANSIENT_FAILURE, + new picker_1.UnavailablePicker({ + code: constants_1.Status.UNAVAILABLE, + details: 'No ready priority', + metadata: new metadata_1.Metadata() + }) + ) + } + updateAddressList(addressList, lbConfig, attributes) { + var _a + if ( + !load_balancing_config_1.isPriorityLoadBalancingConfig(lbConfig) + ) { + // Reject a config of the wrong type + return + } + const priorityConfig = lbConfig.priority + /* For each address, the first element of its localityPath array determines + * which child it belongs to. So we bucket those addresses by that first + * element, and pass along the rest of the localityPath for that child + * to use. */ + const childAddressMap = new Map() + for (const address of addressList) { + if (!isLocalitySubchannelAddress(address)) { + // Reject address that cannot be prioritized + return + } + if (address.localityPath.length < 1) { + // Reject address that cannot be prioritized + return + } + const childName = address.localityPath[0] + const childAddress = Object.assign(Object.assign({}, address), { + localityPath: address.localityPath.slice(1) + }) + let childAddressList = childAddressMap.get(childName) + if (childAddressList === undefined) { + childAddressList = [] + childAddressMap.set(childName, childAddressList) + } + childAddressList.push(childAddress) + } + if (this.currentPriority !== null) { + this.currentChildFromBeforeUpdate = this.children.get( + this.priorities[this.currentPriority] + ) + this.currentPriority = null + } + this.latestAttributes = attributes + this.latestUpdates.clear() + this.priorities = priorityConfig.priorities + /* Pair up the new child configs with the corresponding address lists, and + * update all existing children with their new configs */ + for (const [childName, childConfig] of priorityConfig.children) { + const chosenChildConfig = load_balancer_1.getFirstUsableConfig( + childConfig.config + ) + if (chosenChildConfig !== null) { + const childAddresses = + (_a = childAddressMap.get(childName)) !== null && _a !== void 0 + ? _a + : [] + this.latestUpdates.set(childName, { + subchannelAddress: childAddresses, + lbConfig: chosenChildConfig + }) + const existingChild = this.children.get(childName) + if (existingChild !== undefined) { + existingChild.updateAddressList( + childAddresses, + chosenChildConfig, + attributes + ) + } + } + } + // Deactivate all children that are no longer in the priority list + for (const [childName, child] of this.children) { + if (this.priorities.indexOf(childName) < 0) { + child.deactivate() + } + } + // Only report connecting if there are no existing children + this.tryNextPriority(this.children.size === 0) + } + exitIdle() { + var _a + if (this.currentPriority !== null) { + ;(_a = this.children.get(this.priorities[this.currentPriority])) === + null || _a === void 0 + ? void 0 + : _a.exitIdle() + } + } + resetBackoff() { + for (const child of this.children.values()) { + child.resetBackoff() + } + } + destroy() { + var _a + for (const child of this.children.values()) { + child.destroy() + } + this.children.clear() + ;(_a = this.currentChildFromBeforeUpdate) === null || _a === void 0 + ? void 0 + : _a.destroy() + this.currentChildFromBeforeUpdate = null + } + getTypeName() { + return TYPE_NAME + } + } + exports.PriorityLoadBalancer = PriorityLoadBalancer + function setup() { + load_balancer_1.registerLoadBalancerType( + TYPE_NAME, + PriorityLoadBalancer + ) + } + exports.setup = setup + //# sourceMappingURL=load-balancer-priority.js.map + + /***/ + }, + + /***/ 92787: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /* + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.setup = exports.RoundRobinLoadBalancer = void 0 + const load_balancer_1 = __webpack_require__(52680) + const channel_1 = __webpack_require__(13860) + const picker_1 = __webpack_require__(81611) + const subchannel_1 = __webpack_require__(84764) + const logging = __webpack_require__(35993) + const constants_1 = __webpack_require__(90634) + const TRACER_NAME = 'round_robin' + function trace(text) { + logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, text) + } + const TYPE_NAME = 'round_robin' + class RoundRobinPicker { + constructor(subchannelList, nextIndex = 0) { + this.subchannelList = subchannelList + this.nextIndex = nextIndex + } + pick(pickArgs) { + const pickedSubchannel = this.subchannelList[this.nextIndex] + this.nextIndex = (this.nextIndex + 1) % this.subchannelList.length + return { + pickResultType: picker_1.PickResultType.COMPLETE, + subchannel: pickedSubchannel, + status: null, + extraFilterFactory: null, + onCallStarted: null + } + } + /** + * Check what the next subchannel returned would be. Used by the load + * balancer implementation to preserve this part of the picker state if + * possible when a subchannel connects or disconnects. + */ + peekNextSubchannel() { + return this.subchannelList[this.nextIndex] + } + } + class RoundRobinLoadBalancer { + constructor(channelControlHelper) { + this.channelControlHelper = channelControlHelper + this.subchannels = [] + this.currentState = channel_1.ConnectivityState.IDLE + this.currentReadyPicker = null + this.subchannelStateCounts = { + [channel_1.ConnectivityState.CONNECTING]: 0, + [channel_1.ConnectivityState.IDLE]: 0, + [channel_1.ConnectivityState.READY]: 0, + [channel_1.ConnectivityState.SHUTDOWN]: 0, + [channel_1.ConnectivityState.TRANSIENT_FAILURE]: 0 + } + this.subchannelStateListener = ( + subchannel, + previousState, + newState + ) => { + this.subchannelStateCounts[previousState] -= 1 + this.subchannelStateCounts[newState] += 1 + this.calculateAndUpdateState() + if (newState === channel_1.ConnectivityState.TRANSIENT_FAILURE) { + this.channelControlHelper.requestReresolution() + } + if ( + newState === channel_1.ConnectivityState.TRANSIENT_FAILURE || + newState === channel_1.ConnectivityState.IDLE + ) { + subchannel.startConnecting() + } + } + } + calculateAndUpdateState() { + if ( + this.subchannelStateCounts[channel_1.ConnectivityState.READY] > 0 + ) { + const readySubchannels = this.subchannels.filter( + subchannel => + subchannel.getConnectivityState() === + channel_1.ConnectivityState.READY + ) + let index = 0 + if (this.currentReadyPicker !== null) { + index = readySubchannels.indexOf( + this.currentReadyPicker.peekNextSubchannel() + ) + if (index < 0) { + index = 0 + } + } + this.updateState( + channel_1.ConnectivityState.READY, + new RoundRobinPicker(readySubchannels, index) + ) + } else if ( + this.subchannelStateCounts[channel_1.ConnectivityState.CONNECTING] > + 0 + ) { + this.updateState( + channel_1.ConnectivityState.CONNECTING, + new picker_1.QueuePicker(this) + ) + } else if ( + this.subchannelStateCounts[ + channel_1.ConnectivityState.TRANSIENT_FAILURE + ] > 0 + ) { + this.updateState( + channel_1.ConnectivityState.TRANSIENT_FAILURE, + new picker_1.UnavailablePicker() + ) + } else { + this.updateState( + channel_1.ConnectivityState.IDLE, + new picker_1.QueuePicker(this) + ) + } + } + updateState(newState, picker) { + trace( + channel_1.ConnectivityState[this.currentState] + + ' -> ' + + channel_1.ConnectivityState[newState] + ) + if (newState === channel_1.ConnectivityState.READY) { + this.currentReadyPicker = picker + } else { + this.currentReadyPicker = null + } + this.currentState = newState + this.channelControlHelper.updateState(newState, picker) + } + resetSubchannelList() { + for (const subchannel of this.subchannels) { + subchannel.removeConnectivityStateListener( + this.subchannelStateListener + ) + subchannel.unref() + } + this.subchannelStateCounts = { + [channel_1.ConnectivityState.CONNECTING]: 0, + [channel_1.ConnectivityState.IDLE]: 0, + [channel_1.ConnectivityState.READY]: 0, + [channel_1.ConnectivityState.SHUTDOWN]: 0, + [channel_1.ConnectivityState.TRANSIENT_FAILURE]: 0 + } + this.subchannels = [] + } + updateAddressList(addressList, lbConfig) { + this.resetSubchannelList() + trace( + 'Connect to address list ' + + addressList.map(address => + subchannel_1.subchannelAddressToString(address) + ) + ) + this.subchannels = addressList.map(address => + this.channelControlHelper.createSubchannel(address, {}) + ) + for (const subchannel of this.subchannels) { + subchannel.ref() + subchannel.addConnectivityStateListener( + this.subchannelStateListener + ) + const subchannelState = subchannel.getConnectivityState() + this.subchannelStateCounts[subchannelState] += 1 + if ( + subchannelState === channel_1.ConnectivityState.IDLE || + subchannelState === channel_1.ConnectivityState.TRANSIENT_FAILURE + ) { + subchannel.startConnecting() + } + } + this.calculateAndUpdateState() + } + exitIdle() { + for (const subchannel of this.subchannels) { + subchannel.startConnecting() + } + } + resetBackoff() { + /* The pick first load balancer does not have a connection backoff, so this + * does nothing */ + } + destroy() { + this.resetSubchannelList() + } + getTypeName() { + return TYPE_NAME + } + } + exports.RoundRobinLoadBalancer = RoundRobinLoadBalancer + function setup() { + load_balancer_1.registerLoadBalancerType( + TYPE_NAME, + RoundRobinLoadBalancer + ) + } + exports.setup = setup + //# sourceMappingURL=load-balancer-round-robin.js.map + + /***/ + }, + + /***/ 58569: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /* + * Copyright 2020 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.setup = exports.WeightedTargetLoadBalancer = void 0 + const load_balancer_1 = __webpack_require__(52680) + const load_balancing_config_1 = __webpack_require__(43802) + const picker_1 = __webpack_require__(81611) + const channel_1 = __webpack_require__(13860) + const load_balancer_child_handler_1 = __webpack_require__(17559) + const constants_1 = __webpack_require__(90634) + const metadata_1 = __webpack_require__(83665) + const load_balancer_priority_1 = __webpack_require__(92865) + const TYPE_NAME = 'weighted_target' + const DEFAULT_RETENTION_INTERVAL_MS = 15 * 60 * 1000 + class WeightedTargetPicker { + constructor(pickerList) { + this.pickerList = pickerList + this.rangeTotal = pickerList[pickerList.length - 1].rangeEnd + } + pick(pickArgs) { + // num | 0 is equivalent to floor(num) + const selection = (Math.random() * this.rangeTotal) | 0 + /* Binary search for the element of the list such that + * pickerList[index - 1].rangeEnd <= selection < pickerList[index].rangeEnd + */ + let mid = 0 + let startIndex = 0 + let endIndex = this.pickerList.length - 1 + let index = 0 + while (endIndex > startIndex) { + mid = ((startIndex + endIndex) / 2) | 0 + if (this.pickerList[mid].rangeEnd > selection) { + endIndex = mid + } else if (this.pickerList[mid].rangeEnd < selection) { + startIndex = mid + 1 + } else { + // + 1 here because the range is exclusive at the top end + index = mid + 1 + break + } + } + if (index === 0) { + index = startIndex + } + return this.pickerList[index].picker.pick(pickArgs) + } + } + class WeightedTargetLoadBalancer { + constructor(channelControlHelper) { + this.channelControlHelper = channelControlHelper + this.WeightedChildImpl = class { + constructor(parent, name) { + this.parent = parent + this.name = name + this.connectivityState = channel_1.ConnectivityState.IDLE + this.deactivationTimer = null + this.weight = 0 + this.childBalancer = new load_balancer_child_handler_1.ChildLoadBalancerHandler( + { + createSubchannel: (subchannelAddress, subchannelOptions) => { + return this.parent.channelControlHelper.createSubchannel( + subchannelAddress, + subchannelOptions + ) + }, + updateState: (connectivityState, picker) => { + this.updateState(connectivityState, picker) + }, + requestReresolution: () => { + this.parent.channelControlHelper.requestReresolution() + } + } + ) + this.picker = new picker_1.QueuePicker(this.childBalancer) + } + updateState(connectivityState, picker) { + this.connectivityState = connectivityState + this.picker = picker + this.parent.updateState() + } + updateAddressList(addressList, lbConfig, attributes) { + this.weight = lbConfig.weight + const childConfig = load_balancer_1.getFirstUsableConfig( + lbConfig.child_policy + ) + if (childConfig !== null) { + this.childBalancer.updateAddressList( + addressList, + childConfig, + attributes + ) + } + } + exitIdle() { + this.childBalancer.exitIdle() + } + resetBackoff() { + this.childBalancer.resetBackoff() + } + destroy() { + this.childBalancer.destroy() + if (this.deactivationTimer !== null) { + clearTimeout(this.deactivationTimer) + } + } + deactivate() { + if (this.deactivationTimer === null) { + this.deactivationTimer = setTimeout(() => { + this.parent.targets.delete(this.name) + this.deactivationTimer = null + }, DEFAULT_RETENTION_INTERVAL_MS) + } + } + maybeReactivate() { + if (this.deactivationTimer !== null) { + clearTimeout(this.deactivationTimer) + this.deactivationTimer = null + } + } + getConnectivityState() { + return this.connectivityState + } + getPicker() { + return this.picker + } + getWeight() { + return this.weight + } + } + // end of WeightedChildImpl + /** + * Map of target names to target children. Includes current targets and + * previous targets with deactivation timers that have not yet triggered. + */ + this.targets = new Map() + /** + * List of current target names. + */ + this.targetList = [] + } + updateState() { + const pickerList = [] + let end = 0 + let connectingCount = 0 + let idleCount = 0 + let transientFailureCount = 0 + for (const targetName of this.targetList) { + const target = this.targets.get(targetName) + if (target === undefined) { + continue + } + switch (target.getConnectivityState()) { + case channel_1.ConnectivityState.READY: + end += target.getWeight() + pickerList.push({ + picker: target.getPicker(), + rangeEnd: end + }) + break + case channel_1.ConnectivityState.CONNECTING: + connectingCount += 1 + break + case channel_1.ConnectivityState.IDLE: + idleCount += 1 + break + case channel_1.ConnectivityState.TRANSIENT_FAILURE: + transientFailureCount += 1 + break + default: + // Ignore the other possiblity, SHUTDOWN + } + } + let connectivityState + if (pickerList.length > 0) { + connectivityState = channel_1.ConnectivityState.READY + } else if (connectingCount > 0) { + connectivityState = channel_1.ConnectivityState.CONNECTING + } else if (idleCount > 0) { + connectivityState = channel_1.ConnectivityState.IDLE + } else { + connectivityState = channel_1.ConnectivityState.TRANSIENT_FAILURE + } + let picker + switch (connectivityState) { + case channel_1.ConnectivityState.READY: + picker = new WeightedTargetPicker(pickerList) + break + case channel_1.ConnectivityState.CONNECTING: + case channel_1.ConnectivityState.READY: + picker = new picker_1.QueuePicker(this) + break + default: + picker = new picker_1.UnavailablePicker({ + code: constants_1.Status.UNAVAILABLE, + details: + 'weighted_target: all children report state TRANSIENT_FAILURE', + metadata: new metadata_1.Metadata() + }) + } + this.channelControlHelper.updateState(connectivityState, picker) + } + updateAddressList(addressList, lbConfig, attributes) { + var _a + if ( + !load_balancing_config_1.isWeightedTargetLoadBalancingConfig( + lbConfig + ) + ) { + // Reject a config of the wrong type + return + } + /* For each address, the first element of its localityPath array determines + * which child it belongs to. So we bucket those addresses by that first + * element, and pass along the rest of the localityPath for that child + * to use. */ + const childAddressMap = new Map() + for (const address of addressList) { + if ( + !load_balancer_priority_1.isLocalitySubchannelAddress(address) + ) { + // Reject address that cannot be associated with targets + return + } + if (address.localityPath.length < 1) { + // Reject address that cannot be associated with targets + return + } + const childName = address.localityPath[0] + const childAddress = Object.assign(Object.assign({}, address), { + localityPath: address.localityPath.slice(1) + }) + let childAddressList = childAddressMap.get(childName) + if (childAddressList === undefined) { + childAddressList = [] + childAddressMap.set(childName, childAddressList) + } + childAddressList.push(childAddress) + } + this.targetList = Array.from(lbConfig.weighted_target.targets.keys()) + for (const [targetName, targetConfig] of lbConfig.weighted_target + .targets) { + let target = this.targets.get(targetName) + if (target === undefined) { + target = new this.WeightedChildImpl(this, targetName) + this.targets.set(targetName, target) + } else { + target.maybeReactivate() + } + target.updateAddressList( + (_a = childAddressMap.get(targetName)) !== null && _a !== void 0 + ? _a + : [], + targetConfig, + attributes + ) + } + // Deactivate targets that are not in the new config + for (const [targetName, target] of this.targets) { + if (this.targetList.indexOf(targetName) < 0) { + target.deactivate() + } + } + this.updateState() + } + exitIdle() { + var _a + for (const targetName of this.targetList) { + ;(_a = this.targets.get(targetName)) === null || _a === void 0 + ? void 0 + : _a.exitIdle() + } + } + resetBackoff() { + var _a + for (const targetName of this.targetList) { + ;(_a = this.targets.get(targetName)) === null || _a === void 0 + ? void 0 + : _a.resetBackoff() + } + } + destroy() { + for (const target of this.targets.values()) { + target.destroy() + } + this.targets.clear() + } + getTypeName() { + return TYPE_NAME + } + } + exports.WeightedTargetLoadBalancer = WeightedTargetLoadBalancer + function setup() { + load_balancer_1.registerLoadBalancerType( + TYPE_NAME, + WeightedTargetLoadBalancer + ) + } + exports.setup = setup + //# sourceMappingURL=load-balancer-weighted-target.js.map + + /***/ + }, + + /***/ 52680: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /* + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.registerAll = exports.getFirstUsableConfig = exports.isLoadBalancerNameRegistered = exports.createLoadBalancer = exports.registerLoadBalancerType = void 0 + const load_balancer_pick_first = __webpack_require__(38977) + const load_balancer_round_robin = __webpack_require__(92787) + const load_balancer_priority = __webpack_require__(92865) + const load_balancer_weighted_target = __webpack_require__(58569) + const load_balancer_eds = __webpack_require__(19299) + const load_balancer_cds = __webpack_require__(88012) + const load_balancer_lrs = __webpack_require__(21819) + const registeredLoadBalancerTypes = {} + function registerLoadBalancerType(typeName, loadBalancerType) { + registeredLoadBalancerTypes[typeName] = loadBalancerType + } + exports.registerLoadBalancerType = registerLoadBalancerType + function createLoadBalancer(typeName, channelControlHelper) { + if (typeName in registeredLoadBalancerTypes) { + return new registeredLoadBalancerTypes[typeName](channelControlHelper) + } else { + return null + } + } + exports.createLoadBalancer = createLoadBalancer + function isLoadBalancerNameRegistered(typeName) { + return typeName in registeredLoadBalancerTypes + } + exports.isLoadBalancerNameRegistered = isLoadBalancerNameRegistered + function getFirstUsableConfig(configs) { + for (const config of configs) { + if (config.name in registeredLoadBalancerTypes) { + return config + } + } + return null + } + exports.getFirstUsableConfig = getFirstUsableConfig + function registerAll() { + load_balancer_pick_first.setup() + load_balancer_round_robin.setup() + load_balancer_priority.setup() + load_balancer_weighted_target.setup() + load_balancer_eds.setup() + load_balancer_cds.setup() + load_balancer_lrs.setup() + } + exports.registerAll = registerAll + //# sourceMappingURL=load-balancer.js.map + + /***/ + }, + + /***/ 43802: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + /* + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.validateConfig = exports.isLrsLoadBalancingConfig = exports.isCdsLoadBalancingConfig = exports.isEdsLoadBalancingConfig = exports.isWeightedTargetLoadBalancingConfig = exports.isPriorityLoadBalancingConfig = exports.isGrpcLbLoadBalancingConfig = exports.isXdsLoadBalancingConfig = exports.isRoundRobinLoadBalancingConfig = void 0 + function isRoundRobinLoadBalancingConfig(lbconfig) { + return lbconfig.name === 'round_robin' + } + exports.isRoundRobinLoadBalancingConfig = isRoundRobinLoadBalancingConfig + function isXdsLoadBalancingConfig(lbconfig) { + return lbconfig.name === 'xds' + } + exports.isXdsLoadBalancingConfig = isXdsLoadBalancingConfig + function isGrpcLbLoadBalancingConfig(lbconfig) { + return lbconfig.name === 'grpclb' + } + exports.isGrpcLbLoadBalancingConfig = isGrpcLbLoadBalancingConfig + function isPriorityLoadBalancingConfig(lbconfig) { + return lbconfig.name === 'priority' + } + exports.isPriorityLoadBalancingConfig = isPriorityLoadBalancingConfig + function isWeightedTargetLoadBalancingConfig(lbconfig) { + return lbconfig.name === 'weighted_target' + } + exports.isWeightedTargetLoadBalancingConfig = isWeightedTargetLoadBalancingConfig + function isEdsLoadBalancingConfig(lbconfig) { + return lbconfig.name === 'eds' + } + exports.isEdsLoadBalancingConfig = isEdsLoadBalancingConfig + function isCdsLoadBalancingConfig(lbconfig) { + return lbconfig.name === 'cds' + } + exports.isCdsLoadBalancingConfig = isCdsLoadBalancingConfig + function isLrsLoadBalancingConfig(lbconfig) { + return lbconfig.name === 'lrs' + } + exports.isLrsLoadBalancingConfig = isLrsLoadBalancingConfig + /* In these functions we assume the input came from a JSON object. Therefore we + * expect that the prototype is uninteresting and that `in` can be used + * effectively */ + function validateXdsConfig(xds) { + if (!('balancerName' in xds) || typeof xds.balancerName !== 'string') { + throw new Error('Invalid xds config: invalid balancerName') + } + const xdsConfig = { + balancerName: xds.balancerName, + childPolicy: [], + fallbackPolicy: [] + } + if ('childPolicy' in xds) { + if (!Array.isArray(xds.childPolicy)) { + throw new Error('Invalid xds config: invalid childPolicy') + } + for (const policy of xds.childPolicy) { + xdsConfig.childPolicy.push(validateConfig(policy)) + } + } + if ('fallbackPolicy' in xds) { + if (!Array.isArray(xds.fallbackPolicy)) { + throw new Error('Invalid xds config: invalid fallbackPolicy') + } + for (const policy of xds.fallbackPolicy) { + xdsConfig.fallbackPolicy.push(validateConfig(policy)) + } + } + return xdsConfig + } + function validateGrpcLbConfig(grpclb) { + const grpcLbConfig = { + childPolicy: [] + } + if ('childPolicy' in grpclb) { + if (!Array.isArray(grpclb.childPolicy)) { + throw new Error('Invalid xds config: invalid childPolicy') + } + for (const policy of grpclb.childPolicy) { + grpcLbConfig.childPolicy.push(validateConfig(policy)) + } + } + return grpcLbConfig + } + function validateConfig(obj) { + if ('round_robin' in obj) { + if ('xds' in obj || 'grpclb' in obj) { + throw new Error('Multiple load balancing policies configured') + } + if (obj['round_robin'] instanceof Object) { + return { + name: 'round_robin', + round_robin: {} + } + } + } + if ('xds' in obj) { + if ('grpclb' in obj) { + throw new Error('Multiple load balancing policies configured') + } + return { + name: 'xds', + xds: validateXdsConfig(obj.xds) + } + } + if ('grpclb' in obj) { + return { + name: 'grpclb', + grpclb: validateGrpcLbConfig(obj.grpclb) + } + } + throw new Error('No recognized load balancing policy configured') + } + exports.validateConfig = validateConfig + //# sourceMappingURL=load-balancing-config.js.map + + /***/ + }, + + /***/ 35993: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /* + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.trace = exports.log = exports.setLoggerVerbosity = exports.setLogger = exports.getLogger = void 0 + const constants_1 = __webpack_require__(90634) + let _logger = console + let _logVerbosity = constants_1.LogVerbosity.ERROR + if (process.env.GRPC_VERBOSITY) { + switch (process.env.GRPC_VERBOSITY) { + case 'DEBUG': + _logVerbosity = constants_1.LogVerbosity.DEBUG + break + case 'INFO': + _logVerbosity = constants_1.LogVerbosity.INFO + break + case 'ERROR': + _logVerbosity = constants_1.LogVerbosity.ERROR + break + default: + // Ignore any other values + } + } + exports.getLogger = () => { + return _logger + } + exports.setLogger = logger => { + _logger = logger + } + exports.setLoggerVerbosity = verbosity => { + _logVerbosity = verbosity + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + exports.log = (severity, ...args) => { + if (severity >= _logVerbosity && typeof _logger.error === 'function') { + _logger.error(...args) + } + } + const enabledTracers = process.env.GRPC_TRACE + ? process.env.GRPC_TRACE.split(',') + : [] + const allEnabled = enabledTracers.includes('all') + function trace(severity, tracer, text) { + if (allEnabled || enabledTracers.includes(tracer)) { + exports.log( + severity, + new Date().toISOString() + ' | ' + tracer + ' | ' + text + ) + } + } + exports.trace = trace + //# sourceMappingURL=logging.js.map + + /***/ + }, + + /***/ 38541: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /* + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.loadPackageDefinition = exports.makeClientConstructor = void 0 + const client_1 = __webpack_require__(87172) + /** + * Map with short names for each of the requester maker functions. Used in + * makeClientConstructor + * @private + */ + const requesterFuncs = { + unary: client_1.Client.prototype.makeUnaryRequest, + server_stream: client_1.Client.prototype.makeServerStreamRequest, + client_stream: client_1.Client.prototype.makeClientStreamRequest, + bidi: client_1.Client.prototype.makeBidiStreamRequest + } + /** + * Creates a constructor for a client with the given methods, as specified in + * the methods argument. The resulting class will have an instance method for + * each method in the service, which is a partial application of one of the + * [Client]{@link grpc.Client} request methods, depending on `requestSerialize` + * and `responseSerialize`, with the `method`, `serialize`, and `deserialize` + * arguments predefined. + * @param methods An object mapping method names to + * method attributes + * @param serviceName The fully qualified name of the service + * @param classOptions An options object. + * @return New client constructor, which is a subclass of + * {@link grpc.Client}, and has the same arguments as that constructor. + */ + function makeClientConstructor(methods, serviceName, classOptions) { + if (!classOptions) { + classOptions = {} + } + class ServiceClientImpl extends client_1.Client {} + Object.keys(methods).forEach(name => { + const attrs = methods[name] + let methodType + // TODO(murgatroid99): Verify that we don't need this anymore + if (typeof name === 'string' && name.charAt(0) === '$') { + throw new Error('Method names cannot start with $') + } + if (attrs.requestStream) { + if (attrs.responseStream) { + methodType = 'bidi' + } else { + methodType = 'client_stream' + } + } else { + if (attrs.responseStream) { + methodType = 'server_stream' + } else { + methodType = 'unary' + } + } + const serialize = attrs.requestSerialize + const deserialize = attrs.responseDeserialize + const methodFunc = partial( + requesterFuncs[methodType], + attrs.path, + serialize, + deserialize + ) + ServiceClientImpl.prototype[name] = methodFunc + // Associate all provided attributes with the method + Object.assign(ServiceClientImpl.prototype[name], attrs) + if (attrs.originalName) { + ServiceClientImpl.prototype[attrs.originalName] = + ServiceClientImpl.prototype[name] + } + }) + ServiceClientImpl.service = methods + return ServiceClientImpl + } + exports.makeClientConstructor = makeClientConstructor + function partial(fn, path, serialize, deserialize) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return function (...args) { + return fn.call(this, path, serialize, deserialize, ...args) + } + } + function isProtobufTypeDefinition(obj) { + return 'format' in obj + } + /** + * Load a gRPC package definition as a gRPC object hierarchy. + * @param packageDef The package definition object. + * @return The resulting gRPC object. + */ + function loadPackageDefinition(packageDef) { + const result = {} + for (const serviceFqn in packageDef) { + if (Object.prototype.hasOwnProperty.call(packageDef, serviceFqn)) { + const service = packageDef[serviceFqn] + const nameComponents = serviceFqn.split('.') + const serviceName = nameComponents[nameComponents.length - 1] + let current = result + for (const packageName of nameComponents.slice(0, -1)) { + if (!current[packageName]) { + current[packageName] = {} + } + current = current[packageName] + } + if (isProtobufTypeDefinition(service)) { + current[serviceName] = service + } else { + current[serviceName] = makeClientConstructor( + service, + serviceName, + {} + ) + } + } + } + return result + } + exports.loadPackageDefinition = loadPackageDefinition + //# sourceMappingURL=make-client.js.map + + /***/ + }, + + /***/ 30659: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /* + * Copyright 2020 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.MaxMessageSizeFilterFactory = exports.MaxMessageSizeFilter = void 0 + const filter_1 = __webpack_require__(43392) + const constants_1 = __webpack_require__(90634) + class MaxMessageSizeFilter extends filter_1.BaseFilter { + constructor(options, callStream) { + super() + this.options = options + this.callStream = callStream + this.maxSendMessageSize = constants_1.DEFAULT_MAX_SEND_MESSAGE_LENGTH + this.maxReceiveMessageSize = + constants_1.DEFAULT_MAX_RECEIVE_MESSAGE_LENGTH + if ('grpc.max_send_message_length' in options) { + this.maxSendMessageSize = options['grpc.max_send_message_length'] + } + if ('grpc.max_receive_message_length' in options) { + this.maxReceiveMessageSize = + options['grpc.max_receive_message_length'] + } + } + async sendMessage(message) { + /* A configured size of -1 means that there is no limit, so skip the check + * entirely */ + if (this.maxSendMessageSize === -1) { + return message + } else { + const concreteMessage = await message + if (concreteMessage.message.length > this.maxSendMessageSize) { + this.callStream.cancelWithStatus( + constants_1.Status.RESOURCE_EXHAUSTED, + `Sent message larger than max (${concreteMessage.message.length} vs. ${this.maxSendMessageSize})` + ) + return Promise.reject('Message too large') + } else { + return concreteMessage + } + } + } + async receiveMessage(message) { + /* A configured size of -1 means that there is no limit, so skip the check + * entirely */ + if (this.maxReceiveMessageSize === -1) { + return message + } else { + const concreteMessage = await message + if (concreteMessage.length > this.maxReceiveMessageSize) { + this.callStream.cancelWithStatus( + constants_1.Status.RESOURCE_EXHAUSTED, + `Received message larger than max (${concreteMessage.length} vs. ${this.maxReceiveMessageSize})` + ) + return Promise.reject('Message too large') + } else { + return concreteMessage + } + } + } + } + exports.MaxMessageSizeFilter = MaxMessageSizeFilter + class MaxMessageSizeFilterFactory { + constructor(options) { + this.options = options + } + createFilter(callStream) { + return new MaxMessageSizeFilter(this.options, callStream) + } + } + exports.MaxMessageSizeFilterFactory = MaxMessageSizeFilterFactory + //# sourceMappingURL=max-message-size-filter.js.map + + /***/ + }, + + /***/ 83665: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /* + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.Metadata = void 0 + const logging_1 = __webpack_require__(35993) + const constants_1 = __webpack_require__(90634) + const LEGAL_KEY_REGEX = /^[0-9a-z_.-]+$/ + const LEGAL_NON_BINARY_VALUE_REGEX = /^[ -~]*$/ + function isLegalKey(key) { + return LEGAL_KEY_REGEX.test(key) + } + function isLegalNonBinaryValue(value) { + return LEGAL_NON_BINARY_VALUE_REGEX.test(value) + } + function isBinaryKey(key) { + return key.endsWith('-bin') + } + function isCustomMetadata(key) { + return !key.startsWith('grpc-') + } + function normalizeKey(key) { + return key.toLowerCase() + } + function validate(key, value) { + if (!isLegalKey(key)) { + throw new Error( + 'Metadata key "' + key + '" contains illegal characters' + ) + } + if (value !== null && value !== undefined) { + if (isBinaryKey(key)) { + if (!(value instanceof Buffer)) { + throw new Error( + "keys that end with '-bin' must have Buffer values" + ) + } + } else { + if (value instanceof Buffer) { + throw new Error( + "keys that don't end with '-bin' must have String values" + ) + } + if (!isLegalNonBinaryValue(value)) { + throw new Error( + 'Metadata string value "' + + value + + '" contains illegal characters' + ) + } + } + } + } + /** + * A class for storing metadata. Keys are normalized to lowercase ASCII. + */ + class Metadata { + constructor(options) { + this.internalRepr = new Map() + if (options === undefined) { + this.options = {} + } else { + this.options = options + } + } + /** + * Sets the given value for the given key by replacing any other values + * associated with that key. Normalizes the key. + * @param key The key to whose value should be set. + * @param value The value to set. Must be a buffer if and only + * if the normalized key ends with '-bin'. + */ + set(key, value) { + key = normalizeKey(key) + validate(key, value) + this.internalRepr.set(key, [value]) + } + /** + * Adds the given value for the given key by appending to a list of previous + * values associated with that key. Normalizes the key. + * @param key The key for which a new value should be appended. + * @param value The value to add. Must be a buffer if and only + * if the normalized key ends with '-bin'. + */ + add(key, value) { + key = normalizeKey(key) + validate(key, value) + const existingValue = this.internalRepr.get(key) + if (existingValue === undefined) { + this.internalRepr.set(key, [value]) + } else { + existingValue.push(value) + } + } + /** + * Removes the given key and any associated values. Normalizes the key. + * @param key The key whose values should be removed. + */ + remove(key) { + key = normalizeKey(key) + validate(key) + this.internalRepr.delete(key) + } + /** + * Gets a list of all values associated with the key. Normalizes the key. + * @param key The key whose value should be retrieved. + * @return A list of values associated with the given key. + */ + get(key) { + key = normalizeKey(key) + validate(key) + return this.internalRepr.get(key) || [] + } + /** + * Gets a plain object mapping each key to the first value associated with it. + * This reflects the most common way that people will want to see metadata. + * @return A key/value mapping of the metadata. + */ + getMap() { + const result = {} + this.internalRepr.forEach((values, key) => { + if (values.length > 0) { + const v = values[0] + result[key] = v instanceof Buffer ? v.slice() : v + } + }) + return result + } + /** + * Clones the metadata object. + * @return The newly cloned object. + */ + clone() { + const newMetadata = new Metadata(this.options) + const newInternalRepr = newMetadata.internalRepr + this.internalRepr.forEach((value, key) => { + const clonedValue = value.map(v => { + if (v instanceof Buffer) { + return Buffer.from(v) + } else { + return v + } + }) + newInternalRepr.set(key, clonedValue) + }) + return newMetadata + } + /** + * Merges all key-value pairs from a given Metadata object into this one. + * If both this object and the given object have values in the same key, + * values from the other Metadata object will be appended to this object's + * values. + * @param other A Metadata object. + */ + merge(other) { + other.internalRepr.forEach((values, key) => { + const mergedValue = (this.internalRepr.get(key) || []).concat( + values + ) + this.internalRepr.set(key, mergedValue) + }) + } + setOptions(options) { + this.options = options + } + getOptions() { + return this.options + } + /** + * Creates an OutgoingHttpHeaders object that can be used with the http2 API. + */ + toHttp2Headers() { + // NOTE: Node <8.9 formats http2 headers incorrectly. + const result = {} + this.internalRepr.forEach((values, key) => { + // We assume that the user's interaction with this object is limited to + // through its public API (i.e. keys and values are already validated). + result[key] = values.map(value => { + if (value instanceof Buffer) { + return value.toString('base64') + } else { + return value + } + }) + }) + return result + } + // For compatibility with the other Metadata implementation + _getCoreRepresentation() { + return this.internalRepr + } + /** + * Returns a new Metadata object based fields in a given IncomingHttpHeaders + * object. + * @param headers An IncomingHttpHeaders object. + */ + static fromHttp2Headers(headers) { + const result = new Metadata() + Object.keys(headers).forEach(key => { + // Reserved headers (beginning with `:`) are not valid keys. + if (key.charAt(0) === ':') { + return + } + const values = headers[key] + try { + if (isBinaryKey(key)) { + if (Array.isArray(values)) { + values.forEach(value => { + result.add(key, Buffer.from(value, 'base64')) + }) + } else if (values !== undefined) { + if (isCustomMetadata(key)) { + values.split(',').forEach(v => { + result.add(key, Buffer.from(v.trim(), 'base64')) + }) + } else { + result.add(key, Buffer.from(values, 'base64')) + } + } + } else { + if (Array.isArray(values)) { + values.forEach(value => { + result.add(key, value) + }) + } else if (values !== undefined) { + result.add(key, values) + } + } + } catch (error) { + const message = `Failed to add metadata entry ${key}: ${values}. ${error.message}. For more information see https://github.com/grpc/grpc-node/issues/1173` + logging_1.log(constants_1.LogVerbosity.ERROR, message) + } + }) + return result + } + } + exports.Metadata = Metadata + //# sourceMappingURL=metadata.js.map + + /***/ + }, + + /***/ 81611: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /* + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.QueuePicker = exports.UnavailablePicker = exports.PickResultType = void 0 + const metadata_1 = __webpack_require__(83665) + const constants_1 = __webpack_require__(90634) + var PickResultType + ;(function (PickResultType) { + PickResultType[(PickResultType['COMPLETE'] = 0)] = 'COMPLETE' + PickResultType[(PickResultType['QUEUE'] = 1)] = 'QUEUE' + PickResultType[(PickResultType['TRANSIENT_FAILURE'] = 2)] = + 'TRANSIENT_FAILURE' + PickResultType[(PickResultType['DROP'] = 3)] = 'DROP' + })( + (PickResultType = + exports.PickResultType || (exports.PickResultType = {})) + ) + /** + * A standard picker representing a load balancer in the TRANSIENT_FAILURE + * state. Always responds to every pick request with an UNAVAILABLE status. + */ + class UnavailablePicker { + constructor(status) { + if (status !== undefined) { + this.status = status + } else { + this.status = { + code: constants_1.Status.UNAVAILABLE, + details: 'No connection established', + metadata: new metadata_1.Metadata() + } + } + } + pick(pickArgs) { + return { + pickResultType: PickResultType.TRANSIENT_FAILURE, + subchannel: null, + status: this.status, + extraFilterFactory: null, + onCallStarted: null + } + } + } + exports.UnavailablePicker = UnavailablePicker + /** + * A standard picker representing a load balancer in the IDLE or CONNECTING + * state. Always responds to every pick request with a QUEUE pick result + * indicating that the pick should be tried again with the next `Picker`. Also + * reports back to the load balancer that a connection should be established + * once any pick is attempted. + */ + class QueuePicker { + // Constructed with a load balancer. Calls exitIdle on it the first time pick is called + constructor(loadBalancer) { + this.loadBalancer = loadBalancer + this.calledExitIdle = false + } + pick(pickArgs) { + if (!this.calledExitIdle) { + process.nextTick(() => { + this.loadBalancer.exitIdle() + }) + this.calledExitIdle = true + } + return { + pickResultType: PickResultType.QUEUE, + subchannel: null, + status: null, + extraFilterFactory: null, + onCallStarted: null + } + } + } + exports.QueuePicker = QueuePicker + //# sourceMappingURL=picker.js.map + + /***/ + }, + + /***/ 54886: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /* + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.setup = void 0 + const resolver_1 = __webpack_require__(31594) + const dns = __webpack_require__(40881) + const util = __webpack_require__(31669) + const service_config_1 = __webpack_require__(21761) + const constants_1 = __webpack_require__(90634) + const metadata_1 = __webpack_require__(83665) + const logging = __webpack_require__(35993) + const constants_2 = __webpack_require__(90634) + const uri_parser_1 = __webpack_require__(65974) + const net_1 = __webpack_require__(11631) + const TRACER_NAME = 'dns_resolver' + function trace(text) { + logging.trace(constants_2.LogVerbosity.DEBUG, TRACER_NAME, text) + } + /** + * The default TCP port to connect to if not explicitly specified in the target. + */ + const DEFAULT_PORT = 443 + const resolveTxtPromise = util.promisify(dns.resolveTxt) + const dnsLookupPromise = util.promisify(dns.lookup) + /** + * Merge any number of arrays into a single alternating array + * @param arrays + */ + function mergeArrays(...arrays) { + const result = [] + for ( + let i = 0; + i < + Math.max.apply( + null, + arrays.map(array => array.length) + ); + i++ + ) { + for (const array of arrays) { + if (i < array.length) { + result.push(array[i]) + } + } + } + return result + } + /** + * Resolver implementation that handles DNS names and IP addresses. + */ + class DnsResolver { + constructor(target, listener, channelOptions) { + var _a, _b + this.target = target + this.listener = listener + this.pendingLookupPromise = null + this.pendingTxtPromise = null + this.latestLookupResult = null + this.latestServiceConfig = null + this.latestServiceConfigError = null + trace( + 'Resolver constructed for target ' + + uri_parser_1.uriToString(target) + ) + const hostPort = uri_parser_1.splitHostPort(target.path) + if (hostPort === null) { + this.ipResult = null + this.dnsHostname = null + this.port = null + } else { + if (net_1.isIPv4(hostPort.host) || net_1.isIPv6(hostPort.host)) { + this.ipResult = [ + { + host: hostPort.host, + port: + (_a = hostPort.port) !== null && _a !== void 0 + ? _a + : DEFAULT_PORT + } + ] + this.dnsHostname = null + this.port = null + } else { + this.ipResult = null + this.dnsHostname = hostPort.host + this.port = + (_b = hostPort.port) !== null && _b !== void 0 + ? _b + : DEFAULT_PORT + } + } + this.percentage = Math.random() * 100 + this.defaultResolutionError = { + code: constants_1.Status.UNAVAILABLE, + details: `Name resolution failed for target ${uri_parser_1.uriToString( + this.target + )}`, + metadata: new metadata_1.Metadata() + } + } + /** + * If the target is an IP address, just provide that address as a result. + * Otherwise, initiate A, AAAA, and TXT lookups + */ + startResolution() { + if (this.ipResult !== null) { + trace( + 'Returning IP address for target ' + + uri_parser_1.uriToString(this.target) + ) + setImmediate(() => { + this.listener.onSuccessfulResolution( + this.ipResult, + null, + null, + {} + ) + }) + return + } + if (this.dnsHostname === null) { + setImmediate(() => { + this.listener.onError({ + code: constants_1.Status.UNAVAILABLE, + details: `Failed to parse DNS address ${uri_parser_1.uriToString( + this.target + )}`, + metadata: new metadata_1.Metadata() + }) + }) + } else { + /* We clear out latestLookupResult here to ensure that it contains the + * latest result since the last time we started resolving. That way, the + * TXT resolution handler can use it, but only if it finishes second. We + * don't clear out any previous service config results because it's + * better to use a service config that's slightly out of date than to + * revert to an effectively blank one. */ + this.latestLookupResult = null + const hostname = this.dnsHostname + /* We lookup both address families here and then split them up later + * because when looking up a single family, dns.lookup outputs an error + * if the name exists but there are no records for that family, and that + * error is indistinguishable from other kinds of errors */ + this.pendingLookupPromise = dnsLookupPromise(hostname, { + all: true + }) + this.pendingLookupPromise.then( + addressList => { + this.pendingLookupPromise = null + const ip4Addresses = addressList.filter( + addr => addr.family === 4 + ) + const ip6Addresses = addressList.filter( + addr => addr.family === 6 + ) + this.latestLookupResult = mergeArrays( + ip6Addresses, + ip4Addresses + ).map(addr => ({ host: addr.address, port: +this.port })) + const allAddressesString = + '[' + + this.latestLookupResult + .map(addr => addr.host + ':' + addr.port) + .join(',') + + ']' + trace( + 'Resolved addresses for target ' + + uri_parser_1.uriToString(this.target) + + ': ' + + allAddressesString + ) + if (this.latestLookupResult.length === 0) { + this.listener.onError(this.defaultResolutionError) + return + } + /* If the TXT lookup has not yet finished, both of the last two + * arguments will be null, which is the equivalent of getting an + * empty TXT response. When the TXT lookup does finish, its handler + * can update the service config by using the same address list */ + this.listener.onSuccessfulResolution( + this.latestLookupResult, + this.latestServiceConfig, + this.latestServiceConfigError, + {} + ) + }, + err => { + trace( + 'Resolution error for target ' + + uri_parser_1.uriToString(this.target) + + ': ' + + err.message + ) + this.pendingLookupPromise = null + this.listener.onError(this.defaultResolutionError) + } + ) + /* If there already is a still-pending TXT resolution, we can just use + * that result when it comes in */ + if (this.pendingTxtPromise === null) { + /* We handle the TXT query promise differently than the others because + * the name resolution attempt as a whole is a success even if the TXT + * lookup fails */ + this.pendingTxtPromise = resolveTxtPromise(hostname) + this.pendingTxtPromise.then( + txtRecord => { + this.pendingTxtPromise = null + try { + this.latestServiceConfig = service_config_1.extractAndSelectServiceConfig( + txtRecord, + this.percentage + ) + } catch (err) { + this.latestServiceConfigError = { + code: constants_1.Status.UNAVAILABLE, + details: 'Parsing service config failed', + metadata: new metadata_1.Metadata() + } + } + if (this.latestLookupResult !== null) { + /* We rely here on the assumption that calling this function with + * identical parameters will be essentialy idempotent, and calling + * it with the same address list and a different service config + * should result in a fast and seamless switchover. */ + this.listener.onSuccessfulResolution( + this.latestLookupResult, + this.latestServiceConfig, + this.latestServiceConfigError, + {} + ) + } + }, + err => { + /* If TXT lookup fails we should do nothing, which means that we + * continue to use the result of the most recent successful lookup, + * or the default null config object if there has never been a + * successful lookup. We do not set the latestServiceConfigError + * here because that is specifically used for response validation + * errors. We still need to handle this error so that it does not + * bubble up as an unhandled promise rejection. */ + } + ) + } + } + } + updateResolution() { + trace( + 'Resolution update requested for target ' + + uri_parser_1.uriToString(this.target) + ) + if (this.pendingLookupPromise === null) { + this.startResolution() + } + } + /** + * Get the default authority for the given target. For IP targets, that is + * the IP address. For DNS targets, it is the hostname. + * @param target + */ + static getDefaultAuthority(target) { + return target.path + } + } + /** + * Set up the DNS resolver class by registering it as the handler for the + * "dns:" prefix and as the default resolver. + */ + function setup() { + resolver_1.registerResolver('dns', DnsResolver) + resolver_1.registerDefaultScheme('dns') + } + exports.setup = setup + //# sourceMappingURL=resolver-dns.js.map + + /***/ + }, + + /***/ 5252: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /* + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.setup = void 0 + const resolver_1 = __webpack_require__(31594) + class UdsResolver { + constructor(target, listener, channelOptions) { + this.listener = listener + this.addresses = [] + let path + if (target.authority === '') { + path = '/' + target.path + } else { + path = target.path + } + this.addresses = [{ path }] + } + updateResolution() { + process.nextTick( + this.listener.onSuccessfulResolution, + this.addresses, + null, + null, + {} + ) + } + static getDefaultAuthority(target) { + return 'localhost' + } + } + function setup() { + resolver_1.registerResolver('unix', UdsResolver) + } + exports.setup = setup + //# sourceMappingURL=resolver-uds.js.map + + /***/ + }, + + /***/ 31594: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /* + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.registerAll = exports.mapUriDefaultScheme = exports.getDefaultAuthority = exports.createResolver = exports.registerDefaultScheme = exports.registerResolver = void 0 + const resolver_dns = __webpack_require__(54886) + const resolver_uds = __webpack_require__(5252) + const uri_parser_1 = __webpack_require__(65974) + const registeredResolvers = {} + let defaultScheme = null + /** + * Register a resolver class to handle target names prefixed with the `prefix` + * string. This prefix should correspond to a URI scheme name listed in the + * [gRPC Name Resolution document](https://github.com/grpc/grpc/blob/master/doc/naming.md) + * @param prefix + * @param resolverClass + */ + function registerResolver(scheme, resolverClass) { + registeredResolvers[scheme] = resolverClass + } + exports.registerResolver = registerResolver + /** + * Register a default resolver to handle target names that do not start with + * any registered prefix. + * @param resolverClass + */ + function registerDefaultScheme(scheme) { + defaultScheme = scheme + } + exports.registerDefaultScheme = registerDefaultScheme + /** + * Create a name resolver for the specified target, if possible. Throws an + * error if no such name resolver can be created. + * @param target + * @param listener + */ + function createResolver(target, listener, options) { + if ( + target.scheme !== undefined && + target.scheme in registeredResolvers + ) { + return new registeredResolvers[target.scheme]( + target, + listener, + options + ) + } else { + throw new Error( + `No resolver could be created for target ${uri_parser_1.uriToString( + target + )}` + ) + } + } + exports.createResolver = createResolver + /** + * Get the default authority for the specified target, if possible. Throws an + * error if no registered name resolver can parse that target string. + * @param target + */ + function getDefaultAuthority(target) { + if ( + target.scheme !== undefined && + target.scheme in registeredResolvers + ) { + return registeredResolvers[target.scheme].getDefaultAuthority(target) + } else { + throw new Error(`Invalid target ${uri_parser_1.uriToString(target)}`) + } + } + exports.getDefaultAuthority = getDefaultAuthority + function mapUriDefaultScheme(target) { + if ( + target.scheme === undefined || + !(target.scheme in registeredResolvers) + ) { + if (defaultScheme !== null) { + return { + scheme: defaultScheme, + authority: undefined, + path: uri_parser_1.uriToString(target) + } + } else { + return null + } + } + return target + } + exports.mapUriDefaultScheme = mapUriDefaultScheme + function registerAll() { + resolver_dns.setup() + resolver_uds.setup() + } + exports.registerAll = registerAll + //# sourceMappingURL=resolver.js.map + + /***/ + }, + + /***/ 19192: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /* + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.ResolvingLoadBalancer = void 0 + const load_balancer_1 = __webpack_require__(52680) + const service_config_1 = __webpack_require__(21761) + const channel_1 = __webpack_require__(13860) + const resolver_1 = __webpack_require__(31594) + const picker_1 = __webpack_require__(81611) + const backoff_timeout_1 = __webpack_require__(34186) + const constants_1 = __webpack_require__(90634) + const metadata_1 = __webpack_require__(83665) + const logging = __webpack_require__(35993) + const constants_2 = __webpack_require__(90634) + const uri_parser_1 = __webpack_require__(65974) + const load_balancer_child_handler_1 = __webpack_require__(17559) + const TRACER_NAME = 'resolving_load_balancer' + function trace(text) { + logging.trace(constants_2.LogVerbosity.DEBUG, TRACER_NAME, text) + } + const DEFAULT_LOAD_BALANCER_NAME = 'pick_first' + class ResolvingLoadBalancer { + /** + * Wrapper class that behaves like a `LoadBalancer` and also handles name + * resolution internally. + * @param target The address of the backend to connect to. + * @param channelControlHelper `ChannelControlHelper` instance provided by + * this load balancer's owner. + * @param defaultServiceConfig The default service configuration to be used + * if none is provided by the name resolver. A `null` value indicates + * that the default behavior should be the default unconfigured behavior. + * In practice, that means using the "pick first" load balancer + * implmentation + */ + constructor(target, channelControlHelper, channelOptions) { + this.target = target + this.channelControlHelper = channelControlHelper + this.channelOptions = channelOptions + this.latestChildState = channel_1.ConnectivityState.IDLE + this.latestChildPicker = new picker_1.QueuePicker(this) + /** + * This resolving load balancer's current connectivity state. + */ + this.currentState = channel_1.ConnectivityState.IDLE + /** + * The service config object from the last successful resolution, if + * available. A value of null indicates that we have not yet received a valid + * service config from the resolver. + */ + this.previousServiceConfig = null + /** + * Indicates whether we should attempt to resolve again after the backoff + * timer runs out. + */ + this.continueResolving = false + if (channelOptions['grpc.service_config']) { + this.defaultServiceConfig = service_config_1.validateServiceConfig( + JSON.parse(channelOptions['grpc.service_config']) + ) + } else { + this.defaultServiceConfig = { + loadBalancingConfig: [], + methodConfig: [] + } + } + this.updateState( + channel_1.ConnectivityState.IDLE, + new picker_1.QueuePicker(this) + ) + this.childLoadBalancer = new load_balancer_child_handler_1.ChildLoadBalancerHandler( + { + createSubchannel: channelControlHelper.createSubchannel.bind( + channelControlHelper + ), + requestReresolution: () => { + /* If the backoffTimeout is running, we're still backing off from + * making resolve requests, so we shouldn't make another one here. + * In that case, the backoff timer callback will call + * updateResolution */ + if (this.backoffTimeout.isRunning()) { + this.continueResolving = true + } else { + this.updateResolution() + } + }, + updateState: (newState, picker) => { + this.latestChildState = newState + this.latestChildPicker = picker + this.updateState(newState, picker) + } + } + ) + this.innerResolver = resolver_1.createResolver( + target, + { + onSuccessfulResolution: ( + addressList, + serviceConfig, + serviceConfigError, + attributes + ) => { + var _a + let workingServiceConfig = null + /* This first group of conditionals implements the algorithm described + * in https://github.com/grpc/proposal/blob/master/A21-service-config-error-handling.md + * in the section called "Behavior on receiving a new gRPC Config". + */ + if (serviceConfig === null) { + // Step 4 and 5 + if (serviceConfigError === null) { + // Step 5 + this.previousServiceConfig = null + workingServiceConfig = this.defaultServiceConfig + } else { + // Step 4 + if (this.previousServiceConfig === null) { + // Step 4.ii + this.handleResolutionFailure(serviceConfigError) + } else { + // Step 4.i + workingServiceConfig = this.previousServiceConfig + } + } + } else { + // Step 3 + workingServiceConfig = serviceConfig + this.previousServiceConfig = serviceConfig + } + const workingConfigList = + (_a = + workingServiceConfig === null || + workingServiceConfig === void 0 + ? void 0 + : workingServiceConfig.loadBalancingConfig) !== null && + _a !== void 0 + ? _a + : [] + if (workingConfigList.length === 0) { + workingConfigList.push({ + name: 'pick_first', + pick_first: {} + }) + } + const loadBalancingConfig = load_balancer_1.getFirstUsableConfig( + workingConfigList + ) + if (loadBalancingConfig === null) { + // There were load balancing configs but none are supported. This counts as a resolution failure + this.handleResolutionFailure({ + code: constants_1.Status.UNAVAILABLE, + details: + 'All load balancer options in service config are not compatible', + metadata: new metadata_1.Metadata() + }) + return + } + this.childLoadBalancer.updateAddressList( + addressList, + loadBalancingConfig, + attributes + ) + }, + onError: error => { + this.handleResolutionFailure(error) + } + }, + channelOptions + ) + this.backoffTimeout = new backoff_timeout_1.BackoffTimeout(() => { + if (this.continueResolving) { + this.updateResolution() + this.continueResolving = false + } else { + this.updateState(this.latestChildState, this.latestChildPicker) + } + }) + } + updateResolution() { + this.innerResolver.updateResolution() + if (this.currentState === channel_1.ConnectivityState.IDLE) { + this.updateState( + channel_1.ConnectivityState.CONNECTING, + new picker_1.QueuePicker(this) + ) + } + } + updateState(connectivityState, picker) { + trace( + uri_parser_1.uriToString(this.target) + + ' ' + + channel_1.ConnectivityState[this.currentState] + + ' -> ' + + channel_1.ConnectivityState[connectivityState] + ) + // Ensure that this.exitIdle() is called by the picker + if (connectivityState === channel_1.ConnectivityState.IDLE) { + picker = new picker_1.QueuePicker(this) + } + this.currentState = connectivityState + this.channelControlHelper.updateState(connectivityState, picker) + } + handleResolutionFailure(error) { + if (this.latestChildState === channel_1.ConnectivityState.IDLE) { + this.updateState( + channel_1.ConnectivityState.TRANSIENT_FAILURE, + new picker_1.UnavailablePicker(error) + ) + } + this.backoffTimeout.runOnce() + } + exitIdle() { + this.childLoadBalancer.exitIdle() + if (this.currentState === channel_1.ConnectivityState.IDLE) { + if (this.backoffTimeout.isRunning()) { + this.continueResolving = true + } else { + this.updateResolution() + } + this.updateState( + channel_1.ConnectivityState.CONNECTING, + new picker_1.QueuePicker(this) + ) + } + } + updateAddressList(addressList, lbConfig) { + throw new Error( + 'updateAddressList not supported on ResolvingLoadBalancer' + ) + } + resetBackoff() { + this.backoffTimeout.reset() + this.childLoadBalancer.resetBackoff() + } + destroy() { + this.childLoadBalancer.destroy() + this.updateState( + channel_1.ConnectivityState.SHUTDOWN, + new picker_1.UnavailablePicker() + ) + } + getTypeName() { + return 'resolving_load_balancer' + } + } + exports.ResolvingLoadBalancer = ResolvingLoadBalancer + //# sourceMappingURL=resolving-load-balancer.js.map + + /***/ + }, + + /***/ 62533: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /* + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.Http2ServerCallStream = exports.ServerDuplexStreamImpl = exports.ServerWritableStreamImpl = exports.ServerReadableStreamImpl = exports.ServerUnaryCallImpl = void 0 + const events_1 = __webpack_require__(28614) + const http2 = __webpack_require__(97565) + const stream_1 = __webpack_require__(92413) + const constants_1 = __webpack_require__(90634) + const metadata_1 = __webpack_require__(83665) + const stream_decoder_1 = __webpack_require__(16575) + const logging = __webpack_require__(35993) + const TRACER_NAME = 'server_call' + function trace(text) { + logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, text) + } + const GRPC_ACCEPT_ENCODING_HEADER = 'grpc-accept-encoding' + const GRPC_ENCODING_HEADER = 'grpc-encoding' + const GRPC_MESSAGE_HEADER = 'grpc-message' + const GRPC_STATUS_HEADER = 'grpc-status' + const GRPC_TIMEOUT_HEADER = 'grpc-timeout' + const DEADLINE_REGEX = /(\d{1,8})\s*([HMSmun])/ + const deadlineUnitsToMs = { + H: 3600000, + M: 60000, + S: 1000, + m: 1, + u: 0.001, + n: 0.000001 + } + const defaultResponseHeaders = { + // TODO(cjihrig): Remove these encoding headers from the default response + // once compression is integrated. + [GRPC_ACCEPT_ENCODING_HEADER]: 'identity', + [GRPC_ENCODING_HEADER]: 'identity', + [http2.constants.HTTP2_HEADER_STATUS]: http2.constants.HTTP_STATUS_OK, + [http2.constants.HTTP2_HEADER_CONTENT_TYPE]: 'application/grpc+proto' + } + const defaultResponseOptions = { + waitForTrailers: true + } + class ServerUnaryCallImpl extends events_1.EventEmitter { + constructor(call, metadata) { + super() + this.call = call + this.metadata = metadata + this.cancelled = false + this.request = null + this.call.setupSurfaceCall(this) + } + getPeer() { + return this.call.getPeer() + } + sendMetadata(responseMetadata) { + this.call.sendMetadata(responseMetadata) + } + } + exports.ServerUnaryCallImpl = ServerUnaryCallImpl + class ServerReadableStreamImpl extends stream_1.Readable { + constructor(call, metadata, deserialize) { + super({ objectMode: true }) + this.call = call + this.metadata = metadata + this.deserialize = deserialize + this.cancelled = false + this.call.setupSurfaceCall(this) + this.call.setupReadable(this) + } + _read(size) { + if (!this.call.consumeUnpushedMessages(this)) { + return + } + this.call.resume() + } + getPeer() { + return this.call.getPeer() + } + sendMetadata(responseMetadata) { + this.call.sendMetadata(responseMetadata) + } + } + exports.ServerReadableStreamImpl = ServerReadableStreamImpl + class ServerWritableStreamImpl extends stream_1.Writable { + constructor(call, metadata, serialize) { + super({ objectMode: true }) + this.call = call + this.metadata = metadata + this.serialize = serialize + this.cancelled = false + this.request = null + this.trailingMetadata = new metadata_1.Metadata() + this.call.setupSurfaceCall(this) + this.on('error', err => { + this.call.sendError(err) + this.end() + }) + } + getPeer() { + return this.call.getPeer() + } + sendMetadata(responseMetadata) { + this.call.sendMetadata(responseMetadata) + } + _write( + chunk, + encoding, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + callback + ) { + try { + const response = this.call.serializeMessage(chunk) + if (!this.call.write(response)) { + this.call.once('drain', callback) + return + } + } catch (err) { + err.code = constants_1.Status.INTERNAL + this.emit('error', err) + } + callback() + } + _final(callback) { + this.call.sendStatus({ + code: constants_1.Status.OK, + details: 'OK', + metadata: this.trailingMetadata + }) + callback(null) + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + end(metadata) { + if (metadata) { + this.trailingMetadata = metadata + } + super.end() + } + } + exports.ServerWritableStreamImpl = ServerWritableStreamImpl + class ServerDuplexStreamImpl extends stream_1.Duplex { + constructor(call, metadata, serialize, deserialize) { + super({ objectMode: true }) + this.call = call + this.metadata = metadata + this.serialize = serialize + this.deserialize = deserialize + this.cancelled = false + this.trailingMetadata = new metadata_1.Metadata() + this.call.setupSurfaceCall(this) + this.call.setupReadable(this) + this.on('error', err => { + this.call.sendError(err) + this.end() + }) + } + getPeer() { + return this.call.getPeer() + } + sendMetadata(responseMetadata) { + this.call.sendMetadata(responseMetadata) + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + end(metadata) { + if (metadata) { + this.trailingMetadata = metadata + } + super.end() + } + } + exports.ServerDuplexStreamImpl = ServerDuplexStreamImpl + ServerDuplexStreamImpl.prototype._read = + ServerReadableStreamImpl.prototype._read + ServerDuplexStreamImpl.prototype._write = + ServerWritableStreamImpl.prototype._write + ServerDuplexStreamImpl.prototype._final = + ServerWritableStreamImpl.prototype._final + ServerDuplexStreamImpl.prototype.end = + ServerWritableStreamImpl.prototype.end + // Internal class that wraps the HTTP2 request. + class Http2ServerCallStream extends events_1.EventEmitter { + constructor(stream, handler, options) { + super() + this.stream = stream + this.handler = handler + this.options = options + this.cancelled = false + this.deadline = setTimeout(() => {}, 0) + this.wantTrailers = false + this.metadataSent = false + this.canPush = false + this.isPushPending = false + this.bufferedMessages = [] + this.messagesToPush = [] + this.maxSendMessageSize = constants_1.DEFAULT_MAX_SEND_MESSAGE_LENGTH + this.maxReceiveMessageSize = + constants_1.DEFAULT_MAX_RECEIVE_MESSAGE_LENGTH + this.stream.once('error', err => { + /* We need an error handler to avoid uncaught error event exceptions, but + * there is nothing we can reasonably do here. Any error event should + * have a corresponding close event, which handles emitting the cancelled + * event. And the stream is now in a bad state, so we can't reasonably + * expect to be able to send an error over it. */ + }) + this.stream.once('close', () => { + var _a + trace( + 'Request to method ' + + ((_a = this.handler) === null || _a === void 0 + ? void 0 + : _a.path) + + ' stream closed with rstCode ' + + this.stream.rstCode + ) + this.cancelled = true + this.emit('cancelled', 'cancelled') + }) + this.stream.on('drain', () => { + this.emit('drain') + }) + if ('grpc.max_send_message_length' in options) { + this.maxSendMessageSize = options['grpc.max_send_message_length'] + } + if ('grpc.max_receive_message_length' in options) { + this.maxReceiveMessageSize = + options['grpc.max_receive_message_length'] + } + // Clear noop timer + clearTimeout(this.deadline) + } + checkCancelled() { + /* In some cases the stream can become destroyed before the close event + * fires. That creates a race condition that this check works around */ + if (this.stream.destroyed) { + this.cancelled = true + } + return this.cancelled + } + sendMetadata(customMetadata) { + if (this.checkCancelled()) { + return + } + if (this.metadataSent) { + return + } + this.metadataSent = true + const custom = customMetadata ? customMetadata.toHttp2Headers() : null + // TODO(cjihrig): Include compression headers. + const headers = Object.assign({}, defaultResponseHeaders, custom) + this.stream.respond(headers, defaultResponseOptions) + } + receiveMetadata(headers) { + const metadata = metadata_1.Metadata.fromHttp2Headers(headers) + // TODO(cjihrig): Receive compression metadata. + const timeoutHeader = metadata.get(GRPC_TIMEOUT_HEADER) + if (timeoutHeader.length > 0) { + const match = timeoutHeader[0].toString().match(DEADLINE_REGEX) + if (match === null) { + const err = new Error('Invalid deadline') + err.code = constants_1.Status.OUT_OF_RANGE + this.sendError(err) + return + } + const timeout = (+match[1] * deadlineUnitsToMs[match[2]]) | 0 + this.deadline = setTimeout(handleExpiredDeadline, timeout, this) + metadata.remove(GRPC_TIMEOUT_HEADER) + } + // Remove several headers that should not be propagated to the application + metadata.remove(http2.constants.HTTP2_HEADER_ACCEPT_ENCODING) + metadata.remove(http2.constants.HTTP2_HEADER_TE) + metadata.remove(http2.constants.HTTP2_HEADER_CONTENT_TYPE) + metadata.remove('grpc-encoding') + metadata.remove('grpc-accept-encoding') + return metadata + } + receiveUnaryMessage() { + return new Promise((resolve, reject) => { + const stream = this.stream + const chunks = [] + let totalLength = 0 + stream.on('data', data => { + chunks.push(data) + totalLength += data.byteLength + }) + stream.once('end', async () => { + try { + const requestBytes = Buffer.concat(chunks, totalLength) + if ( + this.maxReceiveMessageSize !== -1 && + requestBytes.length > this.maxReceiveMessageSize + ) { + this.sendError({ + code: constants_1.Status.RESOURCE_EXHAUSTED, + details: `Received message larger than max (${requestBytes.length} vs. ${this.maxReceiveMessageSize})` + }) + resolve() + } + resolve(this.deserializeMessage(requestBytes)) + } catch (err) { + err.code = constants_1.Status.INTERNAL + this.sendError(err) + resolve() + } + }) + }) + } + serializeMessage(value) { + const messageBuffer = this.handler.serialize(value) + // TODO(cjihrig): Call compression aware serializeMessage(). + const byteLength = messageBuffer.byteLength + const output = Buffer.allocUnsafe(byteLength + 5) + output.writeUInt8(0, 0) + output.writeUInt32BE(byteLength, 1) + messageBuffer.copy(output, 5) + return output + } + deserializeMessage(bytes) { + // TODO(cjihrig): Call compression aware deserializeMessage(). + const receivedMessage = bytes.slice(5) + return this.handler.deserialize(receivedMessage) + } + async sendUnaryMessage(err, value, metadata, flags) { + if (this.checkCancelled()) { + return + } + if (!metadata) { + metadata = new metadata_1.Metadata() + } + if (err) { + if (!Object.prototype.hasOwnProperty.call(err, 'metadata')) { + err.metadata = metadata + } + this.sendError(err) + return + } + try { + const response = this.serializeMessage(value) + this.write(response) + this.sendStatus({ + code: constants_1.Status.OK, + details: 'OK', + metadata + }) + } catch (err) { + err.code = constants_1.Status.INTERNAL + this.sendError(err) + } + } + sendStatus(statusObj) { + var _a + if (this.checkCancelled()) { + return + } + trace( + 'Request to method ' + + ((_a = this.handler) === null || _a === void 0 + ? void 0 + : _a.path) + + ' ended with status code: ' + + constants_1.Status[statusObj.code] + + ' details: ' + + statusObj.details + ) + clearTimeout(this.deadline) + if (!this.wantTrailers) { + this.wantTrailers = true + this.stream.once('wantTrailers', () => { + const trailersToSend = Object.assign( + { + [GRPC_STATUS_HEADER]: statusObj.code, + [GRPC_MESSAGE_HEADER]: encodeURI(statusObj.details) + }, + statusObj.metadata.toHttp2Headers() + ) + this.stream.sendTrailers(trailersToSend) + }) + this.sendMetadata() + this.stream.end() + } + } + sendError(error) { + if (this.checkCancelled()) { + return + } + const status = { + code: constants_1.Status.UNKNOWN, + details: 'message' in error ? error.message : 'Unknown Error', + metadata: + 'metadata' in error && error.metadata !== undefined + ? error.metadata + : new metadata_1.Metadata() + } + if ( + 'code' in error && + typeof error.code === 'number' && + Number.isInteger(error.code) + ) { + status.code = error.code + if ('details' in error && typeof error.details === 'string') { + status.details = error.details + } + } + this.sendStatus(status) + } + write(chunk) { + if (this.checkCancelled()) { + return + } + if ( + this.maxSendMessageSize !== -1 && + chunk.length > this.maxSendMessageSize + ) { + this.sendError({ + code: constants_1.Status.RESOURCE_EXHAUSTED, + details: `Sent message larger than max (${chunk.length} vs. ${this.maxSendMessageSize})` + }) + return + } + this.sendMetadata() + return this.stream.write(chunk) + } + resume() { + this.stream.resume() + } + setupSurfaceCall(call) { + this.once('cancelled', reason => { + call.cancelled = true + call.emit('cancelled', reason) + }) + } + setupReadable(readable) { + const decoder = new stream_decoder_1.StreamDecoder() + this.stream.on('data', async data => { + const messages = decoder.write(data) + for (const message of messages) { + if ( + this.maxReceiveMessageSize !== -1 && + message.length > this.maxReceiveMessageSize + ) { + this.sendError({ + code: constants_1.Status.RESOURCE_EXHAUSTED, + details: `Received message larger than max (${message.length} vs. ${this.maxReceiveMessageSize})` + }) + return + } + this.pushOrBufferMessage(readable, message) + } + }) + this.stream.once('end', () => { + this.pushOrBufferMessage(readable, null) + }) + } + consumeUnpushedMessages(readable) { + this.canPush = true + while (this.messagesToPush.length > 0) { + const nextMessage = this.messagesToPush.shift() + const canPush = readable.push(nextMessage) + if (nextMessage === null || canPush === false) { + this.canPush = false + break + } + } + return this.canPush + } + pushOrBufferMessage(readable, messageBytes) { + if (this.isPushPending) { + this.bufferedMessages.push(messageBytes) + } else { + this.pushMessage(readable, messageBytes) + } + } + async pushMessage(readable, messageBytes) { + if (messageBytes === null) { + if (this.canPush) { + readable.push(null) + } else { + this.messagesToPush.push(null) + } + return + } + this.isPushPending = true + try { + const deserialized = await this.deserializeMessage(messageBytes) + if (this.canPush) { + if (!readable.push(deserialized)) { + this.canPush = false + this.stream.pause() + } + } else { + this.messagesToPush.push(deserialized) + } + } catch (error) { + // Ignore any remaining messages when errors occur. + this.bufferedMessages.length = 0 + if ( + !( + 'code' in error && + typeof error.code === 'number' && + Number.isInteger(error.code) && + error.code >= constants_1.Status.OK && + error.code <= constants_1.Status.UNAUTHENTICATED + ) + ) { + // The error code is not a valid gRPC code so its being overwritten. + error.code = constants_1.Status.INTERNAL + } + readable.emit('error', error) + } + this.isPushPending = false + if (this.bufferedMessages.length > 0) { + this.pushMessage(readable, this.bufferedMessages.shift()) + } + } + getPeer() { + const socket = this.stream.session.socket + if (socket.remoteAddress) { + if (socket.remotePort) { + return `${socket.remoteAddress}:${socket.remotePort}` + } else { + return socket.remoteAddress + } + } else { + return 'unknown' + } + } + } + exports.Http2ServerCallStream = Http2ServerCallStream + function handleExpiredDeadline(call) { + const err = new Error('Deadline exceeded') + err.code = constants_1.Status.DEADLINE_EXCEEDED + call.sendError(err) + call.cancelled = true + call.emit('cancelled', 'deadline') + } + //# sourceMappingURL=server-call.js.map + + /***/ + }, + + /***/ 63828: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /* + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.ServerCredentials = void 0 + const tls_helpers_1 = __webpack_require__(86581) + class ServerCredentials { + static createInsecure() { + return new InsecureServerCredentials() + } + static createSsl( + rootCerts, + keyCertPairs, + checkClientCertificate = false + ) { + if (rootCerts !== null && !Buffer.isBuffer(rootCerts)) { + throw new TypeError('rootCerts must be null or a Buffer') + } + if (!Array.isArray(keyCertPairs)) { + throw new TypeError('keyCertPairs must be an array') + } + if (typeof checkClientCertificate !== 'boolean') { + throw new TypeError('checkClientCertificate must be a boolean') + } + const cert = [] + const key = [] + for (let i = 0; i < keyCertPairs.length; i++) { + const pair = keyCertPairs[i] + if (pair === null || typeof pair !== 'object') { + throw new TypeError(`keyCertPair[${i}] must be an object`) + } + if (!Buffer.isBuffer(pair.private_key)) { + throw new TypeError( + `keyCertPair[${i}].private_key must be a Buffer` + ) + } + if (!Buffer.isBuffer(pair.cert_chain)) { + throw new TypeError( + `keyCertPair[${i}].cert_chain must be a Buffer` + ) + } + cert.push(pair.cert_chain) + key.push(pair.private_key) + } + return new SecureServerCredentials({ + ca: rootCerts || tls_helpers_1.getDefaultRootsData() || undefined, + cert, + key, + requestCert: checkClientCertificate, + ciphers: tls_helpers_1.CIPHER_SUITES + }) + } + } + exports.ServerCredentials = ServerCredentials + class InsecureServerCredentials extends ServerCredentials { + _isSecure() { + return false + } + _getSettings() { + return null + } + } + class SecureServerCredentials extends ServerCredentials { + constructor(options) { + super() + this.options = options + } + _isSecure() { + return true + } + _getSettings() { + return this.options + } + } + //# sourceMappingURL=server-credentials.js.map + + /***/ + }, + + /***/ 33389: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /* + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.Server = void 0 + const http2 = __webpack_require__(97565) + const constants_1 = __webpack_require__(90634) + const metadata_1 = __webpack_require__(83665) + const server_call_1 = __webpack_require__(62533) + const resolver_1 = __webpack_require__(31594) + const logging = __webpack_require__(35993) + const subchannel_1 = __webpack_require__(84764) + const uri_parser_1 = __webpack_require__(65974) + const TRACER_NAME = 'server' + function trace(text) { + logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, text) + } + function noop() {} + function getUnimplementedStatusResponse(methodName) { + return { + code: constants_1.Status.UNIMPLEMENTED, + details: `The server does not implement the method ${methodName}`, + metadata: new metadata_1.Metadata() + } + } + function getDefaultHandler(handlerType, methodName) { + const unimplementedStatusResponse = getUnimplementedStatusResponse( + methodName + ) + switch (handlerType) { + case 'unary': + return (call, callback) => { + callback(unimplementedStatusResponse, null) + } + case 'clientStream': + return (call, callback) => { + callback(unimplementedStatusResponse, null) + } + case 'serverStream': + return call => { + call.emit('error', unimplementedStatusResponse) + } + case 'bidi': + return call => { + call.emit('error', unimplementedStatusResponse) + } + default: + throw new Error(`Invalid handlerType ${handlerType}`) + } + } + class Server { + constructor(options) { + this.http2ServerList = [] + this.handlers = new Map() + this.sessions = new Set() + this.started = false + this.options = options !== null && options !== void 0 ? options : {} + } + addProtoService() { + throw new Error('Not implemented. Use addService() instead') + } + addService(service, implementation) { + if (this.started === true) { + throw new Error("Can't add a service to a started server.") + } + if ( + service === null || + typeof service !== 'object' || + implementation === null || + typeof implementation !== 'object' + ) { + throw new Error('addService() requires two objects as arguments') + } + const serviceKeys = Object.keys(service) + if (serviceKeys.length === 0) { + throw new Error('Cannot add an empty service to a server') + } + serviceKeys.forEach(name => { + const attrs = service[name] + let methodType + if (attrs.requestStream) { + if (attrs.responseStream) { + methodType = 'bidi' + } else { + methodType = 'clientStream' + } + } else { + if (attrs.responseStream) { + methodType = 'serverStream' + } else { + methodType = 'unary' + } + } + let implFn = implementation[name] + let impl + if ( + implFn === undefined && + typeof attrs.originalName === 'string' + ) { + implFn = implementation[attrs.originalName] + } + if (implFn !== undefined) { + impl = implFn.bind(implementation) + } else { + impl = getDefaultHandler(methodType, name) + } + const success = this.register( + attrs.path, + impl, + attrs.responseSerialize, + attrs.requestDeserialize, + methodType + ) + if (success === false) { + throw new Error( + `Method handler for ${attrs.path} already provided.` + ) + } + }) + } + bind(port, creds) { + throw new Error('Not implemented. Use bindAsync() instead') + } + bindAsync(port, creds, callback) { + if (this.started === true) { + throw new Error('server is already started') + } + if (typeof port !== 'string') { + throw new TypeError('port must be a string') + } + if (creds === null || typeof creds !== 'object') { + throw new TypeError('creds must be an object') + } + if (typeof callback !== 'function') { + throw new TypeError('callback must be a function') + } + const initialPortUri = uri_parser_1.parseUri(port) + if (initialPortUri === null) { + throw new Error(`Could not parse port "${port}"`) + } + const portUri = resolver_1.mapUriDefaultScheme(initialPortUri) + if (portUri === null) { + throw new Error(`Could not get a default scheme for port "${port}"`) + } + const serverOptions = {} + if ('grpc.max_concurrent_streams' in this.options) { + serverOptions.settings = { + maxConcurrentStreams: this.options['grpc.max_concurrent_streams'] + } + } + const setupServer = () => { + let http2Server + if (creds._isSecure()) { + const secureServerOptions = Object.assign( + serverOptions, + creds._getSettings() + ) + http2Server = http2.createSecureServer(secureServerOptions) + } else { + http2Server = http2.createServer(serverOptions) + } + http2Server.setTimeout(0, noop) + this._setupHandlers(http2Server) + return http2Server + } + const bindSpecificPort = (addressList, portNum, previousCount) => { + if (addressList.length === 0) { + return Promise.resolve({ port: portNum, count: previousCount }) + } + return Promise.all( + addressList.map(address => { + trace( + 'Attempting to bind ' + + subchannel_1.subchannelAddressToString(address) + ) + let addr + if (subchannel_1.isTcpSubchannelAddress(address)) { + addr = { + host: address.host, + port: portNum + } + } else { + addr = address + } + const http2Server = setupServer() + return new Promise((resolve, reject) => { + function onError(err) { + resolve(err) + } + http2Server.once('error', onError) + http2Server.listen(addr, () => { + trace( + 'Successfully bound ' + + subchannel_1.subchannelAddressToString(address) + ) + this.http2ServerList.push(http2Server) + const boundAddress = http2Server.address() + if (typeof boundAddress === 'string') { + resolve(portNum) + } else { + resolve(boundAddress.port) + } + http2Server.removeListener('error', onError) + }) + }) + }) + ).then(results => { + let count = 0 + for (const result of results) { + if (typeof result === 'number') { + count += 1 + if (result !== portNum) { + throw new Error( + 'Invalid state: multiple port numbers added from single address' + ) + } + } + } + return { + port: portNum, + count: count + previousCount + } + }) + } + const bindWildcardPort = addressList => { + if (addressList.length === 0) { + return Promise.resolve({ port: 0, count: 0 }) + } + const address = addressList[0] + const http2Server = setupServer() + return new Promise((resolve, reject) => { + function onError(err) { + resolve(bindWildcardPort(addressList.slice(1))) + } + http2Server.once('error', onError) + http2Server.listen(address, () => { + this.http2ServerList.push(http2Server) + resolve( + bindSpecificPort( + addressList.slice(1), + http2Server.address().port, + 1 + ) + ) + http2Server.removeListener('error', onError) + }) + }) + } + const resolverListener = { + onSuccessfulResolution: ( + addressList, + serviceConfig, + serviceConfigError + ) => { + // We only want one resolution result. Discard all future results + resolverListener.onSuccessfulResolution = () => {} + if (addressList.length === 0) { + callback(new Error(`No addresses resolved for port ${port}`), 0) + return + } + let bindResultPromise + if (subchannel_1.isTcpSubchannelAddress(addressList[0])) { + if (addressList[0].port === 0) { + bindResultPromise = bindWildcardPort(addressList) + } else { + bindResultPromise = bindSpecificPort( + addressList, + addressList[0].port, + 0 + ) + } + } else { + // Use an arbitrary non-zero port for non-TCP addresses + bindResultPromise = bindSpecificPort(addressList, 1, 0) + } + bindResultPromise.then( + bindResult => { + if (bindResult.count === 0) { + const errorString = `No address added out of total ${addressList.length} resolved` + logging.log(constants_1.LogVerbosity.ERROR, errorString) + callback(new Error(errorString), 0) + } else { + if (bindResult.count < addressList.length) { + logging.log( + constants_1.LogVerbosity.INFO, + `WARNING Only ${bindResult.count} addresses added out of total ${addressList.length} resolved` + ) + } + callback(null, bindResult.port) + } + }, + error => { + const errorString = `No address added out of total ${addressList.length} resolved` + logging.log(constants_1.LogVerbosity.ERROR, errorString) + callback(new Error(errorString), 0) + } + ) + }, + onError: error => { + callback(new Error(error.details), 0) + } + } + const resolver = resolver_1.createResolver( + portUri, + resolverListener, + this.options + ) + resolver.updateResolution() + } + forceShutdown() { + // Close the server if it is still running. + for (const http2Server of this.http2ServerList) { + if (http2Server.listening) { + http2Server.close() + } + } + this.started = false + // Always destroy any available sessions. It's possible that one or more + // tryShutdown() calls are in progress. Don't wait on them to finish. + this.sessions.forEach(session => { + // Cast NGHTTP2_CANCEL to any because TypeScript doesn't seem to + // recognize destroy(code) as a valid signature. + // eslint-disable-next-line @typescript-eslint/no-explicit-any + session.destroy(http2.constants.NGHTTP2_CANCEL) + }) + this.sessions.clear() + } + register(name, handler, serialize, deserialize, type) { + if (this.handlers.has(name)) { + return false + } + this.handlers.set(name, { + func: handler, + serialize, + deserialize, + type, + path: name + }) + return true + } + start() { + if ( + this.http2ServerList.length === 0 || + this.http2ServerList.every( + http2Server => http2Server.listening !== true + ) + ) { + throw new Error('server must be bound in order to start') + } + if (this.started === true) { + throw new Error('server is already started') + } + this.started = true + } + tryShutdown(callback) { + let pendingChecks = 0 + function maybeCallback() { + pendingChecks-- + if (pendingChecks === 0) { + callback() + } + } + // Close the server if necessary. + this.started = false + for (const http2Server of this.http2ServerList) { + if (http2Server.listening) { + pendingChecks++ + http2Server.close(maybeCallback) + } + } + this.sessions.forEach(session => { + if (!session.closed) { + pendingChecks += 1 + session.close(maybeCallback) + } + }) + if (pendingChecks === 0) { + callback() + } + } + addHttp2Port() { + throw new Error('Not yet implemented') + } + _setupHandlers(http2Server) { + if (http2Server === null) { + return + } + http2Server.on('stream', (stream, headers) => { + const contentType = + headers[http2.constants.HTTP2_HEADER_CONTENT_TYPE] + if ( + typeof contentType !== 'string' || + !contentType.startsWith('application/grpc') + ) { + stream.respond( + { + [http2.constants.HTTP2_HEADER_STATUS]: + http2.constants.HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE + }, + { endStream: true } + ) + return + } + try { + const path = headers[http2.constants.HTTP2_HEADER_PATH] + const serverAddress = http2Server.address() + let serverAddressString = 'null' + if (serverAddress) { + if (typeof serverAddress === 'string') { + serverAddressString = serverAddress + } else { + serverAddressString = + serverAddress.address + ':' + serverAddress.port + } + } + trace( + 'Received call to method ' + + path + + ' at address ' + + serverAddressString + ) + const handler = this.handlers.get(path) + if (handler === undefined) { + trace( + 'No handler registered for method ' + + path + + '. Sending UNIMPLEMENTED status.' + ) + throw getUnimplementedStatusResponse(path) + } + const call = new server_call_1.Http2ServerCallStream( + stream, + handler, + this.options + ) + const metadata = call.receiveMetadata(headers) + switch (handler.type) { + case 'unary': + handleUnary(call, handler, metadata) + break + case 'clientStream': + handleClientStreaming(call, handler, metadata) + break + case 'serverStream': + handleServerStreaming(call, handler, metadata) + break + case 'bidi': + handleBidiStreaming(call, handler, metadata) + break + default: + throw new Error(`Unknown handler type: ${handler.type}`) + } + } catch (err) { + const call = new server_call_1.Http2ServerCallStream( + stream, + null, + this.options + ) + if (err.code === undefined) { + err.code = constants_1.Status.INTERNAL + } + call.sendError(err) + } + }) + http2Server.on('session', session => { + if (!this.started) { + session.destroy() + return + } + this.sessions.add(session) + session.on('close', () => { + this.sessions.delete(session) + }) + }) + } + } + exports.Server = Server + async function handleUnary(call, handler, metadata) { + const emitter = new server_call_1.ServerUnaryCallImpl(call, metadata) + const request = await call.receiveUnaryMessage() + if (request === undefined || call.cancelled) { + return + } + emitter.request = request + handler.func(emitter, (err, value, trailer, flags) => { + call.sendUnaryMessage(err, value, trailer, flags) + }) + } + function handleClientStreaming(call, handler, metadata) { + const stream = new server_call_1.ServerReadableStreamImpl( + call, + metadata, + handler.deserialize + ) + function respond(err, value, trailer, flags) { + stream.destroy() + call.sendUnaryMessage(err, value, trailer, flags) + } + if (call.cancelled) { + return + } + stream.on('error', respond) + handler.func(stream, respond) + } + async function handleServerStreaming(call, handler, metadata) { + const request = await call.receiveUnaryMessage() + if (request === undefined || call.cancelled) { + return + } + const stream = new server_call_1.ServerWritableStreamImpl( + call, + metadata, + handler.serialize + ) + stream.request = request + handler.func(stream) + } + function handleBidiStreaming(call, handler, metadata) { + const stream = new server_call_1.ServerDuplexStreamImpl( + call, + metadata, + handler.serialize, + handler.deserialize + ) + if (call.cancelled) { + return + } + handler.func(stream) + } + //# sourceMappingURL=server.js.map + + /***/ + }, + + /***/ 21761: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /* + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.extractAndSelectServiceConfig = exports.validateServiceConfig = void 0 + /* This file implements gRFC A2 and the service config spec: + * https://github.com/grpc/proposal/blob/master/A2-service-configs-in-dns.md + * https://github.com/grpc/grpc/blob/master/doc/service_config.md. Each + * function here takes an object with unknown structure and returns its + * specific object type if the input has the right structure, and throws an + * error otherwise. */ + /* The any type is purposely used here. All functions validate their input at + * runtime */ + /* eslint-disable @typescript-eslint/no-explicit-any */ + const lbconfig = __webpack_require__(43802) + const os = __webpack_require__(12087) + /** + * Recognizes a number with up to 9 digits after the decimal point, followed by + * an "s", representing a number of seconds. + */ + const TIMEOUT_REGEX = /^\d+(\.\d{1,9})?s$/ + /** + * Client language name used for determining whether this client matches a + * `ServiceConfigCanaryConfig`'s `clientLanguage` list. + */ + const CLIENT_LANGUAGE_STRING = 'node' + function validateName(obj) { + if (!('service' in obj) || typeof obj.service !== 'string') { + throw new Error('Invalid method config name: invalid service') + } + const result = { + service: obj.service + } + if ('method' in obj) { + if (typeof obj.method === 'string') { + result.method = obj.method + } else { + throw new Error('Invalid method config name: invalid method') + } + } + return result + } + function validateMethodConfig(obj) { + const result = { + name: [] + } + if (!('name' in obj) || !Array.isArray(obj.name)) { + throw new Error('Invalid method config: invalid name array') + } + for (const name of obj.name) { + result.name.push(validateName(name)) + } + if ('waitForReady' in obj) { + if (typeof obj.waitForReady !== 'boolean') { + throw new Error('Invalid method config: invalid waitForReady') + } + result.waitForReady = obj.waitForReady + } + if ('timeout' in obj) { + if ( + !(typeof obj.timeout === 'string') || + !TIMEOUT_REGEX.test(obj.timeout) + ) { + throw new Error('Invalid method config: invalid timeout') + } + result.timeout = obj.timeout + } + if ('maxRequestBytes' in obj) { + if (typeof obj.maxRequestBytes !== 'number') { + throw new Error('Invalid method config: invalid maxRequestBytes') + } + result.maxRequestBytes = obj.maxRequestBytes + } + if ('maxResponseBytes' in obj) { + if (typeof obj.maxResponseBytes !== 'number') { + throw new Error('Invalid method config: invalid maxRequestBytes') + } + result.maxResponseBytes = obj.maxResponseBytes + } + return result + } + function validateServiceConfig(obj) { + const result = { + loadBalancingConfig: [], + methodConfig: [] + } + if ('loadBalancingPolicy' in obj) { + if (typeof obj.loadBalancingPolicy === 'string') { + result.loadBalancingPolicy = obj.loadBalancingPolicy + } else { + throw new Error( + 'Invalid service config: invalid loadBalancingPolicy' + ) + } + } + if ('loadBalancingConfig' in obj) { + if (Array.isArray(obj.loadBalancingConfig)) { + for (const config of obj.loadBalancingConfig) { + result.loadBalancingConfig.push(lbconfig.validateConfig(config)) + } + } else { + throw new Error( + 'Invalid service config: invalid loadBalancingConfig' + ) + } + } + if ('methodConfig' in obj) { + if (Array.isArray(obj.methodConfig)) { + for (const methodConfig of obj.methodConfig) { + result.methodConfig.push(validateMethodConfig(methodConfig)) + } + } + } + // Validate method name uniqueness + const seenMethodNames = [] + for (const methodConfig of result.methodConfig) { + for (const name of methodConfig.name) { + for (const seenName of seenMethodNames) { + if ( + name.service === seenName.service && + name.method === seenName.method + ) { + throw new Error( + `Invalid service config: duplicate name ${name.service}/${name.method}` + ) + } + } + seenMethodNames.push(name) + } + } + return result + } + exports.validateServiceConfig = validateServiceConfig + function validateCanaryConfig(obj) { + if (!('serviceConfig' in obj)) { + throw new Error( + 'Invalid service config choice: missing service config' + ) + } + const result = { + serviceConfig: validateServiceConfig(obj.serviceConfig) + } + if ('clientLanguage' in obj) { + if (Array.isArray(obj.clientLanguage)) { + result.clientLanguage = [] + for (const lang of obj.clientLanguage) { + if (typeof lang === 'string') { + result.clientLanguage.push(lang) + } else { + throw new Error( + 'Invalid service config choice: invalid clientLanguage' + ) + } + } + } else { + throw new Error( + 'Invalid service config choice: invalid clientLanguage' + ) + } + } + if ('clientHostname' in obj) { + if (Array.isArray(obj.clientHostname)) { + result.clientHostname = [] + for (const lang of obj.clientHostname) { + if (typeof lang === 'string') { + result.clientHostname.push(lang) + } else { + throw new Error( + 'Invalid service config choice: invalid clientHostname' + ) + } + } + } else { + throw new Error( + 'Invalid service config choice: invalid clientHostname' + ) + } + } + if ('percentage' in obj) { + if ( + typeof obj.percentage === 'number' && + 0 <= obj.percentage && + obj.percentage <= 100 + ) { + result.percentage = obj.percentage + } else { + throw new Error('Invalid service config choice: invalid percentage') + } + } + // Validate that no unexpected fields are present + const allowedFields = [ + 'clientLanguage', + 'percentage', + 'clientHostname', + 'serviceConfig' + ] + for (const field in obj) { + if (!allowedFields.includes(field)) { + throw new Error( + `Invalid service config choice: unexpected field ${field}` + ) + } + } + return result + } + function validateAndSelectCanaryConfig(obj, percentage) { + if (!Array.isArray(obj)) { + throw new Error('Invalid service config list') + } + for (const config of obj) { + const validatedConfig = validateCanaryConfig(config) + /* For each field, we check if it is present, then only discard the + * config if the field value does not match the current client */ + if ( + typeof validatedConfig.percentage === 'number' && + percentage > validatedConfig.percentage + ) { + continue + } + if (Array.isArray(validatedConfig.clientHostname)) { + let hostnameMatched = false + for (const hostname of validatedConfig.clientHostname) { + if (hostname === os.hostname()) { + hostnameMatched = true + } + } + if (!hostnameMatched) { + continue + } + } + if (Array.isArray(validatedConfig.clientLanguage)) { + let languageMatched = false + for (const language of validatedConfig.clientLanguage) { + if (language === CLIENT_LANGUAGE_STRING) { + languageMatched = true + } + } + if (!languageMatched) { + continue + } + } + return validatedConfig.serviceConfig + } + throw new Error('No matching service config found') + } + /** + * Find the "grpc_config" record among the TXT records, parse its value as JSON, validate its contents, + * and select a service config with selection fields that all match this client. Most of these steps + * can fail with an error; the caller must handle any errors thrown this way. + * @param txtRecord The TXT record array that is output from a successful call to dns.resolveTxt + * @param percentage A number chosen from the range [0, 100) that is used to select which config to use + * @return The service configuration to use, given the percentage value, or null if the service config + * data has a valid format but none of the options match the current client. + */ + function extractAndSelectServiceConfig(txtRecord, percentage) { + for (const record of txtRecord) { + if (record.length > 0 && record[0].startsWith('grpc_config=')) { + /* Treat the list of strings in this record as a single string and remove + * "grpc_config=" from the beginning. The rest should be a JSON string */ + const recordString = record + .join('') + .substring('grpc_config='.length) + const recordJson = JSON.parse(recordString) + return validateAndSelectCanaryConfig(recordJson, percentage) + } + } + return null + } + exports.extractAndSelectServiceConfig = extractAndSelectServiceConfig + //# sourceMappingURL=service-config.js.map + + /***/ + }, + + /***/ 73155: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + /* + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.StatusBuilder = void 0 + /** + * A builder for gRPC status objects. + */ + class StatusBuilder { + constructor() { + this.code = null + this.details = null + this.metadata = null + } + /** + * Adds a status code to the builder. + */ + withCode(code) { + this.code = code + return this + } + /** + * Adds details to the builder. + */ + withDetails(details) { + this.details = details + return this + } + /** + * Adds metadata to the builder. + */ + withMetadata(metadata) { + this.metadata = metadata + return this + } + /** + * Builds the status object. + */ + build() { + const status = {} + if (this.code !== null) { + status.code = this.code + } + if (this.details !== null) { + status.details = this.details + } + if (this.metadata !== null) { + status.metadata = this.metadata + } + return status + } + } + exports.StatusBuilder = StatusBuilder + //# sourceMappingURL=status-builder.js.map + + /***/ + }, + + /***/ 16575: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + /* + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.StreamDecoder = void 0 + var ReadState + ;(function (ReadState) { + ReadState[(ReadState['NO_DATA'] = 0)] = 'NO_DATA' + ReadState[(ReadState['READING_SIZE'] = 1)] = 'READING_SIZE' + ReadState[(ReadState['READING_MESSAGE'] = 2)] = 'READING_MESSAGE' + })(ReadState || (ReadState = {})) + class StreamDecoder { + constructor() { + this.readState = ReadState.NO_DATA + this.readCompressFlag = Buffer.alloc(1) + this.readPartialSize = Buffer.alloc(4) + this.readSizeRemaining = 4 + this.readMessageSize = 0 + this.readPartialMessage = [] + this.readMessageRemaining = 0 + } + write(data) { + let readHead = 0 + let toRead + const result = [] + while (readHead < data.length) { + switch (this.readState) { + case ReadState.NO_DATA: + this.readCompressFlag = data.slice(readHead, readHead + 1) + readHead += 1 + this.readState = ReadState.READING_SIZE + this.readPartialSize.fill(0) + this.readSizeRemaining = 4 + this.readMessageSize = 0 + this.readMessageRemaining = 0 + this.readPartialMessage = [] + break + case ReadState.READING_SIZE: + toRead = Math.min( + data.length - readHead, + this.readSizeRemaining + ) + data.copy( + this.readPartialSize, + 4 - this.readSizeRemaining, + readHead, + readHead + toRead + ) + this.readSizeRemaining -= toRead + readHead += toRead + // readSizeRemaining >=0 here + if (this.readSizeRemaining === 0) { + this.readMessageSize = this.readPartialSize.readUInt32BE(0) + this.readMessageRemaining = this.readMessageSize + if (this.readMessageRemaining > 0) { + this.readState = ReadState.READING_MESSAGE + } else { + const message = Buffer.concat( + [this.readCompressFlag, this.readPartialSize], + 5 + ) + this.readState = ReadState.NO_DATA + result.push(message) + } + } + break + case ReadState.READING_MESSAGE: + toRead = Math.min( + data.length - readHead, + this.readMessageRemaining + ) + this.readPartialMessage.push( + data.slice(readHead, readHead + toRead) + ) + this.readMessageRemaining -= toRead + readHead += toRead + // readMessageRemaining >=0 here + if (this.readMessageRemaining === 0) { + // At this point, we have read a full message + const framedMessageBuffers = [ + this.readCompressFlag, + this.readPartialSize + ].concat(this.readPartialMessage) + const framedMessage = Buffer.concat( + framedMessageBuffers, + this.readMessageSize + 5 + ) + this.readState = ReadState.NO_DATA + result.push(framedMessage) + } + break + default: + throw new Error('Unexpected read state') + } + } + return result + } + } + exports.StreamDecoder = StreamDecoder + //# sourceMappingURL=stream-decoder.js.map + + /***/ + }, + + /***/ 39780: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /* + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.getSubchannelPool = exports.SubchannelPool = void 0 + const channel_options_1 = __webpack_require__(99810) + const subchannel_1 = __webpack_require__(84764) + const uri_parser_1 = __webpack_require__(65974) + // 10 seconds in milliseconds. This value is arbitrary. + /** + * The amount of time in between checks for dropping subchannels that have no + * other references + */ + const REF_CHECK_INTERVAL = 10000 + class SubchannelPool { + /** + * A pool of subchannels use for making connections. Subchannels with the + * exact same parameters will be reused. + * @param global If true, this is the global subchannel pool. Otherwise, it + * is the pool for a single channel. + */ + constructor(global) { + this.global = global + this.pool = Object.create(null) + /** + * A timer of a task performing a periodic subchannel cleanup. + */ + this.cleanupTimer = null + } + /** + * Unrefs all unused subchannels and cancels the cleanup task if all + * subchannels have been unrefed. + */ + unrefUnusedSubchannels() { + let allSubchannelsUnrefed = true + /* These objects are created with Object.create(null), so they do not + * have a prototype, which means that for (... in ...) loops over them + * do not need to be filtered */ + // eslint-disable-disable-next-line:forin + for (const channelTarget in this.pool) { + const subchannelObjArray = this.pool[channelTarget] + const refedSubchannels = subchannelObjArray.filter( + value => !value.subchannel.unrefIfOneRef() + ) + if (refedSubchannels.length > 0) { + allSubchannelsUnrefed = false + } + /* For each subchannel in the pool, try to unref it if it has + * exactly one ref (which is the ref from the pool itself). If that + * does happen, remove the subchannel from the pool */ + this.pool[channelTarget] = refedSubchannels + } + /* Currently we do not delete keys with empty values. If that results + * in significant memory usage we should change it. */ + // Cancel the cleanup task if all subchannels have been unrefed. + if (allSubchannelsUnrefed && this.cleanupTimer !== null) { + clearInterval(this.cleanupTimer) + this.cleanupTimer = null + } + } + /** + * Ensures that the cleanup task is spawned. + */ + ensureCleanupTask() { + var _a, _b + if (this.global && this.cleanupTimer === null) { + this.cleanupTimer = setInterval(() => { + this.unrefUnusedSubchannels() + }, REF_CHECK_INTERVAL) + // Unref because this timer should not keep the event loop running. + // Call unref only if it exists to address electron/electron#21162 + ;(_b = (_a = this.cleanupTimer).unref) === null || _b === void 0 + ? void 0 + : _b.call(_a) + } + } + /** + * Get a subchannel if one already exists with exactly matching parameters. + * Otherwise, create and save a subchannel with those parameters. + * @param channelTarget + * @param subchannelTarget + * @param channelArguments + * @param channelCredentials + */ + getOrCreateSubchannel( + channelTargetUri, + subchannelTarget, + channelArguments, + channelCredentials + ) { + this.ensureCleanupTask() + const channelTarget = uri_parser_1.uriToString(channelTargetUri) + if (channelTarget in this.pool) { + const subchannelObjArray = this.pool[channelTarget] + for (const subchannelObj of subchannelObjArray) { + if ( + subchannel_1.subchannelAddressEqual( + subchannelTarget, + subchannelObj.subchannelAddress + ) && + channel_options_1.channelOptionsEqual( + channelArguments, + subchannelObj.channelArguments + ) && + channelCredentials._equals(subchannelObj.channelCredentials) + ) { + return subchannelObj.subchannel + } + } + } + // If we get here, no matching subchannel was found + const subchannel = new subchannel_1.Subchannel( + channelTargetUri, + subchannelTarget, + channelArguments, + channelCredentials + ) + if (!(channelTarget in this.pool)) { + this.pool[channelTarget] = [] + } + this.pool[channelTarget].push({ + subchannelAddress: subchannelTarget, + channelArguments, + channelCredentials, + subchannel + }) + if (this.global) { + subchannel.ref() + } + return subchannel + } + } + exports.SubchannelPool = SubchannelPool + const globalSubchannelPool = new SubchannelPool(true) + /** + * Get either the global subchannel pool, or a new subchannel pool. + * @param global + */ + function getSubchannelPool(global) { + if (global) { + return globalSubchannelPool + } else { + return new SubchannelPool(false) + } + } + exports.getSubchannelPool = getSubchannelPool + //# sourceMappingURL=subchannel-pool.js.map + + /***/ + }, + + /***/ 84764: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /* + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.Subchannel = exports.subchannelAddressToString = exports.subchannelAddressEqual = exports.isTcpSubchannelAddress = void 0 + const http2 = __webpack_require__(97565) + const tls_1 = __webpack_require__(4016) + const channel_1 = __webpack_require__(13860) + const backoff_timeout_1 = __webpack_require__(34186) + const resolver_1 = __webpack_require__(31594) + const logging = __webpack_require__(35993) + const constants_1 = __webpack_require__(90634) + const http_proxy_1 = __webpack_require__(24000) + const net = __webpack_require__(11631) + const uri_parser_1 = __webpack_require__(65974) + const clientVersion = __webpack_require__(68160) /* .version */.i8 + const TRACER_NAME = 'subchannel' + function trace(text) { + logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, text) + } + const MIN_CONNECT_TIMEOUT_MS = 20000 + const INITIAL_BACKOFF_MS = 1000 + const BACKOFF_MULTIPLIER = 1.6 + const MAX_BACKOFF_MS = 120000 + const BACKOFF_JITTER = 0.2 + /* setInterval and setTimeout only accept signed 32 bit integers. JS doesn't + * have a constant for the max signed 32 bit integer, so this is a simple way + * to calculate it */ + const KEEPALIVE_MAX_TIME_MS = ~(1 << 31) + const KEEPALIVE_TIMEOUT_MS = 20000 + const { + HTTP2_HEADER_AUTHORITY, + HTTP2_HEADER_CONTENT_TYPE, + HTTP2_HEADER_METHOD, + HTTP2_HEADER_PATH, + HTTP2_HEADER_TE, + HTTP2_HEADER_USER_AGENT + } = http2.constants + /** + * Get a number uniformly at random in the range [min, max) + * @param min + * @param max + */ + function uniformRandom(min, max) { + return Math.random() * (max - min) + min + } + const tooManyPingsData = Buffer.from('too_many_pings', 'ascii') + function isTcpSubchannelAddress(address) { + return 'port' in address + } + exports.isTcpSubchannelAddress = isTcpSubchannelAddress + function subchannelAddressEqual(address1, address2) { + if (isTcpSubchannelAddress(address1)) { + return ( + isTcpSubchannelAddress(address2) && + address1.host === address2.host && + address1.port === address2.port + ) + } else { + return ( + !isTcpSubchannelAddress(address2) && address1.path === address2.path + ) + } + } + exports.subchannelAddressEqual = subchannelAddressEqual + function subchannelAddressToString(address) { + if (isTcpSubchannelAddress(address)) { + return address.host + ':' + address.port + } else { + return address.path + } + } + exports.subchannelAddressToString = subchannelAddressToString + class Subchannel { + /** + * A class representing a connection to a single backend. + * @param channelTarget The target string for the channel as a whole + * @param subchannelAddress The address for the backend that this subchannel + * will connect to + * @param options The channel options, plus any specific subchannel options + * for this subchannel + * @param credentials The channel credentials used to establish this + * connection + */ + constructor(channelTarget, subchannelAddress, options, credentials) { + this.channelTarget = channelTarget + this.subchannelAddress = subchannelAddress + this.options = options + this.credentials = credentials + /** + * The subchannel's current connectivity state. Invariant: `session` === `null` + * if and only if `connectivityState` is IDLE or TRANSIENT_FAILURE. + */ + this.connectivityState = channel_1.ConnectivityState.IDLE + /** + * The underlying http2 session used to make requests. + */ + this.session = null + /** + * Indicates that the subchannel should transition from TRANSIENT_FAILURE to + * CONNECTING instead of IDLE when the backoff timeout ends. + */ + this.continueConnecting = false + /** + * A list of listener functions that will be called whenever the connectivity + * state changes. Will be modified by `addConnectivityStateListener` and + * `removeConnectivityStateListener` + */ + this.stateListeners = [] + /** + * A list of listener functions that will be called when the underlying + * socket disconnects. Used for ending active calls with an UNAVAILABLE + * status. + */ + this.disconnectListeners = [] + /** + * The amount of time in between sending pings + */ + this.keepaliveTimeMs = KEEPALIVE_MAX_TIME_MS + /** + * The amount of time to wait for an acknowledgement after sending a ping + */ + this.keepaliveTimeoutMs = KEEPALIVE_TIMEOUT_MS + /** + * Tracks calls with references to this subchannel + */ + this.callRefcount = 0 + /** + * Tracks channels and subchannel pools with references to this subchannel + */ + this.refcount = 0 + // Build user-agent string. + this.userAgent = [ + options['grpc.primary_user_agent'], + `grpc-node-js/${clientVersion}`, + options['grpc.secondary_user_agent'] + ] + .filter(e => e) + .join(' ') // remove falsey values first + if ('grpc.keepalive_time_ms' in options) { + this.keepaliveTimeMs = options['grpc.keepalive_time_ms'] + } + if ('grpc.keepalive_timeout_ms' in options) { + this.keepaliveTimeoutMs = options['grpc.keepalive_timeout_ms'] + } + this.keepaliveIntervalId = setTimeout(() => {}, 0) + clearTimeout(this.keepaliveIntervalId) + this.keepaliveTimeoutId = setTimeout(() => {}, 0) + clearTimeout(this.keepaliveTimeoutId) + const backoffOptions = { + initialDelay: options['grpc.initial_reconnect_backoff_ms'], + maxDelay: options['grpc.max_reconnect_backoff_ms'] + } + this.backoffTimeout = new backoff_timeout_1.BackoffTimeout(() => { + this.handleBackoffTimer() + }, backoffOptions) + this.subchannelAddressString = subchannelAddressToString( + subchannelAddress + ) + } + handleBackoffTimer() { + if (this.continueConnecting) { + this.transitionToState( + [channel_1.ConnectivityState.TRANSIENT_FAILURE], + channel_1.ConnectivityState.CONNECTING + ) + } else { + this.transitionToState( + [channel_1.ConnectivityState.TRANSIENT_FAILURE], + channel_1.ConnectivityState.IDLE + ) + } + } + /** + * Start a backoff timer with the current nextBackoff timeout + */ + startBackoff() { + this.backoffTimeout.runOnce() + } + stopBackoff() { + this.backoffTimeout.stop() + this.backoffTimeout.reset() + } + sendPing() { + this.keepaliveTimeoutId = setTimeout(() => { + this.transitionToState( + [channel_1.ConnectivityState.READY], + channel_1.ConnectivityState.IDLE + ) + }, this.keepaliveTimeoutMs) + this.session.ping((err, duration, payload) => { + clearTimeout(this.keepaliveTimeoutId) + }) + } + startKeepalivePings() { + this.keepaliveIntervalId = setInterval(() => { + this.sendPing() + }, this.keepaliveTimeMs) + this.sendPing() + } + stopKeepalivePings() { + clearInterval(this.keepaliveIntervalId) + clearTimeout(this.keepaliveTimeoutId) + } + createSession(proxyConnectionResult) { + var _a, _b, _c + const targetAuthority = resolver_1.getDefaultAuthority( + (_a = proxyConnectionResult.realTarget) !== null && _a !== void 0 + ? _a + : this.channelTarget + ) + let connectionOptions = this.credentials._getConnectionOptions() || {} + let addressScheme = 'http://' + if ('secureContext' in connectionOptions) { + addressScheme = 'https://' + // If provided, the value of grpc.ssl_target_name_override should be used + // to override the target hostname when checking server identity. + // This option is used for testing only. + if (this.options['grpc.ssl_target_name_override']) { + const sslTargetNameOverride = this.options[ + 'grpc.ssl_target_name_override' + ] + connectionOptions.checkServerIdentity = (host, cert) => { + return tls_1.checkServerIdentity(sslTargetNameOverride, cert) + } + connectionOptions.servername = sslTargetNameOverride + } else { + const authorityHostname = + (_c = + (_b = uri_parser_1.splitHostPort(targetAuthority)) === null || + _b === void 0 + ? void 0 + : _b.host) !== null && _c !== void 0 + ? _c + : 'localhost' + // We want to always set servername to support SNI + connectionOptions.servername = authorityHostname + } + if (proxyConnectionResult.socket) { + /* This is part of the workaround for + * https://github.com/nodejs/node/issues/32922. Without that bug, + * proxyConnectionResult.socket would always be a plaintext socket and + * this would say + * connectionOptions.socket = proxyConnectionResult.socket; */ + connectionOptions.createConnection = (authority, option) => { + return proxyConnectionResult.socket + } + } + } else { + /* In all but the most recent versions of Node, http2.connect does not use + * the options when establishing plaintext connections, so we need to + * establish that connection explicitly. */ + connectionOptions.createConnection = (authority, option) => { + if (proxyConnectionResult.socket) { + return proxyConnectionResult.socket + } else { + /* net.NetConnectOpts is declared in a way that is more restrictive + * than what net.connect will actually accept, so we use the type + * assertion to work around that. */ + return net.connect(this.subchannelAddress) + } + } + } + connectionOptions = Object.assign( + Object.assign({}, connectionOptions), + this.subchannelAddress + ) + /* http2.connect uses the options here: + * https://github.com/nodejs/node/blob/70c32a6d190e2b5d7b9ff9d5b6a459d14e8b7d59/lib/internal/http2/core.js#L3028-L3036 + * The spread operator overides earlier values with later ones, so any port + * or host values in the options will be used rather than any values extracted + * from the first argument. In addition, the path overrides the host and port, + * as documented for plaintext connections here: + * https://nodejs.org/api/net.html#net_socket_connect_options_connectlistener + * and for TLS connections here: + * https://nodejs.org/api/tls.html#tls_tls_connect_options_callback. In + * earlier versions of Node, http2.connect passes these options to + * tls.connect but not net.connect, so in the insecure case we still need + * to set the createConnection option above to create the connection + * explicitly. We cannot do that in the TLS case because http2.connect + * passes necessary additional options to tls.connect. + * The first argument just needs to be parseable as a URL and the scheme + * determines whether the connection will be established over TLS or not. + */ + const session = http2.connect( + addressScheme + targetAuthority, + connectionOptions + ) + this.session = session + session.unref() + /* For all of these events, check if the session at the time of the event + * is the same one currently attached to this subchannel, to ensure that + * old events from previous connection attempts cannot cause invalid state + * transitions. */ + session.once('connect', () => { + if (this.session === session) { + this.transitionToState( + [channel_1.ConnectivityState.CONNECTING], + channel_1.ConnectivityState.READY + ) + } + }) + session.once('close', () => { + if (this.session === session) { + this.transitionToState( + [channel_1.ConnectivityState.CONNECTING], + channel_1.ConnectivityState.TRANSIENT_FAILURE + ) + /* Transitioning directly to IDLE here should be OK because we are not + * doing any backoff, because a connection was established at some + * point */ + this.transitionToState( + [channel_1.ConnectivityState.READY], + channel_1.ConnectivityState.IDLE + ) + } + }) + session.once('goaway', (errorCode, lastStreamID, opaqueData) => { + if (this.session === session) { + /* See the last paragraph of + * https://github.com/grpc/proposal/blob/master/A8-client-side-keepalive.md#basic-keepalive */ + if ( + errorCode === http2.constants.NGHTTP2_ENHANCE_YOUR_CALM && + opaqueData.equals(tooManyPingsData) + ) { + logging.log( + constants_1.LogVerbosity.ERROR, + `Connection to ${this.channelTarget} rejected by server because of excess pings` + ) + this.keepaliveTimeMs = Math.min( + 2 * this.keepaliveTimeMs, + KEEPALIVE_MAX_TIME_MS + ) + } + trace( + this.subchannelAddressString + + ' connection closed by GOAWAY with code ' + + errorCode + ) + this.transitionToState( + [ + channel_1.ConnectivityState.CONNECTING, + channel_1.ConnectivityState.READY + ], + channel_1.ConnectivityState.IDLE + ) + } + }) + session.once('error', error => { + /* Do nothing here. Any error should also trigger a close event, which is + * where we want to handle that. */ + trace( + this.subchannelAddressString + + ' connection closed with error ' + + error.message + ) + }) + } + startConnectingInternal() { + var _a, _b + /* Pass connection options through to the proxy so that it's able to + * upgrade it's connection to support tls if needed. + * This is a workaround for https://github.com/nodejs/node/issues/32922 + * See https://github.com/grpc/grpc-node/pull/1369 for more info. */ + const connectionOptions = + this.credentials._getConnectionOptions() || {} + if ('secureContext' in connectionOptions) { + connectionOptions.ALPNProtocols = ['h2'] + // If provided, the value of grpc.ssl_target_name_override should be used + // to override the target hostname when checking server identity. + // This option is used for testing only. + if (this.options['grpc.ssl_target_name_override']) { + const sslTargetNameOverride = this.options[ + 'grpc.ssl_target_name_override' + ] + connectionOptions.checkServerIdentity = (host, cert) => { + return tls_1.checkServerIdentity(sslTargetNameOverride, cert) + } + connectionOptions.servername = sslTargetNameOverride + } else { + if ('grpc.http_connect_target' in this.options) { + /* This is more or less how servername will be set in createSession + * if a connection is successfully established through the proxy. + * If the proxy is not used, these connectionOptions are discarded + * anyway */ + const targetPath = resolver_1.getDefaultAuthority( + (_a = uri_parser_1.parseUri( + this.options['grpc.http_connect_target'] + )) !== null && _a !== void 0 + ? _a + : { + path: 'localhost' + } + ) + const hostPort = uri_parser_1.splitHostPort(targetPath) + connectionOptions.servername = + (_b = + hostPort === null || hostPort === void 0 + ? void 0 + : hostPort.host) !== null && _b !== void 0 + ? _b + : targetPath + } + } + } + http_proxy_1 + .getProxiedConnection( + this.subchannelAddress, + this.options, + connectionOptions + ) + .then( + result => { + this.createSession(result) + }, + reason => { + this.transitionToState( + [channel_1.ConnectivityState.CONNECTING], + channel_1.ConnectivityState.TRANSIENT_FAILURE + ) + } + ) + } + /** + * Initiate a state transition from any element of oldStates to the new + * state. If the current connectivityState is not in oldStates, do nothing. + * @param oldStates The set of states to transition from + * @param newState The state to transition to + * @returns True if the state changed, false otherwise + */ + transitionToState(oldStates, newState) { + if (oldStates.indexOf(this.connectivityState) === -1) { + return false + } + trace( + this.subchannelAddressString + + ' ' + + channel_1.ConnectivityState[this.connectivityState] + + ' -> ' + + channel_1.ConnectivityState[newState] + ) + const previousState = this.connectivityState + this.connectivityState = newState + switch (newState) { + case channel_1.ConnectivityState.READY: + this.stopBackoff() + this.session.socket.once('close', () => { + for (const listener of this.disconnectListeners) { + listener() + } + }) + break + case channel_1.ConnectivityState.CONNECTING: + this.startBackoff() + this.startConnectingInternal() + this.continueConnecting = false + break + case channel_1.ConnectivityState.TRANSIENT_FAILURE: + if (this.session) { + this.session.close() + } + this.session = null + this.stopKeepalivePings() + /* If the backoff timer has already ended by the time we get to the + * TRANSIENT_FAILURE state, we want to immediately transition out of + * TRANSIENT_FAILURE as though the backoff timer is ending right now */ + if (!this.backoffTimeout.isRunning()) { + process.nextTick(() => { + this.handleBackoffTimer() + }) + } + break + case channel_1.ConnectivityState.IDLE: + if (this.session) { + this.session.close() + } + this.session = null + this.stopKeepalivePings() + break + default: + throw new Error( + `Invalid state: unknown ConnectivityState ${newState}` + ) + } + /* We use a shallow copy of the stateListeners array in case a listener + * is removed during this iteration */ + for (const listener of [...this.stateListeners]) { + listener(this, previousState, newState) + } + return true + } + /** + * Check if the subchannel associated with zero calls and with zero channels. + * If so, shut it down. + */ + checkBothRefcounts() { + /* If no calls, channels, or subchannel pools have any more references to + * this subchannel, we can be sure it will never be used again. */ + if (this.callRefcount === 0 && this.refcount === 0) { + this.transitionToState( + [ + channel_1.ConnectivityState.CONNECTING, + channel_1.ConnectivityState.IDLE, + channel_1.ConnectivityState.READY + ], + channel_1.ConnectivityState.TRANSIENT_FAILURE + ) + } + } + callRef() { + trace( + this.subchannelAddressString + + ' callRefcount ' + + this.callRefcount + + ' -> ' + + (this.callRefcount + 1) + ) + if (this.callRefcount === 0) { + if (this.session) { + this.session.ref() + } + this.startKeepalivePings() + } + this.callRefcount += 1 + } + callUnref() { + trace( + this.subchannelAddressString + + ' callRefcount ' + + this.callRefcount + + ' -> ' + + (this.callRefcount - 1) + ) + this.callRefcount -= 1 + if (this.callRefcount === 0) { + if (this.session) { + this.session.unref() + } + this.stopKeepalivePings() + this.checkBothRefcounts() + } + } + ref() { + trace( + this.subchannelAddressString + + ' refcount ' + + this.refcount + + ' -> ' + + (this.refcount + 1) + ) + this.refcount += 1 + } + unref() { + trace( + this.subchannelAddressString + + ' refcount ' + + this.refcount + + ' -> ' + + (this.refcount - 1) + ) + this.refcount -= 1 + this.checkBothRefcounts() + } + unrefIfOneRef() { + if (this.refcount === 1) { + this.unref() + return true + } + return false + } + /** + * Start a stream on the current session with the given `metadata` as headers + * and then attach it to the `callStream`. Must only be called if the + * subchannel's current connectivity state is READY. + * @param metadata + * @param callStream + */ + startCallStream(metadata, callStream, extraFilterFactory) { + const headers = metadata.toHttp2Headers() + headers[HTTP2_HEADER_AUTHORITY] = callStream.getHost() + headers[HTTP2_HEADER_USER_AGENT] = this.userAgent + headers[HTTP2_HEADER_CONTENT_TYPE] = 'application/grpc' + headers[HTTP2_HEADER_METHOD] = 'POST' + headers[HTTP2_HEADER_PATH] = callStream.getMethod() + headers[HTTP2_HEADER_TE] = 'trailers' + let http2Stream + /* In theory, if an error is thrown by session.request because session has + * become unusable (e.g. because it has received a goaway), this subchannel + * should soon see the corresponding close or goaway event anyway and leave + * READY. But we have seen reports that this does not happen + * (https://github.com/googleapis/nodejs-firestore/issues/1023#issuecomment-653204096) + * so for defense in depth, we just discard the session when we see an + * error here. + */ + try { + http2Stream = this.session.request(headers) + } catch (e) { + this.transitionToState( + [channel_1.ConnectivityState.READY], + channel_1.ConnectivityState.TRANSIENT_FAILURE + ) + throw e + } + let headersString = '' + for (const header of Object.keys(headers)) { + headersString += '\t\t' + header + ': ' + headers[header] + '\n' + } + trace('Starting stream with headers\n' + headersString) + callStream.attachHttp2Stream(http2Stream, this, extraFilterFactory) + } + /** + * If the subchannel is currently IDLE, start connecting and switch to the + * CONNECTING state. If the subchannel is current in TRANSIENT_FAILURE, + * the next time it would transition to IDLE, start connecting again instead. + * Otherwise, do nothing. + */ + startConnecting() { + /* First, try to transition from IDLE to connecting. If that doesn't happen + * because the state is not currently IDLE, check if it is + * TRANSIENT_FAILURE, and if so indicate that it should go back to + * connecting after the backoff timer ends. Otherwise do nothing */ + if ( + !this.transitionToState( + [channel_1.ConnectivityState.IDLE], + channel_1.ConnectivityState.CONNECTING + ) + ) { + if ( + this.connectivityState === + channel_1.ConnectivityState.TRANSIENT_FAILURE + ) { + this.continueConnecting = true + } + } + } + /** + * Get the subchannel's current connectivity state. + */ + getConnectivityState() { + return this.connectivityState + } + /** + * Add a listener function to be called whenever the subchannel's + * connectivity state changes. + * @param listener + */ + addConnectivityStateListener(listener) { + this.stateListeners.push(listener) + } + /** + * Remove a listener previously added with `addConnectivityStateListener` + * @param listener A reference to a function previously passed to + * `addConnectivityStateListener` + */ + removeConnectivityStateListener(listener) { + const listenerIndex = this.stateListeners.indexOf(listener) + if (listenerIndex > -1) { + this.stateListeners.splice(listenerIndex, 1) + } + } + addDisconnectListener(listener) { + this.disconnectListeners.push(listener) + } + removeDisconnectListener(listener) { + const listenerIndex = this.disconnectListeners.indexOf(listener) + if (listenerIndex > -1) { + this.disconnectListeners.splice(listenerIndex, 1) + } + } + /** + * Reset the backoff timeout, and immediately start connecting if in backoff. + */ + resetBackoff() { + this.backoffTimeout.reset() + this.transitionToState( + [channel_1.ConnectivityState.TRANSIENT_FAILURE], + channel_1.ConnectivityState.CONNECTING + ) + } + getAddress() { + return this.subchannelAddressString + } + } + exports.Subchannel = Subchannel + //# sourceMappingURL=subchannel.js.map + + /***/ + }, + + /***/ 86581: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /* + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.getDefaultRootsData = exports.CIPHER_SUITES = void 0 + const fs = __webpack_require__(35747) + exports.CIPHER_SUITES = process.env.GRPC_SSL_CIPHER_SUITES + const DEFAULT_ROOTS_FILE_PATH = + process.env.GRPC_DEFAULT_SSL_ROOTS_FILE_PATH + let defaultRootsData = null + function getDefaultRootsData() { + if (DEFAULT_ROOTS_FILE_PATH) { + if (defaultRootsData === null) { + defaultRootsData = fs.readFileSync(DEFAULT_ROOTS_FILE_PATH) + } + return defaultRootsData + } + return null + } + exports.getDefaultRootsData = getDefaultRootsData + //# sourceMappingURL=tls-helpers.js.map + + /***/ + }, + + /***/ 65974: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + /* + * Copyright 2020 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.uriToString = exports.splitHostPort = exports.parseUri = void 0 + /* + * The groups correspond to URI parts as follows: + * 1. scheme + * 2. authority + * 3. path + */ + const URI_REGEX = /^(?:([A-Za-z0-9+.-]+):)?(?:\/\/([^/]*)\/)?(.+)$/ + function parseUri(uriString) { + const parsedUri = URI_REGEX.exec(uriString) + if (parsedUri === null) { + return null + } + return { + scheme: parsedUri[1], + authority: parsedUri[2], + path: parsedUri[3] + } + } + exports.parseUri = parseUri + const NUMBER_REGEX = /^\d+$/ + function splitHostPort(path) { + if (path.startsWith('[')) { + const hostEnd = path.indexOf(']') + if (hostEnd === -1) { + return null + } + const host = path.substring(1, hostEnd) + /* Only an IPv6 address should be in bracketed notation, and an IPv6 + * address should have at least one colon */ + if (host.indexOf(':') === -1) { + return null + } + if (path.length > hostEnd + 1) { + if (path[hostEnd + 1] === ':') { + const portString = path.substring(hostEnd + 2) + if (NUMBER_REGEX.test(portString)) { + return { + host: host, + port: +portString + } + } else { + return null + } + } else { + return null + } + } else { + return { + host + } + } + } else { + const splitPath = path.split(':') + /* Exactly one colon means that this is host:port. Zero colons means that + * there is no port. And multiple colons means that this is a bare IPv6 + * address with no port */ + if (splitPath.length === 2) { + if (NUMBER_REGEX.test(splitPath[1])) { + return { + host: splitPath[0], + port: +splitPath[1] + } + } else { + return null + } + } else { + return { + host: path + } + } + } + } + exports.splitHostPort = splitHostPort + function uriToString(uri) { + let result = '' + if (uri.scheme !== undefined) { + result += uri.scheme + ':' + } + if (uri.authority !== undefined) { + result += '//' + uri.authority + '/' + } + result += uri.path + return result + } + exports.uriToString = uriToString + //# sourceMappingURL=uri-parser.js.map + + /***/ + }, + + /***/ 39517: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /* + * Copyright 2020 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.loadBootstrapInfo = void 0 + const fs = __webpack_require__(35747) + function validateChannelCredsConfig(obj) { + if (!('type' in obj)) { + throw new Error( + 'type field missing in xds_servers.channel_creds element' + ) + } + if (typeof obj.type !== 'string') { + throw new Error( + `xds_servers.channel_creds.type field: expected string, got ${typeof obj.type}` + ) + } + if ('config' in obj) { + if (typeof obj.config !== 'object' || obj.config === null) { + throw new Error( + 'xds_servers.channel_creds config field must be an object if provided' + ) + } + } + return { + type: obj.type, + config: obj.config + } + } + function validateXdsServerConfig(obj) { + if (!('server_uri' in obj)) { + throw new Error('server_uri field missing in xds_servers element') + } + if (typeof obj.server_uri !== 'string') { + throw new Error( + `xds_servers.server_uri field: expected string, got ${typeof obj.server_uri}` + ) + } + if (!('channel_creds' in obj)) { + throw new Error('channel_creds missing in xds_servers element') + } + if (!Array.isArray(obj.channel_creds)) { + throw new Error( + `xds_servers.channel_creds field: expected array, got ${typeof obj.channel_creds}` + ) + } + if (obj.channel_creds.length === 0) { + throw new Error( + 'xds_servers.channel_creds field: at least one entry is required' + ) + } + return { + serverUri: obj.server_uri, + channelCreds: obj.channel_creds.map(validateChannelCredsConfig) + } + } + function validateValue(obj) { + if (Array.isArray(obj)) { + return { + kind: 'listValue', + listValue: { + values: obj.map(value => validateValue(value)) + } + } + } else { + switch (typeof obj) { + case 'boolean': + return { + kind: 'boolValue', + boolValue: obj + } + case 'number': + return { + kind: 'numberValue', + numberValue: obj + } + case 'string': + return { + kind: 'stringValue', + stringValue: obj + } + case 'object': + if (obj === null) { + return { + kind: 'nullValue', + nullValue: 'NULL_VALUE' + } + } else { + return { + kind: 'structValue', + structValue: getStructFromJson(obj) + } + } + default: + throw new Error( + `Could not handle struct value of type ${typeof obj}` + ) + } + } + } + function getStructFromJson(obj) { + if (typeof obj !== 'object' || obj === null) { + throw new Error('Invalid JSON object for Struct field') + } + const fields = {} + for (const [fieldName, value] of Object.entries(obj)) { + fields[fieldName] = validateValue(value) + } + return { + fields + } + } + /** + * Validate that the input obj is a valid Node proto message. Only checks the + * fields we expect to see: id, cluster, locality, and metadata. + * @param obj + */ + function validateNode(obj) { + const result = {} + if (!('id' in obj)) { + throw new Error('id field missing in node element') + } + if (typeof obj.id !== 'string') { + throw new Error( + `node.id field: expected string, got ${typeof obj.id}` + ) + } + result.id = obj.id + if (!('cluster' in obj)) { + throw new Error('cluster field missing in node element') + } + if (typeof obj.cluster !== 'string') { + throw new Error( + `node.cluster field: expected string, got ${typeof obj.cluster}` + ) + } + result.cluster = obj.cluster + if (!('locality' in obj)) { + throw new Error('locality field missing in node element') + } + result.locality = {} + if ('region' in obj.locality) { + if (typeof obj.locality.region !== 'string') { + throw new Error( + `node.locality.region field: expected string, got ${typeof obj + .locality.region}` + ) + } + result.locality.region = obj.locality.region + } + if ('zone' in obj.locality) { + if (typeof obj.locality.region !== 'string') { + throw new Error( + `node.locality.zone field: expected string, got ${typeof obj + .locality.zone}` + ) + } + result.locality.zone = obj.locality.zone + } + if ('sub_zone' in obj.locality) { + if (typeof obj.locality.sub_zone !== 'string') { + throw new Error( + `node.locality.sub_zone field: expected string, got ${typeof obj + .locality.sub_zone}` + ) + } + result.locality.sub_zone = obj.locality.sub_zone + } + if ('metadata' in obj) { + result.metadata = getStructFromJson(obj.metadata) + } + return result + } + function validateBootstrapFile(obj) { + return { + xdsServers: obj.xds_servers.map(validateXdsServerConfig), + node: validateNode(obj.node) + } + } + let loadedBootstrapInfo = null + async function loadBootstrapInfo() { + if (loadedBootstrapInfo !== null) { + return loadedBootstrapInfo + } + const bootstrapPath = process.env.GRPC_XDS_BOOTSTRAP + if (bootstrapPath === undefined) { + return Promise.reject( + new Error( + 'The GRPC_XDS_BOOTSTRAP environment variable needs to be set to the path to the bootstrap file to use xDS' + ) + ) + } + loadedBootstrapInfo = new Promise((resolve, reject) => { + fs.readFile(bootstrapPath, { encoding: 'utf8' }, (err, data) => { + if (err) { + reject( + new Error( + `Failed to read xDS bootstrap file from path ${bootstrapPath} with error ${err.message}` + ) + ) + } + try { + const parsedFile = JSON.parse(data) + resolve(validateBootstrapFile(parsedFile)) + } catch (e) { + reject( + new Error( + `Failed to parse xDS bootstrap file at path ${bootstrapPath} with error ${e.message}` + ) + ) + } + }) + }) + return loadedBootstrapInfo + } + exports.loadBootstrapInfo = loadBootstrapInfo + //# sourceMappingURL=xds-bootstrap.js.map + + /***/ + }, + + /***/ 67477: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /* + * Copyright 2020 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.XdsClient = void 0 + const protoLoader = __webpack_require__(48934) + const make_client_1 = __webpack_require__(38541) + const channel_credentials_1 = __webpack_require__(44030) + const xds_bootstrap_1 = __webpack_require__(39517) + const net_1 = __webpack_require__(11631) + const constants_1 = __webpack_require__(90634) + const metadata_1 = __webpack_require__(83665) + const logging = __webpack_require__(35993) + const TRACER_NAME = 'xds_client' + function trace(text) { + logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, text) + } + const clientVersion = __webpack_require__(68160) /* .version */.i8 + const EDS_TYPE_URL = + 'type.googleapis.com/envoy.api.v2.ClusterLoadAssignment' + const CDS_TYPE_URL = 'type.googleapis.com/envoy.api.v2.Cluster' + const LDS_TYPE_URL = 'type.googleapis.com/envoy.api.v2.Listener' + const RDS_TYPE_URL = 'type.googleapis.com/envoy.api.v2.RouteConfiguration' + const HTTP_CONNECTION_MANGER_TYPE_URL = + 'type.googleapis.com/envoy.config.filter.network.http_connection_manager.v2.HttpConnectionManager' + let loadedProtos = null + function loadAdsProtos() { + if (loadedProtos !== null) { + return loadedProtos + } + loadedProtos = protoLoader + .load( + [ + 'envoy/service/discovery/v2/ads.proto', + 'envoy/service/load_stats/v2/lrs.proto', + 'envoy/api/v2/listener.proto', + 'envoy/api/v2/route.proto', + 'envoy/api/v2/cluster.proto', + 'envoy/api/v2/endpoint.proto', + 'envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.proto' + ], + { + keepCase: true, + longs: String, + enums: String, + defaults: true, + oneofs: true, + includeDirs: [ + // Paths are relative to src/build + __dirname + '/../../deps/envoy-api/', + __dirname + '/../../deps/udpa/', + __dirname + '/../../deps/googleapis/', + __dirname + '/../../deps/protoc-gen-validate/' + ] + } + ) + .then(packageDefinition => + make_client_1.loadPackageDefinition(packageDefinition) + ) + return loadedProtos + } + function localityEqual(loc1, loc2) { + return ( + loc1.region === loc2.region && + loc1.zone === loc2.zone && + loc1.sub_zone === loc2.sub_zone + ) + } + class ClusterLoadReportMap { + constructor() { + this.statsMap = [] + } + get(clusterName, edsServiceName) { + for (const statsObj of this.statsMap) { + if ( + statsObj.clusterName === clusterName && + statsObj.edsServiceName === edsServiceName + ) { + return statsObj.stats + } + } + return undefined + } + getOrCreate(clusterName, edsServiceName) { + for (const statsObj of this.statsMap) { + if ( + statsObj.clusterName === clusterName && + statsObj.edsServiceName === edsServiceName + ) { + return statsObj.stats + } + } + const newStats = { + callsDropped: new Map(), + localityStats: [], + intervalStart: process.hrtime() + } + this.statsMap.push({ + clusterName, + edsServiceName, + stats: newStats + }) + return newStats + } + *entries() { + for (const statsEntry of this.statsMap) { + yield [ + { + clusterName: statsEntry.clusterName, + edsServiceName: statsEntry.edsServiceName + }, + statsEntry.stats + ] + } + } + } + class EdsState { + constructor(updateResourceNames) { + this.updateResourceNames = updateResourceNames + this.versionInfo = '' + this.nonce = '' + this.watchers = new Map() + this.latestResponses = [] + } + /** + * Add the watcher to the watcher list. Returns true if the list of resource + * names has changed, and false otherwise. + * @param edsServiceName + * @param watcher + */ + addWatcher(edsServiceName, watcher) { + let watchersEntry = this.watchers.get(edsServiceName) + let addedServiceName = false + if (watchersEntry === undefined) { + addedServiceName = true + watchersEntry = [] + this.watchers.set(edsServiceName, watchersEntry) + } + watchersEntry.push(watcher) + /* If we have already received an update for the requested edsServiceName, + * immediately pass that update along to the watcher */ + for (const message of this.latestResponses) { + if (message.cluster_name === edsServiceName) { + /* These updates normally occur asynchronously, so we ensure that + * the same happens here */ + process.nextTick(() => { + watcher.onValidUpdate(message) + }) + } + } + if (addedServiceName) { + this.updateResourceNames() + } + } + removeWatcher(edsServiceName, watcher) { + const watchersEntry = this.watchers.get(edsServiceName) + let removedServiceName = false + if (watchersEntry !== undefined) { + const entryIndex = watchersEntry.indexOf(watcher) + if (entryIndex >= 0) { + watchersEntry.splice(entryIndex, 1) + } + if (watchersEntry.length === 0) { + removedServiceName = true + this.watchers.delete(edsServiceName) + } + } + if (removedServiceName) { + this.updateResourceNames() + } + } + getResourceNames() { + return Array.from(this.watchers.keys()) + } + /** + * Validate the ClusterLoadAssignment object by these rules: + * https://github.com/grpc/proposal/blob/master/A27-xds-global-load-balancing.md#clusterloadassignment-proto + * @param message + */ + validateResponse(message) { + var _a, _b + for (const endpoint of message.endpoints) { + for (const lb of endpoint.lb_endpoints) { + const socketAddress = + (_b = + (_a = lb.endpoint) === null || _a === void 0 + ? void 0 + : _a.address) === null || _b === void 0 + ? void 0 + : _b.socket_address + if (!socketAddress) { + return false + } + if (socketAddress.port_specifier !== 'port_value') { + return false + } + if ( + !( + net_1.isIPv4(socketAddress.address) || + net_1.isIPv6(socketAddress.address) + ) + ) { + return false + } + } + } + return true + } + /** + * Given a list of edsServiceNames (which may actually be the cluster name), + * for each watcher watching a name not on the list, call that watcher's + * onResourceDoesNotExist method. + * @param allClusterNames + */ + handleMissingNames(allEdsServiceNames) { + for (const [edsServiceName, watcherList] of this.watchers.entries()) { + if (!allEdsServiceNames.has(edsServiceName)) { + for (const watcher of watcherList) { + watcher.onResourceDoesNotExist() + } + } + } + } + handleResponses(responses) { + var _a + for (const message of responses) { + if (!this.validateResponse(message)) { + return 'ClusterLoadAssignment validation failed' + } + } + this.latestResponses = responses + const allClusterNames = new Set() + for (const message of responses) { + allClusterNames.add(message.cluster_name) + const watchers = + (_a = this.watchers.get(message.cluster_name)) !== null && + _a !== void 0 + ? _a + : [] + for (const watcher of watchers) { + watcher.onValidUpdate(message) + } + } + this.handleMissingNames(allClusterNames) + return null + } + reportStreamError(status) { + for (const watcherList of this.watchers.values()) { + for (const watcher of watcherList) { + watcher.onTransientError(status) + } + } + } + } + class CdsState { + constructor(edsState, updateResourceNames) { + this.edsState = edsState + this.updateResourceNames = updateResourceNames + this.versionInfo = '' + this.nonce = '' + this.watchers = new Map() + this.latestResponses = [] + } + /** + * Add the watcher to the watcher list. Returns true if the list of resource + * names has changed, and false otherwise. + * @param clusterName + * @param watcher + */ + addWatcher(clusterName, watcher) { + let watchersEntry = this.watchers.get(clusterName) + let addedServiceName = false + if (watchersEntry === undefined) { + addedServiceName = true + watchersEntry = [] + this.watchers.set(clusterName, watchersEntry) + } + watchersEntry.push(watcher) + /* If we have already received an update for the requested edsServiceName, + * immediately pass that update along to the watcher */ + for (const message of this.latestResponses) { + if (message.name === clusterName) { + /* These updates normally occur asynchronously, so we ensure that + * the same happens here */ + process.nextTick(() => { + watcher.onValidUpdate(message) + }) + } + } + if (addedServiceName) { + this.updateResourceNames() + } + } + removeWatcher(clusterName, watcher) { + const watchersEntry = this.watchers.get(clusterName) + let removedServiceName = false + if (watchersEntry !== undefined) { + const entryIndex = watchersEntry.indexOf(watcher) + if (entryIndex >= 0) { + watchersEntry.splice(entryIndex, 1) + } + if (watchersEntry.length === 0) { + removedServiceName = true + this.watchers.delete(clusterName) + } + } + if (removedServiceName) { + this.updateResourceNames() + } + } + getResourceNames() { + return Array.from(this.watchers.keys()) + } + validateResponse(message) { + var _a, _b + if (message.type !== 'EDS') { + return false + } + if ( + !((_b = + (_a = message.eds_cluster_config) === null || _a === void 0 + ? void 0 + : _a.eds_config) === null || _b === void 0 + ? void 0 + : _b.ads) + ) { + return false + } + if (message.lb_policy !== 'ROUND_ROBIN') { + return false + } + if (message.lrs_server) { + if (!message.lrs_server.self) { + return false + } + } + return true + } + /** + * Given a list of edsServiceNames (which may actually be the cluster name), + * for each watcher watching a name not on the list, call that watcher's + * onResourceDoesNotExist method. + * @param allClusterNames + */ + handleMissingNames(allClusterNames) { + for (const [edsServiceName, watcherList] of this.watchers.entries()) { + if (!allClusterNames.has(edsServiceName)) { + for (const watcher of watcherList) { + watcher.onResourceDoesNotExist() + } + } + } + } + handleResponses(responses) { + var _a, _b, _c + for (const message of responses) { + if (!this.validateResponse(message)) { + return 'Cluster validation failed' + } + } + this.latestResponses = responses + const allEdsServiceNames = new Set() + const allClusterNames = new Set() + for (const message of responses) { + allClusterNames.add(message.name) + const edsServiceName = + (_b = + (_a = message.eds_cluster_config) === null || _a === void 0 + ? void 0 + : _a.service_name) !== null && _b !== void 0 + ? _b + : '' + allEdsServiceNames.add( + edsServiceName === '' ? message.name : edsServiceName + ) + const watchers = + (_c = this.watchers.get(message.name)) !== null && _c !== void 0 + ? _c + : [] + for (const watcher of watchers) { + watcher.onValidUpdate(message) + } + } + this.handleMissingNames(allClusterNames) + this.edsState.handleMissingNames(allEdsServiceNames) + return null + } + reportStreamError(status) { + for (const watcherList of this.watchers.values()) { + for (const watcher of watcherList) { + watcher.onTransientError(status) + } + } + } + } + class RdsState { + constructor(watcher, updateResouceNames) { + this.watcher = watcher + this.updateResouceNames = updateResouceNames + this.versionInfo = '' + this.nonce = '' + this.routeConfigName = null + } + getResourceNames() { + return this.routeConfigName ? [this.routeConfigName] : [] + } + handleSingleMessage(message) { + var _a, _b + for (const virtualHost of message.virtual_hosts) { + if (virtualHost.domains.indexOf(this.routeConfigName) >= 0) { + const route = virtualHost.routes[virtualHost.routes.length - 1] + if ( + ((_a = route.match) === null || _a === void 0 + ? void 0 + : _a.prefix) === '' && + ((_b = route.route) === null || _b === void 0 + ? void 0 + : _b.cluster) + ) { + this.watcher.onValidUpdate({ + methodConfig: [], + loadBalancingConfig: [ + { + name: 'cds', + cds: { + cluster: route.route.cluster + } + } + ] + }) + break + } + } + } + /* If none of the routes match the one we are looking for, bubble up an + * error. */ + this.watcher.onResourceDoesNotExist() + } + handleResponses(responses) { + if (this.routeConfigName !== null) { + for (const message of responses) { + if (message.name === this.routeConfigName) { + this.handleSingleMessage(message) + return null + } + } + } + return null + } + setRouteConfigName(name) { + const oldName = this.routeConfigName + this.routeConfigName = name + if (name !== oldName) { + this.updateResouceNames() + } + } + reportStreamError(status) { + this.watcher.onTransientError(status) + } + } + class LdsState { + constructor(targetName, rdsState) { + this.targetName = targetName + this.rdsState = rdsState + this.versionInfo = '' + this.nonce = '' + } + getResourceNames() { + return [this.targetName] + } + validateResponse(message) { + var _a, _b, _c, _d, _e + if ( + !( + ((_a = message.api_listener) === null || _a === void 0 + ? void 0 + : _a.api_listener) && + protoLoader.isAnyExtension(message.api_listener.api_listener) && + ((_b = message.api_listener) === null || _b === void 0 + ? void 0 + : _b.api_listener['@type']) === HTTP_CONNECTION_MANGER_TYPE_URL + ) + ) { + return false + } + const httpConnectionManager = + (_c = message.api_listener) === null || _c === void 0 + ? void 0 + : _c.api_listener + switch (httpConnectionManager.route_specifier) { + case 'rds': + return !!((_e = + (_d = httpConnectionManager.rds) === null || _d === void 0 + ? void 0 + : _d.config_source) === null || _e === void 0 + ? void 0 + : _e.ads) + case 'route_config': + return true + } + return false + } + handleResponses(responses) { + for (const message of responses) { + if (message.name === this.targetName) { + if (this.validateResponse(message)) { + // The validation step ensures that this is correct + const httpConnectionManager = message.api_listener.api_listener + switch (httpConnectionManager.route_specifier) { + case 'rds': + this.rdsState.setRouteConfigName( + httpConnectionManager.rds.route_config_name + ) + break + case 'route_config': + this.rdsState.setRouteConfigName(null) + this.rdsState.handleSingleMessage( + httpConnectionManager.route_config + ) + break + default: + // The validation rules should prevent this + } + } else { + return 'Listener validation failed' + } + } + } + throw new Error('Method not implemented.') + } + reportStreamError(status) { + // Nothing to do here + } + } + function getResponseMessages(typeUrl, resources) { + const result = [] + for (const resource of resources) { + if ( + protoLoader.isAnyExtension(resource) && + resource['@type'] === typeUrl + ) { + result.push(resource) + } else { + throw new Error( + `Invalid resource type ${ + protoLoader.isAnyExtension(resource) + ? resource['@type'] + : resource.type_url + }` + ) + } + } + return result + } + class XdsClient { + constructor(targetName, serviceConfigWatcher, channelOptions) { + this.adsNode = null + this.adsClient = null + this.adsCall = null + this.lrsNode = null + this.lrsClient = null + this.lrsCall = null + this.latestLrsSettings = null + this.clusterStatsMap = new ClusterLoadReportMap() + this.hasShutdown = false + const edsState = new EdsState(() => { + this.updateNames(EDS_TYPE_URL) + }) + const cdsState = new CdsState(edsState, () => { + this.updateNames(CDS_TYPE_URL) + }) + const rdsState = new RdsState(serviceConfigWatcher, () => { + this.updateNames(RDS_TYPE_URL) + }) + const ldsState = new LdsState(targetName, rdsState) + this.adsState = { + [EDS_TYPE_URL]: edsState, + [CDS_TYPE_URL]: cdsState, + [RDS_TYPE_URL]: rdsState, + [LDS_TYPE_URL]: ldsState + } + const channelArgs = Object.assign({}, channelOptions) + const channelArgsToRemove = [ + /* The SSL target name override corresponds to the target, and this + * client has its own target */ + 'grpc.ssl_target_name_override', + /* The default authority also corresponds to the target */ + 'grpc.default_authority', + /* This client will have its own specific keepalive time setting */ + 'grpc.keepalive_time_ms', + /* The service config specifies the load balancing policy. This channel + * needs its own separate load balancing policy setting. In particular, + * recursively using an xDS load balancer for the xDS client would be + * bad */ + 'grpc.service_config' + ] + for (const arg of channelArgsToRemove) { + delete channelArgs[arg] + } + channelArgs['grpc.keepalive_time_ms'] = 5000 + Promise.all([ + xds_bootstrap_1.loadBootstrapInfo(), + loadAdsProtos() + ]).then( + ([bootstrapInfo, protoDefinitions]) => { + if (this.hasShutdown) { + return + } + const node = Object.assign( + Object.assign({}, bootstrapInfo.node), + { + build_version: `gRPC Node Pure JS ${clientVersion}`, + user_agent_name: 'gRPC Node Pure JS' + } + ) + this.adsNode = Object.assign(Object.assign({}, node), { + client_features: ['envoy.lb.does_not_support_overprovisioning'] + }) + this.lrsNode = Object.assign(Object.assign({}, node), { + client_features: ['envoy.lrs.supports_send_all_clusters'] + }) + this.adsClient = new protoDefinitions.envoy.service.discovery.v2.AggregatedDiscoveryService( + bootstrapInfo.xdsServers[0].serverUri, + channel_credentials_1.createGoogleDefaultCredentials(), + channelArgs + ) + this.maybeStartAdsStream() + this.lrsClient = new protoDefinitions.envoy.service.load_stats.v2.LoadReportingService( + bootstrapInfo.xdsServers[0].serverUri, + channel_credentials_1.createGoogleDefaultCredentials(), + channelArgs + ) + this.maybeStartLrsStream() + }, + error => { + trace('Failed to initialize xDS Client. ' + error.message) + // Bubble this error up to any listeners + this.reportStreamError({ + code: constants_1.Status.INTERNAL, + details: `Failed to initialize xDS Client. ${error.message}`, + metadata: new metadata_1.Metadata() + }) + } + ) + this.statsTimer = setInterval(() => {}, 0) + clearInterval(this.statsTimer) + } + handleAdsResponse(message) { + let errorString + /* The cases in this switch statement look redundant but separating them + * out like this is necessary for the typechecker to validate the types + * as narrowly as we need it to. */ + switch (message.type_url) { + case EDS_TYPE_URL: + errorString = this.adsState[message.type_url].handleResponses( + getResponseMessages(message.type_url, message.resources) + ) + break + case CDS_TYPE_URL: + errorString = this.adsState[message.type_url].handleResponses( + getResponseMessages(message.type_url, message.resources) + ) + break + case RDS_TYPE_URL: + errorString = this.adsState[message.type_url].handleResponses( + getResponseMessages(message.type_url, message.resources) + ) + break + case LDS_TYPE_URL: + errorString = this.adsState[message.type_url].handleResponses( + getResponseMessages(message.type_url, message.resources) + ) + break + default: + errorString = `Unknown type_url ${message.type_url}` + } + if (errorString === null) { + /* errorString can only be null in one of the first 4 cases, which + * implies that message.type_url is one of the 4 known type URLs, which + * means that this type assertion is valid. */ + const typeUrl = message.type_url + this.adsState[typeUrl].nonce = message.nonce + this.adsState[typeUrl].versionInfo = message.version_info + this.ack(typeUrl) + } else { + this.nack(message.type_url, errorString) + } + } + /** + * Start the ADS stream if the client exists and there is not already an + * existing stream, and there + */ + maybeStartAdsStream() { + if (this.adsClient === null) { + return + } + if (this.adsCall !== null) { + return + } + if (this.hasShutdown) { + return + } + this.adsCall = this.adsClient.StreamAggregatedResources() + this.adsCall.on('data', message => { + this.handleAdsResponse(message) + }) + this.adsCall.on('error', error => { + trace( + 'ADS stream ended. code=' + + error.code + + ' details= ' + + error.details + ) + this.adsCall = null + this.reportStreamError(error) + /* Connection backoff is handled by the client object, so we can + * immediately start a new request to indicate that it should try to + * reconnect */ + this.maybeStartAdsStream() + }) + const allTypeUrls = [ + EDS_TYPE_URL, + CDS_TYPE_URL, + RDS_TYPE_URL, + LDS_TYPE_URL + ] + for (const typeUrl of allTypeUrls) { + const state = this.adsState[typeUrl] + state.nonce = '' + state.versionInfo = '' + if (state.getResourceNames().length > 0) { + this.updateNames(typeUrl) + } + } + } + /** + * Acknowledge an update. This should be called after the local nonce and + * version info are updated so that it sends the post-update values. + */ + ack(typeUrl) { + this.updateNames(typeUrl) + } + /** + * Reject an update. This should be called without updating the local + * nonce and version info. + */ + nack(typeUrl, message) { + var _a + let resourceNames + let nonce + let versionInfo + switch (typeUrl) { + case EDS_TYPE_URL: + case CDS_TYPE_URL: + case RDS_TYPE_URL: + case LDS_TYPE_URL: + resourceNames = this.adsState[typeUrl].getResourceNames() + nonce = this.adsState[typeUrl].nonce + versionInfo = this.adsState[typeUrl].versionInfo + break + default: + resourceNames = [] + nonce = '' + versionInfo = '' + } + ;(_a = this.adsCall) === null || _a === void 0 + ? void 0 + : _a.write({ + node: this.adsNode, + type_url: typeUrl, + resource_names: resourceNames, + response_nonce: nonce, + version_info: versionInfo, + error_detail: { + message: message + } + }) + } + updateNames(typeUrl) { + var _a + ;(_a = this.adsCall) === null || _a === void 0 + ? void 0 + : _a.write({ + node: this.adsNode, + type_url: typeUrl, + resource_names: this.adsState[typeUrl].getResourceNames(), + response_nonce: this.adsState[typeUrl].nonce, + version_info: this.adsState[typeUrl].versionInfo + }) + } + reportStreamError(status) { + this.adsState[EDS_TYPE_URL].reportStreamError(status) + this.adsState[CDS_TYPE_URL].reportStreamError(status) + this.adsState[RDS_TYPE_URL].reportStreamError(status) + this.adsState[LDS_TYPE_URL].reportStreamError(status) + } + maybeStartLrsStream() { + if (!this.lrsClient) { + return + } + if (this.lrsCall) { + return + } + if (this.hasShutdown) { + return + } + this.lrsCall = this.lrsClient.streamLoadStats() + this.lrsCall.on('data', message => { + var _a, _b, _c, _d, _e, _f + if ( + ((_a = message.load_reporting_interval) === null || _a === void 0 + ? void 0 + : _a.seconds) !== + ((_c = + (_b = this.latestLrsSettings) === null || _b === void 0 + ? void 0 + : _b.load_reporting_interval) === null || _c === void 0 + ? void 0 + : _c.seconds) || + ((_d = message.load_reporting_interval) === null || _d === void 0 + ? void 0 + : _d.nanos) !== + ((_f = + (_e = this.latestLrsSettings) === null || _e === void 0 + ? void 0 + : _e.load_reporting_interval) === null || _f === void 0 + ? void 0 + : _f.nanos) + ) { + /* Only reset the timer if the interval has changed or was not set + * before. */ + clearInterval(this.statsTimer) + /* Convert a google.protobuf.Duration to a number of milliseconds for + * use with setInterval. */ + const loadReportingIntervalMs = + Number.parseInt(message.load_reporting_interval.seconds) * + 1000 + + message.load_reporting_interval.nanos / 1000000 + setInterval(() => { + this.sendStats() + }, loadReportingIntervalMs) + } + this.latestLrsSettings = message + }) + this.lrsCall.on('error', error => { + trace( + 'LRS stream ended. code=' + + error.code + + ' details= ' + + error.details + ) + this.lrsCall = null + clearInterval(this.statsTimer) + /* Connection backoff is handled by the client object, so we can + * immediately start a new request to indicate that it should try to + * reconnect */ + this.maybeStartAdsStream() + }) + this.lrsCall.write({ + node: this.lrsNode + }) + } + sendStats() { + if (!this.lrsCall) { + return + } + const clusterStats = [] + for (const [ + { clusterName, edsServiceName }, + stats + ] of this.clusterStatsMap.entries()) { + if ( + this.latestLrsSettings.send_all_clusters || + this.latestLrsSettings.clusters.indexOf(clusterName) > 0 + ) { + const upstreamLocalityStats = [] + for (const localityStats of stats.localityStats) { + // Skip localities with 0 requests + if ( + localityStats.callsStarted > 0 || + localityStats.callsSucceeded > 0 || + localityStats.callsFailed > 0 + ) { + upstreamLocalityStats.push({ + locality: localityStats.locality, + total_issued_requests: localityStats.callsStarted, + total_successful_requests: localityStats.callsSucceeded, + total_error_requests: localityStats.callsFailed, + total_requests_in_progress: localityStats.callsInProgress + }) + localityStats.callsStarted = 0 + localityStats.callsSucceeded = 0 + localityStats.callsFailed = 0 + } + } + const droppedRequests = [] + let totalDroppedRequests = 0 + for (const [category, count] of stats.callsDropped.entries()) { + if (count > 0) { + droppedRequests.push({ + category, + dropped_count: count + }) + totalDroppedRequests += count + } + } + // Clear out dropped call stats after sending them + stats.callsDropped.clear() + const interval = process.hrtime(stats.intervalStart) + stats.intervalStart = process.hrtime() + // Skip clusters with 0 requests + if ( + upstreamLocalityStats.length > 0 || + totalDroppedRequests > 0 + ) { + clusterStats.push({ + cluster_name: clusterName, + cluster_service_name: edsServiceName, + dropped_requests: droppedRequests, + total_dropped_requests: totalDroppedRequests, + upstream_locality_stats: upstreamLocalityStats, + load_report_interval: { + seconds: interval[0], + nanos: interval[1] + } + }) + } + } + } + this.lrsCall.write({ + node: this.lrsNode, + cluster_stats: clusterStats + }) + } + addEndpointWatcher(edsServiceName, watcher) { + trace('Watcher added for endpoint ' + edsServiceName) + this.adsState[EDS_TYPE_URL].addWatcher(edsServiceName, watcher) + } + removeEndpointWatcher(edsServiceName, watcher) { + trace('Watcher removed for endpoint ' + edsServiceName) + this.adsState[EDS_TYPE_URL].removeWatcher(edsServiceName, watcher) + } + addClusterWatcher(clusterName, watcher) { + trace('Watcher added for cluster ' + clusterName) + this.adsState[CDS_TYPE_URL].addWatcher(clusterName, watcher) + } + removeClusterWatcher(clusterName, watcher) { + trace('Watcher removed for endpoint ' + clusterName) + this.adsState[CDS_TYPE_URL].removeWatcher(clusterName, watcher) + } + /** + * + * @param lrsServer The target name of the server to send stats to. An empty + * string indicates that the default LRS client should be used. Currently + * only the empty string is supported here. + * @param clusterName + * @param edsServiceName + */ + addClusterDropStats(lrsServer, clusterName, edsServiceName) { + if (lrsServer !== '') { + return { + addCallDropped: category => {} + } + } + const clusterStats = this.clusterStatsMap.getOrCreate( + clusterName, + edsServiceName + ) + return { + addCallDropped: category => { + var _a + const prevCount = + (_a = clusterStats.callsDropped.get(category)) !== null && + _a !== void 0 + ? _a + : 0 + clusterStats.callsDropped.set(category, prevCount + 1) + } + } + } + addClusterLocalityStats( + lrsServer, + clusterName, + edsServiceName, + locality + ) { + if (lrsServer !== '') { + return { + addCallStarted: () => {}, + addCallFinished: fail => {} + } + } + const clusterStats = this.clusterStatsMap.getOrCreate( + clusterName, + edsServiceName + ) + let localityStats = null + for (const statsObj of clusterStats.localityStats) { + if (localityEqual(locality, statsObj.locality)) { + localityStats = statsObj + break + } + } + if (localityStats === null) { + localityStats = { + locality: locality, + callsInProgress: 0, + callsStarted: 0, + callsSucceeded: 0, + callsFailed: 0 + } + clusterStats.localityStats.push(localityStats) + } + /* Help the compiler understand that this object is always non-null in the + * closure */ + const finalLocalityStats = localityStats + return { + addCallStarted: () => { + finalLocalityStats.callsStarted += 1 + finalLocalityStats.callsInProgress += 1 + }, + addCallFinished: fail => { + if (fail) { + finalLocalityStats.callsFailed += 1 + } else { + finalLocalityStats.callsSucceeded += 1 + } + finalLocalityStats.callsInProgress -= 1 + } + } + } + shutdown() { + var _a, _b, _c, _d + ;(_a = this.adsCall) === null || _a === void 0 ? void 0 : _a.cancel() + ;(_b = this.adsClient) === null || _b === void 0 ? void 0 : _b.close() + ;(_c = this.lrsCall) === null || _c === void 0 ? void 0 : _c.cancel() + ;(_d = this.lrsClient) === null || _d === void 0 ? void 0 : _d.close() + this.hasShutdown = true + } + } + exports.XdsClient = XdsClient + //# sourceMappingURL=xds-client.js.map + + /***/ + }, + + /***/ 48934: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /** + * @license + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + const camelCase = __webpack_require__(7994) + const Protobuf = __webpack_require__(85881) + const descriptor = __webpack_require__(21629) + const util_1 = __webpack_require__(32358) + function isAnyExtension(obj) { + return '@type' in obj && typeof obj['@type'] === 'string' + } + exports.isAnyExtension = isAnyExtension + const descriptorOptions = { + longs: String, + enums: String, + bytes: String, + defaults: true, + oneofs: true, + json: true + } + function joinName(baseName, name) { + if (baseName === '') { + return name + } else { + return baseName + '.' + name + } + } + function isHandledReflectionObject(obj) { + return ( + obj instanceof Protobuf.Service || + obj instanceof Protobuf.Type || + obj instanceof Protobuf.Enum + ) + } + function isNamespaceBase(obj) { + return obj instanceof Protobuf.Namespace || obj instanceof Protobuf.Root + } + function getAllHandledReflectionObjects(obj, parentName) { + const objName = joinName(parentName, obj.name) + if (isHandledReflectionObject(obj)) { + return [[objName, obj]] + } else { + if (isNamespaceBase(obj) && typeof obj.nested !== 'undefined') { + return Object.keys(obj.nested) + .map(name => { + return getAllHandledReflectionObjects(obj.nested[name], objName) + }) + .reduce( + (accumulator, currentValue) => accumulator.concat(currentValue), + [] + ) + } + } + return [] + } + function createDeserializer(cls, options) { + return function deserialize(argBuf) { + return cls.toObject(cls.decode(argBuf), options) + } + } + function createSerializer(cls) { + return function serialize(arg) { + const message = cls.fromObject(arg) + return cls.encode(message).finish() + } + } + function createMethodDefinition( + method, + serviceName, + options, + fileDescriptors + ) { + /* This is only ever called after the corresponding root.resolveAll(), so we + * can assume that the resolved request and response types are non-null */ + const requestType = method.resolvedRequestType + const responseType = method.resolvedResponseType + return { + path: '/' + serviceName + '/' + method.name, + requestStream: !!method.requestStream, + responseStream: !!method.responseStream, + requestSerialize: createSerializer(requestType), + requestDeserialize: createDeserializer(requestType, options), + responseSerialize: createSerializer(responseType), + responseDeserialize: createDeserializer(responseType, options), + // TODO(murgatroid99): Find a better way to handle this + originalName: camelCase(method.name), + requestType: createMessageDefinition(requestType, fileDescriptors), + responseType: createMessageDefinition(responseType, fileDescriptors) + } + } + function createServiceDefinition( + service, + name, + options, + fileDescriptors + ) { + const def = {} + for (const method of service.methodsArray) { + def[method.name] = createMethodDefinition( + method, + name, + options, + fileDescriptors + ) + } + return def + } + function createMessageDefinition(message, fileDescriptors) { + const messageDescriptor = message.toDescriptor('proto3') + return { + format: 'Protocol Buffer 3 DescriptorProto', + type: messageDescriptor.$type.toObject( + messageDescriptor, + descriptorOptions + ), + fileDescriptorProtos: fileDescriptors + } + } + function createEnumDefinition(enumType, fileDescriptors) { + const enumDescriptor = enumType.toDescriptor('proto3') + return { + format: 'Protocol Buffer 3 EnumDescriptorProto', + type: enumDescriptor.$type.toObject( + enumDescriptor, + descriptorOptions + ), + fileDescriptorProtos: fileDescriptors + } + } + /** + * function createDefinition(obj: Protobuf.Service, name: string, options: + * Options): ServiceDefinition; function createDefinition(obj: Protobuf.Type, + * name: string, options: Options): MessageTypeDefinition; function + * createDefinition(obj: Protobuf.Enum, name: string, options: Options): + * EnumTypeDefinition; + */ + function createDefinition(obj, name, options, fileDescriptors) { + if (obj instanceof Protobuf.Service) { + return createServiceDefinition(obj, name, options, fileDescriptors) + } else if (obj instanceof Protobuf.Type) { + return createMessageDefinition(obj, fileDescriptors) + } else if (obj instanceof Protobuf.Enum) { + return createEnumDefinition(obj, fileDescriptors) + } else { + throw new Error('Type mismatch in reflection object handling') + } + } + function createPackageDefinition(root, options) { + const def = {} + root.resolveAll() + const descriptorList = root.toDescriptor('proto3').file + const bufferList = descriptorList.map(value => + Buffer.from(descriptor.FileDescriptorProto.encode(value).finish()) + ) + for (const [name, obj] of getAllHandledReflectionObjects(root, '')) { + def[name] = createDefinition(obj, name, options, bufferList) + } + return def + } + /** + * Load a .proto file with the specified options. + * @param filename One or multiple file paths to load. Can be an absolute path + * or relative to an include path. + * @param options.keepCase Preserve field names. The default is to change them + * to camel case. + * @param options.longs The type that should be used to represent `long` values. + * Valid options are `Number` and `String`. Defaults to a `Long` object type + * from a library. + * @param options.enums The type that should be used to represent `enum` values. + * The only valid option is `String`. Defaults to the numeric value. + * @param options.bytes The type that should be used to represent `bytes` + * values. Valid options are `Array` and `String`. The default is to use + * `Buffer`. + * @param options.defaults Set default values on output objects. Defaults to + * `false`. + * @param options.arrays Set empty arrays for missing array values even if + * `defaults` is `false`. Defaults to `false`. + * @param options.objects Set empty objects for missing object values even if + * `defaults` is `false`. Defaults to `false`. + * @param options.oneofs Set virtual oneof properties to the present field's + * name + * @param options.json Represent Infinity and NaN as strings in float fields, + * and automatically decode google.protobuf.Any values. + * @param options.includeDirs Paths to search for imported `.proto` files. + */ + function load(filename, options) { + return util_1 + .loadProtosWithOptions(filename, options) + .then(loadedRoot => { + return createPackageDefinition(loadedRoot, options) + }) + } + exports.load = load + function loadSync(filename, options) { + const loadedRoot = util_1.loadProtosWithOptionsSync(filename, options) + return createPackageDefinition(loadedRoot, options) + } + exports.loadSync = loadSync + util_1.addCommonProtos() + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 32358: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /** + * @license + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + Object.defineProperty(exports, '__esModule', { value: true }) + const fs = __webpack_require__(35747) + const path = __webpack_require__(85622) + const Protobuf = __webpack_require__(85881) + function addIncludePathResolver(root, includePaths) { + const originalResolvePath = root.resolvePath + root.resolvePath = (origin, target) => { + if (path.isAbsolute(target)) { + return target + } + for (const directory of includePaths) { + const fullPath = path.join(directory, target) + try { + fs.accessSync(fullPath, fs.constants.R_OK) + return fullPath + } catch (err) { + continue + } + } + process.emitWarning( + `${target} not found in any of the include paths ${includePaths}` + ) + return originalResolvePath(origin, target) + } + } + async function loadProtosWithOptions(filename, options) { + const root = new Protobuf.Root() + options = options || {} + if (!!options.includeDirs) { + if (!Array.isArray(options.includeDirs)) { + return Promise.reject( + new Error('The includeDirs option must be an array') + ) + } + addIncludePathResolver(root, options.includeDirs) + } + const loadedRoot = await root.load(filename, options) + loadedRoot.resolveAll() + return loadedRoot + } + exports.loadProtosWithOptions = loadProtosWithOptions + function loadProtosWithOptionsSync(filename, options) { + const root = new Protobuf.Root() + options = options || {} + if (!!options.includeDirs) { + if (!Array.isArray(options.includeDirs)) { + throw new Error('The includeDirs option must be an array') + } + addIncludePathResolver(root, options.includeDirs) + } + const loadedRoot = root.loadSync(filename, options) + loadedRoot.resolveAll() + return loadedRoot + } + exports.loadProtosWithOptionsSync = loadProtosWithOptionsSync + /** + * Load Google's well-known proto files that aren't exposed by Protobuf.js. + */ + function addCommonProtos() { + // Protobuf.js exposes: any, duration, empty, field_mask, struct, timestamp, + // and wrappers. compiler/plugin is excluded in Protobuf.js and here. + // Using constant strings for compatibility with tools like Webpack + const apiDescriptor = __webpack_require__(78155) + const descriptorDescriptor = __webpack_require__(40333) + const sourceContextDescriptor = __webpack_require__(56663) + const typeDescriptor = __webpack_require__(75715) + Protobuf.common( + 'api', + apiDescriptor.nested.google.nested.protobuf.nested + ) + Protobuf.common( + 'descriptor', + descriptorDescriptor.nested.google.nested.protobuf.nested + ) + Protobuf.common( + 'source_context', + sourceContextDescriptor.nested.google.nested.protobuf.nested + ) + Protobuf.common( + 'type', + typeDescriptor.nested.google.nested.protobuf.nested + ) + } + exports.addCommonProtos = addCommonProtos + //# sourceMappingURL=util.js.map + + /***/ + }, + + /***/ 16627: /***/ (module, exports) => { + exports = module.exports = SemVer + + var debug + /* istanbul ignore next */ + if ( + typeof process === 'object' && + process.env && + process.env.NODE_DEBUG && + /\bsemver\b/i.test(process.env.NODE_DEBUG) + ) { + debug = function () { + var args = Array.prototype.slice.call(arguments, 0) + args.unshift('SEMVER') + console.log.apply(console, args) + } + } else { + debug = function () {} + } + + // Note: this is the semver.org version of the spec that it implements + // Not necessarily the package version of this code. + exports.SEMVER_SPEC_VERSION = '2.0.0' + + var MAX_LENGTH = 256 + var MAX_SAFE_INTEGER = + Number.MAX_SAFE_INTEGER || /* istanbul ignore next */ 9007199254740991 + + // Max safe segment length for coercion. + var MAX_SAFE_COMPONENT_LENGTH = 16 + + // The actual regexps go on exports.re + var re = (exports.re = []) + var src = (exports.src = []) + var t = (exports.tokens = {}) + var R = 0 + + function tok(n) { + t[n] = R++ + } + + // The following Regular Expressions can be used for tokenizing, + // validating, and parsing SemVer version strings. + + // ## Numeric Identifier + // A single `0`, or a non-zero digit followed by zero or more digits. + + tok('NUMERICIDENTIFIER') + src[t.NUMERICIDENTIFIER] = '0|[1-9]\\d*' + tok('NUMERICIDENTIFIERLOOSE') + src[t.NUMERICIDENTIFIERLOOSE] = '[0-9]+' + + // ## Non-numeric Identifier + // Zero or more digits, followed by a letter or hyphen, and then zero or + // more letters, digits, or hyphens. + + tok('NONNUMERICIDENTIFIER') + src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*' + + // ## Main Version + // Three dot-separated numeric identifiers. + + tok('MAINVERSION') + src[t.MAINVERSION] = + '(' + + src[t.NUMERICIDENTIFIER] + + ')\\.' + + '(' + + src[t.NUMERICIDENTIFIER] + + ')\\.' + + '(' + + src[t.NUMERICIDENTIFIER] + + ')' + + tok('MAINVERSIONLOOSE') + src[t.MAINVERSIONLOOSE] = + '(' + + src[t.NUMERICIDENTIFIERLOOSE] + + ')\\.' + + '(' + + src[t.NUMERICIDENTIFIERLOOSE] + + ')\\.' + + '(' + + src[t.NUMERICIDENTIFIERLOOSE] + + ')' + + // ## Pre-release Version Identifier + // A numeric identifier, or a non-numeric identifier. + + tok('PRERELEASEIDENTIFIER') + src[t.PRERELEASEIDENTIFIER] = + '(?:' + + src[t.NUMERICIDENTIFIER] + + '|' + + src[t.NONNUMERICIDENTIFIER] + + ')' + + tok('PRERELEASEIDENTIFIERLOOSE') + src[t.PRERELEASEIDENTIFIERLOOSE] = + '(?:' + + src[t.NUMERICIDENTIFIERLOOSE] + + '|' + + src[t.NONNUMERICIDENTIFIER] + + ')' + + // ## Pre-release Version + // Hyphen, followed by one or more dot-separated pre-release version + // identifiers. + + tok('PRERELEASE') + src[t.PRERELEASE] = + '(?:-(' + + src[t.PRERELEASEIDENTIFIER] + + '(?:\\.' + + src[t.PRERELEASEIDENTIFIER] + + ')*))' + + tok('PRERELEASELOOSE') + src[t.PRERELEASELOOSE] = + '(?:-?(' + + src[t.PRERELEASEIDENTIFIERLOOSE] + + '(?:\\.' + + src[t.PRERELEASEIDENTIFIERLOOSE] + + ')*))' + + // ## Build Metadata Identifier + // Any combination of digits, letters, or hyphens. + + tok('BUILDIDENTIFIER') + src[t.BUILDIDENTIFIER] = '[0-9A-Za-z-]+' + + // ## Build Metadata + // Plus sign, followed by one or more period-separated build metadata + // identifiers. + + tok('BUILD') + src[t.BUILD] = + '(?:\\+(' + + src[t.BUILDIDENTIFIER] + + '(?:\\.' + + src[t.BUILDIDENTIFIER] + + ')*))' + + // ## Full Version String + // A main version, followed optionally by a pre-release version and + // build metadata. + + // Note that the only major, minor, patch, and pre-release sections of + // the version string are capturing groups. The build metadata is not a + // capturing group, because it should not ever be used in version + // comparison. + + tok('FULL') + tok('FULLPLAIN') + src[t.FULLPLAIN] = + 'v?' + src[t.MAINVERSION] + src[t.PRERELEASE] + '?' + src[t.BUILD] + '?' + + src[t.FULL] = '^' + src[t.FULLPLAIN] + '$' + + // like full, but allows v1.2.3 and =1.2.3, which people do sometimes. + // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty + // common in the npm registry. + tok('LOOSEPLAIN') + src[t.LOOSEPLAIN] = + '[v=\\s]*' + + src[t.MAINVERSIONLOOSE] + + src[t.PRERELEASELOOSE] + + '?' + + src[t.BUILD] + + '?' + + tok('LOOSE') + src[t.LOOSE] = '^' + src[t.LOOSEPLAIN] + '$' + + tok('GTLT') + src[t.GTLT] = '((?:<|>)?=?)' + + // Something like "2.*" or "1.2.x". + // Note that "x.x" is a valid xRange identifer, meaning "any version" + // Only the first item is strictly required. + tok('XRANGEIDENTIFIERLOOSE') + src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + '|x|X|\\*' + tok('XRANGEIDENTIFIER') + src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + '|x|X|\\*' + + tok('XRANGEPLAIN') + src[t.XRANGEPLAIN] = + '[v=\\s]*(' + + src[t.XRANGEIDENTIFIER] + + ')' + + '(?:\\.(' + + src[t.XRANGEIDENTIFIER] + + ')' + + '(?:\\.(' + + src[t.XRANGEIDENTIFIER] + + ')' + + '(?:' + + src[t.PRERELEASE] + + ')?' + + src[t.BUILD] + + '?' + + ')?)?' + + tok('XRANGEPLAINLOOSE') + src[t.XRANGEPLAINLOOSE] = + '[v=\\s]*(' + + src[t.XRANGEIDENTIFIERLOOSE] + + ')' + + '(?:\\.(' + + src[t.XRANGEIDENTIFIERLOOSE] + + ')' + + '(?:\\.(' + + src[t.XRANGEIDENTIFIERLOOSE] + + ')' + + '(?:' + + src[t.PRERELEASELOOSE] + + ')?' + + src[t.BUILD] + + '?' + + ')?)?' + + tok('XRANGE') + src[t.XRANGE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAIN] + '$' + tok('XRANGELOOSE') + src[t.XRANGELOOSE] = + '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAINLOOSE] + '$' + + // Coercion. + // Extract anything that could conceivably be a part of a valid semver + tok('COERCE') + src[t.COERCE] = + '(^|[^\\d])' + + '(\\d{1,' + + MAX_SAFE_COMPONENT_LENGTH + + '})' + + '(?:\\.(\\d{1,' + + MAX_SAFE_COMPONENT_LENGTH + + '}))?' + + '(?:\\.(\\d{1,' + + MAX_SAFE_COMPONENT_LENGTH + + '}))?' + + '(?:$|[^\\d])' + tok('COERCERTL') + re[t.COERCERTL] = new RegExp(src[t.COERCE], 'g') + + // Tilde ranges. + // Meaning is "reasonably at or greater than" + tok('LONETILDE') + src[t.LONETILDE] = '(?:~>?)' + + tok('TILDETRIM') + src[t.TILDETRIM] = '(\\s*)' + src[t.LONETILDE] + '\\s+' + re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], 'g') + var tildeTrimReplace = '$1~' + + tok('TILDE') + src[t.TILDE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAIN] + '$' + tok('TILDELOOSE') + src[t.TILDELOOSE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + '$' + + // Caret ranges. + // Meaning is "at least and backwards compatible with" + tok('LONECARET') + src[t.LONECARET] = '(?:\\^)' + + tok('CARETTRIM') + src[t.CARETTRIM] = '(\\s*)' + src[t.LONECARET] + '\\s+' + re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], 'g') + var caretTrimReplace = '$1^' + + tok('CARET') + src[t.CARET] = '^' + src[t.LONECARET] + src[t.XRANGEPLAIN] + '$' + tok('CARETLOOSE') + src[t.CARETLOOSE] = '^' + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + '$' + + // A simple gt/lt/eq thing, or just "" to indicate "any version" + tok('COMPARATORLOOSE') + src[t.COMPARATORLOOSE] = + '^' + src[t.GTLT] + '\\s*(' + src[t.LOOSEPLAIN] + ')$|^$' + tok('COMPARATOR') + src[t.COMPARATOR] = + '^' + src[t.GTLT] + '\\s*(' + src[t.FULLPLAIN] + ')$|^$' + + // An expression to strip any whitespace between the gtlt and the thing + // it modifies, so that `> 1.2.3` ==> `>1.2.3` + tok('COMPARATORTRIM') + src[t.COMPARATORTRIM] = + '(\\s*)' + + src[t.GTLT] + + '\\s*(' + + src[t.LOOSEPLAIN] + + '|' + + src[t.XRANGEPLAIN] + + ')' + + // this one has to use the /g flag + re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], 'g') + var comparatorTrimReplace = '$1$2$3' + + // Something like `1.2.3 - 1.2.4` + // Note that these all use the loose form, because they'll be + // checked against either the strict or loose comparator form + // later. + tok('HYPHENRANGE') + src[t.HYPHENRANGE] = + '^\\s*(' + + src[t.XRANGEPLAIN] + + ')' + + '\\s+-\\s+' + + '(' + + src[t.XRANGEPLAIN] + + ')' + + '\\s*$' + + tok('HYPHENRANGELOOSE') + src[t.HYPHENRANGELOOSE] = + '^\\s*(' + + src[t.XRANGEPLAINLOOSE] + + ')' + + '\\s+-\\s+' + + '(' + + src[t.XRANGEPLAINLOOSE] + + ')' + + '\\s*$' + + // Star ranges basically just allow anything at all. + tok('STAR') + src[t.STAR] = '(<|>)?=?\\s*\\*' + + // Compile to actual regexp objects. + // All are flag-free, unless they were created above with a flag. + for (var i = 0; i < R; i++) { + debug(i, src[i]) + if (!re[i]) { + re[i] = new RegExp(src[i]) + } + } + + exports.parse = parse + function parse(version, options) { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } + + if (version instanceof SemVer) { + return version + } + + if (typeof version !== 'string') { + return null + } + + if (version.length > MAX_LENGTH) { + return null + } + + var r = options.loose ? re[t.LOOSE] : re[t.FULL] + if (!r.test(version)) { + return null + } + + try { + return new SemVer(version, options) + } catch (er) { + return null + } + } + + exports.valid = valid + function valid(version, options) { + var v = parse(version, options) + return v ? v.version : null + } + + exports.clean = clean + function clean(version, options) { + var s = parse(version.trim().replace(/^[=v]+/, ''), options) + return s ? s.version : null + } + + exports.SemVer = SemVer + + function SemVer(version, options) { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } + if (version instanceof SemVer) { + if (version.loose === options.loose) { + return version + } else { + version = version.version + } + } else if (typeof version !== 'string') { + throw new TypeError('Invalid Version: ' + version) + } + + if (version.length > MAX_LENGTH) { + throw new TypeError( + 'version is longer than ' + MAX_LENGTH + ' characters' + ) + } + + if (!(this instanceof SemVer)) { + return new SemVer(version, options) + } + + debug('SemVer', version, options) + this.options = options + this.loose = !!options.loose + + var m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]) + + if (!m) { + throw new TypeError('Invalid Version: ' + version) + } + + this.raw = version + + // these are actually numbers + this.major = +m[1] + this.minor = +m[2] + this.patch = +m[3] + + if (this.major > MAX_SAFE_INTEGER || this.major < 0) { + throw new TypeError('Invalid major version') + } + + if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) { + throw new TypeError('Invalid minor version') + } + + if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) { + throw new TypeError('Invalid patch version') + } + + // numberify any prerelease numeric ids + if (!m[4]) { + this.prerelease = [] + } else { + this.prerelease = m[4].split('.').map(function (id) { + if (/^[0-9]+$/.test(id)) { + var num = +id + if (num >= 0 && num < MAX_SAFE_INTEGER) { + return num + } + } + return id + }) + } + + this.build = m[5] ? m[5].split('.') : [] + this.format() + } + + SemVer.prototype.format = function () { + this.version = this.major + '.' + this.minor + '.' + this.patch + if (this.prerelease.length) { + this.version += '-' + this.prerelease.join('.') + } + return this.version + } + + SemVer.prototype.toString = function () { + return this.version + } + + SemVer.prototype.compare = function (other) { + debug('SemVer.compare', this.version, this.options, other) + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } + + return this.compareMain(other) || this.comparePre(other) + } + + SemVer.prototype.compareMain = function (other) { + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } + + return ( + compareIdentifiers(this.major, other.major) || + compareIdentifiers(this.minor, other.minor) || + compareIdentifiers(this.patch, other.patch) + ) + } + + SemVer.prototype.comparePre = function (other) { + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } + + // NOT having a prerelease is > having one + if (this.prerelease.length && !other.prerelease.length) { + return -1 + } else if (!this.prerelease.length && other.prerelease.length) { + return 1 + } else if (!this.prerelease.length && !other.prerelease.length) { + return 0 + } + + var i = 0 + do { + var a = this.prerelease[i] + var b = other.prerelease[i] + debug('prerelease compare', i, a, b) + if (a === undefined && b === undefined) { + return 0 + } else if (b === undefined) { + return 1 + } else if (a === undefined) { + return -1 + } else if (a === b) { + continue + } else { + return compareIdentifiers(a, b) + } + } while (++i) + } + + SemVer.prototype.compareBuild = function (other) { + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } + + var i = 0 + do { + var a = this.build[i] + var b = other.build[i] + debug('prerelease compare', i, a, b) + if (a === undefined && b === undefined) { + return 0 + } else if (b === undefined) { + return 1 + } else if (a === undefined) { + return -1 + } else if (a === b) { + continue + } else { + return compareIdentifiers(a, b) + } + } while (++i) + } + + // preminor will bump the version up to the next minor release, and immediately + // down to pre-release. premajor and prepatch work the same way. + SemVer.prototype.inc = function (release, identifier) { + switch (release) { + case 'premajor': + this.prerelease.length = 0 + this.patch = 0 + this.minor = 0 + this.major++ + this.inc('pre', identifier) + break + case 'preminor': + this.prerelease.length = 0 + this.patch = 0 + this.minor++ + this.inc('pre', identifier) + break + case 'prepatch': + // If this is already a prerelease, it will bump to the next version + // drop any prereleases that might already exist, since they are not + // relevant at this point. + this.prerelease.length = 0 + this.inc('patch', identifier) + this.inc('pre', identifier) + break + // If the input is a non-prerelease version, this acts the same as + // prepatch. + case 'prerelease': + if (this.prerelease.length === 0) { + this.inc('patch', identifier) + } + this.inc('pre', identifier) + break + + case 'major': + // If this is a pre-major version, bump up to the same major version. + // Otherwise increment major. + // 1.0.0-5 bumps to 1.0.0 + // 1.1.0 bumps to 2.0.0 + if ( + this.minor !== 0 || + this.patch !== 0 || + this.prerelease.length === 0 + ) { + this.major++ + } + this.minor = 0 + this.patch = 0 + this.prerelease = [] + break + case 'minor': + // If this is a pre-minor version, bump up to the same minor version. + // Otherwise increment minor. + // 1.2.0-5 bumps to 1.2.0 + // 1.2.1 bumps to 1.3.0 + if (this.patch !== 0 || this.prerelease.length === 0) { + this.minor++ + } + this.patch = 0 + this.prerelease = [] + break + case 'patch': + // If this is not a pre-release version, it will increment the patch. + // If it is a pre-release it will bump up to the same patch version. + // 1.2.0-5 patches to 1.2.0 + // 1.2.0 patches to 1.2.1 + if (this.prerelease.length === 0) { + this.patch++ + } + this.prerelease = [] + break + // This probably shouldn't be used publicly. + // 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction. + case 'pre': + if (this.prerelease.length === 0) { + this.prerelease = [0] + } else { + var i = this.prerelease.length + while (--i >= 0) { + if (typeof this.prerelease[i] === 'number') { + this.prerelease[i]++ + i = -2 + } + } + if (i === -1) { + // didn't increment anything + this.prerelease.push(0) + } + } + if (identifier) { + // 1.2.0-beta.1 bumps to 1.2.0-beta.2, + // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0 + if (this.prerelease[0] === identifier) { + if (isNaN(this.prerelease[1])) { + this.prerelease = [identifier, 0] + } + } else { + this.prerelease = [identifier, 0] + } + } + break + + default: + throw new Error('invalid increment argument: ' + release) + } + this.format() + this.raw = this.version + return this + } + + exports.inc = inc + function inc(version, release, loose, identifier) { + if (typeof loose === 'string') { + identifier = loose + loose = undefined + } + + try { + return new SemVer(version, loose).inc(release, identifier).version + } catch (er) { + return null + } + } + + exports.diff = diff + function diff(version1, version2) { + if (eq(version1, version2)) { + return null + } else { + var v1 = parse(version1) + var v2 = parse(version2) + var prefix = '' + if (v1.prerelease.length || v2.prerelease.length) { + prefix = 'pre' + var defaultResult = 'prerelease' + } + for (var key in v1) { + if (key === 'major' || key === 'minor' || key === 'patch') { + if (v1[key] !== v2[key]) { + return prefix + key + } + } + } + return defaultResult // may be undefined + } + } + + exports.compareIdentifiers = compareIdentifiers + + var numeric = /^[0-9]+$/ + function compareIdentifiers(a, b) { + var anum = numeric.test(a) + var bnum = numeric.test(b) + + if (anum && bnum) { + a = +a + b = +b + } + + return a === b + ? 0 + : anum && !bnum + ? -1 + : bnum && !anum + ? 1 + : a < b + ? -1 + : 1 + } + + exports.rcompareIdentifiers = rcompareIdentifiers + function rcompareIdentifiers(a, b) { + return compareIdentifiers(b, a) + } + + exports.major = major + function major(a, loose) { + return new SemVer(a, loose).major + } + + exports.minor = minor + function minor(a, loose) { + return new SemVer(a, loose).minor + } + + exports.patch = patch + function patch(a, loose) { + return new SemVer(a, loose).patch + } + + exports.compare = compare + function compare(a, b, loose) { + return new SemVer(a, loose).compare(new SemVer(b, loose)) + } + + exports.compareLoose = compareLoose + function compareLoose(a, b) { + return compare(a, b, true) + } + + exports.compareBuild = compareBuild + function compareBuild(a, b, loose) { + var versionA = new SemVer(a, loose) + var versionB = new SemVer(b, loose) + return versionA.compare(versionB) || versionA.compareBuild(versionB) + } + + exports.rcompare = rcompare + function rcompare(a, b, loose) { + return compare(b, a, loose) + } + + exports.sort = sort + function sort(list, loose) { + return list.sort(function (a, b) { + return exports.compareBuild(a, b, loose) + }) + } + + exports.rsort = rsort + function rsort(list, loose) { + return list.sort(function (a, b) { + return exports.compareBuild(b, a, loose) + }) + } + + exports.gt = gt + function gt(a, b, loose) { + return compare(a, b, loose) > 0 + } + + exports.lt = lt + function lt(a, b, loose) { + return compare(a, b, loose) < 0 + } + + exports.eq = eq + function eq(a, b, loose) { + return compare(a, b, loose) === 0 + } + + exports.neq = neq + function neq(a, b, loose) { + return compare(a, b, loose) !== 0 + } + + exports.gte = gte + function gte(a, b, loose) { + return compare(a, b, loose) >= 0 + } + + exports.lte = lte + function lte(a, b, loose) { + return compare(a, b, loose) <= 0 + } + + exports.cmp = cmp + function cmp(a, op, b, loose) { + switch (op) { + case '===': + if (typeof a === 'object') a = a.version + if (typeof b === 'object') b = b.version + return a === b + + case '!==': + if (typeof a === 'object') a = a.version + if (typeof b === 'object') b = b.version + return a !== b + + case '': + case '=': + case '==': + return eq(a, b, loose) + + case '!=': + return neq(a, b, loose) + + case '>': + return gt(a, b, loose) + + case '>=': + return gte(a, b, loose) + + case '<': + return lt(a, b, loose) + + case '<=': + return lte(a, b, loose) + + default: + throw new TypeError('Invalid operator: ' + op) + } + } + + exports.Comparator = Comparator + function Comparator(comp, options) { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } + + if (comp instanceof Comparator) { + if (comp.loose === !!options.loose) { + return comp + } else { + comp = comp.value + } + } + + if (!(this instanceof Comparator)) { + return new Comparator(comp, options) + } + + debug('comparator', comp, options) + this.options = options + this.loose = !!options.loose + this.parse(comp) + + if (this.semver === ANY) { + this.value = '' + } else { + this.value = this.operator + this.semver.version + } + + debug('comp', this) + } + + var ANY = {} + Comparator.prototype.parse = function (comp) { + var r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] + var m = comp.match(r) + + if (!m) { + throw new TypeError('Invalid comparator: ' + comp) + } + + this.operator = m[1] !== undefined ? m[1] : '' + if (this.operator === '=') { + this.operator = '' + } + + // if it literally is just '>' or '' then allow anything. + if (!m[2]) { + this.semver = ANY + } else { + this.semver = new SemVer(m[2], this.options.loose) + } + } + + Comparator.prototype.toString = function () { + return this.value + } + + Comparator.prototype.test = function (version) { + debug('Comparator.test', version, this.options.loose) + + if (this.semver === ANY || version === ANY) { + return true + } + + if (typeof version === 'string') { + try { + version = new SemVer(version, this.options) + } catch (er) { + return false + } + } + + return cmp(version, this.operator, this.semver, this.options) + } + + Comparator.prototype.intersects = function (comp, options) { + if (!(comp instanceof Comparator)) { + throw new TypeError('a Comparator is required') + } + + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } + + var rangeTmp + + if (this.operator === '') { + if (this.value === '') { + return true + } + rangeTmp = new Range(comp.value, options) + return satisfies(this.value, rangeTmp, options) + } else if (comp.operator === '') { + if (comp.value === '') { + return true + } + rangeTmp = new Range(this.value, options) + return satisfies(comp.semver, rangeTmp, options) + } + + var sameDirectionIncreasing = + (this.operator === '>=' || this.operator === '>') && + (comp.operator === '>=' || comp.operator === '>') + var sameDirectionDecreasing = + (this.operator === '<=' || this.operator === '<') && + (comp.operator === '<=' || comp.operator === '<') + var sameSemVer = this.semver.version === comp.semver.version + var differentDirectionsInclusive = + (this.operator === '>=' || this.operator === '<=') && + (comp.operator === '>=' || comp.operator === '<=') + var oppositeDirectionsLessThan = + cmp(this.semver, '<', comp.semver, options) && + (this.operator === '>=' || this.operator === '>') && + (comp.operator === '<=' || comp.operator === '<') + var oppositeDirectionsGreaterThan = + cmp(this.semver, '>', comp.semver, options) && + (this.operator === '<=' || this.operator === '<') && + (comp.operator === '>=' || comp.operator === '>') + + return ( + sameDirectionIncreasing || + sameDirectionDecreasing || + (sameSemVer && differentDirectionsInclusive) || + oppositeDirectionsLessThan || + oppositeDirectionsGreaterThan + ) + } + + exports.Range = Range + function Range(range, options) { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } + + if (range instanceof Range) { + if ( + range.loose === !!options.loose && + range.includePrerelease === !!options.includePrerelease + ) { + return range + } else { + return new Range(range.raw, options) + } + } + + if (range instanceof Comparator) { + return new Range(range.value, options) + } + + if (!(this instanceof Range)) { + return new Range(range, options) + } + + this.options = options + this.loose = !!options.loose + this.includePrerelease = !!options.includePrerelease + + // First, split based on boolean or || + this.raw = range + this.set = range + .split(/\s*\|\|\s*/) + .map(function (range) { + return this.parseRange(range.trim()) + }, this) + .filter(function (c) { + // throw out any that are not relevant for whatever reason + return c.length + }) + + if (!this.set.length) { + throw new TypeError('Invalid SemVer Range: ' + range) + } + + this.format() + } + + Range.prototype.format = function () { + this.range = this.set + .map(function (comps) { + return comps.join(' ').trim() + }) + .join('||') + .trim() + return this.range + } + + Range.prototype.toString = function () { + return this.range + } + + Range.prototype.parseRange = function (range) { + var loose = this.options.loose + range = range.trim() + // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4` + var hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE] + range = range.replace(hr, hyphenReplace) + debug('hyphen replace', range) + // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5` + range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace) + debug('comparator trim', range, re[t.COMPARATORTRIM]) + + // `~ 1.2.3` => `~1.2.3` + range = range.replace(re[t.TILDETRIM], tildeTrimReplace) + + // `^ 1.2.3` => `^1.2.3` + range = range.replace(re[t.CARETTRIM], caretTrimReplace) + + // normalize spaces + range = range.split(/\s+/).join(' ') + + // At this point, the range is completely trimmed and + // ready to be split into comparators. + + var compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] + var set = range + .split(' ') + .map(function (comp) { + return parseComparator(comp, this.options) + }, this) + .join(' ') + .split(/\s+/) + if (this.options.loose) { + // in loose mode, throw out any that are not valid comparators + set = set.filter(function (comp) { + return !!comp.match(compRe) + }) + } + set = set.map(function (comp) { + return new Comparator(comp, this.options) + }, this) + + return set + } + + Range.prototype.intersects = function (range, options) { + if (!(range instanceof Range)) { + throw new TypeError('a Range is required') + } + + return this.set.some(function (thisComparators) { + return ( + isSatisfiable(thisComparators, options) && + range.set.some(function (rangeComparators) { + return ( + isSatisfiable(rangeComparators, options) && + thisComparators.every(function (thisComparator) { + return rangeComparators.every(function (rangeComparator) { + return thisComparator.intersects(rangeComparator, options) + }) + }) + ) + }) + ) + }) + } + + // take a set of comparators and determine whether there + // exists a version which can satisfy it + function isSatisfiable(comparators, options) { + var result = true + var remainingComparators = comparators.slice() + var testComparator = remainingComparators.pop() + + while (result && remainingComparators.length) { + result = remainingComparators.every(function (otherComparator) { + return testComparator.intersects(otherComparator, options) + }) + + testComparator = remainingComparators.pop() + } + + return result + } + + // Mostly just for testing and legacy API reasons + exports.toComparators = toComparators + function toComparators(range, options) { + return new Range(range, options).set.map(function (comp) { + return comp + .map(function (c) { + return c.value + }) + .join(' ') + .trim() + .split(' ') + }) + } + + // comprised of xranges, tildes, stars, and gtlt's at this point. + // already replaced the hyphen ranges + // turn into a set of JUST comparators. + function parseComparator(comp, options) { + debug('comp', comp, options) + comp = replaceCarets(comp, options) + debug('caret', comp) + comp = replaceTildes(comp, options) + debug('tildes', comp) + comp = replaceXRanges(comp, options) + debug('xrange', comp) + comp = replaceStars(comp, options) + debug('stars', comp) + return comp + } + + function isX(id) { + return !id || id.toLowerCase() === 'x' || id === '*' + } + + // ~, ~> --> * (any, kinda silly) + // ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0 + // ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0 + // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0 + // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0 + // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0 + function replaceTildes(comp, options) { + return comp + .trim() + .split(/\s+/) + .map(function (comp) { + return replaceTilde(comp, options) + }) + .join(' ') + } + + function replaceTilde(comp, options) { + var r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE] + return comp.replace(r, function (_, M, m, p, pr) { + debug('tilde', comp, _, M, m, p, pr) + var ret + + if (isX(M)) { + ret = '' + } else if (isX(m)) { + ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0' + } else if (isX(p)) { + // ~1.2 == >=1.2.0 <1.3.0 + ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0' + } else if (pr) { + debug('replaceTilde pr', pr) + ret = + '>=' + + M + + '.' + + m + + '.' + + p + + '-' + + pr + + ' <' + + M + + '.' + + (+m + 1) + + '.0' + } else { + // ~1.2.3 == >=1.2.3 <1.3.0 + ret = + '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + (+m + 1) + '.0' + } + + debug('tilde return', ret) + return ret + }) + } + + // ^ --> * (any, kinda silly) + // ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0 + // ^2.0, ^2.0.x --> >=2.0.0 <3.0.0 + // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0 + // ^1.2.3 --> >=1.2.3 <2.0.0 + // ^1.2.0 --> >=1.2.0 <2.0.0 + function replaceCarets(comp, options) { + return comp + .trim() + .split(/\s+/) + .map(function (comp) { + return replaceCaret(comp, options) + }) + .join(' ') + } + + function replaceCaret(comp, options) { + debug('caret', comp, options) + var r = options.loose ? re[t.CARETLOOSE] : re[t.CARET] + return comp.replace(r, function (_, M, m, p, pr) { + debug('caret', comp, _, M, m, p, pr) + var ret + + if (isX(M)) { + ret = '' + } else if (isX(m)) { + ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0' + } else if (isX(p)) { + if (M === '0') { + ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0' + } else { + ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0' + } + } else if (pr) { + debug('replaceCaret pr', pr) + if (M === '0') { + if (m === '0') { + ret = + '>=' + + M + + '.' + + m + + '.' + + p + + '-' + + pr + + ' <' + + M + + '.' + + m + + '.' + + (+p + 1) + } else { + ret = + '>=' + + M + + '.' + + m + + '.' + + p + + '-' + + pr + + ' <' + + M + + '.' + + (+m + 1) + + '.0' + } + } else { + ret = + '>=' + + M + + '.' + + m + + '.' + + p + + '-' + + pr + + ' <' + + (+M + 1) + + '.0.0' + } + } else { + debug('no pr') + if (M === '0') { + if (m === '0') { + ret = + '>=' + + M + + '.' + + m + + '.' + + p + + ' <' + + M + + '.' + + m + + '.' + + (+p + 1) + } else { + ret = + '>=' + + M + + '.' + + m + + '.' + + p + + ' <' + + M + + '.' + + (+m + 1) + + '.0' + } + } else { + ret = '>=' + M + '.' + m + '.' + p + ' <' + (+M + 1) + '.0.0' + } + } + + debug('caret return', ret) + return ret + }) + } + + function replaceXRanges(comp, options) { + debug('replaceXRanges', comp, options) + return comp + .split(/\s+/) + .map(function (comp) { + return replaceXRange(comp, options) + }) + .join(' ') + } + + function replaceXRange(comp, options) { + comp = comp.trim() + var r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE] + return comp.replace(r, function (ret, gtlt, M, m, p, pr) { + debug('xRange', comp, ret, gtlt, M, m, p, pr) + var xM = isX(M) + var xm = xM || isX(m) + var xp = xm || isX(p) + var anyX = xp + + if (gtlt === '=' && anyX) { + gtlt = '' + } + + // if we're including prereleases in the match, then we need + // to fix this to -0, the lowest possible prerelease value + pr = options.includePrerelease ? '-0' : '' + + if (xM) { + if (gtlt === '>' || gtlt === '<') { + // nothing is allowed + ret = '<0.0.0-0' + } else { + // nothing is forbidden + ret = '*' + } + } else if (gtlt && anyX) { + // we know patch is an x, because we have any x at all. + // replace X with 0 + if (xm) { + m = 0 + } + p = 0 + + if (gtlt === '>') { + // >1 => >=2.0.0 + // >1.2 => >=1.3.0 + // >1.2.3 => >= 1.2.4 + gtlt = '>=' + if (xm) { + M = +M + 1 + m = 0 + p = 0 + } else { + m = +m + 1 + p = 0 + } + } else if (gtlt === '<=') { + // <=0.7.x is actually <0.8.0, since any 0.7.x should + // pass. Similarly, <=7.x is actually <8.0.0, etc. + gtlt = '<' + if (xm) { + M = +M + 1 + } else { + m = +m + 1 + } + } + + ret = gtlt + M + '.' + m + '.' + p + pr + } else if (xm) { + ret = '>=' + M + '.0.0' + pr + ' <' + (+M + 1) + '.0.0' + pr + } else if (xp) { + ret = + '>=' + + M + + '.' + + m + + '.0' + + pr + + ' <' + + M + + '.' + + (+m + 1) + + '.0' + + pr + } + + debug('xRange return', ret) + + return ret + }) + } + + // Because * is AND-ed with everything else in the comparator, + // and '' means "any version", just remove the *s entirely. + function replaceStars(comp, options) { + debug('replaceStars', comp, options) + // Looseness is ignored here. star is always as loose as it gets! + return comp.trim().replace(re[t.STAR], '') + } + + // This function is passed to string.replace(re[t.HYPHENRANGE]) + // M, m, patch, prerelease, build + // 1.2 - 3.4.5 => >=1.2.0 <=3.4.5 + // 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do + // 1.2 - 3.4 => >=1.2.0 <3.5.0 + function hyphenReplace( + $0, + from, + fM, + fm, + fp, + fpr, + fb, + to, + tM, + tm, + tp, + tpr, + tb + ) { + if (isX(fM)) { + from = '' + } else if (isX(fm)) { + from = '>=' + fM + '.0.0' + } else if (isX(fp)) { + from = '>=' + fM + '.' + fm + '.0' + } else { + from = '>=' + from + } + + if (isX(tM)) { + to = '' + } else if (isX(tm)) { + to = '<' + (+tM + 1) + '.0.0' + } else if (isX(tp)) { + to = '<' + tM + '.' + (+tm + 1) + '.0' + } else if (tpr) { + to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr + } else { + to = '<=' + to + } + + return (from + ' ' + to).trim() + } + + // if ANY of the sets match ALL of its comparators, then pass + Range.prototype.test = function (version) { + if (!version) { + return false + } + + if (typeof version === 'string') { + try { + version = new SemVer(version, this.options) + } catch (er) { + return false + } + } + + for (var i = 0; i < this.set.length; i++) { + if (testSet(this.set[i], version, this.options)) { + return true + } + } + return false + } + + function testSet(set, version, options) { + for (var i = 0; i < set.length; i++) { + if (!set[i].test(version)) { + return false + } + } + + if (version.prerelease.length && !options.includePrerelease) { + // Find the set of versions that are allowed to have prereleases + // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0 + // That should allow `1.2.3-pr.2` to pass. + // However, `1.2.4-alpha.notready` should NOT be allowed, + // even though it's within the range set by the comparators. + for (i = 0; i < set.length; i++) { + debug(set[i].semver) + if (set[i].semver === ANY) { + continue + } + + if (set[i].semver.prerelease.length > 0) { + var allowed = set[i].semver + if ( + allowed.major === version.major && + allowed.minor === version.minor && + allowed.patch === version.patch + ) { + return true + } + } + } + + // Version has a -pre, but it's not one of the ones we like. + return false + } + + return true + } + + exports.satisfies = satisfies + function satisfies(version, range, options) { + try { + range = new Range(range, options) + } catch (er) { + return false + } + return range.test(version) + } + + exports.maxSatisfying = maxSatisfying + function maxSatisfying(versions, range, options) { + var max = null + var maxSV = null + try { + var rangeObj = new Range(range, options) + } catch (er) { + return null + } + versions.forEach(function (v) { + if (rangeObj.test(v)) { + // satisfies(v, range, options) + if (!max || maxSV.compare(v) === -1) { + // compare(max, v, true) + max = v + maxSV = new SemVer(max, options) + } + } + }) + return max + } + + exports.minSatisfying = minSatisfying + function minSatisfying(versions, range, options) { + var min = null + var minSV = null + try { + var rangeObj = new Range(range, options) + } catch (er) { + return null + } + versions.forEach(function (v) { + if (rangeObj.test(v)) { + // satisfies(v, range, options) + if (!min || minSV.compare(v) === 1) { + // compare(min, v, true) + min = v + minSV = new SemVer(min, options) + } + } + }) + return min + } + + exports.minVersion = minVersion + function minVersion(range, loose) { + range = new Range(range, loose) + + var minver = new SemVer('0.0.0') + if (range.test(minver)) { + return minver + } + + minver = new SemVer('0.0.0-0') + if (range.test(minver)) { + return minver + } + + minver = null + for (var i = 0; i < range.set.length; ++i) { + var comparators = range.set[i] + + comparators.forEach(function (comparator) { + // Clone to avoid manipulating the comparator's semver object. + var compver = new SemVer(comparator.semver.version) + switch (comparator.operator) { + case '>': + if (compver.prerelease.length === 0) { + compver.patch++ + } else { + compver.prerelease.push(0) + } + compver.raw = compver.format() + /* fallthrough */ + case '': + case '>=': + if (!minver || gt(minver, compver)) { + minver = compver + } + break + case '<': + case '<=': + /* Ignore maximum versions */ + break + /* istanbul ignore next */ + default: + throw new Error('Unexpected operation: ' + comparator.operator) + } + }) + } + + if (minver && range.test(minver)) { + return minver + } + + return null + } + + exports.validRange = validRange + function validRange(range, options) { + try { + // Return '*' instead of '' so that truthiness works. + // This will throw if it's invalid anyway + return new Range(range, options).range || '*' + } catch (er) { + return null + } + } + + // Determine if version is less than all the versions possible in the range + exports.ltr = ltr + function ltr(version, range, options) { + return outside(version, range, '<', options) + } + + // Determine if version is greater than all the versions possible in the range. + exports.gtr = gtr + function gtr(version, range, options) { + return outside(version, range, '>', options) + } + + exports.outside = outside + function outside(version, range, hilo, options) { + version = new SemVer(version, options) + range = new Range(range, options) + + var gtfn, ltefn, ltfn, comp, ecomp + switch (hilo) { + case '>': + gtfn = gt + ltefn = lte + ltfn = lt + comp = '>' + ecomp = '>=' + break + case '<': + gtfn = lt + ltefn = gte + ltfn = gt + comp = '<' + ecomp = '<=' + break + default: + throw new TypeError('Must provide a hilo val of "<" or ">"') + } + + // If it satisifes the range it is not outside + if (satisfies(version, range, options)) { + return false + } + + // From now on, variable terms are as if we're in "gtr" mode. + // but note that everything is flipped for the "ltr" function. + + for (var i = 0; i < range.set.length; ++i) { + var comparators = range.set[i] + + var high = null + var low = null + + comparators.forEach(function (comparator) { + if (comparator.semver === ANY) { + comparator = new Comparator('>=0.0.0') + } + high = high || comparator + low = low || comparator + if (gtfn(comparator.semver, high.semver, options)) { + high = comparator + } else if (ltfn(comparator.semver, low.semver, options)) { + low = comparator + } + }) + + // If the edge version comparator has a operator then our version + // isn't outside it + if (high.operator === comp || high.operator === ecomp) { + return false + } + + // If the lowest version comparator has an operator and our version + // is less than it then it isn't higher than the range + if ( + (!low.operator || low.operator === comp) && + ltefn(version, low.semver) + ) { + return false + } else if (low.operator === ecomp && ltfn(version, low.semver)) { + return false + } + } + return true + } + + exports.prerelease = prerelease + function prerelease(version, options) { + var parsed = parse(version, options) + return parsed && parsed.prerelease.length ? parsed.prerelease : null + } + + exports.intersects = intersects + function intersects(r1, r2, options) { + r1 = new Range(r1, options) + r2 = new Range(r2, options) + return r1.intersects(r2) + } + + exports.coerce = coerce + function coerce(version, options) { + if (version instanceof SemVer) { + return version + } + + if (typeof version === 'number') { + version = String(version) + } + + if (typeof version !== 'string') { + return null + } + + options = options || {} + + var match = null + if (!options.rtl) { + match = version.match(re[t.COERCE]) + } else { + // Find the right-most coercible string that does not share + // a terminus with a more left-ward coercible string. + // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4' + // + // Walk through the string checking with a /g regexp + // Manually set the index so as to pick up overlapping matches. + // Stop when we get a match that ends at the string end, since no + // coercible string can be more right-ward without the same terminus. + var next + while ( + (next = re[t.COERCERTL].exec(version)) && + (!match || match.index + match[0].length !== version.length) + ) { + if ( + !match || + next.index + next[0].length !== match.index + match[0].length + ) { + match = next + } + re[t.COERCERTL].lastIndex = + next.index + next[1].length + next[2].length + } + // leave it in a clean state + re[t.COERCERTL].lastIndex = -1 + } + + if (match === null) { + return null + } + + return parse( + match[2] + '.' + (match[3] || '0') + '.' + (match[4] || '0'), + options + ) + } + + /***/ + }, + + /***/ 98171: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + Object.defineProperty(exports, '__esModule', { value: true }) + /** + * @license + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + const fs = __webpack_require__(35747) + const path = __webpack_require__(85622) + const Protobuf = __webpack_require__(85881) + const descriptor = __webpack_require__(21629) + const camelCase = __webpack_require__(7994) + const descriptorOptions = { + longs: String, + enums: String, + bytes: String, + defaults: true, + oneofs: true, + json: true + } + function joinName(baseName, name) { + if (baseName === '') { + return name + } else { + return baseName + '.' + name + } + } + function isHandledReflectionObject(obj) { + return ( + obj instanceof Protobuf.Service || + obj instanceof Protobuf.Type || + obj instanceof Protobuf.Enum + ) + } + function isNamespaceBase(obj) { + return obj instanceof Protobuf.Namespace || obj instanceof Protobuf.Root + } + function getAllHandledReflectionObjects(obj, parentName) { + const objName = joinName(parentName, obj.name) + if (isHandledReflectionObject(obj)) { + return [[objName, obj]] + } else { + if (isNamespaceBase(obj) && typeof obj.nested !== 'undefined') { + return Object.keys(obj.nested) + .map(name => { + return getAllHandledReflectionObjects(obj.nested[name], objName) + }) + .reduce( + (accumulator, currentValue) => accumulator.concat(currentValue), + [] + ) + } + } + return [] + } + function createDeserializer(cls, options) { + return function deserialize(argBuf) { + return cls.toObject(cls.decode(argBuf), options) + } + } + function createSerializer(cls) { + return function serialize(arg) { + const message = cls.fromObject(arg) + return cls.encode(message).finish() + } + } + function createMethodDefinition( + method, + serviceName, + options, + fileDescriptors + ) { + /* This is only ever called after the corresponding root.resolveAll(), so we + * can assume that the resolved request and response types are non-null */ + const requestType = method.resolvedRequestType + const responseType = method.resolvedResponseType + return { + path: '/' + serviceName + '/' + method.name, + requestStream: !!method.requestStream, + responseStream: !!method.responseStream, + requestSerialize: createSerializer(requestType), + requestDeserialize: createDeserializer(requestType, options), + responseSerialize: createSerializer(responseType), + responseDeserialize: createDeserializer(responseType, options), + // TODO(murgatroid99): Find a better way to handle this + originalName: camelCase(method.name), + requestType: createMessageDefinition(requestType, fileDescriptors), + responseType: createMessageDefinition(responseType, fileDescriptors) + } + } + function createServiceDefinition( + service, + name, + options, + fileDescriptors + ) { + const def = {} + for (const method of service.methodsArray) { + def[method.name] = createMethodDefinition( + method, + name, + options, + fileDescriptors + ) + } + return def + } + function createMessageDefinition(message, fileDescriptors) { + const messageDescriptor = message.toDescriptor('proto3') + return { + format: 'Protocol Buffer 3 DescriptorProto', + type: messageDescriptor.$type.toObject( + messageDescriptor, + descriptorOptions + ), + fileDescriptorProtos: fileDescriptors + } + } + function createEnumDefinition(enumType, fileDescriptors) { + const enumDescriptor = enumType.toDescriptor('proto3') + return { + format: 'Protocol Buffer 3 EnumDescriptorProto', + type: enumDescriptor.$type.toObject( + enumDescriptor, + descriptorOptions + ), + fileDescriptorProtos: fileDescriptors + } + } + /** + * function createDefinition(obj: Protobuf.Service, name: string, options: + * Options): ServiceDefinition; function createDefinition(obj: Protobuf.Type, + * name: string, options: Options): MessageTypeDefinition; function + * createDefinition(obj: Protobuf.Enum, name: string, options: Options): + * EnumTypeDefinition; + */ + function createDefinition(obj, name, options, fileDescriptors) { + if (obj instanceof Protobuf.Service) { + return createServiceDefinition(obj, name, options, fileDescriptors) + } else if (obj instanceof Protobuf.Type) { + return createMessageDefinition(obj, fileDescriptors) + } else if (obj instanceof Protobuf.Enum) { + return createEnumDefinition(obj, fileDescriptors) + } else { + throw new Error('Type mismatch in reflection object handling') + } + } + function createPackageDefinition(root, options) { + const def = {} + root.resolveAll() + const descriptorList = root.toDescriptor('proto3').file + const bufferList = descriptorList.map(value => + Buffer.from(descriptor.FileDescriptorProto.encode(value).finish()) + ) + for (const [name, obj] of getAllHandledReflectionObjects(root, '')) { + def[name] = createDefinition(obj, name, options, bufferList) + } + return def + } + function addIncludePathResolver(root, includePaths) { + const originalResolvePath = root.resolvePath + root.resolvePath = (origin, target) => { + if (path.isAbsolute(target)) { + return target + } + for (const directory of includePaths) { + const fullPath = path.join(directory, target) + try { + fs.accessSync(fullPath, fs.constants.R_OK) + return fullPath + } catch (err) { + continue + } + } + process.emitWarning( + `${target} not found in any of the include paths ${includePaths}` + ) + return originalResolvePath(origin, target) + } + } + /** + * Load a .proto file with the specified options. + * @param filename One or multiple file paths to load. Can be an absolute path + * or relative to an include path. + * @param options.keepCase Preserve field names. The default is to change them + * to camel case. + * @param options.longs The type that should be used to represent `long` values. + * Valid options are `Number` and `String`. Defaults to a `Long` object type + * from a library. + * @param options.enums The type that should be used to represent `enum` values. + * The only valid option is `String`. Defaults to the numeric value. + * @param options.bytes The type that should be used to represent `bytes` + * values. Valid options are `Array` and `String`. The default is to use + * `Buffer`. + * @param options.defaults Set default values on output objects. Defaults to + * `false`. + * @param options.arrays Set empty arrays for missing array values even if + * `defaults` is `false`. Defaults to `false`. + * @param options.objects Set empty objects for missing object values even if + * `defaults` is `false`. Defaults to `false`. + * @param options.oneofs Set virtual oneof properties to the present field's + * name + * @param options.includeDirs Paths to search for imported `.proto` files. + */ + function load(filename, options) { + const root = new Protobuf.Root() + options = options || {} + if (!!options.includeDirs) { + if (!Array.isArray(options.includeDirs)) { + return Promise.reject( + new Error('The includeDirs option must be an array') + ) + } + addIncludePathResolver(root, options.includeDirs) + } + return root.load(filename, options).then(loadedRoot => { + loadedRoot.resolveAll() + return createPackageDefinition(root, options) + }) + } + exports.load = load + function loadSync(filename, options) { + const root = new Protobuf.Root() + options = options || {} + if (!!options.includeDirs) { + if (!Array.isArray(options.includeDirs)) { + throw new Error('The includeDirs option must be an array') + } + addIncludePathResolver(root, options.includeDirs) + } + const loadedRoot = root.loadSync(filename, options) + loadedRoot.resolveAll() + return createPackageDefinition(root, options) + } + exports.loadSync = loadSync + // Load Google's well-known proto files that aren't exposed by Protobuf.js. + // Protobuf.js exposes: any, duration, empty, field_mask, struct, timestamp, + // and wrappers. compiler/plugin is excluded in Protobuf.js and here. + // Using constant strings for compatibility with tools like Webpack + const apiDescriptor = __webpack_require__(78155) + const descriptorDescriptor = __webpack_require__(40333) + const sourceContextDescriptor = __webpack_require__(56663) + const typeDescriptor = __webpack_require__(75715) + Protobuf.common('api', apiDescriptor.nested.google.nested.protobuf.nested) + Protobuf.common( + 'descriptor', + descriptorDescriptor.nested.google.nested.protobuf.nested + ) + Protobuf.common( + 'source_context', + sourceContextDescriptor.nested.google.nested.protobuf.nested + ) + Protobuf.common( + 'type', + typeDescriptor.nested.google.nested.protobuf.nested + ) + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 40334: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + Object.defineProperty(exports, '__esModule', { value: true }) + + async function auth(token) { + const tokenType = + token.split(/\./).length === 3 + ? 'app' + : /^v\d+\./.test(token) + ? 'installation' + : 'oauth' + return { + type: 'token', + token: token, + tokenType + } + } + + /** + * Prefix token for usage in the Authorization header + * + * @param token OAuth token or JSON Web Token + */ + function withAuthorizationPrefix(token) { + if (token.split(/\./).length === 3) { + return `bearer ${token}` + } + + return `token ${token}` + } + + async function hook(token, request, route, parameters) { + const endpoint = request.endpoint.merge(route, parameters) + endpoint.headers.authorization = withAuthorizationPrefix(token) + return request(endpoint) + } + + const createTokenAuth = function createTokenAuth(token) { + if (!token) { + throw new Error( + '[@octokit/auth-token] No token passed to createTokenAuth' + ) + } + + if (typeof token !== 'string') { + throw new Error( + '[@octokit/auth-token] Token passed to createTokenAuth is not a string' + ) + } + + token = token.replace(/^(token|bearer) +/i, '') + return Object.assign(auth.bind(null, token), { + hook: hook.bind(null, token) + }) + } + + exports.createTokenAuth = createTokenAuth + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 59440: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + Object.defineProperty(exports, '__esModule', { value: true }) + + var isPlainObject = __webpack_require__(70558) + var universalUserAgent = __webpack_require__(11292) + + function lowercaseKeys(object) { + if (!object) { + return {} + } + + return Object.keys(object).reduce((newObj, key) => { + newObj[key.toLowerCase()] = object[key] + return newObj + }, {}) + } + + function mergeDeep(defaults, options) { + const result = Object.assign({}, defaults) + Object.keys(options).forEach(key => { + if (isPlainObject.isPlainObject(options[key])) { + if (!(key in defaults)) + Object.assign(result, { + [key]: options[key] + }) + else result[key] = mergeDeep(defaults[key], options[key]) + } else { + Object.assign(result, { + [key]: options[key] + }) + } + }) + return result + } + + function removeUndefinedProperties(obj) { + for (const key in obj) { + if (obj[key] === undefined) { + delete obj[key] + } + } + + return obj + } + + function merge(defaults, route, options) { + if (typeof route === 'string') { + let [method, url] = route.split(' ') + options = Object.assign( + url + ? { + method, + url + } + : { + url: method + }, + options + ) + } else { + options = Object.assign({}, route) + } // lowercase header names before merging with defaults to avoid duplicates + + options.headers = lowercaseKeys(options.headers) // remove properties with undefined values before merging + + removeUndefinedProperties(options) + removeUndefinedProperties(options.headers) + const mergedOptions = mergeDeep(defaults || {}, options) // mediaType.previews arrays are merged, instead of overwritten + + if (defaults && defaults.mediaType.previews.length) { + mergedOptions.mediaType.previews = defaults.mediaType.previews + .filter( + preview => !mergedOptions.mediaType.previews.includes(preview) + ) + .concat(mergedOptions.mediaType.previews) + } + + mergedOptions.mediaType.previews = mergedOptions.mediaType.previews.map( + preview => preview.replace(/-preview/, '') + ) + return mergedOptions + } + + function addQueryParameters(url, parameters) { + const separator = /\?/.test(url) ? '&' : '?' + const names = Object.keys(parameters) + + if (names.length === 0) { + return url + } + + return ( + url + + separator + + names + .map(name => { + if (name === 'q') { + return ( + 'q=' + + parameters.q.split('+').map(encodeURIComponent).join('+') + ) + } + + return `${name}=${encodeURIComponent(parameters[name])}` + }) + .join('&') + ) + } + + const urlVariableRegex = /\{[^}]+\}/g + + function removeNonChars(variableName) { + return variableName.replace(/^\W+|\W+$/g, '').split(/,/) + } + + function extractUrlVariableNames(url) { + const matches = url.match(urlVariableRegex) + + if (!matches) { + return [] + } + + return matches.map(removeNonChars).reduce((a, b) => a.concat(b), []) + } + + function omit(object, keysToOmit) { + return Object.keys(object) + .filter(option => !keysToOmit.includes(option)) + .reduce((obj, key) => { + obj[key] = object[key] + return obj + }, {}) + } + + // Based on https://github.com/bramstein/url-template, licensed under BSD + // TODO: create separate package. + // + // Copyright (c) 2012-2014, Bram Stein + // All rights reserved. + // Redistribution and use in source and binary forms, with or without + // modification, are permitted provided that the following conditions + // are met: + // 1. Redistributions of source code must retain the above copyright + // notice, this list of conditions and the following disclaimer. + // 2. Redistributions in binary form must reproduce the above copyright + // notice, this list of conditions and the following disclaimer in the + // documentation and/or other materials provided with the distribution. + // 3. The name of the author may not be used to endorse or promote products + // derived from this software without specific prior written permission. + // THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED + // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + // EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + /* istanbul ignore file */ + function encodeReserved(str) { + return str + .split(/(%[0-9A-Fa-f]{2})/g) + .map(function (part) { + if (!/%[0-9A-Fa-f]/.test(part)) { + part = encodeURI(part).replace(/%5B/g, '[').replace(/%5D/g, ']') + } + + return part + }) + .join('') + } + + function encodeUnreserved(str) { + return encodeURIComponent(str).replace(/[!'()*]/g, function (c) { + return '%' + c.charCodeAt(0).toString(16).toUpperCase() + }) + } + + function encodeValue(operator, value, key) { + value = + operator === '+' || operator === '#' + ? encodeReserved(value) + : encodeUnreserved(value) + + if (key) { + return encodeUnreserved(key) + '=' + value + } else { + return value + } + } + + function isDefined(value) { + return value !== undefined && value !== null + } + + function isKeyOperator(operator) { + return operator === ';' || operator === '&' || operator === '?' + } + + function getValues(context, operator, key, modifier) { + var value = context[key], + result = [] + + if (isDefined(value) && value !== '') { + if ( + typeof value === 'string' || + typeof value === 'number' || + typeof value === 'boolean' + ) { + value = value.toString() + + if (modifier && modifier !== '*') { + value = value.substring(0, parseInt(modifier, 10)) + } + + result.push( + encodeValue(operator, value, isKeyOperator(operator) ? key : '') + ) + } else { + if (modifier === '*') { + if (Array.isArray(value)) { + value.filter(isDefined).forEach(function (value) { + result.push( + encodeValue( + operator, + value, + isKeyOperator(operator) ? key : '' + ) + ) + }) + } else { + Object.keys(value).forEach(function (k) { + if (isDefined(value[k])) { + result.push(encodeValue(operator, value[k], k)) + } + }) + } + } else { + const tmp = [] + + if (Array.isArray(value)) { + value.filter(isDefined).forEach(function (value) { + tmp.push(encodeValue(operator, value)) + }) + } else { + Object.keys(value).forEach(function (k) { + if (isDefined(value[k])) { + tmp.push(encodeUnreserved(k)) + tmp.push(encodeValue(operator, value[k].toString())) + } + }) + } + + if (isKeyOperator(operator)) { + result.push(encodeUnreserved(key) + '=' + tmp.join(',')) + } else if (tmp.length !== 0) { + result.push(tmp.join(',')) + } + } + } + } else { + if (operator === ';') { + if (isDefined(value)) { + result.push(encodeUnreserved(key)) + } + } else if (value === '' && (operator === '&' || operator === '?')) { + result.push(encodeUnreserved(key) + '=') + } else if (value === '') { + result.push('') + } + } + + return result + } + + function parseUrl(template) { + return { + expand: expand.bind(null, template) + } + } + + function expand(template, context) { + var operators = ['+', '#', '.', '/', ';', '?', '&'] + return template.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g, function ( + _, + expression, + literal + ) { + if (expression) { + let operator = '' + const values = [] + + if (operators.indexOf(expression.charAt(0)) !== -1) { + operator = expression.charAt(0) + expression = expression.substr(1) + } + + expression.split(/,/g).forEach(function (variable) { + var tmp = /([^:\*]*)(?::(\d+)|(\*))?/.exec(variable) + values.push( + getValues(context, operator, tmp[1], tmp[2] || tmp[3]) + ) + }) + + if (operator && operator !== '+') { + var separator = ',' + + if (operator === '?') { + separator = '&' + } else if (operator !== '#') { + separator = operator + } + + return ( + (values.length !== 0 ? operator : '') + values.join(separator) + ) + } else { + return values.join(',') + } + } else { + return encodeReserved(literal) + } + }) + } + + function parse(options) { + // https://fetch.spec.whatwg.org/#methods + let method = options.method.toUpperCase() // replace :varname with {varname} to make it RFC 6570 compatible + + let url = (options.url || '/').replace(/:([a-z]\w+)/g, '{$1}') + let headers = Object.assign({}, options.headers) + let body + let parameters = omit(options, [ + 'method', + 'baseUrl', + 'url', + 'headers', + 'request', + 'mediaType' + ]) // extract variable names from URL to calculate remaining variables later + + const urlVariableNames = extractUrlVariableNames(url) + url = parseUrl(url).expand(parameters) + + if (!/^http/.test(url)) { + url = options.baseUrl + url + } + + const omittedParameters = Object.keys(options) + .filter(option => urlVariableNames.includes(option)) + .concat('baseUrl') + const remainingParameters = omit(parameters, omittedParameters) + const isBinaryRequest = /application\/octet-stream/i.test( + headers.accept + ) + + if (!isBinaryRequest) { + if (options.mediaType.format) { + // e.g. application/vnd.github.v3+json => application/vnd.github.v3.raw + headers.accept = headers.accept + .split(/,/) + .map(preview => + preview.replace( + /application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/, + `application/vnd$1$2.${options.mediaType.format}` + ) + ) + .join(',') + } + + if (options.mediaType.previews.length) { + const previewsFromAcceptHeader = + headers.accept.match(/[\w-]+(?=-preview)/g) || [] + headers.accept = previewsFromAcceptHeader + .concat(options.mediaType.previews) + .map(preview => { + const format = options.mediaType.format + ? `.${options.mediaType.format}` + : '+json' + return `application/vnd.github.${preview}-preview${format}` + }) + .join(',') + } + } // for GET/HEAD requests, set URL query parameters from remaining parameters + // for PATCH/POST/PUT/DELETE requests, set request body from remaining parameters + + if (['GET', 'HEAD'].includes(method)) { + url = addQueryParameters(url, remainingParameters) + } else { + if ('data' in remainingParameters) { + body = remainingParameters.data + } else { + if (Object.keys(remainingParameters).length) { + body = remainingParameters + } else { + headers['content-length'] = 0 + } + } + } // default content-type for JSON if body is set + + if (!headers['content-type'] && typeof body !== 'undefined') { + headers['content-type'] = 'application/json; charset=utf-8' + } // GitHub expects 'content-length: 0' header for PUT/PATCH requests without body. + // fetch does not allow to set `content-length` header, but we can set body to an empty string + + if (['PATCH', 'PUT'].includes(method) && typeof body === 'undefined') { + body = '' + } // Only return body/request keys if present + + return Object.assign( + { + method, + url, + headers + }, + typeof body !== 'undefined' + ? { + body + } + : null, + options.request + ? { + request: options.request + } + : null + ) + } + + function endpointWithDefaults(defaults, route, options) { + return parse(merge(defaults, route, options)) + } + + function withDefaults(oldDefaults, newDefaults) { + const DEFAULTS = merge(oldDefaults, newDefaults) + const endpoint = endpointWithDefaults.bind(null, DEFAULTS) + return Object.assign(endpoint, { + DEFAULTS, + defaults: withDefaults.bind(null, DEFAULTS), + merge: merge.bind(null, DEFAULTS), + parse + }) + } + + const VERSION = '6.0.9' + + const userAgent = `octokit-endpoint.js/${VERSION} ${universalUserAgent.getUserAgent()}` // DEFAULTS has all properties set that EndpointOptions has, except url. + // So we use RequestParameters and add method as additional required property. + + const DEFAULTS = { + method: 'GET', + baseUrl: 'https://api.github.com', + headers: { + accept: 'application/vnd.github.v3+json', + 'user-agent': userAgent + }, + mediaType: { + format: '', + previews: [] + } + } + + const endpoint = withDefaults(null, DEFAULTS) + + exports.endpoint = endpoint + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 70558: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + Object.defineProperty(exports, '__esModule', { value: true }) + + /*! + * is-plain-object + * + * Copyright (c) 2014-2017, Jon Schlinkert. + * Released under the MIT License. + */ + + function isObject(o) { + return Object.prototype.toString.call(o) === '[object Object]' + } + + function isPlainObject(o) { + var ctor, prot + + if (isObject(o) === false) return false + + // If has modified constructor + ctor = o.constructor + if (ctor === undefined) return true + + // If has modified prototype + prot = ctor.prototype + if (isObject(prot) === false) return false + + // If constructor does not have an Object-specific method + if (prot.hasOwnProperty('isPrototypeOf') === false) { + return false + } + + // Most likely a plain Object + return true + } + + exports.isPlainObject = isPlainObject + + /***/ + }, + + /***/ 11292: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + Object.defineProperty(exports, '__esModule', { value: true }) + + function getUserAgent() { + if (typeof navigator === 'object' && 'userAgent' in navigator) { + return navigator.userAgent + } + + if (typeof process === 'object' && 'version' in process) { + return `Node.js/${process.version.substr(1)} (${process.platform}; ${ + process.arch + })` + } + + return '' + } + + exports.getUserAgent = getUserAgent + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 88467: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + Object.defineProperty(exports, '__esModule', { value: true }) + + var request = __webpack_require__(36234) + var universalUserAgent = __webpack_require__(45030) + + const VERSION = '4.3.1' + + class GraphqlError extends Error { + constructor(request, response) { + const message = response.data.errors[0].message + super(message) + Object.assign(this, response.data) + this.name = 'GraphqlError' + this.request = request // Maintains proper stack trace (only available on V8) + + /* istanbul ignore next */ + + if (Error.captureStackTrace) { + Error.captureStackTrace(this, this.constructor) + } + } + } + + const NON_VARIABLE_OPTIONS = [ + 'method', + 'baseUrl', + 'url', + 'headers', + 'request', + 'query' + ] + function graphql(request, query, options) { + options = + typeof query === 'string' + ? (options = Object.assign( + { + query + }, + options + )) + : (options = query) + const requestOptions = Object.keys(options).reduce((result, key) => { + if (NON_VARIABLE_OPTIONS.includes(key)) { + result[key] = options[key] + return result + } + + if (!result.variables) { + result.variables = {} + } + + result.variables[key] = options[key] + return result + }, {}) + return request(requestOptions).then(response => { + if (response.data.errors) { + throw new GraphqlError(requestOptions, { + data: response.data + }) + } + + return response.data.data + }) + } + + function withDefaults(request$1, newDefaults) { + const newRequest = request$1.defaults(newDefaults) + + const newApi = (query, options) => { + return graphql(newRequest, query, options) + } + + return Object.assign(newApi, { + defaults: withDefaults.bind(null, newRequest), + endpoint: request.request.endpoint + }) + } + + const graphql$1 = withDefaults(request.request, { + headers: { + 'user-agent': `octokit-graphql.js/${VERSION} ${universalUserAgent.getUserAgent()}` + }, + method: 'POST', + url: '/graphql' + }) + function withCustomRequest(customRequest) { + return withDefaults(customRequest, { + method: 'POST', + url: '/graphql' + }) + } + + exports.graphql = graphql$1 + exports.withCustomRequest = withCustomRequest + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 64193: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + Object.defineProperty(exports, '__esModule', { value: true }) + + const VERSION = '1.1.2' + + /** + * Some “list” response that can be paginated have a different response structure + * + * They have a `total_count` key in the response (search also has `incomplete_results`, + * /installation/repositories also has `repository_selection`), as well as a key with + * the list of the items which name varies from endpoint to endpoint: + * + * - https://developer.github.com/v3/search/#example (key `items`) + * - https://developer.github.com/v3/checks/runs/#response-3 (key: `check_runs`) + * - https://developer.github.com/v3/checks/suites/#response-1 (key: `check_suites`) + * - https://developer.github.com/v3/apps/installations/#list-repositories (key: `repositories`) + * - https://developer.github.com/v3/apps/installations/#list-installations-for-a-user (key `installations`) + * + * Octokit normalizes these responses so that paginated results are always returned following + * the same structure. One challenge is that if the list response has only one page, no Link + * header is provided, so this header alone is not sufficient to check wether a response is + * paginated or not. For the exceptions with the namespace, a fallback check for the route + * paths has to be added in order to normalize the response. We cannot check for the total_count + * property because it also exists in the response of Get the combined status for a specific ref. + */ + const REGEX = [ + /^\/search\//, + /^\/repos\/[^/]+\/[^/]+\/commits\/[^/]+\/(check-runs|check-suites)([^/]|$)/, + /^\/installation\/repositories([^/]|$)/, + /^\/user\/installations([^/]|$)/, + /^\/repos\/[^/]+\/[^/]+\/actions\/secrets([^/]|$)/, + /^\/repos\/[^/]+\/[^/]+\/actions\/workflows(\/[^/]+\/runs)?([^/]|$)/, + /^\/repos\/[^/]+\/[^/]+\/actions\/runs(\/[^/]+\/(artifacts|jobs))?([^/]|$)/ + ] + function normalizePaginatedListResponse(octokit, url, response) { + const path = url.replace(octokit.request.endpoint.DEFAULTS.baseUrl, '') + const responseNeedsNormalization = REGEX.find(regex => regex.test(path)) + if (!responseNeedsNormalization) return // keep the additional properties intact as there is currently no other way + // to retrieve the same information. + + const incompleteResults = response.data.incomplete_results + const repositorySelection = response.data.repository_selection + const totalCount = response.data.total_count + delete response.data.incomplete_results + delete response.data.repository_selection + delete response.data.total_count + const namespaceKey = Object.keys(response.data)[0] + const data = response.data[namespaceKey] + response.data = data + + if (typeof incompleteResults !== 'undefined') { + response.data.incomplete_results = incompleteResults + } + + if (typeof repositorySelection !== 'undefined') { + response.data.repository_selection = repositorySelection + } + + response.data.total_count = totalCount + Object.defineProperty(response.data, namespaceKey, { + get() { + octokit.log.warn( + `[@octokit/paginate-rest] "response.data.${namespaceKey}" is deprecated for "GET ${path}". Get the results directly from "response.data"` + ) + return Array.from(data) + } + }) + } + + function iterator(octokit, route, parameters) { + const options = octokit.request.endpoint(route, parameters) + const method = options.method + const headers = options.headers + let url = options.url + return { + [Symbol.asyncIterator]: () => ({ + next() { + if (!url) { + return Promise.resolve({ + done: true + }) + } + + return octokit + .request({ + method, + url, + headers + }) + .then(response => { + normalizePaginatedListResponse(octokit, url, response) // `response.headers.link` format: + // '; rel="next", ; rel="last"' + // sets `url` to undefined if "next" URL is not present or `link` header is not set + + url = ((response.headers.link || '').match( + /<([^>]+)>;\s*rel="next"/ + ) || [])[1] + return { + value: response + } + }) + } + }) + } + } + + function paginate(octokit, route, parameters, mapFn) { + if (typeof parameters === 'function') { + mapFn = parameters + parameters = undefined + } + + return gather( + octokit, + [], + iterator(octokit, route, parameters)[Symbol.asyncIterator](), + mapFn + ) + } + + function gather(octokit, results, iterator, mapFn) { + return iterator.next().then(result => { + if (result.done) { + return results + } + + let earlyExit = false + + function done() { + earlyExit = true + } + + results = results.concat( + mapFn ? mapFn(result.value, done) : result.value.data + ) + + if (earlyExit) { + return results + } + + return gather(octokit, results, iterator, mapFn) + }) + } + + /** + * @param octokit Octokit instance + * @param options Options passed to Octokit constructor + */ + + function paginateRest(octokit) { + return { + paginate: Object.assign(paginate.bind(null, octokit), { + iterator: iterator.bind(null, octokit) + }) + } + } + paginateRest.VERSION = VERSION + + exports.paginateRest = paginateRest + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 68883: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + Object.defineProperty(exports, '__esModule', { value: true }) + + const VERSION = '1.0.2' + + /** + * @param octokit Octokit instance + * @param options Options passed to Octokit constructor + */ + + function requestLog(octokit) { + octokit.hook.wrap('request', (request, options) => { + octokit.log.debug('request', options) + const start = Date.now() + const requestOptions = octokit.request.endpoint.parse(options) + const path = requestOptions.url.replace(options.baseUrl, '') + return request(options) + .then(response => { + octokit.log.info( + `${requestOptions.method} ${path} - ${response.status} in ${ + Date.now() - start + }ms` + ) + return response + }) + .catch(error => { + octokit.log.info( + `${requestOptions.method} ${path} - ${error.status} in ${ + Date.now() - start + }ms` + ) + throw error + }) + }) + } + requestLog.VERSION = VERSION + + exports.requestLog = requestLog + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 83044: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + Object.defineProperty(exports, '__esModule', { value: true }) + + var deprecation = __webpack_require__(58932) + + var endpointsByScope = { + actions: { + cancelWorkflowRun: { + method: 'POST', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + run_id: { + required: true, + type: 'integer' + } + }, + url: '/repos/:owner/:repo/actions/runs/:run_id/cancel' + }, + createOrUpdateSecretForRepo: { + method: 'PUT', + params: { + encrypted_value: { + type: 'string' + }, + key_id: { + type: 'string' + }, + name: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/actions/secrets/:name' + }, + createRegistrationToken: { + method: 'POST', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/actions/runners/registration-token' + }, + createRemoveToken: { + method: 'POST', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/actions/runners/remove-token' + }, + deleteArtifact: { + method: 'DELETE', + params: { + artifact_id: { + required: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/actions/artifacts/:artifact_id' + }, + deleteSecretFromRepo: { + method: 'DELETE', + params: { + name: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/actions/secrets/:name' + }, + downloadArtifact: { + method: 'GET', + params: { + archive_format: { + required: true, + type: 'string' + }, + artifact_id: { + required: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: + '/repos/:owner/:repo/actions/artifacts/:artifact_id/:archive_format' + }, + getArtifact: { + method: 'GET', + params: { + artifact_id: { + required: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/actions/artifacts/:artifact_id' + }, + getPublicKey: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/actions/secrets/public-key' + }, + getSecret: { + method: 'GET', + params: { + name: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/actions/secrets/:name' + }, + getSelfHostedRunner: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + runner_id: { + required: true, + type: 'integer' + } + }, + url: '/repos/:owner/:repo/actions/runners/:runner_id' + }, + getWorkflow: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + workflow_id: { + required: true, + type: 'integer' + } + }, + url: '/repos/:owner/:repo/actions/workflows/:workflow_id' + }, + getWorkflowJob: { + method: 'GET', + params: { + job_id: { + required: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/actions/jobs/:job_id' + }, + getWorkflowRun: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + run_id: { + required: true, + type: 'integer' + } + }, + url: '/repos/:owner/:repo/actions/runs/:run_id' + }, + listDownloadsForSelfHostedRunnerApplication: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/actions/runners/downloads' + }, + listJobsForWorkflowRun: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + }, + run_id: { + required: true, + type: 'integer' + } + }, + url: '/repos/:owner/:repo/actions/runs/:run_id/jobs' + }, + listRepoWorkflowRuns: { + method: 'GET', + params: { + actor: { + type: 'string' + }, + branch: { + type: 'string' + }, + event: { + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + }, + status: { + enum: ['completed', 'status', 'conclusion'], + type: 'string' + } + }, + url: '/repos/:owner/:repo/actions/runs' + }, + listRepoWorkflows: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/actions/workflows' + }, + listSecretsForRepo: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/actions/secrets' + }, + listSelfHostedRunnersForRepo: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/actions/runners' + }, + listWorkflowJobLogs: { + method: 'GET', + params: { + job_id: { + required: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/actions/jobs/:job_id/logs' + }, + listWorkflowRunArtifacts: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + }, + run_id: { + required: true, + type: 'integer' + } + }, + url: '/repos/:owner/:repo/actions/runs/:run_id/artifacts' + }, + listWorkflowRunLogs: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + }, + run_id: { + required: true, + type: 'integer' + } + }, + url: '/repos/:owner/:repo/actions/runs/:run_id/logs' + }, + listWorkflowRuns: { + method: 'GET', + params: { + actor: { + type: 'string' + }, + branch: { + type: 'string' + }, + event: { + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + }, + status: { + enum: ['completed', 'status', 'conclusion'], + type: 'string' + }, + workflow_id: { + required: true, + type: 'integer' + } + }, + url: '/repos/:owner/:repo/actions/workflows/:workflow_id/runs' + }, + reRunWorkflow: { + method: 'POST', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + run_id: { + required: true, + type: 'integer' + } + }, + url: '/repos/:owner/:repo/actions/runs/:run_id/rerun' + }, + removeSelfHostedRunner: { + method: 'DELETE', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + runner_id: { + required: true, + type: 'integer' + } + }, + url: '/repos/:owner/:repo/actions/runners/:runner_id' + } + }, + activity: { + checkStarringRepo: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/user/starred/:owner/:repo' + }, + deleteRepoSubscription: { + method: 'DELETE', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/subscription' + }, + deleteThreadSubscription: { + method: 'DELETE', + params: { + thread_id: { + required: true, + type: 'integer' + } + }, + url: '/notifications/threads/:thread_id/subscription' + }, + getRepoSubscription: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/subscription' + }, + getThread: { + method: 'GET', + params: { + thread_id: { + required: true, + type: 'integer' + } + }, + url: '/notifications/threads/:thread_id' + }, + getThreadSubscription: { + method: 'GET', + params: { + thread_id: { + required: true, + type: 'integer' + } + }, + url: '/notifications/threads/:thread_id/subscription' + }, + listEventsForOrg: { + method: 'GET', + params: { + org: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/users/:username/events/orgs/:org' + }, + listEventsForUser: { + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/users/:username/events' + }, + listFeeds: { + method: 'GET', + params: {}, + url: '/feeds' + }, + listNotifications: { + method: 'GET', + params: { + all: { + type: 'boolean' + }, + before: { + type: 'string' + }, + page: { + type: 'integer' + }, + participating: { + type: 'boolean' + }, + per_page: { + type: 'integer' + }, + since: { + type: 'string' + } + }, + url: '/notifications' + }, + listNotificationsForRepo: { + method: 'GET', + params: { + all: { + type: 'boolean' + }, + before: { + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + participating: { + type: 'boolean' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + }, + since: { + type: 'string' + } + }, + url: '/repos/:owner/:repo/notifications' + }, + listPublicEvents: { + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + } + }, + url: '/events' + }, + listPublicEventsForOrg: { + method: 'GET', + params: { + org: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + } + }, + url: '/orgs/:org/events' + }, + listPublicEventsForRepoNetwork: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/networks/:owner/:repo/events' + }, + listPublicEventsForUser: { + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/users/:username/events/public' + }, + listReceivedEventsForUser: { + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/users/:username/received_events' + }, + listReceivedPublicEventsForUser: { + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/users/:username/received_events/public' + }, + listRepoEvents: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/events' + }, + listReposStarredByAuthenticatedUser: { + method: 'GET', + params: { + direction: { + enum: ['asc', 'desc'], + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + sort: { + enum: ['created', 'updated'], + type: 'string' + } + }, + url: '/user/starred' + }, + listReposStarredByUser: { + method: 'GET', + params: { + direction: { + enum: ['asc', 'desc'], + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + sort: { + enum: ['created', 'updated'], + type: 'string' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/users/:username/starred' + }, + listReposWatchedByUser: { + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/users/:username/subscriptions' + }, + listStargazersForRepo: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/stargazers' + }, + listWatchedReposForAuthenticatedUser: { + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + } + }, + url: '/user/subscriptions' + }, + listWatchersForRepo: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/subscribers' + }, + markAsRead: { + method: 'PUT', + params: { + last_read_at: { + type: 'string' + } + }, + url: '/notifications' + }, + markNotificationsAsReadForRepo: { + method: 'PUT', + params: { + last_read_at: { + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/notifications' + }, + markThreadAsRead: { + method: 'PATCH', + params: { + thread_id: { + required: true, + type: 'integer' + } + }, + url: '/notifications/threads/:thread_id' + }, + setRepoSubscription: { + method: 'PUT', + params: { + ignored: { + type: 'boolean' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + subscribed: { + type: 'boolean' + } + }, + url: '/repos/:owner/:repo/subscription' + }, + setThreadSubscription: { + method: 'PUT', + params: { + ignored: { + type: 'boolean' + }, + thread_id: { + required: true, + type: 'integer' + } + }, + url: '/notifications/threads/:thread_id/subscription' + }, + starRepo: { + method: 'PUT', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/user/starred/:owner/:repo' + }, + unstarRepo: { + method: 'DELETE', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/user/starred/:owner/:repo' + } + }, + apps: { + addRepoToInstallation: { + headers: { + accept: 'application/vnd.github.machine-man-preview+json' + }, + method: 'PUT', + params: { + installation_id: { + required: true, + type: 'integer' + }, + repository_id: { + required: true, + type: 'integer' + } + }, + url: + '/user/installations/:installation_id/repositories/:repository_id' + }, + checkAccountIsAssociatedWithAny: { + method: 'GET', + params: { + account_id: { + required: true, + type: 'integer' + } + }, + url: '/marketplace_listing/accounts/:account_id' + }, + checkAccountIsAssociatedWithAnyStubbed: { + method: 'GET', + params: { + account_id: { + required: true, + type: 'integer' + } + }, + url: '/marketplace_listing/stubbed/accounts/:account_id' + }, + checkAuthorization: { + deprecated: + 'octokit.apps.checkAuthorization() is deprecated, see https://developer.github.com/v3/apps/oauth_applications/#check-an-authorization', + method: 'GET', + params: { + access_token: { + required: true, + type: 'string' + }, + client_id: { + required: true, + type: 'string' + } + }, + url: '/applications/:client_id/tokens/:access_token' + }, + checkToken: { + headers: { + accept: 'application/vnd.github.doctor-strange-preview+json' + }, + method: 'POST', + params: { + access_token: { + type: 'string' + }, + client_id: { + required: true, + type: 'string' + } + }, + url: '/applications/:client_id/token' + }, + createContentAttachment: { + headers: { + accept: 'application/vnd.github.corsair-preview+json' + }, + method: 'POST', + params: { + body: { + required: true, + type: 'string' + }, + content_reference_id: { + required: true, + type: 'integer' + }, + title: { + required: true, + type: 'string' + } + }, + url: '/content_references/:content_reference_id/attachments' + }, + createFromManifest: { + headers: { + accept: 'application/vnd.github.fury-preview+json' + }, + method: 'POST', + params: { + code: { + required: true, + type: 'string' + } + }, + url: '/app-manifests/:code/conversions' + }, + createInstallationToken: { + headers: { + accept: 'application/vnd.github.machine-man-preview+json' + }, + method: 'POST', + params: { + installation_id: { + required: true, + type: 'integer' + }, + permissions: { + type: 'object' + }, + repository_ids: { + type: 'integer[]' + } + }, + url: '/app/installations/:installation_id/access_tokens' + }, + deleteAuthorization: { + headers: { + accept: 'application/vnd.github.doctor-strange-preview+json' + }, + method: 'DELETE', + params: { + access_token: { + type: 'string' + }, + client_id: { + required: true, + type: 'string' + } + }, + url: '/applications/:client_id/grant' + }, + deleteInstallation: { + headers: { + accept: + 'application/vnd.github.gambit-preview+json,application/vnd.github.machine-man-preview+json' + }, + method: 'DELETE', + params: { + installation_id: { + required: true, + type: 'integer' + } + }, + url: '/app/installations/:installation_id' + }, + deleteToken: { + headers: { + accept: 'application/vnd.github.doctor-strange-preview+json' + }, + method: 'DELETE', + params: { + access_token: { + type: 'string' + }, + client_id: { + required: true, + type: 'string' + } + }, + url: '/applications/:client_id/token' + }, + findOrgInstallation: { + deprecated: + 'octokit.apps.findOrgInstallation() has been renamed to octokit.apps.getOrgInstallation() (2019-04-10)', + headers: { + accept: 'application/vnd.github.machine-man-preview+json' + }, + method: 'GET', + params: { + org: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/installation' + }, + findRepoInstallation: { + deprecated: + 'octokit.apps.findRepoInstallation() has been renamed to octokit.apps.getRepoInstallation() (2019-04-10)', + headers: { + accept: 'application/vnd.github.machine-man-preview+json' + }, + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/installation' + }, + findUserInstallation: { + deprecated: + 'octokit.apps.findUserInstallation() has been renamed to octokit.apps.getUserInstallation() (2019-04-10)', + headers: { + accept: 'application/vnd.github.machine-man-preview+json' + }, + method: 'GET', + params: { + username: { + required: true, + type: 'string' + } + }, + url: '/users/:username/installation' + }, + getAuthenticated: { + headers: { + accept: 'application/vnd.github.machine-man-preview+json' + }, + method: 'GET', + params: {}, + url: '/app' + }, + getBySlug: { + headers: { + accept: 'application/vnd.github.machine-man-preview+json' + }, + method: 'GET', + params: { + app_slug: { + required: true, + type: 'string' + } + }, + url: '/apps/:app_slug' + }, + getInstallation: { + headers: { + accept: 'application/vnd.github.machine-man-preview+json' + }, + method: 'GET', + params: { + installation_id: { + required: true, + type: 'integer' + } + }, + url: '/app/installations/:installation_id' + }, + getOrgInstallation: { + headers: { + accept: 'application/vnd.github.machine-man-preview+json' + }, + method: 'GET', + params: { + org: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/installation' + }, + getRepoInstallation: { + headers: { + accept: 'application/vnd.github.machine-man-preview+json' + }, + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/installation' + }, + getUserInstallation: { + headers: { + accept: 'application/vnd.github.machine-man-preview+json' + }, + method: 'GET', + params: { + username: { + required: true, + type: 'string' + } + }, + url: '/users/:username/installation' + }, + listAccountsUserOrOrgOnPlan: { + method: 'GET', + params: { + direction: { + enum: ['asc', 'desc'], + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + plan_id: { + required: true, + type: 'integer' + }, + sort: { + enum: ['created', 'updated'], + type: 'string' + } + }, + url: '/marketplace_listing/plans/:plan_id/accounts' + }, + listAccountsUserOrOrgOnPlanStubbed: { + method: 'GET', + params: { + direction: { + enum: ['asc', 'desc'], + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + plan_id: { + required: true, + type: 'integer' + }, + sort: { + enum: ['created', 'updated'], + type: 'string' + } + }, + url: '/marketplace_listing/stubbed/plans/:plan_id/accounts' + }, + listInstallationReposForAuthenticatedUser: { + headers: { + accept: 'application/vnd.github.machine-man-preview+json' + }, + method: 'GET', + params: { + installation_id: { + required: true, + type: 'integer' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + } + }, + url: '/user/installations/:installation_id/repositories' + }, + listInstallations: { + headers: { + accept: 'application/vnd.github.machine-man-preview+json' + }, + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + } + }, + url: '/app/installations' + }, + listInstallationsForAuthenticatedUser: { + headers: { + accept: 'application/vnd.github.machine-man-preview+json' + }, + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + } + }, + url: '/user/installations' + }, + listMarketplacePurchasesForAuthenticatedUser: { + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + } + }, + url: '/user/marketplace_purchases' + }, + listMarketplacePurchasesForAuthenticatedUserStubbed: { + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + } + }, + url: '/user/marketplace_purchases/stubbed' + }, + listPlans: { + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + } + }, + url: '/marketplace_listing/plans' + }, + listPlansStubbed: { + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + } + }, + url: '/marketplace_listing/stubbed/plans' + }, + listRepos: { + headers: { + accept: 'application/vnd.github.machine-man-preview+json' + }, + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + } + }, + url: '/installation/repositories' + }, + removeRepoFromInstallation: { + headers: { + accept: 'application/vnd.github.machine-man-preview+json' + }, + method: 'DELETE', + params: { + installation_id: { + required: true, + type: 'integer' + }, + repository_id: { + required: true, + type: 'integer' + } + }, + url: + '/user/installations/:installation_id/repositories/:repository_id' + }, + resetAuthorization: { + deprecated: + 'octokit.apps.resetAuthorization() is deprecated, see https://developer.github.com/v3/apps/oauth_applications/#reset-an-authorization', + method: 'POST', + params: { + access_token: { + required: true, + type: 'string' + }, + client_id: { + required: true, + type: 'string' + } + }, + url: '/applications/:client_id/tokens/:access_token' + }, + resetToken: { + headers: { + accept: 'application/vnd.github.doctor-strange-preview+json' + }, + method: 'PATCH', + params: { + access_token: { + type: 'string' + }, + client_id: { + required: true, + type: 'string' + } + }, + url: '/applications/:client_id/token' + }, + revokeAuthorizationForApplication: { + deprecated: + 'octokit.apps.revokeAuthorizationForApplication() is deprecated, see https://developer.github.com/v3/apps/oauth_applications/#revoke-an-authorization-for-an-application', + method: 'DELETE', + params: { + access_token: { + required: true, + type: 'string' + }, + client_id: { + required: true, + type: 'string' + } + }, + url: '/applications/:client_id/tokens/:access_token' + }, + revokeGrantForApplication: { + deprecated: + 'octokit.apps.revokeGrantForApplication() is deprecated, see https://developer.github.com/v3/apps/oauth_applications/#revoke-a-grant-for-an-application', + method: 'DELETE', + params: { + access_token: { + required: true, + type: 'string' + }, + client_id: { + required: true, + type: 'string' + } + }, + url: '/applications/:client_id/grants/:access_token' + }, + revokeInstallationToken: { + headers: { + accept: 'application/vnd.github.gambit-preview+json' + }, + method: 'DELETE', + params: {}, + url: '/installation/token' + } + }, + checks: { + create: { + headers: { + accept: 'application/vnd.github.antiope-preview+json' + }, + method: 'POST', + params: { + actions: { + type: 'object[]' + }, + 'actions[].description': { + required: true, + type: 'string' + }, + 'actions[].identifier': { + required: true, + type: 'string' + }, + 'actions[].label': { + required: true, + type: 'string' + }, + completed_at: { + type: 'string' + }, + conclusion: { + enum: [ + 'success', + 'failure', + 'neutral', + 'cancelled', + 'timed_out', + 'action_required' + ], + type: 'string' + }, + details_url: { + type: 'string' + }, + external_id: { + type: 'string' + }, + head_sha: { + required: true, + type: 'string' + }, + name: { + required: true, + type: 'string' + }, + output: { + type: 'object' + }, + 'output.annotations': { + type: 'object[]' + }, + 'output.annotations[].annotation_level': { + enum: ['notice', 'warning', 'failure'], + required: true, + type: 'string' + }, + 'output.annotations[].end_column': { + type: 'integer' + }, + 'output.annotations[].end_line': { + required: true, + type: 'integer' + }, + 'output.annotations[].message': { + required: true, + type: 'string' + }, + 'output.annotations[].path': { + required: true, + type: 'string' + }, + 'output.annotations[].raw_details': { + type: 'string' + }, + 'output.annotations[].start_column': { + type: 'integer' + }, + 'output.annotations[].start_line': { + required: true, + type: 'integer' + }, + 'output.annotations[].title': { + type: 'string' + }, + 'output.images': { + type: 'object[]' + }, + 'output.images[].alt': { + required: true, + type: 'string' + }, + 'output.images[].caption': { + type: 'string' + }, + 'output.images[].image_url': { + required: true, + type: 'string' + }, + 'output.summary': { + required: true, + type: 'string' + }, + 'output.text': { + type: 'string' + }, + 'output.title': { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + started_at: { + type: 'string' + }, + status: { + enum: ['queued', 'in_progress', 'completed'], + type: 'string' + } + }, + url: '/repos/:owner/:repo/check-runs' + }, + createSuite: { + headers: { + accept: 'application/vnd.github.antiope-preview+json' + }, + method: 'POST', + params: { + head_sha: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/check-suites' + }, + get: { + headers: { + accept: 'application/vnd.github.antiope-preview+json' + }, + method: 'GET', + params: { + check_run_id: { + required: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/check-runs/:check_run_id' + }, + getSuite: { + headers: { + accept: 'application/vnd.github.antiope-preview+json' + }, + method: 'GET', + params: { + check_suite_id: { + required: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/check-suites/:check_suite_id' + }, + listAnnotations: { + headers: { + accept: 'application/vnd.github.antiope-preview+json' + }, + method: 'GET', + params: { + check_run_id: { + required: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/check-runs/:check_run_id/annotations' + }, + listForRef: { + headers: { + accept: 'application/vnd.github.antiope-preview+json' + }, + method: 'GET', + params: { + check_name: { + type: 'string' + }, + filter: { + enum: ['latest', 'all'], + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + ref: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + status: { + enum: ['queued', 'in_progress', 'completed'], + type: 'string' + } + }, + url: '/repos/:owner/:repo/commits/:ref/check-runs' + }, + listForSuite: { + headers: { + accept: 'application/vnd.github.antiope-preview+json' + }, + method: 'GET', + params: { + check_name: { + type: 'string' + }, + check_suite_id: { + required: true, + type: 'integer' + }, + filter: { + enum: ['latest', 'all'], + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + }, + status: { + enum: ['queued', 'in_progress', 'completed'], + type: 'string' + } + }, + url: '/repos/:owner/:repo/check-suites/:check_suite_id/check-runs' + }, + listSuitesForRef: { + headers: { + accept: 'application/vnd.github.antiope-preview+json' + }, + method: 'GET', + params: { + app_id: { + type: 'integer' + }, + check_name: { + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + ref: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/commits/:ref/check-suites' + }, + rerequestSuite: { + headers: { + accept: 'application/vnd.github.antiope-preview+json' + }, + method: 'POST', + params: { + check_suite_id: { + required: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/check-suites/:check_suite_id/rerequest' + }, + setSuitesPreferences: { + headers: { + accept: 'application/vnd.github.antiope-preview+json' + }, + method: 'PATCH', + params: { + auto_trigger_checks: { + type: 'object[]' + }, + 'auto_trigger_checks[].app_id': { + required: true, + type: 'integer' + }, + 'auto_trigger_checks[].setting': { + required: true, + type: 'boolean' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/check-suites/preferences' + }, + update: { + headers: { + accept: 'application/vnd.github.antiope-preview+json' + }, + method: 'PATCH', + params: { + actions: { + type: 'object[]' + }, + 'actions[].description': { + required: true, + type: 'string' + }, + 'actions[].identifier': { + required: true, + type: 'string' + }, + 'actions[].label': { + required: true, + type: 'string' + }, + check_run_id: { + required: true, + type: 'integer' + }, + completed_at: { + type: 'string' + }, + conclusion: { + enum: [ + 'success', + 'failure', + 'neutral', + 'cancelled', + 'timed_out', + 'action_required' + ], + type: 'string' + }, + details_url: { + type: 'string' + }, + external_id: { + type: 'string' + }, + name: { + type: 'string' + }, + output: { + type: 'object' + }, + 'output.annotations': { + type: 'object[]' + }, + 'output.annotations[].annotation_level': { + enum: ['notice', 'warning', 'failure'], + required: true, + type: 'string' + }, + 'output.annotations[].end_column': { + type: 'integer' + }, + 'output.annotations[].end_line': { + required: true, + type: 'integer' + }, + 'output.annotations[].message': { + required: true, + type: 'string' + }, + 'output.annotations[].path': { + required: true, + type: 'string' + }, + 'output.annotations[].raw_details': { + type: 'string' + }, + 'output.annotations[].start_column': { + type: 'integer' + }, + 'output.annotations[].start_line': { + required: true, + type: 'integer' + }, + 'output.annotations[].title': { + type: 'string' + }, + 'output.images': { + type: 'object[]' + }, + 'output.images[].alt': { + required: true, + type: 'string' + }, + 'output.images[].caption': { + type: 'string' + }, + 'output.images[].image_url': { + required: true, + type: 'string' + }, + 'output.summary': { + required: true, + type: 'string' + }, + 'output.text': { + type: 'string' + }, + 'output.title': { + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + started_at: { + type: 'string' + }, + status: { + enum: ['queued', 'in_progress', 'completed'], + type: 'string' + } + }, + url: '/repos/:owner/:repo/check-runs/:check_run_id' + } + }, + codesOfConduct: { + getConductCode: { + headers: { + accept: 'application/vnd.github.scarlet-witch-preview+json' + }, + method: 'GET', + params: { + key: { + required: true, + type: 'string' + } + }, + url: '/codes_of_conduct/:key' + }, + getForRepo: { + headers: { + accept: 'application/vnd.github.scarlet-witch-preview+json' + }, + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/community/code_of_conduct' + }, + listConductCodes: { + headers: { + accept: 'application/vnd.github.scarlet-witch-preview+json' + }, + method: 'GET', + params: {}, + url: '/codes_of_conduct' + } + }, + emojis: { + get: { + method: 'GET', + params: {}, + url: '/emojis' + } + }, + gists: { + checkIsStarred: { + method: 'GET', + params: { + gist_id: { + required: true, + type: 'string' + } + }, + url: '/gists/:gist_id/star' + }, + create: { + method: 'POST', + params: { + description: { + type: 'string' + }, + files: { + required: true, + type: 'object' + }, + 'files.content': { + type: 'string' + }, + public: { + type: 'boolean' + } + }, + url: '/gists' + }, + createComment: { + method: 'POST', + params: { + body: { + required: true, + type: 'string' + }, + gist_id: { + required: true, + type: 'string' + } + }, + url: '/gists/:gist_id/comments' + }, + delete: { + method: 'DELETE', + params: { + gist_id: { + required: true, + type: 'string' + } + }, + url: '/gists/:gist_id' + }, + deleteComment: { + method: 'DELETE', + params: { + comment_id: { + required: true, + type: 'integer' + }, + gist_id: { + required: true, + type: 'string' + } + }, + url: '/gists/:gist_id/comments/:comment_id' + }, + fork: { + method: 'POST', + params: { + gist_id: { + required: true, + type: 'string' + } + }, + url: '/gists/:gist_id/forks' + }, + get: { + method: 'GET', + params: { + gist_id: { + required: true, + type: 'string' + } + }, + url: '/gists/:gist_id' + }, + getComment: { + method: 'GET', + params: { + comment_id: { + required: true, + type: 'integer' + }, + gist_id: { + required: true, + type: 'string' + } + }, + url: '/gists/:gist_id/comments/:comment_id' + }, + getRevision: { + method: 'GET', + params: { + gist_id: { + required: true, + type: 'string' + }, + sha: { + required: true, + type: 'string' + } + }, + url: '/gists/:gist_id/:sha' + }, + list: { + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + since: { + type: 'string' + } + }, + url: '/gists' + }, + listComments: { + method: 'GET', + params: { + gist_id: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + } + }, + url: '/gists/:gist_id/comments' + }, + listCommits: { + method: 'GET', + params: { + gist_id: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + } + }, + url: '/gists/:gist_id/commits' + }, + listForks: { + method: 'GET', + params: { + gist_id: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + } + }, + url: '/gists/:gist_id/forks' + }, + listPublic: { + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + since: { + type: 'string' + } + }, + url: '/gists/public' + }, + listPublicForUser: { + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + since: { + type: 'string' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/users/:username/gists' + }, + listStarred: { + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + since: { + type: 'string' + } + }, + url: '/gists/starred' + }, + star: { + method: 'PUT', + params: { + gist_id: { + required: true, + type: 'string' + } + }, + url: '/gists/:gist_id/star' + }, + unstar: { + method: 'DELETE', + params: { + gist_id: { + required: true, + type: 'string' + } + }, + url: '/gists/:gist_id/star' + }, + update: { + method: 'PATCH', + params: { + description: { + type: 'string' + }, + files: { + type: 'object' + }, + 'files.content': { + type: 'string' + }, + 'files.filename': { + type: 'string' + }, + gist_id: { + required: true, + type: 'string' + } + }, + url: '/gists/:gist_id' + }, + updateComment: { + method: 'PATCH', + params: { + body: { + required: true, + type: 'string' + }, + comment_id: { + required: true, + type: 'integer' + }, + gist_id: { + required: true, + type: 'string' + } + }, + url: '/gists/:gist_id/comments/:comment_id' + } + }, + git: { + createBlob: { + method: 'POST', + params: { + content: { + required: true, + type: 'string' + }, + encoding: { + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/git/blobs' + }, + createCommit: { + method: 'POST', + params: { + author: { + type: 'object' + }, + 'author.date': { + type: 'string' + }, + 'author.email': { + type: 'string' + }, + 'author.name': { + type: 'string' + }, + committer: { + type: 'object' + }, + 'committer.date': { + type: 'string' + }, + 'committer.email': { + type: 'string' + }, + 'committer.name': { + type: 'string' + }, + message: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + parents: { + required: true, + type: 'string[]' + }, + repo: { + required: true, + type: 'string' + }, + signature: { + type: 'string' + }, + tree: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/git/commits' + }, + createRef: { + method: 'POST', + params: { + owner: { + required: true, + type: 'string' + }, + ref: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + sha: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/git/refs' + }, + createTag: { + method: 'POST', + params: { + message: { + required: true, + type: 'string' + }, + object: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + tag: { + required: true, + type: 'string' + }, + tagger: { + type: 'object' + }, + 'tagger.date': { + type: 'string' + }, + 'tagger.email': { + type: 'string' + }, + 'tagger.name': { + type: 'string' + }, + type: { + enum: ['commit', 'tree', 'blob'], + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/git/tags' + }, + createTree: { + method: 'POST', + params: { + base_tree: { + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + tree: { + required: true, + type: 'object[]' + }, + 'tree[].content': { + type: 'string' + }, + 'tree[].mode': { + enum: ['100644', '100755', '040000', '160000', '120000'], + type: 'string' + }, + 'tree[].path': { + type: 'string' + }, + 'tree[].sha': { + allowNull: true, + type: 'string' + }, + 'tree[].type': { + enum: ['blob', 'tree', 'commit'], + type: 'string' + } + }, + url: '/repos/:owner/:repo/git/trees' + }, + deleteRef: { + method: 'DELETE', + params: { + owner: { + required: true, + type: 'string' + }, + ref: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/git/refs/:ref' + }, + getBlob: { + method: 'GET', + params: { + file_sha: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/git/blobs/:file_sha' + }, + getCommit: { + method: 'GET', + params: { + commit_sha: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/git/commits/:commit_sha' + }, + getRef: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + ref: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/git/ref/:ref' + }, + getTag: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + tag_sha: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/git/tags/:tag_sha' + }, + getTree: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + recursive: { + enum: ['1'], + type: 'integer' + }, + repo: { + required: true, + type: 'string' + }, + tree_sha: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/git/trees/:tree_sha' + }, + listMatchingRefs: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + ref: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/git/matching-refs/:ref' + }, + listRefs: { + method: 'GET', + params: { + namespace: { + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/git/refs/:namespace' + }, + updateRef: { + method: 'PATCH', + params: { + force: { + type: 'boolean' + }, + owner: { + required: true, + type: 'string' + }, + ref: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + sha: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/git/refs/:ref' + } + }, + gitignore: { + getTemplate: { + method: 'GET', + params: { + name: { + required: true, + type: 'string' + } + }, + url: '/gitignore/templates/:name' + }, + listTemplates: { + method: 'GET', + params: {}, + url: '/gitignore/templates' + } + }, + interactions: { + addOrUpdateRestrictionsForOrg: { + headers: { + accept: 'application/vnd.github.sombra-preview+json' + }, + method: 'PUT', + params: { + limit: { + enum: [ + 'existing_users', + 'contributors_only', + 'collaborators_only' + ], + required: true, + type: 'string' + }, + org: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/interaction-limits' + }, + addOrUpdateRestrictionsForRepo: { + headers: { + accept: 'application/vnd.github.sombra-preview+json' + }, + method: 'PUT', + params: { + limit: { + enum: [ + 'existing_users', + 'contributors_only', + 'collaborators_only' + ], + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/interaction-limits' + }, + getRestrictionsForOrg: { + headers: { + accept: 'application/vnd.github.sombra-preview+json' + }, + method: 'GET', + params: { + org: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/interaction-limits' + }, + getRestrictionsForRepo: { + headers: { + accept: 'application/vnd.github.sombra-preview+json' + }, + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/interaction-limits' + }, + removeRestrictionsForOrg: { + headers: { + accept: 'application/vnd.github.sombra-preview+json' + }, + method: 'DELETE', + params: { + org: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/interaction-limits' + }, + removeRestrictionsForRepo: { + headers: { + accept: 'application/vnd.github.sombra-preview+json' + }, + method: 'DELETE', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/interaction-limits' + } + }, + issues: { + addAssignees: { + method: 'POST', + params: { + assignees: { + type: 'string[]' + }, + issue_number: { + required: true, + type: 'integer' + }, + number: { + alias: 'issue_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/issues/:issue_number/assignees' + }, + addLabels: { + method: 'POST', + params: { + issue_number: { + required: true, + type: 'integer' + }, + labels: { + required: true, + type: 'string[]' + }, + number: { + alias: 'issue_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/issues/:issue_number/labels' + }, + checkAssignee: { + method: 'GET', + params: { + assignee: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/assignees/:assignee' + }, + create: { + method: 'POST', + params: { + assignee: { + type: 'string' + }, + assignees: { + type: 'string[]' + }, + body: { + type: 'string' + }, + labels: { + type: 'string[]' + }, + milestone: { + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + title: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/issues' + }, + createComment: { + method: 'POST', + params: { + body: { + required: true, + type: 'string' + }, + issue_number: { + required: true, + type: 'integer' + }, + number: { + alias: 'issue_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/issues/:issue_number/comments' + }, + createLabel: { + method: 'POST', + params: { + color: { + required: true, + type: 'string' + }, + description: { + type: 'string' + }, + name: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/labels' + }, + createMilestone: { + method: 'POST', + params: { + description: { + type: 'string' + }, + due_on: { + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + state: { + enum: ['open', 'closed'], + type: 'string' + }, + title: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/milestones' + }, + deleteComment: { + method: 'DELETE', + params: { + comment_id: { + required: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/issues/comments/:comment_id' + }, + deleteLabel: { + method: 'DELETE', + params: { + name: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/labels/:name' + }, + deleteMilestone: { + method: 'DELETE', + params: { + milestone_number: { + required: true, + type: 'integer' + }, + number: { + alias: 'milestone_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/milestones/:milestone_number' + }, + get: { + method: 'GET', + params: { + issue_number: { + required: true, + type: 'integer' + }, + number: { + alias: 'issue_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/issues/:issue_number' + }, + getComment: { + method: 'GET', + params: { + comment_id: { + required: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/issues/comments/:comment_id' + }, + getEvent: { + method: 'GET', + params: { + event_id: { + required: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/issues/events/:event_id' + }, + getLabel: { + method: 'GET', + params: { + name: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/labels/:name' + }, + getMilestone: { + method: 'GET', + params: { + milestone_number: { + required: true, + type: 'integer' + }, + number: { + alias: 'milestone_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/milestones/:milestone_number' + }, + list: { + method: 'GET', + params: { + direction: { + enum: ['asc', 'desc'], + type: 'string' + }, + filter: { + enum: ['assigned', 'created', 'mentioned', 'subscribed', 'all'], + type: 'string' + }, + labels: { + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + since: { + type: 'string' + }, + sort: { + enum: ['created', 'updated', 'comments'], + type: 'string' + }, + state: { + enum: ['open', 'closed', 'all'], + type: 'string' + } + }, + url: '/issues' + }, + listAssignees: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/assignees' + }, + listComments: { + method: 'GET', + params: { + issue_number: { + required: true, + type: 'integer' + }, + number: { + alias: 'issue_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + }, + since: { + type: 'string' + } + }, + url: '/repos/:owner/:repo/issues/:issue_number/comments' + }, + listCommentsForRepo: { + method: 'GET', + params: { + direction: { + enum: ['asc', 'desc'], + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + since: { + type: 'string' + }, + sort: { + enum: ['created', 'updated'], + type: 'string' + } + }, + url: '/repos/:owner/:repo/issues/comments' + }, + listEvents: { + method: 'GET', + params: { + issue_number: { + required: true, + type: 'integer' + }, + number: { + alias: 'issue_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/issues/:issue_number/events' + }, + listEventsForRepo: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/issues/events' + }, + listEventsForTimeline: { + headers: { + accept: 'application/vnd.github.mockingbird-preview+json' + }, + method: 'GET', + params: { + issue_number: { + required: true, + type: 'integer' + }, + number: { + alias: 'issue_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/issues/:issue_number/timeline' + }, + listForAuthenticatedUser: { + method: 'GET', + params: { + direction: { + enum: ['asc', 'desc'], + type: 'string' + }, + filter: { + enum: ['assigned', 'created', 'mentioned', 'subscribed', 'all'], + type: 'string' + }, + labels: { + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + since: { + type: 'string' + }, + sort: { + enum: ['created', 'updated', 'comments'], + type: 'string' + }, + state: { + enum: ['open', 'closed', 'all'], + type: 'string' + } + }, + url: '/user/issues' + }, + listForOrg: { + method: 'GET', + params: { + direction: { + enum: ['asc', 'desc'], + type: 'string' + }, + filter: { + enum: ['assigned', 'created', 'mentioned', 'subscribed', 'all'], + type: 'string' + }, + labels: { + type: 'string' + }, + org: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + since: { + type: 'string' + }, + sort: { + enum: ['created', 'updated', 'comments'], + type: 'string' + }, + state: { + enum: ['open', 'closed', 'all'], + type: 'string' + } + }, + url: '/orgs/:org/issues' + }, + listForRepo: { + method: 'GET', + params: { + assignee: { + type: 'string' + }, + creator: { + type: 'string' + }, + direction: { + enum: ['asc', 'desc'], + type: 'string' + }, + labels: { + type: 'string' + }, + mentioned: { + type: 'string' + }, + milestone: { + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + }, + since: { + type: 'string' + }, + sort: { + enum: ['created', 'updated', 'comments'], + type: 'string' + }, + state: { + enum: ['open', 'closed', 'all'], + type: 'string' + } + }, + url: '/repos/:owner/:repo/issues' + }, + listLabelsForMilestone: { + method: 'GET', + params: { + milestone_number: { + required: true, + type: 'integer' + }, + number: { + alias: 'milestone_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/milestones/:milestone_number/labels' + }, + listLabelsForRepo: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/labels' + }, + listLabelsOnIssue: { + method: 'GET', + params: { + issue_number: { + required: true, + type: 'integer' + }, + number: { + alias: 'issue_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/issues/:issue_number/labels' + }, + listMilestonesForRepo: { + method: 'GET', + params: { + direction: { + enum: ['asc', 'desc'], + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + }, + sort: { + enum: ['due_on', 'completeness'], + type: 'string' + }, + state: { + enum: ['open', 'closed', 'all'], + type: 'string' + } + }, + url: '/repos/:owner/:repo/milestones' + }, + lock: { + method: 'PUT', + params: { + issue_number: { + required: true, + type: 'integer' + }, + lock_reason: { + enum: ['off-topic', 'too heated', 'resolved', 'spam'], + type: 'string' + }, + number: { + alias: 'issue_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/issues/:issue_number/lock' + }, + removeAssignees: { + method: 'DELETE', + params: { + assignees: { + type: 'string[]' + }, + issue_number: { + required: true, + type: 'integer' + }, + number: { + alias: 'issue_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/issues/:issue_number/assignees' + }, + removeLabel: { + method: 'DELETE', + params: { + issue_number: { + required: true, + type: 'integer' + }, + name: { + required: true, + type: 'string' + }, + number: { + alias: 'issue_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/issues/:issue_number/labels/:name' + }, + removeLabels: { + method: 'DELETE', + params: { + issue_number: { + required: true, + type: 'integer' + }, + number: { + alias: 'issue_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/issues/:issue_number/labels' + }, + replaceLabels: { + method: 'PUT', + params: { + issue_number: { + required: true, + type: 'integer' + }, + labels: { + type: 'string[]' + }, + number: { + alias: 'issue_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/issues/:issue_number/labels' + }, + unlock: { + method: 'DELETE', + params: { + issue_number: { + required: true, + type: 'integer' + }, + number: { + alias: 'issue_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/issues/:issue_number/lock' + }, + update: { + method: 'PATCH', + params: { + assignee: { + type: 'string' + }, + assignees: { + type: 'string[]' + }, + body: { + type: 'string' + }, + issue_number: { + required: true, + type: 'integer' + }, + labels: { + type: 'string[]' + }, + milestone: { + allowNull: true, + type: 'integer' + }, + number: { + alias: 'issue_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + state: { + enum: ['open', 'closed'], + type: 'string' + }, + title: { + type: 'string' + } + }, + url: '/repos/:owner/:repo/issues/:issue_number' + }, + updateComment: { + method: 'PATCH', + params: { + body: { + required: true, + type: 'string' + }, + comment_id: { + required: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/issues/comments/:comment_id' + }, + updateLabel: { + method: 'PATCH', + params: { + color: { + type: 'string' + }, + current_name: { + required: true, + type: 'string' + }, + description: { + type: 'string' + }, + name: { + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/labels/:current_name' + }, + updateMilestone: { + method: 'PATCH', + params: { + description: { + type: 'string' + }, + due_on: { + type: 'string' + }, + milestone_number: { + required: true, + type: 'integer' + }, + number: { + alias: 'milestone_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + state: { + enum: ['open', 'closed'], + type: 'string' + }, + title: { + type: 'string' + } + }, + url: '/repos/:owner/:repo/milestones/:milestone_number' + } + }, + licenses: { + get: { + method: 'GET', + params: { + license: { + required: true, + type: 'string' + } + }, + url: '/licenses/:license' + }, + getForRepo: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/license' + }, + list: { + deprecated: + 'octokit.licenses.list() has been renamed to octokit.licenses.listCommonlyUsed() (2019-03-05)', + method: 'GET', + params: {}, + url: '/licenses' + }, + listCommonlyUsed: { + method: 'GET', + params: {}, + url: '/licenses' + } + }, + markdown: { + render: { + method: 'POST', + params: { + context: { + type: 'string' + }, + mode: { + enum: ['markdown', 'gfm'], + type: 'string' + }, + text: { + required: true, + type: 'string' + } + }, + url: '/markdown' + }, + renderRaw: { + headers: { + 'content-type': 'text/plain; charset=utf-8' + }, + method: 'POST', + params: { + data: { + mapTo: 'data', + required: true, + type: 'string' + } + }, + url: '/markdown/raw' + } + }, + meta: { + get: { + method: 'GET', + params: {}, + url: '/meta' + } + }, + migrations: { + cancelImport: { + method: 'DELETE', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/import' + }, + deleteArchiveForAuthenticatedUser: { + headers: { + accept: 'application/vnd.github.wyandotte-preview+json' + }, + method: 'DELETE', + params: { + migration_id: { + required: true, + type: 'integer' + } + }, + url: '/user/migrations/:migration_id/archive' + }, + deleteArchiveForOrg: { + headers: { + accept: 'application/vnd.github.wyandotte-preview+json' + }, + method: 'DELETE', + params: { + migration_id: { + required: true, + type: 'integer' + }, + org: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/migrations/:migration_id/archive' + }, + downloadArchiveForOrg: { + headers: { + accept: 'application/vnd.github.wyandotte-preview+json' + }, + method: 'GET', + params: { + migration_id: { + required: true, + type: 'integer' + }, + org: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/migrations/:migration_id/archive' + }, + getArchiveForAuthenticatedUser: { + headers: { + accept: 'application/vnd.github.wyandotte-preview+json' + }, + method: 'GET', + params: { + migration_id: { + required: true, + type: 'integer' + } + }, + url: '/user/migrations/:migration_id/archive' + }, + getArchiveForOrg: { + deprecated: + 'octokit.migrations.getArchiveForOrg() has been renamed to octokit.migrations.downloadArchiveForOrg() (2020-01-27)', + headers: { + accept: 'application/vnd.github.wyandotte-preview+json' + }, + method: 'GET', + params: { + migration_id: { + required: true, + type: 'integer' + }, + org: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/migrations/:migration_id/archive' + }, + getCommitAuthors: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + since: { + type: 'string' + } + }, + url: '/repos/:owner/:repo/import/authors' + }, + getImportProgress: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/import' + }, + getLargeFiles: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/import/large_files' + }, + getStatusForAuthenticatedUser: { + headers: { + accept: 'application/vnd.github.wyandotte-preview+json' + }, + method: 'GET', + params: { + migration_id: { + required: true, + type: 'integer' + } + }, + url: '/user/migrations/:migration_id' + }, + getStatusForOrg: { + headers: { + accept: 'application/vnd.github.wyandotte-preview+json' + }, + method: 'GET', + params: { + migration_id: { + required: true, + type: 'integer' + }, + org: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/migrations/:migration_id' + }, + listForAuthenticatedUser: { + headers: { + accept: 'application/vnd.github.wyandotte-preview+json' + }, + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + } + }, + url: '/user/migrations' + }, + listForOrg: { + headers: { + accept: 'application/vnd.github.wyandotte-preview+json' + }, + method: 'GET', + params: { + org: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + } + }, + url: '/orgs/:org/migrations' + }, + listReposForOrg: { + headers: { + accept: 'application/vnd.github.wyandotte-preview+json' + }, + method: 'GET', + params: { + migration_id: { + required: true, + type: 'integer' + }, + org: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + } + }, + url: '/orgs/:org/migrations/:migration_id/repositories' + }, + listReposForUser: { + headers: { + accept: 'application/vnd.github.wyandotte-preview+json' + }, + method: 'GET', + params: { + migration_id: { + required: true, + type: 'integer' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + } + }, + url: '/user/:migration_id/repositories' + }, + mapCommitAuthor: { + method: 'PATCH', + params: { + author_id: { + required: true, + type: 'integer' + }, + email: { + type: 'string' + }, + name: { + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/import/authors/:author_id' + }, + setLfsPreference: { + method: 'PATCH', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + use_lfs: { + enum: ['opt_in', 'opt_out'], + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/import/lfs' + }, + startForAuthenticatedUser: { + method: 'POST', + params: { + exclude_attachments: { + type: 'boolean' + }, + lock_repositories: { + type: 'boolean' + }, + repositories: { + required: true, + type: 'string[]' + } + }, + url: '/user/migrations' + }, + startForOrg: { + method: 'POST', + params: { + exclude_attachments: { + type: 'boolean' + }, + lock_repositories: { + type: 'boolean' + }, + org: { + required: true, + type: 'string' + }, + repositories: { + required: true, + type: 'string[]' + } + }, + url: '/orgs/:org/migrations' + }, + startImport: { + method: 'PUT', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + tfvc_project: { + type: 'string' + }, + vcs: { + enum: ['subversion', 'git', 'mercurial', 'tfvc'], + type: 'string' + }, + vcs_password: { + type: 'string' + }, + vcs_url: { + required: true, + type: 'string' + }, + vcs_username: { + type: 'string' + } + }, + url: '/repos/:owner/:repo/import' + }, + unlockRepoForAuthenticatedUser: { + headers: { + accept: 'application/vnd.github.wyandotte-preview+json' + }, + method: 'DELETE', + params: { + migration_id: { + required: true, + type: 'integer' + }, + repo_name: { + required: true, + type: 'string' + } + }, + url: '/user/migrations/:migration_id/repos/:repo_name/lock' + }, + unlockRepoForOrg: { + headers: { + accept: 'application/vnd.github.wyandotte-preview+json' + }, + method: 'DELETE', + params: { + migration_id: { + required: true, + type: 'integer' + }, + org: { + required: true, + type: 'string' + }, + repo_name: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/migrations/:migration_id/repos/:repo_name/lock' + }, + updateImport: { + method: 'PATCH', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + vcs_password: { + type: 'string' + }, + vcs_username: { + type: 'string' + } + }, + url: '/repos/:owner/:repo/import' + } + }, + oauthAuthorizations: { + checkAuthorization: { + deprecated: + 'octokit.oauthAuthorizations.checkAuthorization() has been renamed to octokit.apps.checkAuthorization() (2019-11-05)', + method: 'GET', + params: { + access_token: { + required: true, + type: 'string' + }, + client_id: { + required: true, + type: 'string' + } + }, + url: '/applications/:client_id/tokens/:access_token' + }, + createAuthorization: { + deprecated: + 'octokit.oauthAuthorizations.createAuthorization() is deprecated, see https://developer.github.com/v3/oauth_authorizations/#create-a-new-authorization', + method: 'POST', + params: { + client_id: { + type: 'string' + }, + client_secret: { + type: 'string' + }, + fingerprint: { + type: 'string' + }, + note: { + required: true, + type: 'string' + }, + note_url: { + type: 'string' + }, + scopes: { + type: 'string[]' + } + }, + url: '/authorizations' + }, + deleteAuthorization: { + deprecated: + 'octokit.oauthAuthorizations.deleteAuthorization() is deprecated, see https://developer.github.com/v3/oauth_authorizations/#delete-an-authorization', + method: 'DELETE', + params: { + authorization_id: { + required: true, + type: 'integer' + } + }, + url: '/authorizations/:authorization_id' + }, + deleteGrant: { + deprecated: + 'octokit.oauthAuthorizations.deleteGrant() is deprecated, see https://developer.github.com/v3/oauth_authorizations/#delete-a-grant', + method: 'DELETE', + params: { + grant_id: { + required: true, + type: 'integer' + } + }, + url: '/applications/grants/:grant_id' + }, + getAuthorization: { + deprecated: + 'octokit.oauthAuthorizations.getAuthorization() is deprecated, see https://developer.github.com/v3/oauth_authorizations/#get-a-single-authorization', + method: 'GET', + params: { + authorization_id: { + required: true, + type: 'integer' + } + }, + url: '/authorizations/:authorization_id' + }, + getGrant: { + deprecated: + 'octokit.oauthAuthorizations.getGrant() is deprecated, see https://developer.github.com/v3/oauth_authorizations/#get-a-single-grant', + method: 'GET', + params: { + grant_id: { + required: true, + type: 'integer' + } + }, + url: '/applications/grants/:grant_id' + }, + getOrCreateAuthorizationForApp: { + deprecated: + 'octokit.oauthAuthorizations.getOrCreateAuthorizationForApp() is deprecated, see https://developer.github.com/v3/oauth_authorizations/#get-or-create-an-authorization-for-a-specific-app', + method: 'PUT', + params: { + client_id: { + required: true, + type: 'string' + }, + client_secret: { + required: true, + type: 'string' + }, + fingerprint: { + type: 'string' + }, + note: { + type: 'string' + }, + note_url: { + type: 'string' + }, + scopes: { + type: 'string[]' + } + }, + url: '/authorizations/clients/:client_id' + }, + getOrCreateAuthorizationForAppAndFingerprint: { + deprecated: + 'octokit.oauthAuthorizations.getOrCreateAuthorizationForAppAndFingerprint() is deprecated, see https://developer.github.com/v3/oauth_authorizations/#get-or-create-an-authorization-for-a-specific-app-and-fingerprint', + method: 'PUT', + params: { + client_id: { + required: true, + type: 'string' + }, + client_secret: { + required: true, + type: 'string' + }, + fingerprint: { + required: true, + type: 'string' + }, + note: { + type: 'string' + }, + note_url: { + type: 'string' + }, + scopes: { + type: 'string[]' + } + }, + url: '/authorizations/clients/:client_id/:fingerprint' + }, + getOrCreateAuthorizationForAppFingerprint: { + deprecated: + 'octokit.oauthAuthorizations.getOrCreateAuthorizationForAppFingerprint() has been renamed to octokit.oauthAuthorizations.getOrCreateAuthorizationForAppAndFingerprint() (2018-12-27)', + method: 'PUT', + params: { + client_id: { + required: true, + type: 'string' + }, + client_secret: { + required: true, + type: 'string' + }, + fingerprint: { + required: true, + type: 'string' + }, + note: { + type: 'string' + }, + note_url: { + type: 'string' + }, + scopes: { + type: 'string[]' + } + }, + url: '/authorizations/clients/:client_id/:fingerprint' + }, + listAuthorizations: { + deprecated: + 'octokit.oauthAuthorizations.listAuthorizations() is deprecated, see https://developer.github.com/v3/oauth_authorizations/#list-your-authorizations', + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + } + }, + url: '/authorizations' + }, + listGrants: { + deprecated: + 'octokit.oauthAuthorizations.listGrants() is deprecated, see https://developer.github.com/v3/oauth_authorizations/#list-your-grants', + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + } + }, + url: '/applications/grants' + }, + resetAuthorization: { + deprecated: + 'octokit.oauthAuthorizations.resetAuthorization() has been renamed to octokit.apps.resetAuthorization() (2019-11-05)', + method: 'POST', + params: { + access_token: { + required: true, + type: 'string' + }, + client_id: { + required: true, + type: 'string' + } + }, + url: '/applications/:client_id/tokens/:access_token' + }, + revokeAuthorizationForApplication: { + deprecated: + 'octokit.oauthAuthorizations.revokeAuthorizationForApplication() has been renamed to octokit.apps.revokeAuthorizationForApplication() (2019-11-05)', + method: 'DELETE', + params: { + access_token: { + required: true, + type: 'string' + }, + client_id: { + required: true, + type: 'string' + } + }, + url: '/applications/:client_id/tokens/:access_token' + }, + revokeGrantForApplication: { + deprecated: + 'octokit.oauthAuthorizations.revokeGrantForApplication() has been renamed to octokit.apps.revokeGrantForApplication() (2019-11-05)', + method: 'DELETE', + params: { + access_token: { + required: true, + type: 'string' + }, + client_id: { + required: true, + type: 'string' + } + }, + url: '/applications/:client_id/grants/:access_token' + }, + updateAuthorization: { + deprecated: + 'octokit.oauthAuthorizations.updateAuthorization() is deprecated, see https://developer.github.com/v3/oauth_authorizations/#update-an-existing-authorization', + method: 'PATCH', + params: { + add_scopes: { + type: 'string[]' + }, + authorization_id: { + required: true, + type: 'integer' + }, + fingerprint: { + type: 'string' + }, + note: { + type: 'string' + }, + note_url: { + type: 'string' + }, + remove_scopes: { + type: 'string[]' + }, + scopes: { + type: 'string[]' + } + }, + url: '/authorizations/:authorization_id' + } + }, + orgs: { + addOrUpdateMembership: { + method: 'PUT', + params: { + org: { + required: true, + type: 'string' + }, + role: { + enum: ['admin', 'member'], + type: 'string' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/memberships/:username' + }, + blockUser: { + method: 'PUT', + params: { + org: { + required: true, + type: 'string' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/blocks/:username' + }, + checkBlockedUser: { + method: 'GET', + params: { + org: { + required: true, + type: 'string' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/blocks/:username' + }, + checkMembership: { + method: 'GET', + params: { + org: { + required: true, + type: 'string' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/members/:username' + }, + checkPublicMembership: { + method: 'GET', + params: { + org: { + required: true, + type: 'string' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/public_members/:username' + }, + concealMembership: { + method: 'DELETE', + params: { + org: { + required: true, + type: 'string' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/public_members/:username' + }, + convertMemberToOutsideCollaborator: { + method: 'PUT', + params: { + org: { + required: true, + type: 'string' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/outside_collaborators/:username' + }, + createHook: { + method: 'POST', + params: { + active: { + type: 'boolean' + }, + config: { + required: true, + type: 'object' + }, + 'config.content_type': { + type: 'string' + }, + 'config.insecure_ssl': { + type: 'string' + }, + 'config.secret': { + type: 'string' + }, + 'config.url': { + required: true, + type: 'string' + }, + events: { + type: 'string[]' + }, + name: { + required: true, + type: 'string' + }, + org: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/hooks' + }, + createInvitation: { + method: 'POST', + params: { + email: { + type: 'string' + }, + invitee_id: { + type: 'integer' + }, + org: { + required: true, + type: 'string' + }, + role: { + enum: ['admin', 'direct_member', 'billing_manager'], + type: 'string' + }, + team_ids: { + type: 'integer[]' + } + }, + url: '/orgs/:org/invitations' + }, + deleteHook: { + method: 'DELETE', + params: { + hook_id: { + required: true, + type: 'integer' + }, + org: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/hooks/:hook_id' + }, + get: { + method: 'GET', + params: { + org: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org' + }, + getHook: { + method: 'GET', + params: { + hook_id: { + required: true, + type: 'integer' + }, + org: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/hooks/:hook_id' + }, + getMembership: { + method: 'GET', + params: { + org: { + required: true, + type: 'string' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/memberships/:username' + }, + getMembershipForAuthenticatedUser: { + method: 'GET', + params: { + org: { + required: true, + type: 'string' + } + }, + url: '/user/memberships/orgs/:org' + }, + list: { + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + since: { + type: 'integer' + } + }, + url: '/organizations' + }, + listBlockedUsers: { + method: 'GET', + params: { + org: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/blocks' + }, + listForAuthenticatedUser: { + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + } + }, + url: '/user/orgs' + }, + listForUser: { + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/users/:username/orgs' + }, + listHooks: { + method: 'GET', + params: { + org: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + } + }, + url: '/orgs/:org/hooks' + }, + listInstallations: { + headers: { + accept: 'application/vnd.github.machine-man-preview+json' + }, + method: 'GET', + params: { + org: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + } + }, + url: '/orgs/:org/installations' + }, + listInvitationTeams: { + method: 'GET', + params: { + invitation_id: { + required: true, + type: 'integer' + }, + org: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + } + }, + url: '/orgs/:org/invitations/:invitation_id/teams' + }, + listMembers: { + method: 'GET', + params: { + filter: { + enum: ['2fa_disabled', 'all'], + type: 'string' + }, + org: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + role: { + enum: ['all', 'admin', 'member'], + type: 'string' + } + }, + url: '/orgs/:org/members' + }, + listMemberships: { + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + state: { + enum: ['active', 'pending'], + type: 'string' + } + }, + url: '/user/memberships/orgs' + }, + listOutsideCollaborators: { + method: 'GET', + params: { + filter: { + enum: ['2fa_disabled', 'all'], + type: 'string' + }, + org: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + } + }, + url: '/orgs/:org/outside_collaborators' + }, + listPendingInvitations: { + method: 'GET', + params: { + org: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + } + }, + url: '/orgs/:org/invitations' + }, + listPublicMembers: { + method: 'GET', + params: { + org: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + } + }, + url: '/orgs/:org/public_members' + }, + pingHook: { + method: 'POST', + params: { + hook_id: { + required: true, + type: 'integer' + }, + org: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/hooks/:hook_id/pings' + }, + publicizeMembership: { + method: 'PUT', + params: { + org: { + required: true, + type: 'string' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/public_members/:username' + }, + removeMember: { + method: 'DELETE', + params: { + org: { + required: true, + type: 'string' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/members/:username' + }, + removeMembership: { + method: 'DELETE', + params: { + org: { + required: true, + type: 'string' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/memberships/:username' + }, + removeOutsideCollaborator: { + method: 'DELETE', + params: { + org: { + required: true, + type: 'string' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/outside_collaborators/:username' + }, + unblockUser: { + method: 'DELETE', + params: { + org: { + required: true, + type: 'string' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/blocks/:username' + }, + update: { + method: 'PATCH', + params: { + billing_email: { + type: 'string' + }, + company: { + type: 'string' + }, + default_repository_permission: { + enum: ['read', 'write', 'admin', 'none'], + type: 'string' + }, + description: { + type: 'string' + }, + email: { + type: 'string' + }, + has_organization_projects: { + type: 'boolean' + }, + has_repository_projects: { + type: 'boolean' + }, + location: { + type: 'string' + }, + members_allowed_repository_creation_type: { + enum: ['all', 'private', 'none'], + type: 'string' + }, + members_can_create_internal_repositories: { + type: 'boolean' + }, + members_can_create_private_repositories: { + type: 'boolean' + }, + members_can_create_public_repositories: { + type: 'boolean' + }, + members_can_create_repositories: { + type: 'boolean' + }, + name: { + type: 'string' + }, + org: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org' + }, + updateHook: { + method: 'PATCH', + params: { + active: { + type: 'boolean' + }, + config: { + type: 'object' + }, + 'config.content_type': { + type: 'string' + }, + 'config.insecure_ssl': { + type: 'string' + }, + 'config.secret': { + type: 'string' + }, + 'config.url': { + required: true, + type: 'string' + }, + events: { + type: 'string[]' + }, + hook_id: { + required: true, + type: 'integer' + }, + org: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/hooks/:hook_id' + }, + updateMembership: { + method: 'PATCH', + params: { + org: { + required: true, + type: 'string' + }, + state: { + enum: ['active'], + required: true, + type: 'string' + } + }, + url: '/user/memberships/orgs/:org' + } + }, + projects: { + addCollaborator: { + headers: { + accept: 'application/vnd.github.inertia-preview+json' + }, + method: 'PUT', + params: { + permission: { + enum: ['read', 'write', 'admin'], + type: 'string' + }, + project_id: { + required: true, + type: 'integer' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/projects/:project_id/collaborators/:username' + }, + createCard: { + headers: { + accept: 'application/vnd.github.inertia-preview+json' + }, + method: 'POST', + params: { + column_id: { + required: true, + type: 'integer' + }, + content_id: { + type: 'integer' + }, + content_type: { + type: 'string' + }, + note: { + type: 'string' + } + }, + url: '/projects/columns/:column_id/cards' + }, + createColumn: { + headers: { + accept: 'application/vnd.github.inertia-preview+json' + }, + method: 'POST', + params: { + name: { + required: true, + type: 'string' + }, + project_id: { + required: true, + type: 'integer' + } + }, + url: '/projects/:project_id/columns' + }, + createForAuthenticatedUser: { + headers: { + accept: 'application/vnd.github.inertia-preview+json' + }, + method: 'POST', + params: { + body: { + type: 'string' + }, + name: { + required: true, + type: 'string' + } + }, + url: '/user/projects' + }, + createForOrg: { + headers: { + accept: 'application/vnd.github.inertia-preview+json' + }, + method: 'POST', + params: { + body: { + type: 'string' + }, + name: { + required: true, + type: 'string' + }, + org: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/projects' + }, + createForRepo: { + headers: { + accept: 'application/vnd.github.inertia-preview+json' + }, + method: 'POST', + params: { + body: { + type: 'string' + }, + name: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/projects' + }, + delete: { + headers: { + accept: 'application/vnd.github.inertia-preview+json' + }, + method: 'DELETE', + params: { + project_id: { + required: true, + type: 'integer' + } + }, + url: '/projects/:project_id' + }, + deleteCard: { + headers: { + accept: 'application/vnd.github.inertia-preview+json' + }, + method: 'DELETE', + params: { + card_id: { + required: true, + type: 'integer' + } + }, + url: '/projects/columns/cards/:card_id' + }, + deleteColumn: { + headers: { + accept: 'application/vnd.github.inertia-preview+json' + }, + method: 'DELETE', + params: { + column_id: { + required: true, + type: 'integer' + } + }, + url: '/projects/columns/:column_id' + }, + get: { + headers: { + accept: 'application/vnd.github.inertia-preview+json' + }, + method: 'GET', + params: { + project_id: { + required: true, + type: 'integer' + } + }, + url: '/projects/:project_id' + }, + getCard: { + headers: { + accept: 'application/vnd.github.inertia-preview+json' + }, + method: 'GET', + params: { + card_id: { + required: true, + type: 'integer' + } + }, + url: '/projects/columns/cards/:card_id' + }, + getColumn: { + headers: { + accept: 'application/vnd.github.inertia-preview+json' + }, + method: 'GET', + params: { + column_id: { + required: true, + type: 'integer' + } + }, + url: '/projects/columns/:column_id' + }, + listCards: { + headers: { + accept: 'application/vnd.github.inertia-preview+json' + }, + method: 'GET', + params: { + archived_state: { + enum: ['all', 'archived', 'not_archived'], + type: 'string' + }, + column_id: { + required: true, + type: 'integer' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + } + }, + url: '/projects/columns/:column_id/cards' + }, + listCollaborators: { + headers: { + accept: 'application/vnd.github.inertia-preview+json' + }, + method: 'GET', + params: { + affiliation: { + enum: ['outside', 'direct', 'all'], + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + project_id: { + required: true, + type: 'integer' + } + }, + url: '/projects/:project_id/collaborators' + }, + listColumns: { + headers: { + accept: 'application/vnd.github.inertia-preview+json' + }, + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + project_id: { + required: true, + type: 'integer' + } + }, + url: '/projects/:project_id/columns' + }, + listForOrg: { + headers: { + accept: 'application/vnd.github.inertia-preview+json' + }, + method: 'GET', + params: { + org: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + state: { + enum: ['open', 'closed', 'all'], + type: 'string' + } + }, + url: '/orgs/:org/projects' + }, + listForRepo: { + headers: { + accept: 'application/vnd.github.inertia-preview+json' + }, + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + }, + state: { + enum: ['open', 'closed', 'all'], + type: 'string' + } + }, + url: '/repos/:owner/:repo/projects' + }, + listForUser: { + headers: { + accept: 'application/vnd.github.inertia-preview+json' + }, + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + state: { + enum: ['open', 'closed', 'all'], + type: 'string' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/users/:username/projects' + }, + moveCard: { + headers: { + accept: 'application/vnd.github.inertia-preview+json' + }, + method: 'POST', + params: { + card_id: { + required: true, + type: 'integer' + }, + column_id: { + type: 'integer' + }, + position: { + required: true, + type: 'string', + validation: '^(top|bottom|after:\\d+)$' + } + }, + url: '/projects/columns/cards/:card_id/moves' + }, + moveColumn: { + headers: { + accept: 'application/vnd.github.inertia-preview+json' + }, + method: 'POST', + params: { + column_id: { + required: true, + type: 'integer' + }, + position: { + required: true, + type: 'string', + validation: '^(first|last|after:\\d+)$' + } + }, + url: '/projects/columns/:column_id/moves' + }, + removeCollaborator: { + headers: { + accept: 'application/vnd.github.inertia-preview+json' + }, + method: 'DELETE', + params: { + project_id: { + required: true, + type: 'integer' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/projects/:project_id/collaborators/:username' + }, + reviewUserPermissionLevel: { + headers: { + accept: 'application/vnd.github.inertia-preview+json' + }, + method: 'GET', + params: { + project_id: { + required: true, + type: 'integer' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/projects/:project_id/collaborators/:username/permission' + }, + update: { + headers: { + accept: 'application/vnd.github.inertia-preview+json' + }, + method: 'PATCH', + params: { + body: { + type: 'string' + }, + name: { + type: 'string' + }, + organization_permission: { + type: 'string' + }, + private: { + type: 'boolean' + }, + project_id: { + required: true, + type: 'integer' + }, + state: { + enum: ['open', 'closed'], + type: 'string' + } + }, + url: '/projects/:project_id' + }, + updateCard: { + headers: { + accept: 'application/vnd.github.inertia-preview+json' + }, + method: 'PATCH', + params: { + archived: { + type: 'boolean' + }, + card_id: { + required: true, + type: 'integer' + }, + note: { + type: 'string' + } + }, + url: '/projects/columns/cards/:card_id' + }, + updateColumn: { + headers: { + accept: 'application/vnd.github.inertia-preview+json' + }, + method: 'PATCH', + params: { + column_id: { + required: true, + type: 'integer' + }, + name: { + required: true, + type: 'string' + } + }, + url: '/projects/columns/:column_id' + } + }, + pulls: { + checkIfMerged: { + method: 'GET', + params: { + number: { + alias: 'pull_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + pull_number: { + required: true, + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/pulls/:pull_number/merge' + }, + create: { + method: 'POST', + params: { + base: { + required: true, + type: 'string' + }, + body: { + type: 'string' + }, + draft: { + type: 'boolean' + }, + head: { + required: true, + type: 'string' + }, + maintainer_can_modify: { + type: 'boolean' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + title: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/pulls' + }, + createComment: { + method: 'POST', + params: { + body: { + required: true, + type: 'string' + }, + commit_id: { + required: true, + type: 'string' + }, + in_reply_to: { + deprecated: true, + description: + 'The comment ID to reply to. **Note**: This must be the ID of a top-level comment, not a reply to that comment. Replies to replies are not supported.', + type: 'integer' + }, + line: { + type: 'integer' + }, + number: { + alias: 'pull_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + path: { + required: true, + type: 'string' + }, + position: { + type: 'integer' + }, + pull_number: { + required: true, + type: 'integer' + }, + repo: { + required: true, + type: 'string' + }, + side: { + enum: ['LEFT', 'RIGHT'], + type: 'string' + }, + start_line: { + type: 'integer' + }, + start_side: { + enum: ['LEFT', 'RIGHT', 'side'], + type: 'string' + } + }, + url: '/repos/:owner/:repo/pulls/:pull_number/comments' + }, + createCommentReply: { + deprecated: + 'octokit.pulls.createCommentReply() has been renamed to octokit.pulls.createComment() (2019-09-09)', + method: 'POST', + params: { + body: { + required: true, + type: 'string' + }, + commit_id: { + required: true, + type: 'string' + }, + in_reply_to: { + deprecated: true, + description: + 'The comment ID to reply to. **Note**: This must be the ID of a top-level comment, not a reply to that comment. Replies to replies are not supported.', + type: 'integer' + }, + line: { + type: 'integer' + }, + number: { + alias: 'pull_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + path: { + required: true, + type: 'string' + }, + position: { + type: 'integer' + }, + pull_number: { + required: true, + type: 'integer' + }, + repo: { + required: true, + type: 'string' + }, + side: { + enum: ['LEFT', 'RIGHT'], + type: 'string' + }, + start_line: { + type: 'integer' + }, + start_side: { + enum: ['LEFT', 'RIGHT', 'side'], + type: 'string' + } + }, + url: '/repos/:owner/:repo/pulls/:pull_number/comments' + }, + createFromIssue: { + deprecated: + 'octokit.pulls.createFromIssue() is deprecated, see https://developer.github.com/v3/pulls/#create-a-pull-request', + method: 'POST', + params: { + base: { + required: true, + type: 'string' + }, + draft: { + type: 'boolean' + }, + head: { + required: true, + type: 'string' + }, + issue: { + required: true, + type: 'integer' + }, + maintainer_can_modify: { + type: 'boolean' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/pulls' + }, + createReview: { + method: 'POST', + params: { + body: { + type: 'string' + }, + comments: { + type: 'object[]' + }, + 'comments[].body': { + required: true, + type: 'string' + }, + 'comments[].path': { + required: true, + type: 'string' + }, + 'comments[].position': { + required: true, + type: 'integer' + }, + commit_id: { + type: 'string' + }, + event: { + enum: ['APPROVE', 'REQUEST_CHANGES', 'COMMENT'], + type: 'string' + }, + number: { + alias: 'pull_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + pull_number: { + required: true, + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/pulls/:pull_number/reviews' + }, + createReviewCommentReply: { + method: 'POST', + params: { + body: { + required: true, + type: 'string' + }, + comment_id: { + required: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + pull_number: { + required: true, + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: + '/repos/:owner/:repo/pulls/:pull_number/comments/:comment_id/replies' + }, + createReviewRequest: { + method: 'POST', + params: { + number: { + alias: 'pull_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + pull_number: { + required: true, + type: 'integer' + }, + repo: { + required: true, + type: 'string' + }, + reviewers: { + type: 'string[]' + }, + team_reviewers: { + type: 'string[]' + } + }, + url: '/repos/:owner/:repo/pulls/:pull_number/requested_reviewers' + }, + deleteComment: { + method: 'DELETE', + params: { + comment_id: { + required: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/pulls/comments/:comment_id' + }, + deletePendingReview: { + method: 'DELETE', + params: { + number: { + alias: 'pull_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + pull_number: { + required: true, + type: 'integer' + }, + repo: { + required: true, + type: 'string' + }, + review_id: { + required: true, + type: 'integer' + } + }, + url: '/repos/:owner/:repo/pulls/:pull_number/reviews/:review_id' + }, + deleteReviewRequest: { + method: 'DELETE', + params: { + number: { + alias: 'pull_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + pull_number: { + required: true, + type: 'integer' + }, + repo: { + required: true, + type: 'string' + }, + reviewers: { + type: 'string[]' + }, + team_reviewers: { + type: 'string[]' + } + }, + url: '/repos/:owner/:repo/pulls/:pull_number/requested_reviewers' + }, + dismissReview: { + method: 'PUT', + params: { + message: { + required: true, + type: 'string' + }, + number: { + alias: 'pull_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + pull_number: { + required: true, + type: 'integer' + }, + repo: { + required: true, + type: 'string' + }, + review_id: { + required: true, + type: 'integer' + } + }, + url: + '/repos/:owner/:repo/pulls/:pull_number/reviews/:review_id/dismissals' + }, + get: { + method: 'GET', + params: { + number: { + alias: 'pull_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + pull_number: { + required: true, + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/pulls/:pull_number' + }, + getComment: { + method: 'GET', + params: { + comment_id: { + required: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/pulls/comments/:comment_id' + }, + getCommentsForReview: { + method: 'GET', + params: { + number: { + alias: 'pull_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + pull_number: { + required: true, + type: 'integer' + }, + repo: { + required: true, + type: 'string' + }, + review_id: { + required: true, + type: 'integer' + } + }, + url: + '/repos/:owner/:repo/pulls/:pull_number/reviews/:review_id/comments' + }, + getReview: { + method: 'GET', + params: { + number: { + alias: 'pull_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + pull_number: { + required: true, + type: 'integer' + }, + repo: { + required: true, + type: 'string' + }, + review_id: { + required: true, + type: 'integer' + } + }, + url: '/repos/:owner/:repo/pulls/:pull_number/reviews/:review_id' + }, + list: { + method: 'GET', + params: { + base: { + type: 'string' + }, + direction: { + enum: ['asc', 'desc'], + type: 'string' + }, + head: { + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + }, + sort: { + enum: ['created', 'updated', 'popularity', 'long-running'], + type: 'string' + }, + state: { + enum: ['open', 'closed', 'all'], + type: 'string' + } + }, + url: '/repos/:owner/:repo/pulls' + }, + listComments: { + method: 'GET', + params: { + direction: { + enum: ['asc', 'desc'], + type: 'string' + }, + number: { + alias: 'pull_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + pull_number: { + required: true, + type: 'integer' + }, + repo: { + required: true, + type: 'string' + }, + since: { + type: 'string' + }, + sort: { + enum: ['created', 'updated'], + type: 'string' + } + }, + url: '/repos/:owner/:repo/pulls/:pull_number/comments' + }, + listCommentsForRepo: { + method: 'GET', + params: { + direction: { + enum: ['asc', 'desc'], + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + }, + since: { + type: 'string' + }, + sort: { + enum: ['created', 'updated'], + type: 'string' + } + }, + url: '/repos/:owner/:repo/pulls/comments' + }, + listCommits: { + method: 'GET', + params: { + number: { + alias: 'pull_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + pull_number: { + required: true, + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/pulls/:pull_number/commits' + }, + listFiles: { + method: 'GET', + params: { + number: { + alias: 'pull_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + pull_number: { + required: true, + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/pulls/:pull_number/files' + }, + listReviewRequests: { + method: 'GET', + params: { + number: { + alias: 'pull_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + pull_number: { + required: true, + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/pulls/:pull_number/requested_reviewers' + }, + listReviews: { + method: 'GET', + params: { + number: { + alias: 'pull_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + pull_number: { + required: true, + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/pulls/:pull_number/reviews' + }, + merge: { + method: 'PUT', + params: { + commit_message: { + type: 'string' + }, + commit_title: { + type: 'string' + }, + merge_method: { + enum: ['merge', 'squash', 'rebase'], + type: 'string' + }, + number: { + alias: 'pull_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + pull_number: { + required: true, + type: 'integer' + }, + repo: { + required: true, + type: 'string' + }, + sha: { + type: 'string' + } + }, + url: '/repos/:owner/:repo/pulls/:pull_number/merge' + }, + submitReview: { + method: 'POST', + params: { + body: { + type: 'string' + }, + event: { + enum: ['APPROVE', 'REQUEST_CHANGES', 'COMMENT'], + required: true, + type: 'string' + }, + number: { + alias: 'pull_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + pull_number: { + required: true, + type: 'integer' + }, + repo: { + required: true, + type: 'string' + }, + review_id: { + required: true, + type: 'integer' + } + }, + url: + '/repos/:owner/:repo/pulls/:pull_number/reviews/:review_id/events' + }, + update: { + method: 'PATCH', + params: { + base: { + type: 'string' + }, + body: { + type: 'string' + }, + maintainer_can_modify: { + type: 'boolean' + }, + number: { + alias: 'pull_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + pull_number: { + required: true, + type: 'integer' + }, + repo: { + required: true, + type: 'string' + }, + state: { + enum: ['open', 'closed'], + type: 'string' + }, + title: { + type: 'string' + } + }, + url: '/repos/:owner/:repo/pulls/:pull_number' + }, + updateBranch: { + headers: { + accept: 'application/vnd.github.lydian-preview+json' + }, + method: 'PUT', + params: { + expected_head_sha: { + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + pull_number: { + required: true, + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/pulls/:pull_number/update-branch' + }, + updateComment: { + method: 'PATCH', + params: { + body: { + required: true, + type: 'string' + }, + comment_id: { + required: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/pulls/comments/:comment_id' + }, + updateReview: { + method: 'PUT', + params: { + body: { + required: true, + type: 'string' + }, + number: { + alias: 'pull_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + pull_number: { + required: true, + type: 'integer' + }, + repo: { + required: true, + type: 'string' + }, + review_id: { + required: true, + type: 'integer' + } + }, + url: '/repos/:owner/:repo/pulls/:pull_number/reviews/:review_id' + } + }, + rateLimit: { + get: { + method: 'GET', + params: {}, + url: '/rate_limit' + } + }, + reactions: { + createForCommitComment: { + headers: { + accept: 'application/vnd.github.squirrel-girl-preview+json' + }, + method: 'POST', + params: { + comment_id: { + required: true, + type: 'integer' + }, + content: { + enum: [ + '+1', + '-1', + 'laugh', + 'confused', + 'heart', + 'hooray', + 'rocket', + 'eyes' + ], + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/comments/:comment_id/reactions' + }, + createForIssue: { + headers: { + accept: 'application/vnd.github.squirrel-girl-preview+json' + }, + method: 'POST', + params: { + content: { + enum: [ + '+1', + '-1', + 'laugh', + 'confused', + 'heart', + 'hooray', + 'rocket', + 'eyes' + ], + required: true, + type: 'string' + }, + issue_number: { + required: true, + type: 'integer' + }, + number: { + alias: 'issue_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/issues/:issue_number/reactions' + }, + createForIssueComment: { + headers: { + accept: 'application/vnd.github.squirrel-girl-preview+json' + }, + method: 'POST', + params: { + comment_id: { + required: true, + type: 'integer' + }, + content: { + enum: [ + '+1', + '-1', + 'laugh', + 'confused', + 'heart', + 'hooray', + 'rocket', + 'eyes' + ], + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/issues/comments/:comment_id/reactions' + }, + createForPullRequestReviewComment: { + headers: { + accept: 'application/vnd.github.squirrel-girl-preview+json' + }, + method: 'POST', + params: { + comment_id: { + required: true, + type: 'integer' + }, + content: { + enum: [ + '+1', + '-1', + 'laugh', + 'confused', + 'heart', + 'hooray', + 'rocket', + 'eyes' + ], + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/pulls/comments/:comment_id/reactions' + }, + createForTeamDiscussion: { + deprecated: + 'octokit.reactions.createForTeamDiscussion() has been renamed to octokit.reactions.createForTeamDiscussionLegacy() (2020-01-16)', + headers: { + accept: 'application/vnd.github.squirrel-girl-preview+json' + }, + method: 'POST', + params: { + content: { + enum: [ + '+1', + '-1', + 'laugh', + 'confused', + 'heart', + 'hooray', + 'rocket', + 'eyes' + ], + required: true, + type: 'string' + }, + discussion_number: { + required: true, + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id/discussions/:discussion_number/reactions' + }, + createForTeamDiscussionComment: { + deprecated: + 'octokit.reactions.createForTeamDiscussionComment() has been renamed to octokit.reactions.createForTeamDiscussionCommentLegacy() (2020-01-16)', + headers: { + accept: 'application/vnd.github.squirrel-girl-preview+json' + }, + method: 'POST', + params: { + comment_number: { + required: true, + type: 'integer' + }, + content: { + enum: [ + '+1', + '-1', + 'laugh', + 'confused', + 'heart', + 'hooray', + 'rocket', + 'eyes' + ], + required: true, + type: 'string' + }, + discussion_number: { + required: true, + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: + '/teams/:team_id/discussions/:discussion_number/comments/:comment_number/reactions' + }, + createForTeamDiscussionCommentInOrg: { + headers: { + accept: 'application/vnd.github.squirrel-girl-preview+json' + }, + method: 'POST', + params: { + comment_number: { + required: true, + type: 'integer' + }, + content: { + enum: [ + '+1', + '-1', + 'laugh', + 'confused', + 'heart', + 'hooray', + 'rocket', + 'eyes' + ], + required: true, + type: 'string' + }, + discussion_number: { + required: true, + type: 'integer' + }, + org: { + required: true, + type: 'string' + }, + team_slug: { + required: true, + type: 'string' + } + }, + url: + '/orgs/:org/teams/:team_slug/discussions/:discussion_number/comments/:comment_number/reactions' + }, + createForTeamDiscussionCommentLegacy: { + deprecated: + 'octokit.reactions.createForTeamDiscussionCommentLegacy() is deprecated, see https://developer.github.com/v3/reactions/#create-reaction-for-a-team-discussion-comment-legacy', + headers: { + accept: 'application/vnd.github.squirrel-girl-preview+json' + }, + method: 'POST', + params: { + comment_number: { + required: true, + type: 'integer' + }, + content: { + enum: [ + '+1', + '-1', + 'laugh', + 'confused', + 'heart', + 'hooray', + 'rocket', + 'eyes' + ], + required: true, + type: 'string' + }, + discussion_number: { + required: true, + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: + '/teams/:team_id/discussions/:discussion_number/comments/:comment_number/reactions' + }, + createForTeamDiscussionInOrg: { + headers: { + accept: 'application/vnd.github.squirrel-girl-preview+json' + }, + method: 'POST', + params: { + content: { + enum: [ + '+1', + '-1', + 'laugh', + 'confused', + 'heart', + 'hooray', + 'rocket', + 'eyes' + ], + required: true, + type: 'string' + }, + discussion_number: { + required: true, + type: 'integer' + }, + org: { + required: true, + type: 'string' + }, + team_slug: { + required: true, + type: 'string' + } + }, + url: + '/orgs/:org/teams/:team_slug/discussions/:discussion_number/reactions' + }, + createForTeamDiscussionLegacy: { + deprecated: + 'octokit.reactions.createForTeamDiscussionLegacy() is deprecated, see https://developer.github.com/v3/reactions/#create-reaction-for-a-team-discussion-legacy', + headers: { + accept: 'application/vnd.github.squirrel-girl-preview+json' + }, + method: 'POST', + params: { + content: { + enum: [ + '+1', + '-1', + 'laugh', + 'confused', + 'heart', + 'hooray', + 'rocket', + 'eyes' + ], + required: true, + type: 'string' + }, + discussion_number: { + required: true, + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id/discussions/:discussion_number/reactions' + }, + delete: { + headers: { + accept: 'application/vnd.github.squirrel-girl-preview+json' + }, + method: 'DELETE', + params: { + reaction_id: { + required: true, + type: 'integer' + } + }, + url: '/reactions/:reaction_id' + }, + listForCommitComment: { + headers: { + accept: 'application/vnd.github.squirrel-girl-preview+json' + }, + method: 'GET', + params: { + comment_id: { + required: true, + type: 'integer' + }, + content: { + enum: [ + '+1', + '-1', + 'laugh', + 'confused', + 'heart', + 'hooray', + 'rocket', + 'eyes' + ], + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/comments/:comment_id/reactions' + }, + listForIssue: { + headers: { + accept: 'application/vnd.github.squirrel-girl-preview+json' + }, + method: 'GET', + params: { + content: { + enum: [ + '+1', + '-1', + 'laugh', + 'confused', + 'heart', + 'hooray', + 'rocket', + 'eyes' + ], + type: 'string' + }, + issue_number: { + required: true, + type: 'integer' + }, + number: { + alias: 'issue_number', + deprecated: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/issues/:issue_number/reactions' + }, + listForIssueComment: { + headers: { + accept: 'application/vnd.github.squirrel-girl-preview+json' + }, + method: 'GET', + params: { + comment_id: { + required: true, + type: 'integer' + }, + content: { + enum: [ + '+1', + '-1', + 'laugh', + 'confused', + 'heart', + 'hooray', + 'rocket', + 'eyes' + ], + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/issues/comments/:comment_id/reactions' + }, + listForPullRequestReviewComment: { + headers: { + accept: 'application/vnd.github.squirrel-girl-preview+json' + }, + method: 'GET', + params: { + comment_id: { + required: true, + type: 'integer' + }, + content: { + enum: [ + '+1', + '-1', + 'laugh', + 'confused', + 'heart', + 'hooray', + 'rocket', + 'eyes' + ], + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/pulls/comments/:comment_id/reactions' + }, + listForTeamDiscussion: { + deprecated: + 'octokit.reactions.listForTeamDiscussion() has been renamed to octokit.reactions.listForTeamDiscussionLegacy() (2020-01-16)', + headers: { + accept: 'application/vnd.github.squirrel-girl-preview+json' + }, + method: 'GET', + params: { + content: { + enum: [ + '+1', + '-1', + 'laugh', + 'confused', + 'heart', + 'hooray', + 'rocket', + 'eyes' + ], + type: 'string' + }, + discussion_number: { + required: true, + type: 'integer' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id/discussions/:discussion_number/reactions' + }, + listForTeamDiscussionComment: { + deprecated: + 'octokit.reactions.listForTeamDiscussionComment() has been renamed to octokit.reactions.listForTeamDiscussionCommentLegacy() (2020-01-16)', + headers: { + accept: 'application/vnd.github.squirrel-girl-preview+json' + }, + method: 'GET', + params: { + comment_number: { + required: true, + type: 'integer' + }, + content: { + enum: [ + '+1', + '-1', + 'laugh', + 'confused', + 'heart', + 'hooray', + 'rocket', + 'eyes' + ], + type: 'string' + }, + discussion_number: { + required: true, + type: 'integer' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: + '/teams/:team_id/discussions/:discussion_number/comments/:comment_number/reactions' + }, + listForTeamDiscussionCommentInOrg: { + headers: { + accept: 'application/vnd.github.squirrel-girl-preview+json' + }, + method: 'GET', + params: { + comment_number: { + required: true, + type: 'integer' + }, + content: { + enum: [ + '+1', + '-1', + 'laugh', + 'confused', + 'heart', + 'hooray', + 'rocket', + 'eyes' + ], + type: 'string' + }, + discussion_number: { + required: true, + type: 'integer' + }, + org: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + team_slug: { + required: true, + type: 'string' + } + }, + url: + '/orgs/:org/teams/:team_slug/discussions/:discussion_number/comments/:comment_number/reactions' + }, + listForTeamDiscussionCommentLegacy: { + deprecated: + 'octokit.reactions.listForTeamDiscussionCommentLegacy() is deprecated, see https://developer.github.com/v3/reactions/#list-reactions-for-a-team-discussion-comment-legacy', + headers: { + accept: 'application/vnd.github.squirrel-girl-preview+json' + }, + method: 'GET', + params: { + comment_number: { + required: true, + type: 'integer' + }, + content: { + enum: [ + '+1', + '-1', + 'laugh', + 'confused', + 'heart', + 'hooray', + 'rocket', + 'eyes' + ], + type: 'string' + }, + discussion_number: { + required: true, + type: 'integer' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: + '/teams/:team_id/discussions/:discussion_number/comments/:comment_number/reactions' + }, + listForTeamDiscussionInOrg: { + headers: { + accept: 'application/vnd.github.squirrel-girl-preview+json' + }, + method: 'GET', + params: { + content: { + enum: [ + '+1', + '-1', + 'laugh', + 'confused', + 'heart', + 'hooray', + 'rocket', + 'eyes' + ], + type: 'string' + }, + discussion_number: { + required: true, + type: 'integer' + }, + org: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + team_slug: { + required: true, + type: 'string' + } + }, + url: + '/orgs/:org/teams/:team_slug/discussions/:discussion_number/reactions' + }, + listForTeamDiscussionLegacy: { + deprecated: + 'octokit.reactions.listForTeamDiscussionLegacy() is deprecated, see https://developer.github.com/v3/reactions/#list-reactions-for-a-team-discussion-legacy', + headers: { + accept: 'application/vnd.github.squirrel-girl-preview+json' + }, + method: 'GET', + params: { + content: { + enum: [ + '+1', + '-1', + 'laugh', + 'confused', + 'heart', + 'hooray', + 'rocket', + 'eyes' + ], + type: 'string' + }, + discussion_number: { + required: true, + type: 'integer' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id/discussions/:discussion_number/reactions' + } + }, + repos: { + acceptInvitation: { + method: 'PATCH', + params: { + invitation_id: { + required: true, + type: 'integer' + } + }, + url: '/user/repository_invitations/:invitation_id' + }, + addCollaborator: { + method: 'PUT', + params: { + owner: { + required: true, + type: 'string' + }, + permission: { + enum: ['pull', 'push', 'admin'], + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/collaborators/:username' + }, + addDeployKey: { + method: 'POST', + params: { + key: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + read_only: { + type: 'boolean' + }, + repo: { + required: true, + type: 'string' + }, + title: { + type: 'string' + } + }, + url: '/repos/:owner/:repo/keys' + }, + addProtectedBranchAdminEnforcement: { + method: 'POST', + params: { + branch: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: + '/repos/:owner/:repo/branches/:branch/protection/enforce_admins' + }, + addProtectedBranchAppRestrictions: { + method: 'POST', + params: { + apps: { + mapTo: 'data', + required: true, + type: 'string[]' + }, + branch: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: + '/repos/:owner/:repo/branches/:branch/protection/restrictions/apps' + }, + addProtectedBranchRequiredSignatures: { + headers: { + accept: 'application/vnd.github.zzzax-preview+json' + }, + method: 'POST', + params: { + branch: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: + '/repos/:owner/:repo/branches/:branch/protection/required_signatures' + }, + addProtectedBranchRequiredStatusChecksContexts: { + method: 'POST', + params: { + branch: { + required: true, + type: 'string' + }, + contexts: { + mapTo: 'data', + required: true, + type: 'string[]' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: + '/repos/:owner/:repo/branches/:branch/protection/required_status_checks/contexts' + }, + addProtectedBranchTeamRestrictions: { + method: 'POST', + params: { + branch: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + teams: { + mapTo: 'data', + required: true, + type: 'string[]' + } + }, + url: + '/repos/:owner/:repo/branches/:branch/protection/restrictions/teams' + }, + addProtectedBranchUserRestrictions: { + method: 'POST', + params: { + branch: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + users: { + mapTo: 'data', + required: true, + type: 'string[]' + } + }, + url: + '/repos/:owner/:repo/branches/:branch/protection/restrictions/users' + }, + checkCollaborator: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/collaborators/:username' + }, + checkVulnerabilityAlerts: { + headers: { + accept: 'application/vnd.github.dorian-preview+json' + }, + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/vulnerability-alerts' + }, + compareCommits: { + method: 'GET', + params: { + base: { + required: true, + type: 'string' + }, + head: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/compare/:base...:head' + }, + createCommitComment: { + method: 'POST', + params: { + body: { + required: true, + type: 'string' + }, + commit_sha: { + required: true, + type: 'string' + }, + line: { + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + path: { + type: 'string' + }, + position: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + }, + sha: { + alias: 'commit_sha', + deprecated: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/commits/:commit_sha/comments' + }, + createDeployment: { + method: 'POST', + params: { + auto_merge: { + type: 'boolean' + }, + description: { + type: 'string' + }, + environment: { + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + payload: { + type: 'string' + }, + production_environment: { + type: 'boolean' + }, + ref: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + required_contexts: { + type: 'string[]' + }, + task: { + type: 'string' + }, + transient_environment: { + type: 'boolean' + } + }, + url: '/repos/:owner/:repo/deployments' + }, + createDeploymentStatus: { + method: 'POST', + params: { + auto_inactive: { + type: 'boolean' + }, + deployment_id: { + required: true, + type: 'integer' + }, + description: { + type: 'string' + }, + environment: { + enum: ['production', 'staging', 'qa'], + type: 'string' + }, + environment_url: { + type: 'string' + }, + log_url: { + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + state: { + enum: [ + 'error', + 'failure', + 'inactive', + 'in_progress', + 'queued', + 'pending', + 'success' + ], + required: true, + type: 'string' + }, + target_url: { + type: 'string' + } + }, + url: '/repos/:owner/:repo/deployments/:deployment_id/statuses' + }, + createDispatchEvent: { + method: 'POST', + params: { + client_payload: { + type: 'object' + }, + event_type: { + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/dispatches' + }, + createFile: { + deprecated: + 'octokit.repos.createFile() has been renamed to octokit.repos.createOrUpdateFile() (2019-06-07)', + method: 'PUT', + params: { + author: { + type: 'object' + }, + 'author.email': { + required: true, + type: 'string' + }, + 'author.name': { + required: true, + type: 'string' + }, + branch: { + type: 'string' + }, + committer: { + type: 'object' + }, + 'committer.email': { + required: true, + type: 'string' + }, + 'committer.name': { + required: true, + type: 'string' + }, + content: { + required: true, + type: 'string' + }, + message: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + path: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + sha: { + type: 'string' + } + }, + url: '/repos/:owner/:repo/contents/:path' + }, + createForAuthenticatedUser: { + method: 'POST', + params: { + allow_merge_commit: { + type: 'boolean' + }, + allow_rebase_merge: { + type: 'boolean' + }, + allow_squash_merge: { + type: 'boolean' + }, + auto_init: { + type: 'boolean' + }, + delete_branch_on_merge: { + type: 'boolean' + }, + description: { + type: 'string' + }, + gitignore_template: { + type: 'string' + }, + has_issues: { + type: 'boolean' + }, + has_projects: { + type: 'boolean' + }, + has_wiki: { + type: 'boolean' + }, + homepage: { + type: 'string' + }, + is_template: { + type: 'boolean' + }, + license_template: { + type: 'string' + }, + name: { + required: true, + type: 'string' + }, + private: { + type: 'boolean' + }, + team_id: { + type: 'integer' + }, + visibility: { + enum: ['public', 'private', 'visibility', 'internal'], + type: 'string' + } + }, + url: '/user/repos' + }, + createFork: { + method: 'POST', + params: { + organization: { + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/forks' + }, + createHook: { + method: 'POST', + params: { + active: { + type: 'boolean' + }, + config: { + required: true, + type: 'object' + }, + 'config.content_type': { + type: 'string' + }, + 'config.insecure_ssl': { + type: 'string' + }, + 'config.secret': { + type: 'string' + }, + 'config.url': { + required: true, + type: 'string' + }, + events: { + type: 'string[]' + }, + name: { + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/hooks' + }, + createInOrg: { + method: 'POST', + params: { + allow_merge_commit: { + type: 'boolean' + }, + allow_rebase_merge: { + type: 'boolean' + }, + allow_squash_merge: { + type: 'boolean' + }, + auto_init: { + type: 'boolean' + }, + delete_branch_on_merge: { + type: 'boolean' + }, + description: { + type: 'string' + }, + gitignore_template: { + type: 'string' + }, + has_issues: { + type: 'boolean' + }, + has_projects: { + type: 'boolean' + }, + has_wiki: { + type: 'boolean' + }, + homepage: { + type: 'string' + }, + is_template: { + type: 'boolean' + }, + license_template: { + type: 'string' + }, + name: { + required: true, + type: 'string' + }, + org: { + required: true, + type: 'string' + }, + private: { + type: 'boolean' + }, + team_id: { + type: 'integer' + }, + visibility: { + enum: ['public', 'private', 'visibility', 'internal'], + type: 'string' + } + }, + url: '/orgs/:org/repos' + }, + createOrUpdateFile: { + method: 'PUT', + params: { + author: { + type: 'object' + }, + 'author.email': { + required: true, + type: 'string' + }, + 'author.name': { + required: true, + type: 'string' + }, + branch: { + type: 'string' + }, + committer: { + type: 'object' + }, + 'committer.email': { + required: true, + type: 'string' + }, + 'committer.name': { + required: true, + type: 'string' + }, + content: { + required: true, + type: 'string' + }, + message: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + path: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + sha: { + type: 'string' + } + }, + url: '/repos/:owner/:repo/contents/:path' + }, + createRelease: { + method: 'POST', + params: { + body: { + type: 'string' + }, + draft: { + type: 'boolean' + }, + name: { + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + prerelease: { + type: 'boolean' + }, + repo: { + required: true, + type: 'string' + }, + tag_name: { + required: true, + type: 'string' + }, + target_commitish: { + type: 'string' + } + }, + url: '/repos/:owner/:repo/releases' + }, + createStatus: { + method: 'POST', + params: { + context: { + type: 'string' + }, + description: { + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + sha: { + required: true, + type: 'string' + }, + state: { + enum: ['error', 'failure', 'pending', 'success'], + required: true, + type: 'string' + }, + target_url: { + type: 'string' + } + }, + url: '/repos/:owner/:repo/statuses/:sha' + }, + createUsingTemplate: { + headers: { + accept: 'application/vnd.github.baptiste-preview+json' + }, + method: 'POST', + params: { + description: { + type: 'string' + }, + name: { + required: true, + type: 'string' + }, + owner: { + type: 'string' + }, + private: { + type: 'boolean' + }, + template_owner: { + required: true, + type: 'string' + }, + template_repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:template_owner/:template_repo/generate' + }, + declineInvitation: { + method: 'DELETE', + params: { + invitation_id: { + required: true, + type: 'integer' + } + }, + url: '/user/repository_invitations/:invitation_id' + }, + delete: { + method: 'DELETE', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo' + }, + deleteCommitComment: { + method: 'DELETE', + params: { + comment_id: { + required: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/comments/:comment_id' + }, + deleteDownload: { + method: 'DELETE', + params: { + download_id: { + required: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/downloads/:download_id' + }, + deleteFile: { + method: 'DELETE', + params: { + author: { + type: 'object' + }, + 'author.email': { + type: 'string' + }, + 'author.name': { + type: 'string' + }, + branch: { + type: 'string' + }, + committer: { + type: 'object' + }, + 'committer.email': { + type: 'string' + }, + 'committer.name': { + type: 'string' + }, + message: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + path: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + sha: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/contents/:path' + }, + deleteHook: { + method: 'DELETE', + params: { + hook_id: { + required: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/hooks/:hook_id' + }, + deleteInvitation: { + method: 'DELETE', + params: { + invitation_id: { + required: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/invitations/:invitation_id' + }, + deleteRelease: { + method: 'DELETE', + params: { + owner: { + required: true, + type: 'string' + }, + release_id: { + required: true, + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/releases/:release_id' + }, + deleteReleaseAsset: { + method: 'DELETE', + params: { + asset_id: { + required: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/releases/assets/:asset_id' + }, + disableAutomatedSecurityFixes: { + headers: { + accept: 'application/vnd.github.london-preview+json' + }, + method: 'DELETE', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/automated-security-fixes' + }, + disablePagesSite: { + headers: { + accept: 'application/vnd.github.switcheroo-preview+json' + }, + method: 'DELETE', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/pages' + }, + disableVulnerabilityAlerts: { + headers: { + accept: 'application/vnd.github.dorian-preview+json' + }, + method: 'DELETE', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/vulnerability-alerts' + }, + enableAutomatedSecurityFixes: { + headers: { + accept: 'application/vnd.github.london-preview+json' + }, + method: 'PUT', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/automated-security-fixes' + }, + enablePagesSite: { + headers: { + accept: 'application/vnd.github.switcheroo-preview+json' + }, + method: 'POST', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + source: { + type: 'object' + }, + 'source.branch': { + enum: ['master', 'gh-pages'], + type: 'string' + }, + 'source.path': { + type: 'string' + } + }, + url: '/repos/:owner/:repo/pages' + }, + enableVulnerabilityAlerts: { + headers: { + accept: 'application/vnd.github.dorian-preview+json' + }, + method: 'PUT', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/vulnerability-alerts' + }, + get: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo' + }, + getAppsWithAccessToProtectedBranch: { + method: 'GET', + params: { + branch: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: + '/repos/:owner/:repo/branches/:branch/protection/restrictions/apps' + }, + getArchiveLink: { + method: 'GET', + params: { + archive_format: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + ref: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/:archive_format/:ref' + }, + getBranch: { + method: 'GET', + params: { + branch: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/branches/:branch' + }, + getBranchProtection: { + method: 'GET', + params: { + branch: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/branches/:branch/protection' + }, + getClones: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + per: { + enum: ['day', 'week'], + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/traffic/clones' + }, + getCodeFrequencyStats: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/stats/code_frequency' + }, + getCollaboratorPermissionLevel: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/collaborators/:username/permission' + }, + getCombinedStatusForRef: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + ref: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/commits/:ref/status' + }, + getCommit: { + method: 'GET', + params: { + commit_sha: { + alias: 'ref', + deprecated: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + ref: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + sha: { + alias: 'ref', + deprecated: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/commits/:ref' + }, + getCommitActivityStats: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/stats/commit_activity' + }, + getCommitComment: { + method: 'GET', + params: { + comment_id: { + required: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/comments/:comment_id' + }, + getCommitRefSha: { + deprecated: + 'octokit.repos.getCommitRefSha() is deprecated, see https://developer.github.com/v3/repos/commits/#get-a-single-commit', + headers: { + accept: 'application/vnd.github.v3.sha' + }, + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + ref: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/commits/:ref' + }, + getContents: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + path: { + required: true, + type: 'string' + }, + ref: { + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/contents/:path' + }, + getContributorsStats: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/stats/contributors' + }, + getDeployKey: { + method: 'GET', + params: { + key_id: { + required: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/keys/:key_id' + }, + getDeployment: { + method: 'GET', + params: { + deployment_id: { + required: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/deployments/:deployment_id' + }, + getDeploymentStatus: { + method: 'GET', + params: { + deployment_id: { + required: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + status_id: { + required: true, + type: 'integer' + } + }, + url: + '/repos/:owner/:repo/deployments/:deployment_id/statuses/:status_id' + }, + getDownload: { + method: 'GET', + params: { + download_id: { + required: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/downloads/:download_id' + }, + getHook: { + method: 'GET', + params: { + hook_id: { + required: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/hooks/:hook_id' + }, + getLatestPagesBuild: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/pages/builds/latest' + }, + getLatestRelease: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/releases/latest' + }, + getPages: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/pages' + }, + getPagesBuild: { + method: 'GET', + params: { + build_id: { + required: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/pages/builds/:build_id' + }, + getParticipationStats: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/stats/participation' + }, + getProtectedBranchAdminEnforcement: { + method: 'GET', + params: { + branch: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: + '/repos/:owner/:repo/branches/:branch/protection/enforce_admins' + }, + getProtectedBranchPullRequestReviewEnforcement: { + method: 'GET', + params: { + branch: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: + '/repos/:owner/:repo/branches/:branch/protection/required_pull_request_reviews' + }, + getProtectedBranchRequiredSignatures: { + headers: { + accept: 'application/vnd.github.zzzax-preview+json' + }, + method: 'GET', + params: { + branch: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: + '/repos/:owner/:repo/branches/:branch/protection/required_signatures' + }, + getProtectedBranchRequiredStatusChecks: { + method: 'GET', + params: { + branch: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: + '/repos/:owner/:repo/branches/:branch/protection/required_status_checks' + }, + getProtectedBranchRestrictions: { + method: 'GET', + params: { + branch: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/branches/:branch/protection/restrictions' + }, + getPunchCardStats: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/stats/punch_card' + }, + getReadme: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + ref: { + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/readme' + }, + getRelease: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + release_id: { + required: true, + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/releases/:release_id' + }, + getReleaseAsset: { + method: 'GET', + params: { + asset_id: { + required: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/releases/assets/:asset_id' + }, + getReleaseByTag: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + tag: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/releases/tags/:tag' + }, + getTeamsWithAccessToProtectedBranch: { + method: 'GET', + params: { + branch: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: + '/repos/:owner/:repo/branches/:branch/protection/restrictions/teams' + }, + getTopPaths: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/traffic/popular/paths' + }, + getTopReferrers: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/traffic/popular/referrers' + }, + getUsersWithAccessToProtectedBranch: { + method: 'GET', + params: { + branch: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: + '/repos/:owner/:repo/branches/:branch/protection/restrictions/users' + }, + getViews: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + per: { + enum: ['day', 'week'], + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/traffic/views' + }, + list: { + method: 'GET', + params: { + affiliation: { + type: 'string' + }, + direction: { + enum: ['asc', 'desc'], + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + sort: { + enum: ['created', 'updated', 'pushed', 'full_name'], + type: 'string' + }, + type: { + enum: ['all', 'owner', 'public', 'private', 'member'], + type: 'string' + }, + visibility: { + enum: ['all', 'public', 'private'], + type: 'string' + } + }, + url: '/user/repos' + }, + listAppsWithAccessToProtectedBranch: { + deprecated: + 'octokit.repos.listAppsWithAccessToProtectedBranch() has been renamed to octokit.repos.getAppsWithAccessToProtectedBranch() (2019-09-13)', + method: 'GET', + params: { + branch: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: + '/repos/:owner/:repo/branches/:branch/protection/restrictions/apps' + }, + listAssetsForRelease: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + release_id: { + required: true, + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/releases/:release_id/assets' + }, + listBranches: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + protected: { + type: 'boolean' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/branches' + }, + listBranchesForHeadCommit: { + headers: { + accept: 'application/vnd.github.groot-preview+json' + }, + method: 'GET', + params: { + commit_sha: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/commits/:commit_sha/branches-where-head' + }, + listCollaborators: { + method: 'GET', + params: { + affiliation: { + enum: ['outside', 'direct', 'all'], + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/collaborators' + }, + listCommentsForCommit: { + method: 'GET', + params: { + commit_sha: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + ref: { + alias: 'commit_sha', + deprecated: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/commits/:commit_sha/comments' + }, + listCommitComments: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/comments' + }, + listCommits: { + method: 'GET', + params: { + author: { + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + path: { + type: 'string' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + }, + sha: { + type: 'string' + }, + since: { + type: 'string' + }, + until: { + type: 'string' + } + }, + url: '/repos/:owner/:repo/commits' + }, + listContributors: { + method: 'GET', + params: { + anon: { + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/contributors' + }, + listDeployKeys: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/keys' + }, + listDeploymentStatuses: { + method: 'GET', + params: { + deployment_id: { + required: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/deployments/:deployment_id/statuses' + }, + listDeployments: { + method: 'GET', + params: { + environment: { + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + ref: { + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + sha: { + type: 'string' + }, + task: { + type: 'string' + } + }, + url: '/repos/:owner/:repo/deployments' + }, + listDownloads: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/downloads' + }, + listForOrg: { + method: 'GET', + params: { + direction: { + enum: ['asc', 'desc'], + type: 'string' + }, + org: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + sort: { + enum: ['created', 'updated', 'pushed', 'full_name'], + type: 'string' + }, + type: { + enum: [ + 'all', + 'public', + 'private', + 'forks', + 'sources', + 'member', + 'internal' + ], + type: 'string' + } + }, + url: '/orgs/:org/repos' + }, + listForUser: { + method: 'GET', + params: { + direction: { + enum: ['asc', 'desc'], + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + sort: { + enum: ['created', 'updated', 'pushed', 'full_name'], + type: 'string' + }, + type: { + enum: ['all', 'owner', 'member'], + type: 'string' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/users/:username/repos' + }, + listForks: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + }, + sort: { + enum: ['newest', 'oldest', 'stargazers'], + type: 'string' + } + }, + url: '/repos/:owner/:repo/forks' + }, + listHooks: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/hooks' + }, + listInvitations: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/invitations' + }, + listInvitationsForAuthenticatedUser: { + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + } + }, + url: '/user/repository_invitations' + }, + listLanguages: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/languages' + }, + listPagesBuilds: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/pages/builds' + }, + listProtectedBranchRequiredStatusChecksContexts: { + method: 'GET', + params: { + branch: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: + '/repos/:owner/:repo/branches/:branch/protection/required_status_checks/contexts' + }, + listProtectedBranchTeamRestrictions: { + deprecated: + 'octokit.repos.listProtectedBranchTeamRestrictions() has been renamed to octokit.repos.getTeamsWithAccessToProtectedBranch() (2019-09-09)', + method: 'GET', + params: { + branch: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: + '/repos/:owner/:repo/branches/:branch/protection/restrictions/teams' + }, + listProtectedBranchUserRestrictions: { + deprecated: + 'octokit.repos.listProtectedBranchUserRestrictions() has been renamed to octokit.repos.getUsersWithAccessToProtectedBranch() (2019-09-09)', + method: 'GET', + params: { + branch: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: + '/repos/:owner/:repo/branches/:branch/protection/restrictions/users' + }, + listPublic: { + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + since: { + type: 'integer' + } + }, + url: '/repositories' + }, + listPullRequestsAssociatedWithCommit: { + headers: { + accept: 'application/vnd.github.groot-preview+json' + }, + method: 'GET', + params: { + commit_sha: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/commits/:commit_sha/pulls' + }, + listReleases: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/releases' + }, + listStatusesForRef: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + ref: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/commits/:ref/statuses' + }, + listTags: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/tags' + }, + listTeams: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/teams' + }, + listTeamsWithAccessToProtectedBranch: { + deprecated: + 'octokit.repos.listTeamsWithAccessToProtectedBranch() has been renamed to octokit.repos.getTeamsWithAccessToProtectedBranch() (2019-09-13)', + method: 'GET', + params: { + branch: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: + '/repos/:owner/:repo/branches/:branch/protection/restrictions/teams' + }, + listTopics: { + headers: { + accept: 'application/vnd.github.mercy-preview+json' + }, + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/topics' + }, + listUsersWithAccessToProtectedBranch: { + deprecated: + 'octokit.repos.listUsersWithAccessToProtectedBranch() has been renamed to octokit.repos.getUsersWithAccessToProtectedBranch() (2019-09-13)', + method: 'GET', + params: { + branch: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: + '/repos/:owner/:repo/branches/:branch/protection/restrictions/users' + }, + merge: { + method: 'POST', + params: { + base: { + required: true, + type: 'string' + }, + commit_message: { + type: 'string' + }, + head: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/merges' + }, + pingHook: { + method: 'POST', + params: { + hook_id: { + required: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/hooks/:hook_id/pings' + }, + removeBranchProtection: { + method: 'DELETE', + params: { + branch: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/branches/:branch/protection' + }, + removeCollaborator: { + method: 'DELETE', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/collaborators/:username' + }, + removeDeployKey: { + method: 'DELETE', + params: { + key_id: { + required: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/keys/:key_id' + }, + removeProtectedBranchAdminEnforcement: { + method: 'DELETE', + params: { + branch: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: + '/repos/:owner/:repo/branches/:branch/protection/enforce_admins' + }, + removeProtectedBranchAppRestrictions: { + method: 'DELETE', + params: { + apps: { + mapTo: 'data', + required: true, + type: 'string[]' + }, + branch: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: + '/repos/:owner/:repo/branches/:branch/protection/restrictions/apps' + }, + removeProtectedBranchPullRequestReviewEnforcement: { + method: 'DELETE', + params: { + branch: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: + '/repos/:owner/:repo/branches/:branch/protection/required_pull_request_reviews' + }, + removeProtectedBranchRequiredSignatures: { + headers: { + accept: 'application/vnd.github.zzzax-preview+json' + }, + method: 'DELETE', + params: { + branch: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: + '/repos/:owner/:repo/branches/:branch/protection/required_signatures' + }, + removeProtectedBranchRequiredStatusChecks: { + method: 'DELETE', + params: { + branch: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: + '/repos/:owner/:repo/branches/:branch/protection/required_status_checks' + }, + removeProtectedBranchRequiredStatusChecksContexts: { + method: 'DELETE', + params: { + branch: { + required: true, + type: 'string' + }, + contexts: { + mapTo: 'data', + required: true, + type: 'string[]' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: + '/repos/:owner/:repo/branches/:branch/protection/required_status_checks/contexts' + }, + removeProtectedBranchRestrictions: { + method: 'DELETE', + params: { + branch: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/branches/:branch/protection/restrictions' + }, + removeProtectedBranchTeamRestrictions: { + method: 'DELETE', + params: { + branch: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + teams: { + mapTo: 'data', + required: true, + type: 'string[]' + } + }, + url: + '/repos/:owner/:repo/branches/:branch/protection/restrictions/teams' + }, + removeProtectedBranchUserRestrictions: { + method: 'DELETE', + params: { + branch: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + users: { + mapTo: 'data', + required: true, + type: 'string[]' + } + }, + url: + '/repos/:owner/:repo/branches/:branch/protection/restrictions/users' + }, + replaceProtectedBranchAppRestrictions: { + method: 'PUT', + params: { + apps: { + mapTo: 'data', + required: true, + type: 'string[]' + }, + branch: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: + '/repos/:owner/:repo/branches/:branch/protection/restrictions/apps' + }, + replaceProtectedBranchRequiredStatusChecksContexts: { + method: 'PUT', + params: { + branch: { + required: true, + type: 'string' + }, + contexts: { + mapTo: 'data', + required: true, + type: 'string[]' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: + '/repos/:owner/:repo/branches/:branch/protection/required_status_checks/contexts' + }, + replaceProtectedBranchTeamRestrictions: { + method: 'PUT', + params: { + branch: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + teams: { + mapTo: 'data', + required: true, + type: 'string[]' + } + }, + url: + '/repos/:owner/:repo/branches/:branch/protection/restrictions/teams' + }, + replaceProtectedBranchUserRestrictions: { + method: 'PUT', + params: { + branch: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + users: { + mapTo: 'data', + required: true, + type: 'string[]' + } + }, + url: + '/repos/:owner/:repo/branches/:branch/protection/restrictions/users' + }, + replaceTopics: { + headers: { + accept: 'application/vnd.github.mercy-preview+json' + }, + method: 'PUT', + params: { + names: { + required: true, + type: 'string[]' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/topics' + }, + requestPageBuild: { + method: 'POST', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/pages/builds' + }, + retrieveCommunityProfileMetrics: { + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/community/profile' + }, + testPushHook: { + method: 'POST', + params: { + hook_id: { + required: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/hooks/:hook_id/tests' + }, + transfer: { + method: 'POST', + params: { + new_owner: { + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + team_ids: { + type: 'integer[]' + } + }, + url: '/repos/:owner/:repo/transfer' + }, + update: { + method: 'PATCH', + params: { + allow_merge_commit: { + type: 'boolean' + }, + allow_rebase_merge: { + type: 'boolean' + }, + allow_squash_merge: { + type: 'boolean' + }, + archived: { + type: 'boolean' + }, + default_branch: { + type: 'string' + }, + delete_branch_on_merge: { + type: 'boolean' + }, + description: { + type: 'string' + }, + has_issues: { + type: 'boolean' + }, + has_projects: { + type: 'boolean' + }, + has_wiki: { + type: 'boolean' + }, + homepage: { + type: 'string' + }, + is_template: { + type: 'boolean' + }, + name: { + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + private: { + type: 'boolean' + }, + repo: { + required: true, + type: 'string' + }, + visibility: { + enum: ['public', 'private', 'visibility', 'internal'], + type: 'string' + } + }, + url: '/repos/:owner/:repo' + }, + updateBranchProtection: { + method: 'PUT', + params: { + allow_deletions: { + type: 'boolean' + }, + allow_force_pushes: { + allowNull: true, + type: 'boolean' + }, + branch: { + required: true, + type: 'string' + }, + enforce_admins: { + allowNull: true, + required: true, + type: 'boolean' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + required_linear_history: { + type: 'boolean' + }, + required_pull_request_reviews: { + allowNull: true, + required: true, + type: 'object' + }, + 'required_pull_request_reviews.dismiss_stale_reviews': { + type: 'boolean' + }, + 'required_pull_request_reviews.dismissal_restrictions': { + type: 'object' + }, + 'required_pull_request_reviews.dismissal_restrictions.teams': { + type: 'string[]' + }, + 'required_pull_request_reviews.dismissal_restrictions.users': { + type: 'string[]' + }, + 'required_pull_request_reviews.require_code_owner_reviews': { + type: 'boolean' + }, + 'required_pull_request_reviews.required_approving_review_count': { + type: 'integer' + }, + required_status_checks: { + allowNull: true, + required: true, + type: 'object' + }, + 'required_status_checks.contexts': { + required: true, + type: 'string[]' + }, + 'required_status_checks.strict': { + required: true, + type: 'boolean' + }, + restrictions: { + allowNull: true, + required: true, + type: 'object' + }, + 'restrictions.apps': { + type: 'string[]' + }, + 'restrictions.teams': { + required: true, + type: 'string[]' + }, + 'restrictions.users': { + required: true, + type: 'string[]' + } + }, + url: '/repos/:owner/:repo/branches/:branch/protection' + }, + updateCommitComment: { + method: 'PATCH', + params: { + body: { + required: true, + type: 'string' + }, + comment_id: { + required: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/comments/:comment_id' + }, + updateFile: { + deprecated: + 'octokit.repos.updateFile() has been renamed to octokit.repos.createOrUpdateFile() (2019-06-07)', + method: 'PUT', + params: { + author: { + type: 'object' + }, + 'author.email': { + required: true, + type: 'string' + }, + 'author.name': { + required: true, + type: 'string' + }, + branch: { + type: 'string' + }, + committer: { + type: 'object' + }, + 'committer.email': { + required: true, + type: 'string' + }, + 'committer.name': { + required: true, + type: 'string' + }, + content: { + required: true, + type: 'string' + }, + message: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + path: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + sha: { + type: 'string' + } + }, + url: '/repos/:owner/:repo/contents/:path' + }, + updateHook: { + method: 'PATCH', + params: { + active: { + type: 'boolean' + }, + add_events: { + type: 'string[]' + }, + config: { + type: 'object' + }, + 'config.content_type': { + type: 'string' + }, + 'config.insecure_ssl': { + type: 'string' + }, + 'config.secret': { + type: 'string' + }, + 'config.url': { + required: true, + type: 'string' + }, + events: { + type: 'string[]' + }, + hook_id: { + required: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + remove_events: { + type: 'string[]' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/hooks/:hook_id' + }, + updateInformationAboutPagesSite: { + method: 'PUT', + params: { + cname: { + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + source: { + enum: ['"gh-pages"', '"master"', '"master /docs"'], + type: 'string' + } + }, + url: '/repos/:owner/:repo/pages' + }, + updateInvitation: { + method: 'PATCH', + params: { + invitation_id: { + required: true, + type: 'integer' + }, + owner: { + required: true, + type: 'string' + }, + permissions: { + enum: ['read', 'write', 'admin'], + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/invitations/:invitation_id' + }, + updateProtectedBranchPullRequestReviewEnforcement: { + method: 'PATCH', + params: { + branch: { + required: true, + type: 'string' + }, + dismiss_stale_reviews: { + type: 'boolean' + }, + dismissal_restrictions: { + type: 'object' + }, + 'dismissal_restrictions.teams': { + type: 'string[]' + }, + 'dismissal_restrictions.users': { + type: 'string[]' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + require_code_owner_reviews: { + type: 'boolean' + }, + required_approving_review_count: { + type: 'integer' + } + }, + url: + '/repos/:owner/:repo/branches/:branch/protection/required_pull_request_reviews' + }, + updateProtectedBranchRequiredStatusChecks: { + method: 'PATCH', + params: { + branch: { + required: true, + type: 'string' + }, + contexts: { + type: 'string[]' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + strict: { + type: 'boolean' + } + }, + url: + '/repos/:owner/:repo/branches/:branch/protection/required_status_checks' + }, + updateRelease: { + method: 'PATCH', + params: { + body: { + type: 'string' + }, + draft: { + type: 'boolean' + }, + name: { + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + prerelease: { + type: 'boolean' + }, + release_id: { + required: true, + type: 'integer' + }, + repo: { + required: true, + type: 'string' + }, + tag_name: { + type: 'string' + }, + target_commitish: { + type: 'string' + } + }, + url: '/repos/:owner/:repo/releases/:release_id' + }, + updateReleaseAsset: { + method: 'PATCH', + params: { + asset_id: { + required: true, + type: 'integer' + }, + label: { + type: 'string' + }, + name: { + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + } + }, + url: '/repos/:owner/:repo/releases/assets/:asset_id' + }, + uploadReleaseAsset: { + method: 'POST', + params: { + data: { + mapTo: 'data', + required: true, + type: 'string | object' + }, + file: { + alias: 'data', + deprecated: true, + type: 'string | object' + }, + headers: { + required: true, + type: 'object' + }, + 'headers.content-length': { + required: true, + type: 'integer' + }, + 'headers.content-type': { + required: true, + type: 'string' + }, + label: { + type: 'string' + }, + name: { + required: true, + type: 'string' + }, + url: { + required: true, + type: 'string' + } + }, + url: ':url' + } + }, + search: { + code: { + method: 'GET', + params: { + order: { + enum: ['desc', 'asc'], + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + q: { + required: true, + type: 'string' + }, + sort: { + enum: ['indexed'], + type: 'string' + } + }, + url: '/search/code' + }, + commits: { + headers: { + accept: 'application/vnd.github.cloak-preview+json' + }, + method: 'GET', + params: { + order: { + enum: ['desc', 'asc'], + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + q: { + required: true, + type: 'string' + }, + sort: { + enum: ['author-date', 'committer-date'], + type: 'string' + } + }, + url: '/search/commits' + }, + issues: { + deprecated: + 'octokit.search.issues() has been renamed to octokit.search.issuesAndPullRequests() (2018-12-27)', + method: 'GET', + params: { + order: { + enum: ['desc', 'asc'], + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + q: { + required: true, + type: 'string' + }, + sort: { + enum: [ + 'comments', + 'reactions', + 'reactions-+1', + 'reactions--1', + 'reactions-smile', + 'reactions-thinking_face', + 'reactions-heart', + 'reactions-tada', + 'interactions', + 'created', + 'updated' + ], + type: 'string' + } + }, + url: '/search/issues' + }, + issuesAndPullRequests: { + method: 'GET', + params: { + order: { + enum: ['desc', 'asc'], + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + q: { + required: true, + type: 'string' + }, + sort: { + enum: [ + 'comments', + 'reactions', + 'reactions-+1', + 'reactions--1', + 'reactions-smile', + 'reactions-thinking_face', + 'reactions-heart', + 'reactions-tada', + 'interactions', + 'created', + 'updated' + ], + type: 'string' + } + }, + url: '/search/issues' + }, + labels: { + method: 'GET', + params: { + order: { + enum: ['desc', 'asc'], + type: 'string' + }, + q: { + required: true, + type: 'string' + }, + repository_id: { + required: true, + type: 'integer' + }, + sort: { + enum: ['created', 'updated'], + type: 'string' + } + }, + url: '/search/labels' + }, + repos: { + method: 'GET', + params: { + order: { + enum: ['desc', 'asc'], + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + q: { + required: true, + type: 'string' + }, + sort: { + enum: ['stars', 'forks', 'help-wanted-issues', 'updated'], + type: 'string' + } + }, + url: '/search/repositories' + }, + topics: { + method: 'GET', + params: { + q: { + required: true, + type: 'string' + } + }, + url: '/search/topics' + }, + users: { + method: 'GET', + params: { + order: { + enum: ['desc', 'asc'], + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + q: { + required: true, + type: 'string' + }, + sort: { + enum: ['followers', 'repositories', 'joined'], + type: 'string' + } + }, + url: '/search/users' + } + }, + teams: { + addMember: { + deprecated: + 'octokit.teams.addMember() has been renamed to octokit.teams.addMemberLegacy() (2020-01-16)', + method: 'PUT', + params: { + team_id: { + required: true, + type: 'integer' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/teams/:team_id/members/:username' + }, + addMemberLegacy: { + deprecated: + 'octokit.teams.addMemberLegacy() is deprecated, see https://developer.github.com/v3/teams/members/#add-team-member-legacy', + method: 'PUT', + params: { + team_id: { + required: true, + type: 'integer' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/teams/:team_id/members/:username' + }, + addOrUpdateMembership: { + deprecated: + 'octokit.teams.addOrUpdateMembership() has been renamed to octokit.teams.addOrUpdateMembershipLegacy() (2020-01-16)', + method: 'PUT', + params: { + role: { + enum: ['member', 'maintainer'], + type: 'string' + }, + team_id: { + required: true, + type: 'integer' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/teams/:team_id/memberships/:username' + }, + addOrUpdateMembershipInOrg: { + method: 'PUT', + params: { + org: { + required: true, + type: 'string' + }, + role: { + enum: ['member', 'maintainer'], + type: 'string' + }, + team_slug: { + required: true, + type: 'string' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/teams/:team_slug/memberships/:username' + }, + addOrUpdateMembershipLegacy: { + deprecated: + 'octokit.teams.addOrUpdateMembershipLegacy() is deprecated, see https://developer.github.com/v3/teams/members/#add-or-update-team-membership-legacy', + method: 'PUT', + params: { + role: { + enum: ['member', 'maintainer'], + type: 'string' + }, + team_id: { + required: true, + type: 'integer' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/teams/:team_id/memberships/:username' + }, + addOrUpdateProject: { + deprecated: + 'octokit.teams.addOrUpdateProject() has been renamed to octokit.teams.addOrUpdateProjectLegacy() (2020-01-16)', + headers: { + accept: 'application/vnd.github.inertia-preview+json' + }, + method: 'PUT', + params: { + permission: { + enum: ['read', 'write', 'admin'], + type: 'string' + }, + project_id: { + required: true, + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id/projects/:project_id' + }, + addOrUpdateProjectInOrg: { + headers: { + accept: 'application/vnd.github.inertia-preview+json' + }, + method: 'PUT', + params: { + org: { + required: true, + type: 'string' + }, + permission: { + enum: ['read', 'write', 'admin'], + type: 'string' + }, + project_id: { + required: true, + type: 'integer' + }, + team_slug: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/teams/:team_slug/projects/:project_id' + }, + addOrUpdateProjectLegacy: { + deprecated: + 'octokit.teams.addOrUpdateProjectLegacy() is deprecated, see https://developer.github.com/v3/teams/#add-or-update-team-project-legacy', + headers: { + accept: 'application/vnd.github.inertia-preview+json' + }, + method: 'PUT', + params: { + permission: { + enum: ['read', 'write', 'admin'], + type: 'string' + }, + project_id: { + required: true, + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id/projects/:project_id' + }, + addOrUpdateRepo: { + deprecated: + 'octokit.teams.addOrUpdateRepo() has been renamed to octokit.teams.addOrUpdateRepoLegacy() (2020-01-16)', + method: 'PUT', + params: { + owner: { + required: true, + type: 'string' + }, + permission: { + enum: ['pull', 'push', 'admin'], + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id/repos/:owner/:repo' + }, + addOrUpdateRepoInOrg: { + method: 'PUT', + params: { + org: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + permission: { + enum: ['pull', 'push', 'admin'], + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + team_slug: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/teams/:team_slug/repos/:owner/:repo' + }, + addOrUpdateRepoLegacy: { + deprecated: + 'octokit.teams.addOrUpdateRepoLegacy() is deprecated, see https://developer.github.com/v3/teams/#add-or-update-team-repository-legacy', + method: 'PUT', + params: { + owner: { + required: true, + type: 'string' + }, + permission: { + enum: ['pull', 'push', 'admin'], + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id/repos/:owner/:repo' + }, + checkManagesRepo: { + deprecated: + 'octokit.teams.checkManagesRepo() has been renamed to octokit.teams.checkManagesRepoLegacy() (2020-01-16)', + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id/repos/:owner/:repo' + }, + checkManagesRepoInOrg: { + method: 'GET', + params: { + org: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + team_slug: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/teams/:team_slug/repos/:owner/:repo' + }, + checkManagesRepoLegacy: { + deprecated: + 'octokit.teams.checkManagesRepoLegacy() is deprecated, see https://developer.github.com/v3/teams/#check-if-a-team-manages-a-repository-legacy', + method: 'GET', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id/repos/:owner/:repo' + }, + create: { + method: 'POST', + params: { + description: { + type: 'string' + }, + maintainers: { + type: 'string[]' + }, + name: { + required: true, + type: 'string' + }, + org: { + required: true, + type: 'string' + }, + parent_team_id: { + type: 'integer' + }, + permission: { + enum: ['pull', 'push', 'admin'], + type: 'string' + }, + privacy: { + enum: ['secret', 'closed'], + type: 'string' + }, + repo_names: { + type: 'string[]' + } + }, + url: '/orgs/:org/teams' + }, + createDiscussion: { + deprecated: + 'octokit.teams.createDiscussion() has been renamed to octokit.teams.createDiscussionLegacy() (2020-01-16)', + method: 'POST', + params: { + body: { + required: true, + type: 'string' + }, + private: { + type: 'boolean' + }, + team_id: { + required: true, + type: 'integer' + }, + title: { + required: true, + type: 'string' + } + }, + url: '/teams/:team_id/discussions' + }, + createDiscussionComment: { + deprecated: + 'octokit.teams.createDiscussionComment() has been renamed to octokit.teams.createDiscussionCommentLegacy() (2020-01-16)', + method: 'POST', + params: { + body: { + required: true, + type: 'string' + }, + discussion_number: { + required: true, + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id/discussions/:discussion_number/comments' + }, + createDiscussionCommentInOrg: { + method: 'POST', + params: { + body: { + required: true, + type: 'string' + }, + discussion_number: { + required: true, + type: 'integer' + }, + org: { + required: true, + type: 'string' + }, + team_slug: { + required: true, + type: 'string' + } + }, + url: + '/orgs/:org/teams/:team_slug/discussions/:discussion_number/comments' + }, + createDiscussionCommentLegacy: { + deprecated: + 'octokit.teams.createDiscussionCommentLegacy() is deprecated, see https://developer.github.com/v3/teams/discussion_comments/#create-a-comment-legacy', + method: 'POST', + params: { + body: { + required: true, + type: 'string' + }, + discussion_number: { + required: true, + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id/discussions/:discussion_number/comments' + }, + createDiscussionInOrg: { + method: 'POST', + params: { + body: { + required: true, + type: 'string' + }, + org: { + required: true, + type: 'string' + }, + private: { + type: 'boolean' + }, + team_slug: { + required: true, + type: 'string' + }, + title: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/teams/:team_slug/discussions' + }, + createDiscussionLegacy: { + deprecated: + 'octokit.teams.createDiscussionLegacy() is deprecated, see https://developer.github.com/v3/teams/discussions/#create-a-discussion-legacy', + method: 'POST', + params: { + body: { + required: true, + type: 'string' + }, + private: { + type: 'boolean' + }, + team_id: { + required: true, + type: 'integer' + }, + title: { + required: true, + type: 'string' + } + }, + url: '/teams/:team_id/discussions' + }, + delete: { + deprecated: + 'octokit.teams.delete() has been renamed to octokit.teams.deleteLegacy() (2020-01-16)', + method: 'DELETE', + params: { + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id' + }, + deleteDiscussion: { + deprecated: + 'octokit.teams.deleteDiscussion() has been renamed to octokit.teams.deleteDiscussionLegacy() (2020-01-16)', + method: 'DELETE', + params: { + discussion_number: { + required: true, + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id/discussions/:discussion_number' + }, + deleteDiscussionComment: { + deprecated: + 'octokit.teams.deleteDiscussionComment() has been renamed to octokit.teams.deleteDiscussionCommentLegacy() (2020-01-16)', + method: 'DELETE', + params: { + comment_number: { + required: true, + type: 'integer' + }, + discussion_number: { + required: true, + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: + '/teams/:team_id/discussions/:discussion_number/comments/:comment_number' + }, + deleteDiscussionCommentInOrg: { + method: 'DELETE', + params: { + comment_number: { + required: true, + type: 'integer' + }, + discussion_number: { + required: true, + type: 'integer' + }, + org: { + required: true, + type: 'string' + }, + team_slug: { + required: true, + type: 'string' + } + }, + url: + '/orgs/:org/teams/:team_slug/discussions/:discussion_number/comments/:comment_number' + }, + deleteDiscussionCommentLegacy: { + deprecated: + 'octokit.teams.deleteDiscussionCommentLegacy() is deprecated, see https://developer.github.com/v3/teams/discussion_comments/#delete-a-comment-legacy', + method: 'DELETE', + params: { + comment_number: { + required: true, + type: 'integer' + }, + discussion_number: { + required: true, + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: + '/teams/:team_id/discussions/:discussion_number/comments/:comment_number' + }, + deleteDiscussionInOrg: { + method: 'DELETE', + params: { + discussion_number: { + required: true, + type: 'integer' + }, + org: { + required: true, + type: 'string' + }, + team_slug: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/teams/:team_slug/discussions/:discussion_number' + }, + deleteDiscussionLegacy: { + deprecated: + 'octokit.teams.deleteDiscussionLegacy() is deprecated, see https://developer.github.com/v3/teams/discussions/#delete-a-discussion-legacy', + method: 'DELETE', + params: { + discussion_number: { + required: true, + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id/discussions/:discussion_number' + }, + deleteInOrg: { + method: 'DELETE', + params: { + org: { + required: true, + type: 'string' + }, + team_slug: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/teams/:team_slug' + }, + deleteLegacy: { + deprecated: + 'octokit.teams.deleteLegacy() is deprecated, see https://developer.github.com/v3/teams/#delete-team-legacy', + method: 'DELETE', + params: { + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id' + }, + get: { + deprecated: + 'octokit.teams.get() has been renamed to octokit.teams.getLegacy() (2020-01-16)', + method: 'GET', + params: { + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id' + }, + getByName: { + method: 'GET', + params: { + org: { + required: true, + type: 'string' + }, + team_slug: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/teams/:team_slug' + }, + getDiscussion: { + deprecated: + 'octokit.teams.getDiscussion() has been renamed to octokit.teams.getDiscussionLegacy() (2020-01-16)', + method: 'GET', + params: { + discussion_number: { + required: true, + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id/discussions/:discussion_number' + }, + getDiscussionComment: { + deprecated: + 'octokit.teams.getDiscussionComment() has been renamed to octokit.teams.getDiscussionCommentLegacy() (2020-01-16)', + method: 'GET', + params: { + comment_number: { + required: true, + type: 'integer' + }, + discussion_number: { + required: true, + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: + '/teams/:team_id/discussions/:discussion_number/comments/:comment_number' + }, + getDiscussionCommentInOrg: { + method: 'GET', + params: { + comment_number: { + required: true, + type: 'integer' + }, + discussion_number: { + required: true, + type: 'integer' + }, + org: { + required: true, + type: 'string' + }, + team_slug: { + required: true, + type: 'string' + } + }, + url: + '/orgs/:org/teams/:team_slug/discussions/:discussion_number/comments/:comment_number' + }, + getDiscussionCommentLegacy: { + deprecated: + 'octokit.teams.getDiscussionCommentLegacy() is deprecated, see https://developer.github.com/v3/teams/discussion_comments/#get-a-single-comment-legacy', + method: 'GET', + params: { + comment_number: { + required: true, + type: 'integer' + }, + discussion_number: { + required: true, + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: + '/teams/:team_id/discussions/:discussion_number/comments/:comment_number' + }, + getDiscussionInOrg: { + method: 'GET', + params: { + discussion_number: { + required: true, + type: 'integer' + }, + org: { + required: true, + type: 'string' + }, + team_slug: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/teams/:team_slug/discussions/:discussion_number' + }, + getDiscussionLegacy: { + deprecated: + 'octokit.teams.getDiscussionLegacy() is deprecated, see https://developer.github.com/v3/teams/discussions/#get-a-single-discussion-legacy', + method: 'GET', + params: { + discussion_number: { + required: true, + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id/discussions/:discussion_number' + }, + getLegacy: { + deprecated: + 'octokit.teams.getLegacy() is deprecated, see https://developer.github.com/v3/teams/#get-team-legacy', + method: 'GET', + params: { + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id' + }, + getMember: { + deprecated: + 'octokit.teams.getMember() has been renamed to octokit.teams.getMemberLegacy() (2020-01-16)', + method: 'GET', + params: { + team_id: { + required: true, + type: 'integer' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/teams/:team_id/members/:username' + }, + getMemberLegacy: { + deprecated: + 'octokit.teams.getMemberLegacy() is deprecated, see https://developer.github.com/v3/teams/members/#get-team-member-legacy', + method: 'GET', + params: { + team_id: { + required: true, + type: 'integer' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/teams/:team_id/members/:username' + }, + getMembership: { + deprecated: + 'octokit.teams.getMembership() has been renamed to octokit.teams.getMembershipLegacy() (2020-01-16)', + method: 'GET', + params: { + team_id: { + required: true, + type: 'integer' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/teams/:team_id/memberships/:username' + }, + getMembershipInOrg: { + method: 'GET', + params: { + org: { + required: true, + type: 'string' + }, + team_slug: { + required: true, + type: 'string' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/teams/:team_slug/memberships/:username' + }, + getMembershipLegacy: { + deprecated: + 'octokit.teams.getMembershipLegacy() is deprecated, see https://developer.github.com/v3/teams/members/#get-team-membership-legacy', + method: 'GET', + params: { + team_id: { + required: true, + type: 'integer' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/teams/:team_id/memberships/:username' + }, + list: { + method: 'GET', + params: { + org: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + } + }, + url: '/orgs/:org/teams' + }, + listChild: { + deprecated: + 'octokit.teams.listChild() has been renamed to octokit.teams.listChildLegacy() (2020-01-16)', + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id/teams' + }, + listChildInOrg: { + method: 'GET', + params: { + org: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + team_slug: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/teams/:team_slug/teams' + }, + listChildLegacy: { + deprecated: + 'octokit.teams.listChildLegacy() is deprecated, see https://developer.github.com/v3/teams/#list-child-teams-legacy', + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id/teams' + }, + listDiscussionComments: { + deprecated: + 'octokit.teams.listDiscussionComments() has been renamed to octokit.teams.listDiscussionCommentsLegacy() (2020-01-16)', + method: 'GET', + params: { + direction: { + enum: ['asc', 'desc'], + type: 'string' + }, + discussion_number: { + required: true, + type: 'integer' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id/discussions/:discussion_number/comments' + }, + listDiscussionCommentsInOrg: { + method: 'GET', + params: { + direction: { + enum: ['asc', 'desc'], + type: 'string' + }, + discussion_number: { + required: true, + type: 'integer' + }, + org: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + team_slug: { + required: true, + type: 'string' + } + }, + url: + '/orgs/:org/teams/:team_slug/discussions/:discussion_number/comments' + }, + listDiscussionCommentsLegacy: { + deprecated: + 'octokit.teams.listDiscussionCommentsLegacy() is deprecated, see https://developer.github.com/v3/teams/discussion_comments/#list-comments-legacy', + method: 'GET', + params: { + direction: { + enum: ['asc', 'desc'], + type: 'string' + }, + discussion_number: { + required: true, + type: 'integer' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id/discussions/:discussion_number/comments' + }, + listDiscussions: { + deprecated: + 'octokit.teams.listDiscussions() has been renamed to octokit.teams.listDiscussionsLegacy() (2020-01-16)', + method: 'GET', + params: { + direction: { + enum: ['asc', 'desc'], + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id/discussions' + }, + listDiscussionsInOrg: { + method: 'GET', + params: { + direction: { + enum: ['asc', 'desc'], + type: 'string' + }, + org: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + team_slug: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/teams/:team_slug/discussions' + }, + listDiscussionsLegacy: { + deprecated: + 'octokit.teams.listDiscussionsLegacy() is deprecated, see https://developer.github.com/v3/teams/discussions/#list-discussions-legacy', + method: 'GET', + params: { + direction: { + enum: ['asc', 'desc'], + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id/discussions' + }, + listForAuthenticatedUser: { + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + } + }, + url: '/user/teams' + }, + listMembers: { + deprecated: + 'octokit.teams.listMembers() has been renamed to octokit.teams.listMembersLegacy() (2020-01-16)', + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + role: { + enum: ['member', 'maintainer', 'all'], + type: 'string' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id/members' + }, + listMembersInOrg: { + method: 'GET', + params: { + org: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + role: { + enum: ['member', 'maintainer', 'all'], + type: 'string' + }, + team_slug: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/teams/:team_slug/members' + }, + listMembersLegacy: { + deprecated: + 'octokit.teams.listMembersLegacy() is deprecated, see https://developer.github.com/v3/teams/members/#list-team-members-legacy', + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + role: { + enum: ['member', 'maintainer', 'all'], + type: 'string' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id/members' + }, + listPendingInvitations: { + deprecated: + 'octokit.teams.listPendingInvitations() has been renamed to octokit.teams.listPendingInvitationsLegacy() (2020-01-16)', + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id/invitations' + }, + listPendingInvitationsInOrg: { + method: 'GET', + params: { + org: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + team_slug: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/teams/:team_slug/invitations' + }, + listPendingInvitationsLegacy: { + deprecated: + 'octokit.teams.listPendingInvitationsLegacy() is deprecated, see https://developer.github.com/v3/teams/members/#list-pending-team-invitations-legacy', + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id/invitations' + }, + listProjects: { + deprecated: + 'octokit.teams.listProjects() has been renamed to octokit.teams.listProjectsLegacy() (2020-01-16)', + headers: { + accept: 'application/vnd.github.inertia-preview+json' + }, + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id/projects' + }, + listProjectsInOrg: { + headers: { + accept: 'application/vnd.github.inertia-preview+json' + }, + method: 'GET', + params: { + org: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + team_slug: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/teams/:team_slug/projects' + }, + listProjectsLegacy: { + deprecated: + 'octokit.teams.listProjectsLegacy() is deprecated, see https://developer.github.com/v3/teams/#list-team-projects-legacy', + headers: { + accept: 'application/vnd.github.inertia-preview+json' + }, + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id/projects' + }, + listRepos: { + deprecated: + 'octokit.teams.listRepos() has been renamed to octokit.teams.listReposLegacy() (2020-01-16)', + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id/repos' + }, + listReposInOrg: { + method: 'GET', + params: { + org: { + required: true, + type: 'string' + }, + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + team_slug: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/teams/:team_slug/repos' + }, + listReposLegacy: { + deprecated: + 'octokit.teams.listReposLegacy() is deprecated, see https://developer.github.com/v3/teams/#list-team-repos-legacy', + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id/repos' + }, + removeMember: { + deprecated: + 'octokit.teams.removeMember() has been renamed to octokit.teams.removeMemberLegacy() (2020-01-16)', + method: 'DELETE', + params: { + team_id: { + required: true, + type: 'integer' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/teams/:team_id/members/:username' + }, + removeMemberLegacy: { + deprecated: + 'octokit.teams.removeMemberLegacy() is deprecated, see https://developer.github.com/v3/teams/members/#remove-team-member-legacy', + method: 'DELETE', + params: { + team_id: { + required: true, + type: 'integer' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/teams/:team_id/members/:username' + }, + removeMembership: { + deprecated: + 'octokit.teams.removeMembership() has been renamed to octokit.teams.removeMembershipLegacy() (2020-01-16)', + method: 'DELETE', + params: { + team_id: { + required: true, + type: 'integer' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/teams/:team_id/memberships/:username' + }, + removeMembershipInOrg: { + method: 'DELETE', + params: { + org: { + required: true, + type: 'string' + }, + team_slug: { + required: true, + type: 'string' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/teams/:team_slug/memberships/:username' + }, + removeMembershipLegacy: { + deprecated: + 'octokit.teams.removeMembershipLegacy() is deprecated, see https://developer.github.com/v3/teams/members/#remove-team-membership-legacy', + method: 'DELETE', + params: { + team_id: { + required: true, + type: 'integer' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/teams/:team_id/memberships/:username' + }, + removeProject: { + deprecated: + 'octokit.teams.removeProject() has been renamed to octokit.teams.removeProjectLegacy() (2020-01-16)', + method: 'DELETE', + params: { + project_id: { + required: true, + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id/projects/:project_id' + }, + removeProjectInOrg: { + method: 'DELETE', + params: { + org: { + required: true, + type: 'string' + }, + project_id: { + required: true, + type: 'integer' + }, + team_slug: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/teams/:team_slug/projects/:project_id' + }, + removeProjectLegacy: { + deprecated: + 'octokit.teams.removeProjectLegacy() is deprecated, see https://developer.github.com/v3/teams/#remove-team-project-legacy', + method: 'DELETE', + params: { + project_id: { + required: true, + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id/projects/:project_id' + }, + removeRepo: { + deprecated: + 'octokit.teams.removeRepo() has been renamed to octokit.teams.removeRepoLegacy() (2020-01-16)', + method: 'DELETE', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id/repos/:owner/:repo' + }, + removeRepoInOrg: { + method: 'DELETE', + params: { + org: { + required: true, + type: 'string' + }, + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + team_slug: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/teams/:team_slug/repos/:owner/:repo' + }, + removeRepoLegacy: { + deprecated: + 'octokit.teams.removeRepoLegacy() is deprecated, see https://developer.github.com/v3/teams/#remove-team-repository-legacy', + method: 'DELETE', + params: { + owner: { + required: true, + type: 'string' + }, + repo: { + required: true, + type: 'string' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id/repos/:owner/:repo' + }, + reviewProject: { + deprecated: + 'octokit.teams.reviewProject() has been renamed to octokit.teams.reviewProjectLegacy() (2020-01-16)', + headers: { + accept: 'application/vnd.github.inertia-preview+json' + }, + method: 'GET', + params: { + project_id: { + required: true, + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id/projects/:project_id' + }, + reviewProjectInOrg: { + headers: { + accept: 'application/vnd.github.inertia-preview+json' + }, + method: 'GET', + params: { + org: { + required: true, + type: 'string' + }, + project_id: { + required: true, + type: 'integer' + }, + team_slug: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/teams/:team_slug/projects/:project_id' + }, + reviewProjectLegacy: { + deprecated: + 'octokit.teams.reviewProjectLegacy() is deprecated, see https://developer.github.com/v3/teams/#review-a-team-project-legacy', + headers: { + accept: 'application/vnd.github.inertia-preview+json' + }, + method: 'GET', + params: { + project_id: { + required: true, + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id/projects/:project_id' + }, + update: { + deprecated: + 'octokit.teams.update() has been renamed to octokit.teams.updateLegacy() (2020-01-16)', + method: 'PATCH', + params: { + description: { + type: 'string' + }, + name: { + required: true, + type: 'string' + }, + parent_team_id: { + type: 'integer' + }, + permission: { + enum: ['pull', 'push', 'admin'], + type: 'string' + }, + privacy: { + enum: ['secret', 'closed'], + type: 'string' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id' + }, + updateDiscussion: { + deprecated: + 'octokit.teams.updateDiscussion() has been renamed to octokit.teams.updateDiscussionLegacy() (2020-01-16)', + method: 'PATCH', + params: { + body: { + type: 'string' + }, + discussion_number: { + required: true, + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + }, + title: { + type: 'string' + } + }, + url: '/teams/:team_id/discussions/:discussion_number' + }, + updateDiscussionComment: { + deprecated: + 'octokit.teams.updateDiscussionComment() has been renamed to octokit.teams.updateDiscussionCommentLegacy() (2020-01-16)', + method: 'PATCH', + params: { + body: { + required: true, + type: 'string' + }, + comment_number: { + required: true, + type: 'integer' + }, + discussion_number: { + required: true, + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: + '/teams/:team_id/discussions/:discussion_number/comments/:comment_number' + }, + updateDiscussionCommentInOrg: { + method: 'PATCH', + params: { + body: { + required: true, + type: 'string' + }, + comment_number: { + required: true, + type: 'integer' + }, + discussion_number: { + required: true, + type: 'integer' + }, + org: { + required: true, + type: 'string' + }, + team_slug: { + required: true, + type: 'string' + } + }, + url: + '/orgs/:org/teams/:team_slug/discussions/:discussion_number/comments/:comment_number' + }, + updateDiscussionCommentLegacy: { + deprecated: + 'octokit.teams.updateDiscussionCommentLegacy() is deprecated, see https://developer.github.com/v3/teams/discussion_comments/#edit-a-comment-legacy', + method: 'PATCH', + params: { + body: { + required: true, + type: 'string' + }, + comment_number: { + required: true, + type: 'integer' + }, + discussion_number: { + required: true, + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: + '/teams/:team_id/discussions/:discussion_number/comments/:comment_number' + }, + updateDiscussionInOrg: { + method: 'PATCH', + params: { + body: { + type: 'string' + }, + discussion_number: { + required: true, + type: 'integer' + }, + org: { + required: true, + type: 'string' + }, + team_slug: { + required: true, + type: 'string' + }, + title: { + type: 'string' + } + }, + url: '/orgs/:org/teams/:team_slug/discussions/:discussion_number' + }, + updateDiscussionLegacy: { + deprecated: + 'octokit.teams.updateDiscussionLegacy() is deprecated, see https://developer.github.com/v3/teams/discussions/#edit-a-discussion-legacy', + method: 'PATCH', + params: { + body: { + type: 'string' + }, + discussion_number: { + required: true, + type: 'integer' + }, + team_id: { + required: true, + type: 'integer' + }, + title: { + type: 'string' + } + }, + url: '/teams/:team_id/discussions/:discussion_number' + }, + updateInOrg: { + method: 'PATCH', + params: { + description: { + type: 'string' + }, + name: { + required: true, + type: 'string' + }, + org: { + required: true, + type: 'string' + }, + parent_team_id: { + type: 'integer' + }, + permission: { + enum: ['pull', 'push', 'admin'], + type: 'string' + }, + privacy: { + enum: ['secret', 'closed'], + type: 'string' + }, + team_slug: { + required: true, + type: 'string' + } + }, + url: '/orgs/:org/teams/:team_slug' + }, + updateLegacy: { + deprecated: + 'octokit.teams.updateLegacy() is deprecated, see https://developer.github.com/v3/teams/#edit-team-legacy', + method: 'PATCH', + params: { + description: { + type: 'string' + }, + name: { + required: true, + type: 'string' + }, + parent_team_id: { + type: 'integer' + }, + permission: { + enum: ['pull', 'push', 'admin'], + type: 'string' + }, + privacy: { + enum: ['secret', 'closed'], + type: 'string' + }, + team_id: { + required: true, + type: 'integer' + } + }, + url: '/teams/:team_id' + } + }, + users: { + addEmails: { + method: 'POST', + params: { + emails: { + required: true, + type: 'string[]' + } + }, + url: '/user/emails' + }, + block: { + method: 'PUT', + params: { + username: { + required: true, + type: 'string' + } + }, + url: '/user/blocks/:username' + }, + checkBlocked: { + method: 'GET', + params: { + username: { + required: true, + type: 'string' + } + }, + url: '/user/blocks/:username' + }, + checkFollowing: { + method: 'GET', + params: { + username: { + required: true, + type: 'string' + } + }, + url: '/user/following/:username' + }, + checkFollowingForUser: { + method: 'GET', + params: { + target_user: { + required: true, + type: 'string' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/users/:username/following/:target_user' + }, + createGpgKey: { + method: 'POST', + params: { + armored_public_key: { + type: 'string' + } + }, + url: '/user/gpg_keys' + }, + createPublicKey: { + method: 'POST', + params: { + key: { + type: 'string' + }, + title: { + type: 'string' + } + }, + url: '/user/keys' + }, + deleteEmails: { + method: 'DELETE', + params: { + emails: { + required: true, + type: 'string[]' + } + }, + url: '/user/emails' + }, + deleteGpgKey: { + method: 'DELETE', + params: { + gpg_key_id: { + required: true, + type: 'integer' + } + }, + url: '/user/gpg_keys/:gpg_key_id' + }, + deletePublicKey: { + method: 'DELETE', + params: { + key_id: { + required: true, + type: 'integer' + } + }, + url: '/user/keys/:key_id' + }, + follow: { + method: 'PUT', + params: { + username: { + required: true, + type: 'string' + } + }, + url: '/user/following/:username' + }, + getAuthenticated: { + method: 'GET', + params: {}, + url: '/user' + }, + getByUsername: { + method: 'GET', + params: { + username: { + required: true, + type: 'string' + } + }, + url: '/users/:username' + }, + getContextForUser: { + method: 'GET', + params: { + subject_id: { + type: 'string' + }, + subject_type: { + enum: ['organization', 'repository', 'issue', 'pull_request'], + type: 'string' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/users/:username/hovercard' + }, + getGpgKey: { + method: 'GET', + params: { + gpg_key_id: { + required: true, + type: 'integer' + } + }, + url: '/user/gpg_keys/:gpg_key_id' + }, + getPublicKey: { + method: 'GET', + params: { + key_id: { + required: true, + type: 'integer' + } + }, + url: '/user/keys/:key_id' + }, + list: { + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + since: { + type: 'string' + } + }, + url: '/users' + }, + listBlocked: { + method: 'GET', + params: {}, + url: '/user/blocks' + }, + listEmails: { + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + } + }, + url: '/user/emails' + }, + listFollowersForAuthenticatedUser: { + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + } + }, + url: '/user/followers' + }, + listFollowersForUser: { + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/users/:username/followers' + }, + listFollowingForAuthenticatedUser: { + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + } + }, + url: '/user/following' + }, + listFollowingForUser: { + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/users/:username/following' + }, + listGpgKeys: { + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + } + }, + url: '/user/gpg_keys' + }, + listGpgKeysForUser: { + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/users/:username/gpg_keys' + }, + listPublicEmails: { + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + } + }, + url: '/user/public_emails' + }, + listPublicKeys: { + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + } + }, + url: '/user/keys' + }, + listPublicKeysForUser: { + method: 'GET', + params: { + page: { + type: 'integer' + }, + per_page: { + type: 'integer' + }, + username: { + required: true, + type: 'string' + } + }, + url: '/users/:username/keys' + }, + togglePrimaryEmailVisibility: { + method: 'PATCH', + params: { + email: { + required: true, + type: 'string' + }, + visibility: { + required: true, + type: 'string' + } + }, + url: '/user/email/visibility' + }, + unblock: { + method: 'DELETE', + params: { + username: { + required: true, + type: 'string' + } + }, + url: '/user/blocks/:username' + }, + unfollow: { + method: 'DELETE', + params: { + username: { + required: true, + type: 'string' + } + }, + url: '/user/following/:username' + }, + updateAuthenticated: { + method: 'PATCH', + params: { + bio: { + type: 'string' + }, + blog: { + type: 'string' + }, + company: { + type: 'string' + }, + email: { + type: 'string' + }, + hireable: { + type: 'boolean' + }, + location: { + type: 'string' + }, + name: { + type: 'string' + } + }, + url: '/user' + } + } + } + + const VERSION = '2.4.0' + + function registerEndpoints(octokit, routes) { + Object.keys(routes).forEach(namespaceName => { + if (!octokit[namespaceName]) { + octokit[namespaceName] = {} + } + + Object.keys(routes[namespaceName]).forEach(apiName => { + const apiOptions = routes[namespaceName][apiName] + const endpointDefaults = ['method', 'url', 'headers'].reduce( + (map, key) => { + if (typeof apiOptions[key] !== 'undefined') { + map[key] = apiOptions[key] + } + + return map + }, + {} + ) + endpointDefaults.request = { + validate: apiOptions.params + } + let request = octokit.request.defaults(endpointDefaults) // patch request & endpoint methods to support deprecated parameters. + // Not the most elegant solution, but we don’t want to move deprecation + // logic into octokit/endpoint.js as it’s out of scope + + const hasDeprecatedParam = Object.keys( + apiOptions.params || {} + ).find(key => apiOptions.params[key].deprecated) + + if (hasDeprecatedParam) { + const patch = patchForDeprecation.bind(null, octokit, apiOptions) + request = patch( + octokit.request.defaults(endpointDefaults), + `.${namespaceName}.${apiName}()` + ) + request.endpoint = patch( + request.endpoint, + `.${namespaceName}.${apiName}.endpoint()` + ) + request.endpoint.merge = patch( + request.endpoint.merge, + `.${namespaceName}.${apiName}.endpoint.merge()` + ) + } + + if (apiOptions.deprecated) { + octokit[namespaceName][apiName] = Object.assign( + function deprecatedEndpointMethod() { + octokit.log.warn( + new deprecation.Deprecation( + `[@octokit/rest] ${apiOptions.deprecated}` + ) + ) + octokit[namespaceName][apiName] = request + return request.apply(null, arguments) + }, + request + ) + return + } + + octokit[namespaceName][apiName] = request + }) + }) + } + + function patchForDeprecation(octokit, apiOptions, method, methodName) { + const patchedMethod = options => { + options = Object.assign({}, options) + Object.keys(options).forEach(key => { + if (apiOptions.params[key] && apiOptions.params[key].deprecated) { + const aliasKey = apiOptions.params[key].alias + octokit.log.warn( + new deprecation.Deprecation( + `[@octokit/rest] "${key}" parameter is deprecated for "${methodName}". Use "${aliasKey}" instead` + ) + ) + + if (!(aliasKey in options)) { + options[aliasKey] = options[key] + } + + delete options[key] + } + }) + return method(options) + } + + Object.keys(method).forEach(key => { + patchedMethod[key] = method[key] + }) + return patchedMethod + } + + /** + * This plugin is a 1:1 copy of internal @octokit/rest plugins. The primary + * goal is to rebuild @octokit/rest on top of @octokit/core. Once that is + * done, we will remove the registerEndpoints methods and return the methods + * directly as with the other plugins. At that point we will also remove the + * legacy workarounds and deprecations. + * + * See the plan at + * https://github.com/octokit/plugin-rest-endpoint-methods.js/pull/1 + */ + + function restEndpointMethods(octokit) { + // @ts-ignore + octokit.registerEndpoints = registerEndpoints.bind(null, octokit) + registerEndpoints(octokit, endpointsByScope) // Aliasing scopes for backward compatibility + // See https://github.com/octokit/rest.js/pull/1134 + + ;[ + ['gitdata', 'git'], + ['authorization', 'oauthAuthorizations'], + ['pullRequests', 'pulls'] + ].forEach(([deprecatedScope, scope]) => { + Object.defineProperty(octokit, deprecatedScope, { + get() { + octokit.log.warn( + // @ts-ignore + new deprecation.Deprecation( + `[@octokit/plugin-rest-endpoint-methods] "octokit.${deprecatedScope}.*" methods are deprecated, use "octokit.${scope}.*" instead` + ) + ) // @ts-ignore + + return octokit[scope] + } + }) + }) + return {} + } + restEndpointMethods.VERSION = VERSION + + exports.restEndpointMethods = restEndpointMethods + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 10537: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + Object.defineProperty(exports, '__esModule', { value: true }) + + function _interopDefault(ex) { + return ex && typeof ex === 'object' && 'default' in ex + ? ex['default'] + : ex + } + + var deprecation = __webpack_require__(58932) + var once = _interopDefault(__webpack_require__(1223)) + + const logOnce = once(deprecation => console.warn(deprecation)) + /** + * Error with extra properties to help with debugging + */ + + class RequestError extends Error { + constructor(message, statusCode, options) { + super(message) // Maintains proper stack trace (only available on V8) + + /* istanbul ignore next */ + + if (Error.captureStackTrace) { + Error.captureStackTrace(this, this.constructor) + } + + this.name = 'HttpError' + this.status = statusCode + Object.defineProperty(this, 'code', { + get() { + logOnce( + new deprecation.Deprecation( + '[@octokit/request-error] `error.code` is deprecated, use `error.status`.' + ) + ) + return statusCode + } + }) + this.headers = options.headers || {} // redact request credentials without mutating original request options + + const requestCopy = Object.assign({}, options.request) + + if (options.request.headers.authorization) { + requestCopy.headers = Object.assign({}, options.request.headers, { + authorization: options.request.headers.authorization.replace( + / .*$/, + ' [REDACTED]' + ) + }) + } + + requestCopy.url = requestCopy.url // client_id & client_secret can be passed as URL query parameters to increase rate limit + // see https://developer.github.com/v3/#increasing-the-unauthenticated-rate-limit-for-oauth-applications + .replace(/\bclient_secret=\w+/g, 'client_secret=[REDACTED]') // OAuth tokens can be passed as URL query parameters, although it is not recommended + // see https://developer.github.com/v3/#oauth2-token-sent-in-a-header + .replace(/\baccess_token=\w+/g, 'access_token=[REDACTED]') + this.request = requestCopy + } + } + + exports.RequestError = RequestError + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 36234: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + Object.defineProperty(exports, '__esModule', { value: true }) + + function _interopDefault(ex) { + return ex && typeof ex === 'object' && 'default' in ex + ? ex['default'] + : ex + } + + var endpoint = __webpack_require__(59440) + var universalUserAgent = __webpack_require__(41441) + var isPlainObject = __webpack_require__(49062) + var nodeFetch = _interopDefault(__webpack_require__(80467)) + var requestError = __webpack_require__(10537) + + const VERSION = '5.4.10' + + function getBufferResponse(response) { + return response.arrayBuffer() + } + + function fetchWrapper(requestOptions) { + if ( + isPlainObject.isPlainObject(requestOptions.body) || + Array.isArray(requestOptions.body) + ) { + requestOptions.body = JSON.stringify(requestOptions.body) + } + + let headers = {} + let status + let url + const fetch = + (requestOptions.request && requestOptions.request.fetch) || nodeFetch + return fetch( + requestOptions.url, + Object.assign( + { + method: requestOptions.method, + body: requestOptions.body, + headers: requestOptions.headers, + redirect: requestOptions.redirect + }, + requestOptions.request + ) + ) + .then(response => { + url = response.url + status = response.status + + for (const keyAndValue of response.headers) { + headers[keyAndValue[0]] = keyAndValue[1] + } + + if (status === 204 || status === 205) { + return + } // GitHub API returns 200 for HEAD requests + + if (requestOptions.method === 'HEAD') { + if (status < 400) { + return + } + + throw new requestError.RequestError(response.statusText, status, { + headers, + request: requestOptions + }) + } + + if (status === 304) { + throw new requestError.RequestError('Not modified', status, { + headers, + request: requestOptions + }) + } + + if (status >= 400) { + return response.text().then(message => { + const error = new requestError.RequestError(message, status, { + headers, + request: requestOptions + }) + + try { + let responseBody = JSON.parse(error.message) + Object.assign(error, responseBody) + let errors = responseBody.errors // Assumption `errors` would always be in Array format + + error.message = + error.message + ': ' + errors.map(JSON.stringify).join(', ') + } catch (e) { + // ignore, see octokit/rest.js#684 + } + + throw error + }) + } + + const contentType = response.headers.get('content-type') + + if (/application\/json/.test(contentType)) { + return response.json() + } + + if (!contentType || /^text\/|charset=utf-8$/.test(contentType)) { + return response.text() + } + + return getBufferResponse(response) + }) + .then(data => { + return { + status, + url, + headers, + data + } + }) + .catch(error => { + if (error instanceof requestError.RequestError) { + throw error + } + + throw new requestError.RequestError(error.message, 500, { + headers, + request: requestOptions + }) + }) + } + + function withDefaults(oldEndpoint, newDefaults) { + const endpoint = oldEndpoint.defaults(newDefaults) + + const newApi = function (route, parameters) { + const endpointOptions = endpoint.merge(route, parameters) + + if (!endpointOptions.request || !endpointOptions.request.hook) { + return fetchWrapper(endpoint.parse(endpointOptions)) + } + + const request = (route, parameters) => { + return fetchWrapper( + endpoint.parse(endpoint.merge(route, parameters)) + ) + } + + Object.assign(request, { + endpoint, + defaults: withDefaults.bind(null, endpoint) + }) + return endpointOptions.request.hook(request, endpointOptions) + } + + return Object.assign(newApi, { + endpoint, + defaults: withDefaults.bind(null, endpoint) + }) + } + + const request = withDefaults(endpoint.endpoint, { + headers: { + 'user-agent': `octokit-request.js/${VERSION} ${universalUserAgent.getUserAgent()}` + } + }) + + exports.request = request + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 49062: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + Object.defineProperty(exports, '__esModule', { value: true }) + + /*! + * is-plain-object + * + * Copyright (c) 2014-2017, Jon Schlinkert. + * Released under the MIT License. + */ + + function isObject(o) { + return Object.prototype.toString.call(o) === '[object Object]' + } + + function isPlainObject(o) { + var ctor, prot + + if (isObject(o) === false) return false + + // If has modified constructor + ctor = o.constructor + if (ctor === undefined) return true + + // If has modified prototype + prot = ctor.prototype + if (isObject(prot) === false) return false + + // If constructor does not have an Object-specific method + if (prot.hasOwnProperty('isPrototypeOf') === false) { + return false + } + + // Most likely a plain Object + return true + } + + exports.isPlainObject = isPlainObject + + /***/ + }, + + /***/ 41441: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + Object.defineProperty(exports, '__esModule', { value: true }) + + function getUserAgent() { + if (typeof navigator === 'object' && 'userAgent' in navigator) { + return navigator.userAgent + } + + if (typeof process === 'object' && 'version' in process) { + return `Node.js/${process.version.substr(1)} (${process.platform}; ${ + process.arch + })` + } + + return '' + } + + exports.getUserAgent = getUserAgent + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 29351: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + const { requestLog } = __webpack_require__(68883) + const { restEndpointMethods } = __webpack_require__(83044) + + const Core = __webpack_require__(29833) + + const CORE_PLUGINS = [ + __webpack_require__(64555), + __webpack_require__(33691), // deprecated: remove in v17 + requestLog, + __webpack_require__(18579), + restEndpointMethods, + __webpack_require__(42657), + + __webpack_require__(82072) // deprecated: remove in v17 + ] + + const OctokitRest = Core.plugin(CORE_PLUGINS) + + function DeprecatedOctokit(options) { + const warn = + options && options.log && options.log.warn + ? options.log.warn + : console.warn + warn( + '[@octokit/rest] `const Octokit = require("@octokit/rest")` is deprecated. Use `const { Octokit } = require("@octokit/rest")` instead' + ) + return new OctokitRest(options) + } + + const Octokit = Object.assign(DeprecatedOctokit, { + Octokit: OctokitRest + }) + + Object.keys(OctokitRest).forEach(key => { + /* istanbul ignore else */ + if (OctokitRest.hasOwnProperty(key)) { + Octokit[key] = OctokitRest[key] + } + }) + + module.exports = Octokit + + /***/ + }, + + /***/ 30823: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + module.exports = Octokit + + const { request } = __webpack_require__(36234) + const Hook = __webpack_require__(83682) + + const parseClientOptions = __webpack_require__(64613) + + function Octokit(plugins, options) { + options = options || {} + const hook = new Hook.Collection() + const log = Object.assign( + { + debug: () => {}, + info: () => {}, + warn: console.warn, + error: console.error + }, + options && options.log + ) + const api = { + hook, + log, + request: request.defaults(parseClientOptions(options, log, hook)) + } + + plugins.forEach(pluginFunction => pluginFunction(api, options)) + + return api + } + + /***/ + }, + + /***/ 29833: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + const factory = __webpack_require__(35320) + + module.exports = factory() + + /***/ + }, + + /***/ 35320: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + module.exports = factory + + const Octokit = __webpack_require__(30823) + const registerPlugin = __webpack_require__(77826) + + function factory(plugins) { + const Api = Octokit.bind(null, plugins || []) + Api.plugin = registerPlugin.bind(null, plugins || []) + return Api + } + + /***/ + }, + + /***/ 64613: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + module.exports = parseOptions + + const { Deprecation } = __webpack_require__(58932) + const { getUserAgent } = __webpack_require__(45030) + const once = __webpack_require__(1223) + + const pkg = __webpack_require__(9674) + + const deprecateOptionsTimeout = once((log, deprecation) => + log.warn(deprecation) + ) + const deprecateOptionsAgent = once((log, deprecation) => + log.warn(deprecation) + ) + const deprecateOptionsHeaders = once((log, deprecation) => + log.warn(deprecation) + ) + + function parseOptions(options, log, hook) { + if (options.headers) { + options.headers = Object.keys(options.headers).reduce( + (newObj, key) => { + newObj[key.toLowerCase()] = options.headers[key] + return newObj + }, + {} + ) + } + + const clientDefaults = { + headers: options.headers || {}, + request: options.request || {}, + mediaType: { + previews: [], + format: '' + } + } + + if (options.baseUrl) { + clientDefaults.baseUrl = options.baseUrl + } + + if (options.userAgent) { + clientDefaults.headers['user-agent'] = options.userAgent + } + + if (options.previews) { + clientDefaults.mediaType.previews = options.previews + } + + if (options.timeZone) { + clientDefaults.headers['time-zone'] = options.timeZone + } + + if (options.timeout) { + deprecateOptionsTimeout( + log, + new Deprecation( + '[@octokit/rest] new Octokit({timeout}) is deprecated. Use {request: {timeout}} instead. See https://github.com/octokit/request.js#request' + ) + ) + clientDefaults.request.timeout = options.timeout + } + + if (options.agent) { + deprecateOptionsAgent( + log, + new Deprecation( + '[@octokit/rest] new Octokit({agent}) is deprecated. Use {request: {agent}} instead. See https://github.com/octokit/request.js#request' + ) + ) + clientDefaults.request.agent = options.agent + } + + if (options.headers) { + deprecateOptionsHeaders( + log, + new Deprecation( + '[@octokit/rest] new Octokit({headers}) is deprecated. Use {userAgent, previews} instead. See https://github.com/octokit/request.js#request' + ) + ) + } + + const userAgentOption = clientDefaults.headers['user-agent'] + const defaultUserAgent = `octokit.js/${pkg.version} ${getUserAgent()}` + + clientDefaults.headers['user-agent'] = [ + userAgentOption, + defaultUserAgent + ] + .filter(Boolean) + .join(' ') + + clientDefaults.request.hook = hook.bind(null, 'request') + + return clientDefaults + } + + /***/ + }, + + /***/ 77826: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + module.exports = registerPlugin + + const factory = __webpack_require__(35320) + + function registerPlugin(plugins, pluginFunction) { + return factory( + plugins.includes(pluginFunction) + ? plugins + : plugins.concat(pluginFunction) + ) + } + + /***/ + }, + + /***/ 96239: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + Object.defineProperty(exports, '__esModule', { value: true }) + + function _interopDefault(ex) { + return ex && typeof ex === 'object' && 'default' in ex + ? ex['default'] + : ex + } + + var deprecation = __webpack_require__(58932) + var once = _interopDefault(__webpack_require__(1223)) + + const logOnce = once(deprecation => console.warn(deprecation)) + /** + * Error with extra properties to help with debugging + */ + + class RequestError extends Error { + constructor(message, statusCode, options) { + super(message) // Maintains proper stack trace (only available on V8) + + /* istanbul ignore next */ + + if (Error.captureStackTrace) { + Error.captureStackTrace(this, this.constructor) + } + + this.name = 'HttpError' + this.status = statusCode + Object.defineProperty(this, 'code', { + get() { + logOnce( + new deprecation.Deprecation( + '[@octokit/request-error] `error.code` is deprecated, use `error.status`.' + ) + ) + return statusCode + } + }) + this.headers = options.headers || {} // redact request credentials without mutating original request options + + const requestCopy = Object.assign({}, options.request) + + if (options.request.headers.authorization) { + requestCopy.headers = Object.assign({}, options.request.headers, { + authorization: options.request.headers.authorization.replace( + / .*$/, + ' [REDACTED]' + ) + }) + } + + requestCopy.url = requestCopy.url // client_id & client_secret can be passed as URL query parameters to increase rate limit + // see https://developer.github.com/v3/#increasing-the-unauthenticated-rate-limit-for-oauth-applications + .replace(/\bclient_secret=\w+/g, 'client_secret=[REDACTED]') // OAuth tokens can be passed as URL query parameters, although it is not recommended + // see https://developer.github.com/v3/#oauth2-token-sent-in-a-header + .replace(/\baccess_token=\w+/g, 'access_token=[REDACTED]') + this.request = requestCopy + } + } + + exports.RequestError = RequestError + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 795: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + module.exports = authenticate + + const { Deprecation } = __webpack_require__(58932) + const once = __webpack_require__(1223) + + const deprecateAuthenticate = once((log, deprecation) => + log.warn(deprecation) + ) + + function authenticate(state, options) { + deprecateAuthenticate( + state.octokit.log, + new Deprecation( + '[@octokit/rest] octokit.authenticate() is deprecated. Use "auth" constructor option instead.' + ) + ) + + if (!options) { + state.auth = false + return + } + + switch (options.type) { + case 'basic': + if (!options.username || !options.password) { + throw new Error( + 'Basic authentication requires both a username and password to be set' + ) + } + break + + case 'oauth': + if (!options.token && !(options.key && options.secret)) { + throw new Error( + 'OAuth2 authentication requires a token or key & secret to be set' + ) + } + break + + case 'token': + case 'app': + if (!options.token) { + throw new Error('Token authentication requires a token to be set') + } + break + + default: + throw new Error( + "Invalid authentication type, must be 'basic', 'oauth', 'token' or 'app'" + ) + } + + state.auth = options + } + + /***/ + }, + + /***/ 47578: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + module.exports = authenticationBeforeRequest + + const btoa = __webpack_require__(72358) + const uniq = __webpack_require__(78216) + + function authenticationBeforeRequest(state, options) { + if (!state.auth.type) { + return + } + + if (state.auth.type === 'basic') { + const hash = btoa(`${state.auth.username}:${state.auth.password}`) + options.headers.authorization = `Basic ${hash}` + return + } + + if (state.auth.type === 'token') { + options.headers.authorization = `token ${state.auth.token}` + return + } + + if (state.auth.type === 'app') { + options.headers.authorization = `Bearer ${state.auth.token}` + const acceptHeaders = options.headers.accept + .split(',') + .concat('application/vnd.github.machine-man-preview+json') + options.headers.accept = uniq(acceptHeaders).filter(Boolean).join(',') + return + } + + options.url += options.url.indexOf('?') === -1 ? '?' : '&' + + if (state.auth.token) { + options.url += `access_token=${encodeURIComponent(state.auth.token)}` + return + } + + const key = encodeURIComponent(state.auth.key) + const secret = encodeURIComponent(state.auth.secret) + options.url += `client_id=${key}&client_secret=${secret}` + } + + /***/ + }, + + /***/ 33691: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + module.exports = authenticationPlugin + + const { Deprecation } = __webpack_require__(58932) + const once = __webpack_require__(1223) + + const deprecateAuthenticate = once((log, deprecation) => + log.warn(deprecation) + ) + + const authenticate = __webpack_require__(795) + const beforeRequest = __webpack_require__(47578) + const requestError = __webpack_require__(54275) + + function authenticationPlugin(octokit, options) { + if (options.auth) { + octokit.authenticate = () => { + deprecateAuthenticate( + octokit.log, + new Deprecation( + '[@octokit/rest] octokit.authenticate() is deprecated and has no effect when "auth" option is set on Octokit constructor' + ) + ) + } + return + } + const state = { + octokit, + auth: false + } + octokit.authenticate = authenticate.bind(null, state) + octokit.hook.before('request', beforeRequest.bind(null, state)) + octokit.hook.error('request', requestError.bind(null, state)) + } + + /***/ + }, + + /***/ 54275: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + module.exports = authenticationRequestError + + const { RequestError } = __webpack_require__(96239) + + function authenticationRequestError(state, error, options) { + /* istanbul ignore next */ + if (!error.headers) throw error + + const otpRequired = /required/.test(error.headers['x-github-otp'] || '') + // handle "2FA required" error only + if (error.status !== 401 || !otpRequired) { + throw error + } + + if ( + error.status === 401 && + otpRequired && + error.request && + error.request.headers['x-github-otp'] + ) { + throw new RequestError( + 'Invalid one-time password for two-factor authentication', + 401, + { + headers: error.headers, + request: options + } + ) + } + + if (typeof state.auth.on2fa !== 'function') { + throw new RequestError( + '2FA required, but options.on2fa is not a function. See https://github.com/octokit/rest.js#authentication', + 401, + { + headers: error.headers, + request: options + } + ) + } + + return Promise.resolve() + .then(() => { + return state.auth.on2fa() + }) + .then(oneTimePassword => { + const newOptions = Object.assign(options, { + headers: Object.assign( + { 'x-github-otp': oneTimePassword }, + options.headers + ) + }) + return state.octokit.request(newOptions) + }) + } + + /***/ + }, + + /***/ 99733: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + module.exports = authenticationBeforeRequest + + const btoa = __webpack_require__(72358) + + const withAuthorizationPrefix = __webpack_require__(19603) + + function authenticationBeforeRequest(state, options) { + if (typeof state.auth === 'string') { + options.headers.authorization = withAuthorizationPrefix(state.auth) + return + } + + if (state.auth.username) { + const hash = btoa(`${state.auth.username}:${state.auth.password}`) + options.headers.authorization = `Basic ${hash}` + if (state.otp) { + options.headers['x-github-otp'] = state.otp + } + return + } + + if (state.auth.clientId) { + // There is a special case for OAuth applications, when `clientId` and `clientSecret` is passed as + // Basic Authorization instead of query parameters. The only routes where that applies share the same + // URL though: `/applications/:client_id/tokens/:access_token`. + // + // 1. [Check an authorization](https://developer.github.com/v3/oauth_authorizations/#check-an-authorization) + // 2. [Reset an authorization](https://developer.github.com/v3/oauth_authorizations/#reset-an-authorization) + // 3. [Revoke an authorization for an application](https://developer.github.com/v3/oauth_authorizations/#revoke-an-authorization-for-an-application) + // + // We identify by checking the URL. It must merge both "/applications/:client_id/tokens/:access_token" + // as well as "/applications/123/tokens/token456" + if ( + /\/applications\/:?[\w_]+\/tokens\/:?[\w_]+($|\?)/.test(options.url) + ) { + const hash = btoa( + `${state.auth.clientId}:${state.auth.clientSecret}` + ) + options.headers.authorization = `Basic ${hash}` + return + } + + options.url += options.url.indexOf('?') === -1 ? '?' : '&' + options.url += `client_id=${state.auth.clientId}&client_secret=${state.auth.clientSecret}` + return + } + + return Promise.resolve() + + .then(() => { + return state.auth() + }) + + .then(authorization => { + options.headers.authorization = withAuthorizationPrefix( + authorization + ) + }) + } + + /***/ + }, + + /***/ 64555: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + module.exports = authenticationPlugin + + const { createTokenAuth } = __webpack_require__(40334) + const { Deprecation } = __webpack_require__(58932) + const once = __webpack_require__(1223) + + const beforeRequest = __webpack_require__(99733) + const requestError = __webpack_require__(3217) + const validate = __webpack_require__(18997) + const withAuthorizationPrefix = __webpack_require__(19603) + + const deprecateAuthBasic = once((log, deprecation) => + log.warn(deprecation) + ) + const deprecateAuthObject = once((log, deprecation) => + log.warn(deprecation) + ) + + function authenticationPlugin(octokit, options) { + // If `options.authStrategy` is set then use it and pass in `options.auth` + if (options.authStrategy) { + const auth = options.authStrategy(options.auth) + octokit.hook.wrap('request', auth.hook) + octokit.auth = auth + return + } + + // If neither `options.authStrategy` nor `options.auth` are set, the `octokit` instance + // is unauthenticated. The `octokit.auth()` method is a no-op and no request hook is registred. + if (!options.auth) { + octokit.auth = () => + Promise.resolve({ + type: 'unauthenticated' + }) + return + } + + const isBasicAuthString = + typeof options.auth === 'string' && + /^basic/.test(withAuthorizationPrefix(options.auth)) + + // If only `options.auth` is set to a string, use the default token authentication strategy. + if (typeof options.auth === 'string' && !isBasicAuthString) { + const auth = createTokenAuth(options.auth) + octokit.hook.wrap('request', auth.hook) + octokit.auth = auth + return + } + + // Otherwise log a deprecation message + const [deprecationMethod, deprecationMessapge] = isBasicAuthString + ? [ + deprecateAuthBasic, + 'Setting the "new Octokit({ auth })" option to a Basic Auth string is deprecated. Use https://github.com/octokit/auth-basic.js instead. See (https://octokit.github.io/rest.js/#authentication)' + ] + : [ + deprecateAuthObject, + 'Setting the "new Octokit({ auth })" option to an object without also setting the "authStrategy" option is deprecated and will be removed in v17. See (https://octokit.github.io/rest.js/#authentication)' + ] + deprecationMethod( + octokit.log, + new Deprecation('[@octokit/rest] ' + deprecationMessapge) + ) + + octokit.auth = () => + Promise.resolve({ + type: 'deprecated', + message: deprecationMessapge + }) + + validate(options.auth) + + const state = { + octokit, + auth: options.auth + } + + octokit.hook.before('request', beforeRequest.bind(null, state)) + octokit.hook.error('request', requestError.bind(null, state)) + } + + /***/ + }, + + /***/ 3217: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + module.exports = authenticationRequestError + + const { RequestError } = __webpack_require__(96239) + + function authenticationRequestError(state, error, options) { + if (!error.headers) throw error + + const otpRequired = /required/.test(error.headers['x-github-otp'] || '') + // handle "2FA required" error only + if (error.status !== 401 || !otpRequired) { + throw error + } + + if ( + error.status === 401 && + otpRequired && + error.request && + error.request.headers['x-github-otp'] + ) { + if (state.otp) { + delete state.otp // no longer valid, request again + } else { + throw new RequestError( + 'Invalid one-time password for two-factor authentication', + 401, + { + headers: error.headers, + request: options + } + ) + } + } + + if (typeof state.auth.on2fa !== 'function') { + throw new RequestError( + '2FA required, but options.on2fa is not a function. See https://github.com/octokit/rest.js#authentication', + 401, + { + headers: error.headers, + request: options + } + ) + } + + return Promise.resolve() + .then(() => { + return state.auth.on2fa() + }) + .then(oneTimePassword => { + const newOptions = Object.assign(options, { + headers: Object.assign(options.headers, { + 'x-github-otp': oneTimePassword + }) + }) + return state.octokit.request(newOptions).then(response => { + // If OTP still valid, then persist it for following requests + state.otp = oneTimePassword + return response + }) + }) + } + + /***/ + }, + + /***/ 18997: /***/ module => { + module.exports = validateAuth + + function validateAuth(auth) { + if (typeof auth === 'string') { + return + } + + if (typeof auth === 'function') { + return + } + + if (auth.username && auth.password) { + return + } + + if (auth.clientId && auth.clientSecret) { + return + } + + throw new Error(`Invalid "auth" option: ${JSON.stringify(auth)}`) + } + + /***/ + }, + + /***/ 19603: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + module.exports = withAuthorizationPrefix + + const atob = __webpack_require__(55224) + + const REGEX_IS_BASIC_AUTH = /^[\w-]+:/ + + function withAuthorizationPrefix(authorization) { + if (/^(basic|bearer|token) /i.test(authorization)) { + return authorization + } + + try { + if (REGEX_IS_BASIC_AUTH.test(atob(authorization))) { + return `basic ${authorization}` + } + } catch (error) {} + + if (authorization.split(/\./).length === 3) { + return `bearer ${authorization}` + } + + return `token ${authorization}` + } + + /***/ + }, + + /***/ 18579: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + module.exports = paginatePlugin + + const { paginateRest } = __webpack_require__(64193) + + function paginatePlugin(octokit) { + Object.assign(octokit, paginateRest(octokit)) + } + + /***/ + }, + + /***/ 42657: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + module.exports = octokitValidate + + const validate = __webpack_require__(6132) + + function octokitValidate(octokit) { + octokit.hook.before('request', validate.bind(null, octokit)) + } + + /***/ + }, + + /***/ 6132: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + 'use strict' + + module.exports = validate + + const { RequestError } = __webpack_require__(96239) + const get = __webpack_require__(99197) + const set = __webpack_require__(51552) + + function validate(octokit, options) { + if (!options.request.validate) { + return + } + const { validate: params } = options.request + + Object.keys(params).forEach(parameterName => { + const parameter = get(params, parameterName) + + const expectedType = parameter.type + let parentParameterName + let parentValue + let parentParamIsPresent = true + let parentParameterIsArray = false + + if (/\./.test(parameterName)) { + parentParameterName = parameterName.replace(/\.[^.]+$/, '') + parentParameterIsArray = parentParameterName.slice(-2) === '[]' + if (parentParameterIsArray) { + parentParameterName = parentParameterName.slice(0, -2) + } + parentValue = get(options, parentParameterName) + parentParamIsPresent = + parentParameterName === 'headers' || + (typeof parentValue === 'object' && parentValue !== null) + } + + const values = parentParameterIsArray + ? (get(options, parentParameterName) || []).map( + value => value[parameterName.split(/\./).pop()] + ) + : [get(options, parameterName)] + + values.forEach((value, i) => { + const valueIsPresent = typeof value !== 'undefined' + const valueIsNull = value === null + const currentParameterName = parentParameterIsArray + ? parameterName.replace(/\[\]/, `[${i}]`) + : parameterName + + if (!parameter.required && !valueIsPresent) { + return + } + + // if the parent parameter is of type object but allows null + // then the child parameters can be ignored + if (!parentParamIsPresent) { + return + } + + if (parameter.allowNull && valueIsNull) { + return + } + + if (!parameter.allowNull && valueIsNull) { + throw new RequestError( + `'${currentParameterName}' cannot be null`, + 400, + { + request: options + } + ) + } + + if (parameter.required && !valueIsPresent) { + throw new RequestError( + `Empty value for parameter '${currentParameterName}': ${JSON.stringify( + value + )}`, + 400, + { + request: options + } + ) + } + + // parse to integer before checking for enum + // so that string "1" will match enum with number 1 + if (expectedType === 'integer') { + const unparsedValue = value + value = parseInt(value, 10) + if (isNaN(value)) { + throw new RequestError( + `Invalid value for parameter '${currentParameterName}': ${JSON.stringify( + unparsedValue + )} is NaN`, + 400, + { + request: options + } + ) + } + } + + if ( + parameter.enum && + parameter.enum.indexOf(String(value)) === -1 + ) { + throw new RequestError( + `Invalid value for parameter '${currentParameterName}': ${JSON.stringify( + value + )}`, + 400, + { + request: options + } + ) + } + + if (parameter.validation) { + const regex = new RegExp(parameter.validation) + if (!regex.test(value)) { + throw new RequestError( + `Invalid value for parameter '${currentParameterName}': ${JSON.stringify( + value + )}`, + 400, + { + request: options + } + ) + } + } + + if (expectedType === 'object' && typeof value === 'string') { + try { + value = JSON.parse(value) + } catch (exception) { + throw new RequestError( + `JSON parse error of value for parameter '${currentParameterName}': ${JSON.stringify( + value + )}`, + 400, + { + request: options + } + ) + } + } + + set(options, parameter.mapTo || currentParameterName, value) + }) + }) + + return options + } + + /***/ + }, + + /***/ 94469: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /** + * Copyright 2018, OpenCensus Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p] + } + Object.defineProperty(exports, '__esModule', { value: true }) + __export(__webpack_require__(44641)) + const v1API = __webpack_require__(4876) + /** + * @deprecated since version 0.0.10 - use {@link StackdriverFormat} instead + * All other propagation exports a class constructor, while Stackdriver v1 + * propagation exports an implementation of Propagation. + */ + exports.v1 = { + extract: v1API.extract, + inject: v1API.inject, + generate: v1API.generate + } + // Also export the v1 API as the default API. + // tslint:disable-next-line:deprecation + exports.extract = exports.v1.extract + // tslint:disable-next-line:deprecation + exports.inject = exports.v1.inject + // tslint:disable-next-line:deprecation + exports.generate = exports.v1.generate + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 44641: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /** + * Copyright 2019 OpenCensus Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + /** + * This file implements propagation for the Stackdriver Trace v1 Trace Context + * format. + * + * The header specification is: + * "X-Cloud-Trace-Context: TRACE_ID/SPAN_ID;o=TRACE_TRUE" + * Where: + * {TRACE_ID} is a 32-character hexadecimal value representing a 128-bit + * number. It should be unique between your requests, unless you + * intentionally want to bundle the requests together. + * {SPAN_ID} is the decimal representation of the (unsigned) span ID. It + * should be 0 for the first span in your trace. For subsequent requests, + * set SPAN_ID to the span ID of the parent request. + * {TRACE_TRUE} must be 1 to trace request. Specify 0 to not trace the request. + */ + const crypto = __webpack_require__(76417) + const hex2dec_1 = __webpack_require__(86426) + const uuid = __webpack_require__(4552) + /** Header that carries span context across Google infrastructure. */ + exports.TRACE_CONTEXT_HEADER_NAME = 'x-cloud-trace-context' + const SPAN_ID_RANDOM_BYTES = 8 + const TRACE_TRUE = 0x1 + /** Propagates span context through Stackdriver Format propagation. */ + class StackdriverFormat { + /** + * Gets the span context from a request headers. If there is no span context + * in the headers, null is returned. + * @param getter + */ + extract(getter) { + const traceContextHeader = getter.getHeader( + exports.TRACE_CONTEXT_HEADER_NAME + ) + if (typeof traceContextHeader !== 'string') { + return null + } + const matches = traceContextHeader.match( + /^([0-9a-fA-F]+)(?:\/([0-9]+))(?:;o=(.*))?/ + ) + if ( + !matches || + matches.length !== 4 || + matches[0] !== traceContextHeader || + (matches[2] && isNaN(Number(matches[2]))) + ) { + return null + } + return { + traceId: matches[1], + // strip 0x prefix from hex output from decToHex, and and pad so it's + // always a length-16 hex string + spanId: `0000000000000000${hex2dec_1 + .decToHex(matches[2]) + .slice(2)}`.slice(-16), + options: isNaN(Number(matches[3])) ? TRACE_TRUE : Number(matches[3]) + } + } + /** + * Adds a span context in a request headers. + * @param setter + * @param spanContext + */ + inject(setter, spanContext) { + let header = `${spanContext.traceId}/${hex2dec_1.hexToDec( + spanContext.spanId + )}` + if (spanContext.options) { + header += `;o=${spanContext.options}` + } + setter.setHeader(exports.TRACE_CONTEXT_HEADER_NAME, header) + } + /** Generate SpanContexts */ + generate() { + return { + traceId: uuid.v4().replace(/-/g, ''), + spanId: spanRandomBuffer().toString('hex'), + options: TRACE_TRUE + } + } + } + exports.StackdriverFormat = StackdriverFormat + // Use the faster crypto.randomFillSync when available (Node 7+) falling back to + // using crypto.randomBytes. + // TODO(ofrobots): Use alternate logic for the browser where crypto and Buffer + // are not available. + const spanIdBuffer = Buffer.alloc(SPAN_ID_RANDOM_BYTES) + const randomFillSync = crypto.randomFillSync + const randomBytes = crypto.randomBytes + const spanRandomBuffer = randomFillSync + ? () => randomFillSync(spanIdBuffer) + : () => randomBytes(SPAN_ID_RANDOM_BYTES) + //# sourceMappingURL=stackdriver-format.js.map + + /***/ + }, + + /***/ 4876: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /** + * Copyright 2015 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + /** + * This file implements propagation for the Stackdriver Trace v1 Trace Context + * format. + * Full details at https://cloud.google.com/trace/docs/support. + */ + const crypto = __webpack_require__(76417) + const hex2dec_1 = __webpack_require__(86426) + const uuid = __webpack_require__(4552) + const TRACE_CONTEXT_HEADER_NAME = 'x-cloud-trace-context' + function parseContextFromHeader(str) { + if (typeof str !== 'string') { + return null + } + const matches = str.match(/^([0-9a-fA-F]+)(?:\/([0-9]+))(?:;o=(.*))?/) + if ( + !matches || + matches.length !== 4 || + matches[0] !== str || + (matches[2] && isNaN(Number(matches[2]))) + ) { + return null + } + return { + traceId: matches[1], + // strip 0x prefix from hex output from decToHex, and and pad so it's always + // a length-16 hex string + spanId: `0000000000000000${hex2dec_1 + .decToHex(matches[2]) + .slice(2)}`.slice(-16), + options: isNaN(Number(matches[3])) ? undefined : Number(matches[3]) + } + } + exports.parseContextFromHeader = parseContextFromHeader + function serializeSpanContext(spanContext) { + let header = `${spanContext.traceId}/${hex2dec_1.hexToDec( + spanContext.spanId + )}` + if (spanContext.options) { + header += `;o=${spanContext.options}` + } + return header + } + exports.serializeSpanContext = serializeSpanContext + function extract(getter) { + return parseContextFromHeader( + getter.getHeader(TRACE_CONTEXT_HEADER_NAME) + ) + } + exports.extract = extract + function inject(setter, spanContext) { + setter.setHeader( + TRACE_CONTEXT_HEADER_NAME, + serializeSpanContext(spanContext) + ) + } + exports.inject = inject + const SPAN_ID_RANDOM_BYTES = 8 + // Use the faster crypto.randomFillSync when available (Node 7+) falling back to + // using crypto.randomBytes. + // TODO(ofrobots): Use alternate logic for the browser where crypto and Buffer + // are not available. + const spanIdBuffer = Buffer.alloc(SPAN_ID_RANDOM_BYTES) + const randomFillSync = crypto.randomFillSync + const randomBytes = crypto.randomBytes + const spanRandomBuffer = randomFillSync + ? () => randomFillSync(spanIdBuffer) + : () => randomBytes(SPAN_ID_RANDOM_BYTES) + function generate() { + return { + traceId: uuid.v4().split('-').join(''), + spanId: spanRandomBuffer().toString('hex') + } + } + exports.generate = generate + //# sourceMappingURL=v1.js.map + + /***/ + }, + + /***/ 252: /***/ module => { + 'use strict' + + module.exports = asPromise + + /** + * Callback as used by {@link util.asPromise}. + * @typedef asPromiseCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {...*} params Additional arguments + * @returns {undefined} + */ + + /** + * Returns a promise from a node-style callback function. + * @memberof util + * @param {asPromiseCallback} fn Function to call + * @param {*} ctx Function context + * @param {...*} params Function arguments + * @returns {Promise<*>} Promisified function + */ + function asPromise(fn, ctx /*, varargs */) { + var params = new Array(arguments.length - 1), + offset = 0, + index = 2, + pending = true + while (index < arguments.length) params[offset++] = arguments[index++] + return new Promise(function executor(resolve, reject) { + params[offset] = function callback(err /*, varargs */) { + if (pending) { + pending = false + if (err) reject(err) + else { + var params = new Array(arguments.length - 1), + offset = 0 + while (offset < params.length) + params[offset++] = arguments[offset] + resolve.apply(null, params) + } + } + } + try { + fn.apply(ctx || null, params) + } catch (err) { + if (pending) { + pending = false + reject(err) + } + } + }) + } + + /***/ + }, + + /***/ 26718: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + /** + * A minimal base64 implementation for number arrays. + * @memberof util + * @namespace + */ + var base64 = exports + + /** + * Calculates the byte length of a base64 encoded string. + * @param {string} string Base64 encoded string + * @returns {number} Byte length + */ + base64.length = function length(string) { + var p = string.length + if (!p) return 0 + var n = 0 + while (--p % 4 > 1 && string.charAt(p) === '=') ++n + return Math.ceil(string.length * 3) / 4 - n + } + + // Base64 encoding table + var b64 = new Array(64) + + // Base64 decoding table + var s64 = new Array(123) + + // 65..90, 97..122, 48..57, 43, 47 + for (var i = 0; i < 64; ) + s64[ + (b64[i] = + i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : (i - 59) | 43) + ] = i++ + + /** + * Encodes a buffer to a base64 encoded string. + * @param {Uint8Array} buffer Source buffer + * @param {number} start Source start + * @param {number} end Source end + * @returns {string} Base64 encoded string + */ + base64.encode = function encode(buffer, start, end) { + var parts = null, + chunk = [] + var i = 0, // output index + j = 0, // goto index + t // temporary + while (start < end) { + var b = buffer[start++] + switch (j) { + case 0: + chunk[i++] = b64[b >> 2] + t = (b & 3) << 4 + j = 1 + break + case 1: + chunk[i++] = b64[t | (b >> 4)] + t = (b & 15) << 2 + j = 2 + break + case 2: + chunk[i++] = b64[t | (b >> 6)] + chunk[i++] = b64[b & 63] + j = 0 + break + } + if (i > 8191) { + ;(parts || (parts = [])).push( + String.fromCharCode.apply(String, chunk) + ) + i = 0 + } + } + if (j) { + chunk[i++] = b64[t] + chunk[i++] = 61 + if (j === 1) chunk[i++] = 61 + } + if (parts) { + if (i) + parts.push(String.fromCharCode.apply(String, chunk.slice(0, i))) + return parts.join('') + } + return String.fromCharCode.apply(String, chunk.slice(0, i)) + } + + var invalidEncoding = 'invalid encoding' + + /** + * Decodes a base64 encoded string to a buffer. + * @param {string} string Source string + * @param {Uint8Array} buffer Destination buffer + * @param {number} offset Destination offset + * @returns {number} Number of bytes written + * @throws {Error} If encoding is invalid + */ + base64.decode = function decode(string, buffer, offset) { + var start = offset + var j = 0, // goto index + t // temporary + for (var i = 0; i < string.length; ) { + var c = string.charCodeAt(i++) + if (c === 61 && j > 1) break + if ((c = s64[c]) === undefined) throw Error(invalidEncoding) + switch (j) { + case 0: + t = c + j = 1 + break + case 1: + buffer[offset++] = (t << 2) | ((c & 48) >> 4) + t = c + j = 2 + break + case 2: + buffer[offset++] = ((t & 15) << 4) | ((c & 60) >> 2) + t = c + j = 3 + break + case 3: + buffer[offset++] = ((t & 3) << 6) | c + j = 0 + break + } + } + if (j === 1) throw Error(invalidEncoding) + return offset - start + } + + /** + * Tests if the specified string appears to be base64 encoded. + * @param {string} string String to test + * @returns {boolean} `true` if probably base64 encoded, otherwise false + */ + base64.test = function test(string) { + return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test( + string + ) + } + + /***/ + }, + + /***/ 58882: /***/ module => { + 'use strict' + + module.exports = codegen + + /** + * Begins generating a function. + * @memberof util + * @param {string[]} functionParams Function parameter names + * @param {string} [functionName] Function name if not anonymous + * @returns {Codegen} Appender that appends code to the function's body + */ + function codegen(functionParams, functionName) { + /* istanbul ignore if */ + if (typeof functionParams === 'string') { + functionName = functionParams + functionParams = undefined + } + + var body = [] + + /** + * Appends code to the function's body or finishes generation. + * @typedef Codegen + * @type {function} + * @param {string|Object.} [formatStringOrScope] Format string or, to finish the function, an object of additional scope variables, if any + * @param {...*} [formatParams] Format parameters + * @returns {Codegen|Function} Itself or the generated function if finished + * @throws {Error} If format parameter counts do not match + */ + + function Codegen(formatStringOrScope) { + // note that explicit array handling below makes this ~50% faster + + // finish the function + if (typeof formatStringOrScope !== 'string') { + var source = toString() + if (codegen.verbose) console.log('codegen: ' + source) // eslint-disable-line no-console + source = 'return ' + source + if (formatStringOrScope) { + var scopeKeys = Object.keys(formatStringOrScope), + scopeParams = new Array(scopeKeys.length + 1), + scopeValues = new Array(scopeKeys.length), + scopeOffset = 0 + while (scopeOffset < scopeKeys.length) { + scopeParams[scopeOffset] = scopeKeys[scopeOffset] + scopeValues[scopeOffset] = + formatStringOrScope[scopeKeys[scopeOffset++]] + } + scopeParams[scopeOffset] = source + return Function.apply(null, scopeParams).apply(null, scopeValues) // eslint-disable-line no-new-func + } + return Function(source)() // eslint-disable-line no-new-func + } + + // otherwise append to body + var formatParams = new Array(arguments.length - 1), + formatOffset = 0 + while (formatOffset < formatParams.length) + formatParams[formatOffset] = arguments[++formatOffset] + formatOffset = 0 + formatStringOrScope = formatStringOrScope.replace( + /%([%dfijs])/g, + function replace($0, $1) { + var value = formatParams[formatOffset++] + switch ($1) { + case 'd': + case 'f': + return String(Number(value)) + case 'i': + return String(Math.floor(value)) + case 'j': + return JSON.stringify(value) + case 's': + return String(value) + } + return '%' + } + ) + if (formatOffset !== formatParams.length) + throw Error('parameter count mismatch') + body.push(formatStringOrScope) + return Codegen + } + + function toString(functionNameOverride) { + return ( + 'function ' + + (functionNameOverride || functionName || '') + + '(' + + ((functionParams && functionParams.join(',')) || '') + + '){\n ' + + body.join('\n ') + + '\n}' + ) + } + + Codegen.toString = toString + return Codegen + } + + /** + * Begins generating a function. + * @memberof util + * @function codegen + * @param {string} [functionName] Function name if not anonymous + * @returns {Codegen} Appender that appends code to the function's body + * @variation 2 + */ + + /** + * When set to `true`, codegen will log generated code to console. Useful for debugging. + * @name util.codegen.verbose + * @type {boolean} + */ + codegen.verbose = false + + /***/ + }, + + /***/ 86850: /***/ module => { + 'use strict' + + module.exports = EventEmitter + + /** + * Constructs a new event emitter instance. + * @classdesc A minimal event emitter. + * @memberof util + * @constructor + */ + function EventEmitter() { + /** + * Registered listeners. + * @type {Object.} + * @private + */ + this._listeners = {} + } + + /** + * Registers an event listener. + * @param {string} evt Event name + * @param {function} fn Listener + * @param {*} [ctx] Listener context + * @returns {util.EventEmitter} `this` + */ + EventEmitter.prototype.on = function on(evt, fn, ctx) { + ;(this._listeners[evt] || (this._listeners[evt] = [])).push({ + fn: fn, + ctx: ctx || this + }) + return this + } + + /** + * Removes an event listener or any matching listeners if arguments are omitted. + * @param {string} [evt] Event name. Removes all listeners if omitted. + * @param {function} [fn] Listener to remove. Removes all listeners of `evt` if omitted. + * @returns {util.EventEmitter} `this` + */ + EventEmitter.prototype.off = function off(evt, fn) { + if (evt === undefined) this._listeners = {} + else { + if (fn === undefined) this._listeners[evt] = [] + else { + var listeners = this._listeners[evt] + for (var i = 0; i < listeners.length; ) + if (listeners[i].fn === fn) listeners.splice(i, 1) + else ++i + } + } + return this + } + + /** + * Emits an event by calling its listeners with the specified arguments. + * @param {string} evt Event name + * @param {...*} args Arguments + * @returns {util.EventEmitter} `this` + */ + EventEmitter.prototype.emit = function emit(evt) { + var listeners = this._listeners[evt] + if (listeners) { + var args = [], + i = 1 + for (; i < arguments.length; ) args.push(arguments[i++]) + for (i = 0; i < listeners.length; ) + listeners[i].fn.apply(listeners[i++].ctx, args) + } + return this + } + + /***/ + }, + + /***/ 50663: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + 'use strict' + + module.exports = fetch + + var asPromise = __webpack_require__(252), + inquire = __webpack_require__(60094) + + var fs = inquire('fs') + + /** + * Node-style callback as used by {@link util.fetch}. + * @typedef FetchCallback + * @type {function} + * @param {?Error} error Error, if any, otherwise `null` + * @param {string} [contents] File contents, if there hasn't been an error + * @returns {undefined} + */ + + /** + * Options as used by {@link util.fetch}. + * @typedef FetchOptions + * @type {Object} + * @property {boolean} [binary=false] Whether expecting a binary response + * @property {boolean} [xhr=false] If `true`, forces the use of XMLHttpRequest + */ + + /** + * Fetches the contents of a file. + * @memberof util + * @param {string} filename File path or url + * @param {FetchOptions} options Fetch options + * @param {FetchCallback} callback Callback function + * @returns {undefined} + */ + function fetch(filename, options, callback) { + if (typeof options === 'function') { + callback = options + options = {} + } else if (!options) options = {} + + if (!callback) return asPromise(fetch, this, filename, options) // eslint-disable-line no-invalid-this + + // if a node-like filesystem is present, try it first but fall back to XHR if nothing is found. + if (!options.xhr && fs && fs.readFile) + return fs.readFile(filename, function fetchReadFileCallback( + err, + contents + ) { + return err && typeof XMLHttpRequest !== 'undefined' + ? fetch.xhr(filename, options, callback) + : err + ? callback(err) + : callback( + null, + options.binary ? contents : contents.toString('utf8') + ) + }) + + // use the XHR version otherwise. + return fetch.xhr(filename, options, callback) + } + + /** + * Fetches the contents of a file. + * @name util.fetch + * @function + * @param {string} path File path or url + * @param {FetchCallback} callback Callback function + * @returns {undefined} + * @variation 2 + */ + + /** + * Fetches the contents of a file. + * @name util.fetch + * @function + * @param {string} path File path or url + * @param {FetchOptions} [options] Fetch options + * @returns {Promise} Promise + * @variation 3 + */ + + /**/ + fetch.xhr = function fetch_xhr(filename, options, callback) { + var xhr = new XMLHttpRequest() + xhr.onreadystatechange /* works everywhere */ = function fetchOnReadyStateChange() { + if (xhr.readyState !== 4) return undefined + + // local cors security errors return status 0 / empty string, too. afaik this cannot be + // reliably distinguished from an actually empty file for security reasons. feel free + // to send a pull request if you are aware of a solution. + if (xhr.status !== 0 && xhr.status !== 200) + return callback(Error('status ' + xhr.status)) + + // if binary data is expected, make sure that some sort of array is returned, even if + // ArrayBuffers are not supported. the binary string fallback, however, is unsafe. + if (options.binary) { + var buffer = xhr.response + if (!buffer) { + buffer = [] + for (var i = 0; i < xhr.responseText.length; ++i) + buffer.push(xhr.responseText.charCodeAt(i) & 255) + } + return callback( + null, + typeof Uint8Array !== 'undefined' + ? new Uint8Array(buffer) + : buffer + ) + } + return callback(null, xhr.responseText) + } + + if (options.binary) { + // ref: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Sending_and_Receiving_Binary_Data#Receiving_binary_data_in_older_browsers + if ('overrideMimeType' in xhr) + xhr.overrideMimeType('text/plain; charset=x-user-defined') + xhr.responseType = 'arraybuffer' + } + + xhr.open('GET', filename) + xhr.send() + } + + /***/ + }, + + /***/ 21843: /***/ module => { + 'use strict' + + module.exports = factory(factory) + + /** + * Reads / writes floats / doubles from / to buffers. + * @name util.float + * @namespace + */ + + /** + * Writes a 32 bit float to a buffer using little endian byte order. + * @name util.float.writeFloatLE + * @function + * @param {number} val Value to write + * @param {Uint8Array} buf Target buffer + * @param {number} pos Target buffer offset + * @returns {undefined} + */ + + /** + * Writes a 32 bit float to a buffer using big endian byte order. + * @name util.float.writeFloatBE + * @function + * @param {number} val Value to write + * @param {Uint8Array} buf Target buffer + * @param {number} pos Target buffer offset + * @returns {undefined} + */ + + /** + * Reads a 32 bit float from a buffer using little endian byte order. + * @name util.float.readFloatLE + * @function + * @param {Uint8Array} buf Source buffer + * @param {number} pos Source buffer offset + * @returns {number} Value read + */ + + /** + * Reads a 32 bit float from a buffer using big endian byte order. + * @name util.float.readFloatBE + * @function + * @param {Uint8Array} buf Source buffer + * @param {number} pos Source buffer offset + * @returns {number} Value read + */ + + /** + * Writes a 64 bit double to a buffer using little endian byte order. + * @name util.float.writeDoubleLE + * @function + * @param {number} val Value to write + * @param {Uint8Array} buf Target buffer + * @param {number} pos Target buffer offset + * @returns {undefined} + */ + + /** + * Writes a 64 bit double to a buffer using big endian byte order. + * @name util.float.writeDoubleBE + * @function + * @param {number} val Value to write + * @param {Uint8Array} buf Target buffer + * @param {number} pos Target buffer offset + * @returns {undefined} + */ + + /** + * Reads a 64 bit double from a buffer using little endian byte order. + * @name util.float.readDoubleLE + * @function + * @param {Uint8Array} buf Source buffer + * @param {number} pos Source buffer offset + * @returns {number} Value read + */ + + /** + * Reads a 64 bit double from a buffer using big endian byte order. + * @name util.float.readDoubleBE + * @function + * @param {Uint8Array} buf Source buffer + * @param {number} pos Source buffer offset + * @returns {number} Value read + */ + + // Factory function for the purpose of node-based testing in modified global environments + function factory(exports) { + // float: typed array + if (typeof Float32Array !== 'undefined') + (function () { + var f32 = new Float32Array([-0]), + f8b = new Uint8Array(f32.buffer), + le = f8b[3] === 128 + + function writeFloat_f32_cpy(val, buf, pos) { + f32[0] = val + buf[pos] = f8b[0] + buf[pos + 1] = f8b[1] + buf[pos + 2] = f8b[2] + buf[pos + 3] = f8b[3] + } + + function writeFloat_f32_rev(val, buf, pos) { + f32[0] = val + buf[pos] = f8b[3] + buf[pos + 1] = f8b[2] + buf[pos + 2] = f8b[1] + buf[pos + 3] = f8b[0] + } + + /* istanbul ignore next */ + exports.writeFloatLE = le ? writeFloat_f32_cpy : writeFloat_f32_rev + /* istanbul ignore next */ + exports.writeFloatBE = le ? writeFloat_f32_rev : writeFloat_f32_cpy + + function readFloat_f32_cpy(buf, pos) { + f8b[0] = buf[pos] + f8b[1] = buf[pos + 1] + f8b[2] = buf[pos + 2] + f8b[3] = buf[pos + 3] + return f32[0] + } + + function readFloat_f32_rev(buf, pos) { + f8b[3] = buf[pos] + f8b[2] = buf[pos + 1] + f8b[1] = buf[pos + 2] + f8b[0] = buf[pos + 3] + return f32[0] + } + + /* istanbul ignore next */ + exports.readFloatLE = le ? readFloat_f32_cpy : readFloat_f32_rev + /* istanbul ignore next */ + exports.readFloatBE = le ? readFloat_f32_rev : readFloat_f32_cpy + + // float: ieee754 + })() + else + (function () { + function writeFloat_ieee754(writeUint, val, buf, pos) { + var sign = val < 0 ? 1 : 0 + if (sign) val = -val + if (val === 0) + writeUint( + 1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, + buf, + pos + ) + else if (isNaN(val)) writeUint(2143289344, buf, pos) + else if (val > 3.4028234663852886e38) + // +-Infinity + writeUint(((sign << 31) | 2139095040) >>> 0, buf, pos) + else if (val < 1.1754943508222875e-38) + // denormal + writeUint( + ((sign << 31) | Math.round(val / 1.401298464324817e-45)) >>> + 0, + buf, + pos + ) + else { + var exponent = Math.floor(Math.log(val) / Math.LN2), + mantissa = + Math.round(val * Math.pow(2, -exponent) * 8388608) & 8388607 + writeUint( + ((sign << 31) | ((exponent + 127) << 23) | mantissa) >>> 0, + buf, + pos + ) + } + } + + exports.writeFloatLE = writeFloat_ieee754.bind(null, writeUintLE) + exports.writeFloatBE = writeFloat_ieee754.bind(null, writeUintBE) + + function readFloat_ieee754(readUint, buf, pos) { + var uint = readUint(buf, pos), + sign = (uint >> 31) * 2 + 1, + exponent = (uint >>> 23) & 255, + mantissa = uint & 8388607 + return exponent === 255 + ? mantissa + ? NaN + : sign * Infinity + : exponent === 0 // denormal + ? sign * 1.401298464324817e-45 * mantissa + : sign * Math.pow(2, exponent - 150) * (mantissa + 8388608) + } + + exports.readFloatLE = readFloat_ieee754.bind(null, readUintLE) + exports.readFloatBE = readFloat_ieee754.bind(null, readUintBE) + })() + + // double: typed array + if (typeof Float64Array !== 'undefined') + (function () { + var f64 = new Float64Array([-0]), + f8b = new Uint8Array(f64.buffer), + le = f8b[7] === 128 + + function writeDouble_f64_cpy(val, buf, pos) { + f64[0] = val + buf[pos] = f8b[0] + buf[pos + 1] = f8b[1] + buf[pos + 2] = f8b[2] + buf[pos + 3] = f8b[3] + buf[pos + 4] = f8b[4] + buf[pos + 5] = f8b[5] + buf[pos + 6] = f8b[6] + buf[pos + 7] = f8b[7] + } + + function writeDouble_f64_rev(val, buf, pos) { + f64[0] = val + buf[pos] = f8b[7] + buf[pos + 1] = f8b[6] + buf[pos + 2] = f8b[5] + buf[pos + 3] = f8b[4] + buf[pos + 4] = f8b[3] + buf[pos + 5] = f8b[2] + buf[pos + 6] = f8b[1] + buf[pos + 7] = f8b[0] + } + + /* istanbul ignore next */ + exports.writeDoubleLE = le + ? writeDouble_f64_cpy + : writeDouble_f64_rev + /* istanbul ignore next */ + exports.writeDoubleBE = le + ? writeDouble_f64_rev + : writeDouble_f64_cpy + + function readDouble_f64_cpy(buf, pos) { + f8b[0] = buf[pos] + f8b[1] = buf[pos + 1] + f8b[2] = buf[pos + 2] + f8b[3] = buf[pos + 3] + f8b[4] = buf[pos + 4] + f8b[5] = buf[pos + 5] + f8b[6] = buf[pos + 6] + f8b[7] = buf[pos + 7] + return f64[0] + } + + function readDouble_f64_rev(buf, pos) { + f8b[7] = buf[pos] + f8b[6] = buf[pos + 1] + f8b[5] = buf[pos + 2] + f8b[4] = buf[pos + 3] + f8b[3] = buf[pos + 4] + f8b[2] = buf[pos + 5] + f8b[1] = buf[pos + 6] + f8b[0] = buf[pos + 7] + return f64[0] + } + + /* istanbul ignore next */ + exports.readDoubleLE = le ? readDouble_f64_cpy : readDouble_f64_rev + /* istanbul ignore next */ + exports.readDoubleBE = le ? readDouble_f64_rev : readDouble_f64_cpy + + // double: ieee754 + })() + else + (function () { + function writeDouble_ieee754(writeUint, off0, off1, val, buf, pos) { + var sign = val < 0 ? 1 : 0 + if (sign) val = -val + if (val === 0) { + writeUint(0, buf, pos + off0) + writeUint( + 1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, + buf, + pos + off1 + ) + } else if (isNaN(val)) { + writeUint(0, buf, pos + off0) + writeUint(2146959360, buf, pos + off1) + } else if (val > 1.7976931348623157e308) { + // +-Infinity + writeUint(0, buf, pos + off0) + writeUint(((sign << 31) | 2146435072) >>> 0, buf, pos + off1) + } else { + var mantissa + if (val < 2.2250738585072014e-308) { + // denormal + mantissa = val / 5e-324 + writeUint(mantissa >>> 0, buf, pos + off0) + writeUint( + ((sign << 31) | (mantissa / 4294967296)) >>> 0, + buf, + pos + off1 + ) + } else { + var exponent = Math.floor(Math.log(val) / Math.LN2) + if (exponent === 1024) exponent = 1023 + mantissa = val * Math.pow(2, -exponent) + writeUint( + (mantissa * 4503599627370496) >>> 0, + buf, + pos + off0 + ) + writeUint( + ((sign << 31) | + ((exponent + 1023) << 20) | + ((mantissa * 1048576) & 1048575)) >>> + 0, + buf, + pos + off1 + ) + } + } + } + + exports.writeDoubleLE = writeDouble_ieee754.bind( + null, + writeUintLE, + 0, + 4 + ) + exports.writeDoubleBE = writeDouble_ieee754.bind( + null, + writeUintBE, + 4, + 0 + ) + + function readDouble_ieee754(readUint, off0, off1, buf, pos) { + var lo = readUint(buf, pos + off0), + hi = readUint(buf, pos + off1) + var sign = (hi >> 31) * 2 + 1, + exponent = (hi >>> 20) & 2047, + mantissa = 4294967296 * (hi & 1048575) + lo + return exponent === 2047 + ? mantissa + ? NaN + : sign * Infinity + : exponent === 0 // denormal + ? sign * 5e-324 * mantissa + : sign * + Math.pow(2, exponent - 1075) * + (mantissa + 4503599627370496) + } + + exports.readDoubleLE = readDouble_ieee754.bind( + null, + readUintLE, + 0, + 4 + ) + exports.readDoubleBE = readDouble_ieee754.bind( + null, + readUintBE, + 4, + 0 + ) + })() + + return exports + } + + // uint helpers + + function writeUintLE(val, buf, pos) { + buf[pos] = val & 255 + buf[pos + 1] = (val >>> 8) & 255 + buf[pos + 2] = (val >>> 16) & 255 + buf[pos + 3] = val >>> 24 + } + + function writeUintBE(val, buf, pos) { + buf[pos] = val >>> 24 + buf[pos + 1] = (val >>> 16) & 255 + buf[pos + 2] = (val >>> 8) & 255 + buf[pos + 3] = val & 255 + } + + function readUintLE(buf, pos) { + return ( + (buf[pos] | + (buf[pos + 1] << 8) | + (buf[pos + 2] << 16) | + (buf[pos + 3] << 24)) >>> + 0 + ) + } + + function readUintBE(buf, pos) { + return ( + ((buf[pos] << 24) | + (buf[pos + 1] << 16) | + (buf[pos + 2] << 8) | + buf[pos + 3]) >>> + 0 + ) + } + + /***/ + }, + + /***/ 60094: /***/ module => { + 'use strict' + + module.exports = inquire + + /** + * Requires a module only if available. + * @memberof util + * @param {string} moduleName Module to require + * @returns {?Object} Required module if available and not empty, otherwise `null` + */ + function inquire(moduleName) { + try { + var mod = eval('quire'.replace(/^/, 're'))(moduleName) // eslint-disable-line no-eval + if (mod && (mod.length || Object.keys(mod).length)) return mod + } catch (e) {} // eslint-disable-line no-empty + return null + } + + /***/ + }, + + /***/ 24761: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + /** + * A minimal path module to resolve Unix, Windows and URL paths alike. + * @memberof util + * @namespace + */ + var path = exports + + var isAbsolute = + /** + * Tests if the specified path is absolute. + * @param {string} path Path to test + * @returns {boolean} `true` if path is absolute + */ + (path.isAbsolute = function isAbsolute(path) { + return /^(?:\/|\w+:)/.test(path) + }) + + var normalize = + /** + * Normalizes the specified path. + * @param {string} path Path to normalize + * @returns {string} Normalized path + */ + (path.normalize = function normalize(path) { + path = path.replace(/\\/g, '/').replace(/\/{2,}/g, '/') + var parts = path.split('/'), + absolute = isAbsolute(path), + prefix = '' + if (absolute) prefix = parts.shift() + '/' + for (var i = 0; i < parts.length; ) { + if (parts[i] === '..') { + if (i > 0 && parts[i - 1] !== '..') parts.splice(--i, 2) + else if (absolute) parts.splice(i, 1) + else ++i + } else if (parts[i] === '.') parts.splice(i, 1) + else ++i + } + return prefix + parts.join('/') + }) + + /** + * Resolves the specified include path against the specified origin path. + * @param {string} originPath Path to the origin file + * @param {string} includePath Include path relative to origin path + * @param {boolean} [alreadyNormalized=false] `true` if both paths are already known to be normalized + * @returns {string} Path to the include file + */ + path.resolve = function resolve( + originPath, + includePath, + alreadyNormalized + ) { + if (!alreadyNormalized) includePath = normalize(includePath) + if (isAbsolute(includePath)) return includePath + if (!alreadyNormalized) originPath = normalize(originPath) + return (originPath = originPath.replace(/(?:\/|^)[^/]+$/, '')).length + ? normalize(originPath + '/' + includePath) + : includePath + } + + /***/ + }, + + /***/ 47743: /***/ module => { + 'use strict' + + module.exports = pool + + /** + * An allocator as used by {@link util.pool}. + * @typedef PoolAllocator + * @type {function} + * @param {number} size Buffer size + * @returns {Uint8Array} Buffer + */ + + /** + * A slicer as used by {@link util.pool}. + * @typedef PoolSlicer + * @type {function} + * @param {number} start Start offset + * @param {number} end End offset + * @returns {Uint8Array} Buffer slice + * @this {Uint8Array} + */ + + /** + * A general purpose buffer pool. + * @memberof util + * @function + * @param {PoolAllocator} alloc Allocator + * @param {PoolSlicer} slice Slicer + * @param {number} [size=8192] Slab size + * @returns {PoolAllocator} Pooled allocator + */ + function pool(alloc, slice, size) { + var SIZE = size || 8192 + var MAX = SIZE >>> 1 + var slab = null + var offset = SIZE + return function pool_alloc(size) { + if (size < 1 || size > MAX) return alloc(size) + if (offset + size > SIZE) { + slab = alloc(SIZE) + offset = 0 + } + var buf = slice.call(slab, offset, (offset += size)) + if (offset & 7) + // align to 32 bit + offset = (offset | 7) + 1 + return buf + } + } + + /***/ + }, + + /***/ 99049: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + /** + * A minimal UTF8 implementation for number arrays. + * @memberof util + * @namespace + */ + var utf8 = exports + + /** + * Calculates the UTF8 byte length of a string. + * @param {string} string String + * @returns {number} Byte length + */ + utf8.length = function utf8_length(string) { + var len = 0, + c = 0 + for (var i = 0; i < string.length; ++i) { + c = string.charCodeAt(i) + if (c < 128) len += 1 + else if (c < 2048) len += 2 + else if ( + (c & 0xfc00) === 0xd800 && + (string.charCodeAt(i + 1) & 0xfc00) === 0xdc00 + ) { + ++i + len += 4 + } else len += 3 + } + return len + } + + /** + * Reads UTF8 bytes as a string. + * @param {Uint8Array} buffer Source buffer + * @param {number} start Source start + * @param {number} end Source end + * @returns {string} String read + */ + utf8.read = function utf8_read(buffer, start, end) { + var len = end - start + if (len < 1) return '' + var parts = null, + chunk = [], + i = 0, // char offset + t // temporary + while (start < end) { + t = buffer[start++] + if (t < 128) chunk[i++] = t + else if (t > 191 && t < 224) + chunk[i++] = ((t & 31) << 6) | (buffer[start++] & 63) + else if (t > 239 && t < 365) { + t = + (((t & 7) << 18) | + ((buffer[start++] & 63) << 12) | + ((buffer[start++] & 63) << 6) | + (buffer[start++] & 63)) - + 0x10000 + chunk[i++] = 0xd800 + (t >> 10) + chunk[i++] = 0xdc00 + (t & 1023) + } else + chunk[i++] = + ((t & 15) << 12) | + ((buffer[start++] & 63) << 6) | + (buffer[start++] & 63) + if (i > 8191) { + ;(parts || (parts = [])).push( + String.fromCharCode.apply(String, chunk) + ) + i = 0 + } + } + if (parts) { + if (i) + parts.push(String.fromCharCode.apply(String, chunk.slice(0, i))) + return parts.join('') + } + return String.fromCharCode.apply(String, chunk.slice(0, i)) + } + + /** + * Writes a string as UTF8 bytes. + * @param {string} string Source string + * @param {Uint8Array} buffer Destination buffer + * @param {number} offset Destination offset + * @returns {number} Bytes written + */ + utf8.write = function utf8_write(string, buffer, offset) { + var start = offset, + c1, // character 1 + c2 // character 2 + for (var i = 0; i < string.length; ++i) { + c1 = string.charCodeAt(i) + if (c1 < 128) { + buffer[offset++] = c1 + } else if (c1 < 2048) { + buffer[offset++] = (c1 >> 6) | 192 + buffer[offset++] = (c1 & 63) | 128 + } else if ( + (c1 & 0xfc00) === 0xd800 && + ((c2 = string.charCodeAt(i + 1)) & 0xfc00) === 0xdc00 + ) { + c1 = 0x10000 + ((c1 & 0x03ff) << 10) + (c2 & 0x03ff) + ++i + buffer[offset++] = (c1 >> 18) | 240 + buffer[offset++] = ((c1 >> 12) & 63) | 128 + buffer[offset++] = ((c1 >> 6) & 63) | 128 + buffer[offset++] = (c1 & 63) | 128 + } else { + buffer[offset++] = (c1 >> 12) | 224 + buffer[offset++] = ((c1 >> 6) & 63) | 128 + buffer[offset++] = (c1 & 63) | 128 + } + } + return offset - start + } + + /***/ + }, + + /***/ 90785: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var utils_1 = __webpack_require__(1620) + var SENTRY_API_VERSION = '7' + /** Helper class to provide urls to different Sentry endpoints. */ + var API = /** @class */ (function () { + /** Create a new instance of API */ + function API(dsn) { + this.dsn = dsn + this._dsnObject = new utils_1.Dsn(dsn) + } + /** Returns the Dsn object. */ + API.prototype.getDsn = function () { + return this._dsnObject + } + /** Returns the prefix to construct Sentry ingestion API endpoints. */ + API.prototype.getBaseApiEndpoint = function () { + var dsn = this._dsnObject + var protocol = dsn.protocol ? dsn.protocol + ':' : '' + var port = dsn.port ? ':' + dsn.port : '' + return ( + protocol + + '//' + + dsn.host + + port + + (dsn.path ? '/' + dsn.path : '') + + '/api/' + ) + } + /** Returns the store endpoint URL. */ + API.prototype.getStoreEndpoint = function () { + return this._getIngestEndpoint('store') + } + /** + * Returns the store endpoint URL with auth in the query string. + * + * Sending auth as part of the query string and not as custom HTTP headers avoids CORS preflight requests. + */ + API.prototype.getStoreEndpointWithUrlEncodedAuth = function () { + return this.getStoreEndpoint() + '?' + this._encodedAuth() + } + /** + * Returns the envelope endpoint URL with auth in the query string. + * + * Sending auth as part of the query string and not as custom HTTP headers avoids CORS preflight requests. + */ + API.prototype.getEnvelopeEndpointWithUrlEncodedAuth = function () { + return this._getEnvelopeEndpoint() + '?' + this._encodedAuth() + } + /** Returns only the path component for the store endpoint. */ + API.prototype.getStoreEndpointPath = function () { + var dsn = this._dsnObject + return ( + (dsn.path ? '/' + dsn.path : '') + + '/api/' + + dsn.projectId + + '/store/' + ) + } + /** + * Returns an object that can be used in request headers. + * This is needed for node and the old /store endpoint in sentry + */ + API.prototype.getRequestHeaders = function (clientName, clientVersion) { + var dsn = this._dsnObject + var header = ['Sentry sentry_version=' + SENTRY_API_VERSION] + header.push('sentry_client=' + clientName + '/' + clientVersion) + header.push('sentry_key=' + dsn.user) + if (dsn.pass) { + header.push('sentry_secret=' + dsn.pass) + } + return { + 'Content-Type': 'application/json', + 'X-Sentry-Auth': header.join(', ') + } + } + /** Returns the url to the report dialog endpoint. */ + API.prototype.getReportDialogEndpoint = function (dialogOptions) { + if (dialogOptions === void 0) { + dialogOptions = {} + } + var dsn = this._dsnObject + var endpoint = this.getBaseApiEndpoint() + 'embed/error-page/' + var encodedOptions = [] + encodedOptions.push('dsn=' + dsn.toString()) + for (var key in dialogOptions) { + if (key === 'user') { + if (!dialogOptions.user) { + continue + } + if (dialogOptions.user.name) { + encodedOptions.push( + 'name=' + encodeURIComponent(dialogOptions.user.name) + ) + } + if (dialogOptions.user.email) { + encodedOptions.push( + 'email=' + encodeURIComponent(dialogOptions.user.email) + ) + } + } else { + encodedOptions.push( + encodeURIComponent(key) + + '=' + + encodeURIComponent(dialogOptions[key]) + ) + } + } + if (encodedOptions.length) { + return endpoint + '?' + encodedOptions.join('&') + } + return endpoint + } + /** Returns the envelope endpoint URL. */ + API.prototype._getEnvelopeEndpoint = function () { + return this._getIngestEndpoint('envelope') + } + /** Returns the ingest API endpoint for target. */ + API.prototype._getIngestEndpoint = function (target) { + var base = this.getBaseApiEndpoint() + var dsn = this._dsnObject + return '' + base + dsn.projectId + '/' + target + '/' + } + /** Returns a URL-encoded string with auth config suitable for a query string. */ + API.prototype._encodedAuth = function () { + var dsn = this._dsnObject + var auth = { + // We send only the minimum set of required information. See + // https://github.com/getsentry/sentry-javascript/issues/2572. + sentry_key: dsn.user, + sentry_version: SENTRY_API_VERSION + } + return utils_1.urlEncode(auth) + } + return API + })() + exports.API = API + //# sourceMappingURL=api.js.map + + /***/ + }, + + /***/ 25886: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var utils_1 = __webpack_require__(1620) + var noop_1 = __webpack_require__(68641) + /** + * This is the base implemention of a Backend. + * @hidden + */ + var BaseBackend = /** @class */ (function () { + /** Creates a new backend instance. */ + function BaseBackend(options) { + this._options = options + if (!this._options.dsn) { + utils_1.logger.warn( + 'No DSN provided, backend will not do anything.' + ) + } + this._transport = this._setupTransport() + } + /** + * @inheritDoc + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types + BaseBackend.prototype.eventFromException = function ( + _exception, + _hint + ) { + throw new utils_1.SentryError( + 'Backend has to implement `eventFromException` method' + ) + } + /** + * @inheritDoc + */ + BaseBackend.prototype.eventFromMessage = function ( + _message, + _level, + _hint + ) { + throw new utils_1.SentryError( + 'Backend has to implement `eventFromMessage` method' + ) + } + /** + * @inheritDoc + */ + BaseBackend.prototype.sendEvent = function (event) { + this._transport.sendEvent(event).then(null, function (reason) { + utils_1.logger.error('Error while sending event: ' + reason) + }) + } + /** + * @inheritDoc + */ + BaseBackend.prototype.sendSession = function (session) { + if (!this._transport.sendSession) { + utils_1.logger.warn( + "Dropping session because custom transport doesn't implement sendSession" + ) + return + } + this._transport.sendSession(session).then(null, function (reason) { + utils_1.logger.error('Error while sending session: ' + reason) + }) + } + /** + * @inheritDoc + */ + BaseBackend.prototype.getTransport = function () { + return this._transport + } + /** + * Sets up the transport so it can be used later to send requests. + */ + BaseBackend.prototype._setupTransport = function () { + return new noop_1.NoopTransport() + } + return BaseBackend + })() + exports.BaseBackend = BaseBackend + //# sourceMappingURL=basebackend.js.map + + /***/ + }, + + /***/ 25684: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var tslib_1 = __webpack_require__(75636) + /* eslint-disable max-lines */ + var hub_1 = __webpack_require__(6393) + var types_1 = __webpack_require__(83789) + var utils_1 = __webpack_require__(1620) + var integration_1 = __webpack_require__(58500) + /** + * Base implementation for all JavaScript SDK clients. + * + * Call the constructor with the corresponding backend constructor and options + * specific to the client subclass. To access these options later, use + * {@link Client.getOptions}. Also, the Backend instance is available via + * {@link Client.getBackend}. + * + * If a Dsn is specified in the options, it will be parsed and stored. Use + * {@link Client.getDsn} to retrieve the Dsn at any moment. In case the Dsn is + * invalid, the constructor will throw a {@link SentryException}. Note that + * without a valid Dsn, the SDK will not send any events to Sentry. + * + * Before sending an event via the backend, it is passed through + * {@link BaseClient.prepareEvent} to add SDK information and scope data + * (breadcrumbs and context). To add more custom information, override this + * method and extend the resulting prepared event. + * + * To issue automatically created events (e.g. via instrumentation), use + * {@link Client.captureEvent}. It will prepare the event and pass it through + * the callback lifecycle. To issue auto-breadcrumbs, use + * {@link Client.addBreadcrumb}. + * + * @example + * class NodeClient extends BaseClient { + * public constructor(options: NodeOptions) { + * super(NodeBackend, options); + * } + * + * // ... + * } + */ + var BaseClient = /** @class */ (function () { + /** + * Initializes this client instance. + * + * @param backendClass A constructor function to create the backend. + * @param options Options for the client. + */ + function BaseClient(backendClass, options) { + /** Array of used integrations. */ + this._integrations = {} + /** Number of call being processed */ + this._processing = 0 + this._backend = new backendClass(options) + this._options = options + if (options.dsn) { + this._dsn = new utils_1.Dsn(options.dsn) + } + } + /** + * @inheritDoc + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types + BaseClient.prototype.captureException = function ( + exception, + hint, + scope + ) { + var _this = this + var eventId = hint && hint.event_id + this._process( + this._getBackend() + .eventFromException(exception, hint) + .then(function (event) { + return _this._captureEvent(event, hint, scope) + }) + .then(function (result) { + eventId = result + }) + ) + return eventId + } + /** + * @inheritDoc + */ + BaseClient.prototype.captureMessage = function ( + message, + level, + hint, + scope + ) { + var _this = this + var eventId = hint && hint.event_id + var promisedEvent = utils_1.isPrimitive(message) + ? this._getBackend().eventFromMessage('' + message, level, hint) + : this._getBackend().eventFromException(message, hint) + this._process( + promisedEvent + .then(function (event) { + return _this._captureEvent(event, hint, scope) + }) + .then(function (result) { + eventId = result + }) + ) + return eventId + } + /** + * @inheritDoc + */ + BaseClient.prototype.captureEvent = function (event, hint, scope) { + var eventId = hint && hint.event_id + this._process( + this._captureEvent(event, hint, scope).then(function (result) { + eventId = result + }) + ) + return eventId + } + /** + * @inheritDoc + */ + BaseClient.prototype.captureSession = function (session) { + if (!session.release) { + utils_1.logger.warn('Discarded session because of missing release') + } else { + this._sendSession(session) + } + } + /** + * @inheritDoc + */ + BaseClient.prototype.getDsn = function () { + return this._dsn + } + /** + * @inheritDoc + */ + BaseClient.prototype.getOptions = function () { + return this._options + } + /** + * @inheritDoc + */ + BaseClient.prototype.flush = function (timeout) { + var _this = this + return this._isClientProcessing(timeout).then(function (ready) { + return _this + ._getBackend() + .getTransport() + .close(timeout) + .then(function (transportFlushed) { + return ready && transportFlushed + }) + }) + } + /** + * @inheritDoc + */ + BaseClient.prototype.close = function (timeout) { + var _this = this + return this.flush(timeout).then(function (result) { + _this.getOptions().enabled = false + return result + }) + } + /** + * Sets up the integrations + */ + BaseClient.prototype.setupIntegrations = function () { + if (this._isEnabled()) { + this._integrations = integration_1.setupIntegrations(this._options) + } + } + /** + * @inheritDoc + */ + BaseClient.prototype.getIntegration = function (integration) { + try { + return this._integrations[integration.id] || null + } catch (_oO) { + utils_1.logger.warn( + 'Cannot retrieve integration ' + + integration.id + + ' from the current Client' + ) + return null + } + } + /** Updates existing session based on the provided event */ + BaseClient.prototype._updateSessionFromEvent = function ( + session, + event + ) { + var e_1, _a + var crashed = false + var errored = false + var userAgent + var exceptions = event.exception && event.exception.values + if (exceptions) { + errored = true + try { + for ( + var exceptions_1 = tslib_1.__values(exceptions), + exceptions_1_1 = exceptions_1.next(); + !exceptions_1_1.done; + exceptions_1_1 = exceptions_1.next() + ) { + var ex = exceptions_1_1.value + var mechanism = ex.mechanism + if (mechanism && mechanism.handled === false) { + crashed = true + break + } + } + } catch (e_1_1) { + e_1 = { error: e_1_1 } + } finally { + try { + if ( + exceptions_1_1 && + !exceptions_1_1.done && + (_a = exceptions_1.return) + ) + _a.call(exceptions_1) + } finally { + if (e_1) throw e_1.error + } + } + } + var user = event.user + if (!session.userAgent) { + var headers = event.request ? event.request.headers : {} + for (var key in headers) { + if (key.toLowerCase() === 'user-agent') { + userAgent = headers[key] + break + } + } + } + session.update( + tslib_1.__assign( + tslib_1.__assign( + {}, + crashed && { status: types_1.SessionStatus.Crashed } + ), + { + user: user, + userAgent: userAgent, + errors: session.errors + Number(errored || crashed) + } + ) + ) + } + /** Deliver captured session to Sentry */ + BaseClient.prototype._sendSession = function (session) { + this._getBackend().sendSession(session) + } + /** Waits for the client to be done with processing. */ + BaseClient.prototype._isClientProcessing = function (timeout) { + var _this = this + return new utils_1.SyncPromise(function (resolve) { + var ticked = 0 + var tick = 1 + var interval = setInterval(function () { + if (_this._processing == 0) { + clearInterval(interval) + resolve(true) + } else { + ticked += tick + if (timeout && ticked >= timeout) { + clearInterval(interval) + resolve(false) + } + } + }, tick) + }) + } + /** Returns the current backend. */ + BaseClient.prototype._getBackend = function () { + return this._backend + } + /** Determines whether this SDK is enabled and a valid Dsn is present. */ + BaseClient.prototype._isEnabled = function () { + return this.getOptions().enabled !== false && this._dsn !== undefined + } + /** + * Adds common information to events. + * + * The information includes release and environment from `options`, + * breadcrumbs and context (extra, tags and user) from the scope. + * + * Information that is already present in the event is never overwritten. For + * nested objects, such as the context, keys are merged. + * + * @param event The original event. + * @param hint May contain additional information about the original exception. + * @param scope A scope containing event metadata. + * @returns A new event with more information. + */ + BaseClient.prototype._prepareEvent = function (event, scope, hint) { + var _this = this + var _a = this.getOptions().normalizeDepth, + normalizeDepth = _a === void 0 ? 3 : _a + var prepared = tslib_1.__assign(tslib_1.__assign({}, event), { + event_id: + event.event_id || + (hint && hint.event_id ? hint.event_id : utils_1.uuid4()), + timestamp: event.timestamp || utils_1.dateTimestampInSeconds() + }) + this._applyClientOptions(prepared) + this._applyIntegrationsMetadata(prepared) + // If we have scope given to us, use it as the base for further modifications. + // This allows us to prevent unnecessary copying of data if `captureContext` is not provided. + var finalScope = scope + if (hint && hint.captureContext) { + finalScope = hub_1.Scope.clone(finalScope).update( + hint.captureContext + ) + } + // We prepare the result here with a resolved Event. + var result = utils_1.SyncPromise.resolve(prepared) + // This should be the last thing called, since we want that + // {@link Hub.addEventProcessor} gets the finished prepared event. + if (finalScope) { + // In case we have a hub we reassign it. + result = finalScope.applyToEvent(prepared, hint) + } + return result.then(function (evt) { + if (typeof normalizeDepth === 'number' && normalizeDepth > 0) { + return _this._normalizeEvent(evt, normalizeDepth) + } + return evt + }) + } + /** + * Applies `normalize` function on necessary `Event` attributes to make them safe for serialization. + * Normalized keys: + * - `breadcrumbs.data` + * - `user` + * - `contexts` + * - `extra` + * @param event Event + * @returns Normalized event + */ + BaseClient.prototype._normalizeEvent = function (event, depth) { + if (!event) { + return null + } + var normalized = tslib_1.__assign( + tslib_1.__assign( + tslib_1.__assign( + tslib_1.__assign( + tslib_1.__assign({}, event), + event.breadcrumbs && { + breadcrumbs: event.breadcrumbs.map(function (b) { + return tslib_1.__assign( + tslib_1.__assign({}, b), + b.data && { + data: utils_1.normalize(b.data, depth) + } + ) + }) + } + ), + event.user && { + user: utils_1.normalize(event.user, depth) + } + ), + event.contexts && { + contexts: utils_1.normalize(event.contexts, depth) + } + ), + event.extra && { + extra: utils_1.normalize(event.extra, depth) + } + ) + // event.contexts.trace stores information about a Transaction. Similarly, + // event.spans[] stores information about child Spans. Given that a + // Transaction is conceptually a Span, normalization should apply to both + // Transactions and Spans consistently. + // For now the decision is to skip normalization of Transactions and Spans, + // so this block overwrites the normalized event to add back the original + // Transaction information prior to normalization. + if (event.contexts && event.contexts.trace) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + normalized.contexts.trace = event.contexts.trace + } + return normalized + } + /** + * Enhances event using the client configuration. + * It takes care of all "static" values like environment, release and `dist`, + * as well as truncating overly long values. + * @param event event instance to be enhanced + */ + BaseClient.prototype._applyClientOptions = function (event) { + var options = this.getOptions() + var environment = options.environment, + release = options.release, + dist = options.dist, + _a = options.maxValueLength, + maxValueLength = _a === void 0 ? 250 : _a + if (!('environment' in event)) { + event.environment = + 'environment' in options ? environment : 'production' + } + if (event.release === undefined && release !== undefined) { + event.release = release + } + if (event.dist === undefined && dist !== undefined) { + event.dist = dist + } + if (event.message) { + event.message = utils_1.truncate(event.message, maxValueLength) + } + var exception = + event.exception && + event.exception.values && + event.exception.values[0] + if (exception && exception.value) { + exception.value = utils_1.truncate(exception.value, maxValueLength) + } + var request = event.request + if (request && request.url) { + request.url = utils_1.truncate(request.url, maxValueLength) + } + } + /** + * This function adds all used integrations to the SDK info in the event. + * @param sdkInfo The sdkInfo of the event that will be filled with all integrations. + */ + BaseClient.prototype._applyIntegrationsMetadata = function (event) { + var sdkInfo = event.sdk + var integrationsArray = Object.keys(this._integrations) + if (sdkInfo && integrationsArray.length > 0) { + sdkInfo.integrations = integrationsArray + } + } + /** + * Tells the backend to send this event + * @param event The Sentry event to send + */ + BaseClient.prototype._sendEvent = function (event) { + this._getBackend().sendEvent(event) + } + /** + * Processes the event and logs an error in case of rejection + * @param event + * @param hint + * @param scope + */ + BaseClient.prototype._captureEvent = function (event, hint, scope) { + return this._processEvent(event, hint, scope).then( + function (finalEvent) { + return finalEvent.event_id + }, + function (reason) { + utils_1.logger.error(reason) + return undefined + } + ) + } + /** + * Processes an event (either error or message) and sends it to Sentry. + * + * This also adds breadcrumbs and context information to the event. However, + * platform specific meta data (such as the User's IP address) must be added + * by the SDK implementor. + * + * + * @param event The event to send to Sentry. + * @param hint May contain additional information about the original exception. + * @param scope A scope containing event metadata. + * @returns A SyncPromise that resolves with the event or rejects in case event was/will not be send. + */ + BaseClient.prototype._processEvent = function (event, hint, scope) { + var _this = this + // eslint-disable-next-line @typescript-eslint/unbound-method + var _a = this.getOptions(), + beforeSend = _a.beforeSend, + sampleRate = _a.sampleRate + if (!this._isEnabled()) { + return utils_1.SyncPromise.reject( + new utils_1.SentryError('SDK not enabled, will not send event.') + ) + } + var isTransaction = event.type === 'transaction' + // 1.0 === 100% events are sent + // 0.0 === 0% events are sent + // Sampling for transaction happens somewhere else + if ( + !isTransaction && + typeof sampleRate === 'number' && + Math.random() > sampleRate + ) { + return utils_1.SyncPromise.reject( + new utils_1.SentryError( + 'This event has been sampled, will not send event.' + ) + ) + } + return this._prepareEvent(event, scope, hint) + .then(function (prepared) { + if (prepared === null) { + throw new utils_1.SentryError( + 'An event processor returned null, will not send event.' + ) + } + var isInternalException = + hint && hint.data && hint.data.__sentry__ === true + if (isInternalException || isTransaction || !beforeSend) { + return prepared + } + var beforeSendResult = beforeSend(prepared, hint) + if (typeof beforeSendResult === 'undefined') { + throw new utils_1.SentryError( + '`beforeSend` method has to return `null` or a valid event.' + ) + } else if (utils_1.isThenable(beforeSendResult)) { + return beforeSendResult.then( + function (event) { + return event + }, + function (e) { + throw new utils_1.SentryError( + 'beforeSend rejected with ' + e + ) + } + ) + } + return beforeSendResult + }) + .then(function (processedEvent) { + if (processedEvent === null) { + throw new utils_1.SentryError( + '`beforeSend` returned `null`, will not send event.' + ) + } + var session = scope && scope.getSession && scope.getSession() + if (!isTransaction && session) { + _this._updateSessionFromEvent(session, processedEvent) + } + _this._sendEvent(processedEvent) + return processedEvent + }) + .then(null, function (reason) { + if (reason instanceof utils_1.SentryError) { + throw reason + } + _this.captureException(reason, { + data: { + __sentry__: true + }, + originalException: reason + }) + throw new utils_1.SentryError( + 'Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event.\nReason: ' + + reason + ) + }) + } + /** + * Occupies the client with processing and event + */ + BaseClient.prototype._process = function (promise) { + var _this = this + this._processing += 1 + promise.then( + function (value) { + _this._processing -= 1 + return value + }, + function (reason) { + _this._processing -= 1 + return reason + } + ) + } + return BaseClient + })() + exports.BaseClient = BaseClient + //# sourceMappingURL=baseclient.js.map + + /***/ + }, + + /***/ 79212: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var minimal_1 = __webpack_require__(88455) + exports.addBreadcrumb = minimal_1.addBreadcrumb + exports.captureException = minimal_1.captureException + exports.captureEvent = minimal_1.captureEvent + exports.captureMessage = minimal_1.captureMessage + exports.configureScope = minimal_1.configureScope + exports.startTransaction = minimal_1.startTransaction + exports.setContext = minimal_1.setContext + exports.setExtra = minimal_1.setExtra + exports.setExtras = minimal_1.setExtras + exports.setTag = minimal_1.setTag + exports.setTags = minimal_1.setTags + exports.setUser = minimal_1.setUser + exports.withScope = minimal_1.withScope + var hub_1 = __webpack_require__(6393) + exports.addGlobalEventProcessor = hub_1.addGlobalEventProcessor + exports.getCurrentHub = hub_1.getCurrentHub + exports.getHubFromCarrier = hub_1.getHubFromCarrier + exports.Hub = hub_1.Hub + exports.makeMain = hub_1.makeMain + exports.Scope = hub_1.Scope + var api_1 = __webpack_require__(90785) + exports.API = api_1.API + var baseclient_1 = __webpack_require__(25684) + exports.BaseClient = baseclient_1.BaseClient + var basebackend_1 = __webpack_require__(25886) + exports.BaseBackend = basebackend_1.BaseBackend + var request_1 = __webpack_require__(1553) + exports.eventToSentryRequest = request_1.eventToSentryRequest + exports.sessionToSentryRequest = request_1.sessionToSentryRequest + var sdk_1 = __webpack_require__(46406) + exports.initAndBind = sdk_1.initAndBind + var noop_1 = __webpack_require__(68641) + exports.NoopTransport = noop_1.NoopTransport + var Integrations = __webpack_require__(96727) + exports.Integrations = Integrations + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 58500: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var tslib_1 = __webpack_require__(75636) + var hub_1 = __webpack_require__(6393) + var utils_1 = __webpack_require__(1620) + exports.installedIntegrations = [] + /** Gets integration to install */ + function getIntegrationsToSetup(options) { + var defaultIntegrations = + (options.defaultIntegrations && + tslib_1.__spread(options.defaultIntegrations)) || + [] + var userIntegrations = options.integrations + var integrations = [] + if (Array.isArray(userIntegrations)) { + var userIntegrationsNames_1 = userIntegrations.map(function (i) { + return i.name + }) + var pickedIntegrationsNames_1 = [] + // Leave only unique default integrations, that were not overridden with provided user integrations + defaultIntegrations.forEach(function (defaultIntegration) { + if ( + userIntegrationsNames_1.indexOf(defaultIntegration.name) === -1 && + pickedIntegrationsNames_1.indexOf(defaultIntegration.name) === -1 + ) { + integrations.push(defaultIntegration) + pickedIntegrationsNames_1.push(defaultIntegration.name) + } + }) + // Don't add same user integration twice + userIntegrations.forEach(function (userIntegration) { + if ( + pickedIntegrationsNames_1.indexOf(userIntegration.name) === -1 + ) { + integrations.push(userIntegration) + pickedIntegrationsNames_1.push(userIntegration.name) + } + }) + } else if (typeof userIntegrations === 'function') { + integrations = userIntegrations(defaultIntegrations) + integrations = Array.isArray(integrations) + ? integrations + : [integrations] + } else { + integrations = tslib_1.__spread(defaultIntegrations) + } + // Make sure that if present, `Debug` integration will always run last + var integrationsNames = integrations.map(function (i) { + return i.name + }) + var alwaysLastToRun = 'Debug' + if (integrationsNames.indexOf(alwaysLastToRun) !== -1) { + integrations.push.apply( + integrations, + tslib_1.__spread( + integrations.splice(integrationsNames.indexOf(alwaysLastToRun), 1) + ) + ) + } + return integrations + } + exports.getIntegrationsToSetup = getIntegrationsToSetup + /** Setup given integration */ + function setupIntegration(integration) { + if (exports.installedIntegrations.indexOf(integration.name) !== -1) { + return + } + integration.setupOnce( + hub_1.addGlobalEventProcessor, + hub_1.getCurrentHub + ) + exports.installedIntegrations.push(integration.name) + utils_1.logger.log('Integration installed: ' + integration.name) + } + exports.setupIntegration = setupIntegration + /** + * Given a list of integration instances this installs them all. When `withDefaults` is set to `true` then all default + * integrations are added unless they were already provided before. + * @param integrations array of integration instances + * @param withDefault should enable default integrations + */ + function setupIntegrations(options) { + var integrations = {} + getIntegrationsToSetup(options).forEach(function (integration) { + integrations[integration.name] = integration + setupIntegration(integration) + }) + return integrations + } + exports.setupIntegrations = setupIntegrations + //# sourceMappingURL=integration.js.map + + /***/ + }, + + /***/ 87349: /***/ (__unused_webpack_module, exports) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var originalFunctionToString + /** Patch toString calls to return proper name for wrapped functions */ + var FunctionToString = /** @class */ (function () { + function FunctionToString() { + /** + * @inheritDoc + */ + this.name = FunctionToString.id + } + /** + * @inheritDoc + */ + FunctionToString.prototype.setupOnce = function () { + // eslint-disable-next-line @typescript-eslint/unbound-method + originalFunctionToString = Function.prototype.toString + // eslint-disable-next-line @typescript-eslint/no-explicit-any + Function.prototype.toString = function () { + var args = [] + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i] + } + var context = this.__sentry_original__ || this + return originalFunctionToString.apply(context, args) + } + } + /** + * @inheritDoc + */ + FunctionToString.id = 'FunctionToString' + return FunctionToString + })() + exports.FunctionToString = FunctionToString + //# sourceMappingURL=functiontostring.js.map + + /***/ + }, + + /***/ 54838: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var tslib_1 = __webpack_require__(75636) + var hub_1 = __webpack_require__(6393) + var utils_1 = __webpack_require__(1620) + // "Script error." is hard coded into browsers for errors that it can't read. + // this is the result of a script being pulled in from an external domain and CORS. + var DEFAULT_IGNORE_ERRORS = [ + /^Script error\.?$/, + /^Javascript error: Script error\.? on line 0$/ + ] + /** Inbound filters configurable by the user */ + var InboundFilters = /** @class */ (function () { + function InboundFilters(_options) { + if (_options === void 0) { + _options = {} + } + this._options = _options + /** + * @inheritDoc + */ + this.name = InboundFilters.id + } + /** + * @inheritDoc + */ + InboundFilters.prototype.setupOnce = function () { + hub_1.addGlobalEventProcessor(function (event) { + var hub = hub_1.getCurrentHub() + if (!hub) { + return event + } + var self = hub.getIntegration(InboundFilters) + if (self) { + var client = hub.getClient() + var clientOptions = client ? client.getOptions() : {} + var options = self._mergeOptions(clientOptions) + if (self._shouldDropEvent(event, options)) { + return null + } + } + return event + }) + } + /** JSDoc */ + InboundFilters.prototype._shouldDropEvent = function (event, options) { + if (this._isSentryError(event, options)) { + utils_1.logger.warn( + 'Event dropped due to being internal Sentry Error.\nEvent: ' + + utils_1.getEventDescription(event) + ) + return true + } + if (this._isIgnoredError(event, options)) { + utils_1.logger.warn( + 'Event dropped due to being matched by `ignoreErrors` option.\nEvent: ' + + utils_1.getEventDescription(event) + ) + return true + } + if (this._isDeniedUrl(event, options)) { + utils_1.logger.warn( + 'Event dropped due to being matched by `denyUrls` option.\nEvent: ' + + utils_1.getEventDescription(event) + + '.\nUrl: ' + + this._getEventFilterUrl(event) + ) + return true + } + if (!this._isAllowedUrl(event, options)) { + utils_1.logger.warn( + 'Event dropped due to not being matched by `allowUrls` option.\nEvent: ' + + utils_1.getEventDescription(event) + + '.\nUrl: ' + + this._getEventFilterUrl(event) + ) + return true + } + return false + } + /** JSDoc */ + InboundFilters.prototype._isSentryError = function (event, options) { + if (!options.ignoreInternal) { + return false + } + try { + return ( + (event && + event.exception && + event.exception.values && + event.exception.values[0] && + event.exception.values[0].type === 'SentryError') || + false + ) + } catch (_oO) { + return false + } + } + /** JSDoc */ + InboundFilters.prototype._isIgnoredError = function (event, options) { + if (!options.ignoreErrors || !options.ignoreErrors.length) { + return false + } + return this._getPossibleEventMessages(event).some(function (message) { + // Not sure why TypeScript complains here... + return options.ignoreErrors.some(function (pattern) { + return utils_1.isMatchingPattern(message, pattern) + }) + }) + } + /** JSDoc */ + InboundFilters.prototype._isDeniedUrl = function (event, options) { + // TODO: Use Glob instead? + if (!options.denyUrls || !options.denyUrls.length) { + return false + } + var url = this._getEventFilterUrl(event) + return !url + ? false + : options.denyUrls.some(function (pattern) { + return utils_1.isMatchingPattern(url, pattern) + }) + } + /** JSDoc */ + InboundFilters.prototype._isAllowedUrl = function (event, options) { + // TODO: Use Glob instead? + if (!options.allowUrls || !options.allowUrls.length) { + return true + } + var url = this._getEventFilterUrl(event) + return !url + ? true + : options.allowUrls.some(function (pattern) { + return utils_1.isMatchingPattern(url, pattern) + }) + } + /** JSDoc */ + InboundFilters.prototype._mergeOptions = function (clientOptions) { + if (clientOptions === void 0) { + clientOptions = {} + } + return { + allowUrls: tslib_1.__spread( + this._options.whitelistUrls || [], + this._options.allowUrls || [], + clientOptions.whitelistUrls || [], + clientOptions.allowUrls || [] + ), + denyUrls: tslib_1.__spread( + this._options.blacklistUrls || [], + this._options.denyUrls || [], + clientOptions.blacklistUrls || [], + clientOptions.denyUrls || [] + ), + ignoreErrors: tslib_1.__spread( + this._options.ignoreErrors || [], + clientOptions.ignoreErrors || [], + DEFAULT_IGNORE_ERRORS + ), + ignoreInternal: + typeof this._options.ignoreInternal !== 'undefined' + ? this._options.ignoreInternal + : true + } + } + /** JSDoc */ + InboundFilters.prototype._getPossibleEventMessages = function (event) { + if (event.message) { + return [event.message] + } + if (event.exception) { + try { + var _a = + (event.exception.values && event.exception.values[0]) || {}, + _b = _a.type, + type = _b === void 0 ? '' : _b, + _c = _a.value, + value = _c === void 0 ? '' : _c + return ['' + value, type + ': ' + value] + } catch (oO) { + utils_1.logger.error( + 'Cannot extract message for event ' + + utils_1.getEventDescription(event) + ) + return [] + } + } + return [] + } + /** JSDoc */ + InboundFilters.prototype._getEventFilterUrl = function (event) { + try { + if (event.stacktrace) { + var frames_1 = event.stacktrace.frames + return ( + (frames_1 && frames_1[frames_1.length - 1].filename) || null + ) + } + if (event.exception) { + var frames_2 = + event.exception.values && + event.exception.values[0].stacktrace && + event.exception.values[0].stacktrace.frames + return ( + (frames_2 && frames_2[frames_2.length - 1].filename) || null + ) + } + return null + } catch (oO) { + utils_1.logger.error( + 'Cannot extract url for event ' + + utils_1.getEventDescription(event) + ) + return null + } + } + /** + * @inheritDoc + */ + InboundFilters.id = 'InboundFilters' + return InboundFilters + })() + exports.InboundFilters = InboundFilters + //# sourceMappingURL=inboundfilters.js.map + + /***/ + }, + + /***/ 96727: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var functiontostring_1 = __webpack_require__(87349) + exports.FunctionToString = functiontostring_1.FunctionToString + var inboundfilters_1 = __webpack_require__(54838) + exports.InboundFilters = inboundfilters_1.InboundFilters + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 1553: /***/ (__unused_webpack_module, exports) => { + Object.defineProperty(exports, '__esModule', { value: true }) + /** Creates a SentryRequest from an event. */ + function sessionToSentryRequest(session, api) { + var envelopeHeaders = JSON.stringify({ + sent_at: new Date().toISOString() + }) + var itemHeaders = JSON.stringify({ + type: 'session' + }) + return { + body: + envelopeHeaders + + '\n' + + itemHeaders + + '\n' + + JSON.stringify(session), + type: 'session', + url: api.getEnvelopeEndpointWithUrlEncodedAuth() + } + } + exports.sessionToSentryRequest = sessionToSentryRequest + /** Creates a SentryRequest from an event. */ + function eventToSentryRequest(event, api) { + var useEnvelope = event.type === 'transaction' + var req = { + body: JSON.stringify(event), + type: event.type || 'event', + url: useEnvelope + ? api.getEnvelopeEndpointWithUrlEncodedAuth() + : api.getStoreEndpointWithUrlEncodedAuth() + } + // https://develop.sentry.dev/sdk/envelopes/ + // Since we don't need to manipulate envelopes nor store them, there is no + // exported concept of an Envelope with operations including serialization and + // deserialization. Instead, we only implement a minimal subset of the spec to + // serialize events inline here. + if (useEnvelope) { + var envelopeHeaders = JSON.stringify({ + event_id: event.event_id, + // We need to add * 1000 since we divide it by 1000 by default but JS works with ms precision + // The reason we use timestampWithMs here is that all clocks across the SDK use the same clock + sent_at: new Date().toISOString() + }) + var itemHeaders = JSON.stringify({ + type: event.type + }) + // The trailing newline is optional. We intentionally don't send it to avoid + // sending unnecessary bytes. + // + // const envelope = `${envelopeHeaders}\n${itemHeaders}\n${req.body}\n`; + var envelope = envelopeHeaders + '\n' + itemHeaders + '\n' + req.body + req.body = envelope + } + return req + } + exports.eventToSentryRequest = eventToSentryRequest + //# sourceMappingURL=request.js.map + + /***/ + }, + + /***/ 46406: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var hub_1 = __webpack_require__(6393) + var utils_1 = __webpack_require__(1620) + /** + * Internal function to create a new SDK client instance. The client is + * installed and then bound to the current scope. + * + * @param clientClass The client class to instantiate. + * @param options Options to pass to the client. + */ + function initAndBind(clientClass, options) { + if (options.debug === true) { + utils_1.logger.enable() + } + var hub = hub_1.getCurrentHub() + var client = new clientClass(options) + hub.bindClient(client) + } + exports.initAndBind = initAndBind + //# sourceMappingURL=sdk.js.map + + /***/ + }, + + /***/ 68641: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var types_1 = __webpack_require__(83789) + var utils_1 = __webpack_require__(1620) + /** Noop transport */ + var NoopTransport = /** @class */ (function () { + function NoopTransport() {} + /** + * @inheritDoc + */ + NoopTransport.prototype.sendEvent = function (_) { + return utils_1.SyncPromise.resolve({ + reason: + 'NoopTransport: Event has been skipped because no Dsn is configured.', + status: types_1.Status.Skipped + }) + } + /** + * @inheritDoc + */ + NoopTransport.prototype.close = function (_) { + return utils_1.SyncPromise.resolve(true) + } + return NoopTransport + })() + exports.NoopTransport = NoopTransport + //# sourceMappingURL=noop.js.map + + /***/ + }, + + /***/ 53536: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var tslib_1 = __webpack_require__(75636) + var utils_1 = __webpack_require__(1620) + var scope_1 = __webpack_require__(4213) + var session_1 = __webpack_require__(12474) + /** + * API compatibility version of this hub. + * + * WARNING: This number should only be increased when the global interface + * changes and new methods are introduced. + * + * @hidden + */ + exports.API_VERSION = 3 + /** + * Default maximum number of breadcrumbs added to an event. Can be overwritten + * with {@link Options.maxBreadcrumbs}. + */ + var DEFAULT_BREADCRUMBS = 100 + /** + * Absolute maximum number of breadcrumbs added to an event. The + * `maxBreadcrumbs` option cannot be higher than this value. + */ + var MAX_BREADCRUMBS = 100 + /** + * @inheritDoc + */ + var Hub = /** @class */ (function () { + /** + * Creates a new instance of the hub, will push one {@link Layer} into the + * internal stack on creation. + * + * @param client bound to the hub. + * @param scope bound to the hub. + * @param version number, higher number means higher priority. + */ + function Hub(client, scope, _version) { + if (scope === void 0) { + scope = new scope_1.Scope() + } + if (_version === void 0) { + _version = exports.API_VERSION + } + this._version = _version + /** Is a {@link Layer}[] containing the client and scope */ + this._stack = [{}] + this.getStackTop().scope = scope + this.bindClient(client) + } + /** + * @inheritDoc + */ + Hub.prototype.isOlderThan = function (version) { + return this._version < version + } + /** + * @inheritDoc + */ + Hub.prototype.bindClient = function (client) { + var top = this.getStackTop() + top.client = client + if (client && client.setupIntegrations) { + client.setupIntegrations() + } + } + /** + * @inheritDoc + */ + Hub.prototype.pushScope = function () { + // We want to clone the content of prev scope + var scope = scope_1.Scope.clone(this.getScope()) + this.getStack().push({ + client: this.getClient(), + scope: scope + }) + return scope + } + /** + * @inheritDoc + */ + Hub.prototype.popScope = function () { + if (this.getStack().length <= 1) return false + return !!this.getStack().pop() + } + /** + * @inheritDoc + */ + Hub.prototype.withScope = function (callback) { + var scope = this.pushScope() + try { + callback(scope) + } finally { + this.popScope() + } + } + /** + * @inheritDoc + */ + Hub.prototype.getClient = function () { + return this.getStackTop().client + } + /** Returns the scope of the top stack. */ + Hub.prototype.getScope = function () { + return this.getStackTop().scope + } + /** Returns the scope stack for domains or the process. */ + Hub.prototype.getStack = function () { + return this._stack + } + /** Returns the topmost scope layer in the order domain > local > process. */ + Hub.prototype.getStackTop = function () { + return this._stack[this._stack.length - 1] + } + /** + * @inheritDoc + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types + Hub.prototype.captureException = function (exception, hint) { + var eventId = (this._lastEventId = utils_1.uuid4()) + var finalHint = hint + // If there's no explicit hint provided, mimick the same thing that would happen + // in the minimal itself to create a consistent behavior. + // We don't do this in the client, as it's the lowest level API, and doing this, + // would prevent user from having full control over direct calls. + if (!hint) { + var syntheticException = void 0 + try { + throw new Error('Sentry syntheticException') + } catch (exception) { + syntheticException = exception + } + finalHint = { + originalException: exception, + syntheticException: syntheticException + } + } + this._invokeClient( + 'captureException', + exception, + tslib_1.__assign(tslib_1.__assign({}, finalHint), { + event_id: eventId + }) + ) + return eventId + } + /** + * @inheritDoc + */ + Hub.prototype.captureMessage = function (message, level, hint) { + var eventId = (this._lastEventId = utils_1.uuid4()) + var finalHint = hint + // If there's no explicit hint provided, mimick the same thing that would happen + // in the minimal itself to create a consistent behavior. + // We don't do this in the client, as it's the lowest level API, and doing this, + // would prevent user from having full control over direct calls. + if (!hint) { + var syntheticException = void 0 + try { + throw new Error(message) + } catch (exception) { + syntheticException = exception + } + finalHint = { + originalException: message, + syntheticException: syntheticException + } + } + this._invokeClient( + 'captureMessage', + message, + level, + tslib_1.__assign(tslib_1.__assign({}, finalHint), { + event_id: eventId + }) + ) + return eventId + } + /** + * @inheritDoc + */ + Hub.prototype.captureEvent = function (event, hint) { + var eventId = (this._lastEventId = utils_1.uuid4()) + this._invokeClient( + 'captureEvent', + event, + tslib_1.__assign(tslib_1.__assign({}, hint), { event_id: eventId }) + ) + return eventId + } + /** + * @inheritDoc + */ + Hub.prototype.lastEventId = function () { + return this._lastEventId + } + /** + * @inheritDoc + */ + Hub.prototype.addBreadcrumb = function (breadcrumb, hint) { + var _a = this.getStackTop(), + scope = _a.scope, + client = _a.client + if (!scope || !client) return + // eslint-disable-next-line @typescript-eslint/unbound-method + var _b = (client.getOptions && client.getOptions()) || {}, + _c = _b.beforeBreadcrumb, + beforeBreadcrumb = _c === void 0 ? null : _c, + _d = _b.maxBreadcrumbs, + maxBreadcrumbs = _d === void 0 ? DEFAULT_BREADCRUMBS : _d + if (maxBreadcrumbs <= 0) return + var timestamp = utils_1.dateTimestampInSeconds() + var mergedBreadcrumb = tslib_1.__assign( + { timestamp: timestamp }, + breadcrumb + ) + var finalBreadcrumb = beforeBreadcrumb + ? utils_1.consoleSandbox(function () { + return beforeBreadcrumb(mergedBreadcrumb, hint) + }) + : mergedBreadcrumb + if (finalBreadcrumb === null) return + scope.addBreadcrumb( + finalBreadcrumb, + Math.min(maxBreadcrumbs, MAX_BREADCRUMBS) + ) + } + /** + * @inheritDoc + */ + Hub.prototype.setUser = function (user) { + var scope = this.getScope() + if (scope) scope.setUser(user) + } + /** + * @inheritDoc + */ + Hub.prototype.setTags = function (tags) { + var scope = this.getScope() + if (scope) scope.setTags(tags) + } + /** + * @inheritDoc + */ + Hub.prototype.setExtras = function (extras) { + var scope = this.getScope() + if (scope) scope.setExtras(extras) + } + /** + * @inheritDoc + */ + Hub.prototype.setTag = function (key, value) { + var scope = this.getScope() + if (scope) scope.setTag(key, value) + } + /** + * @inheritDoc + */ + Hub.prototype.setExtra = function (key, extra) { + var scope = this.getScope() + if (scope) scope.setExtra(key, extra) + } + /** + * @inheritDoc + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + Hub.prototype.setContext = function (name, context) { + var scope = this.getScope() + if (scope) scope.setContext(name, context) + } + /** + * @inheritDoc + */ + Hub.prototype.configureScope = function (callback) { + var _a = this.getStackTop(), + scope = _a.scope, + client = _a.client + if (scope && client) { + callback(scope) + } + } + /** + * @inheritDoc + */ + Hub.prototype.run = function (callback) { + var oldHub = makeMain(this) + try { + callback(this) + } finally { + makeMain(oldHub) + } + } + /** + * @inheritDoc + */ + Hub.prototype.getIntegration = function (integration) { + var client = this.getClient() + if (!client) return null + try { + return client.getIntegration(integration) + } catch (_oO) { + utils_1.logger.warn( + 'Cannot retrieve integration ' + + integration.id + + ' from the current Hub' + ) + return null + } + } + /** + * @inheritDoc + */ + Hub.prototype.startSpan = function (context) { + return this._callExtensionMethod('startSpan', context) + } + /** + * @inheritDoc + */ + Hub.prototype.startTransaction = function ( + context, + customSamplingContext + ) { + return this._callExtensionMethod( + 'startTransaction', + context, + customSamplingContext + ) + } + /** + * @inheritDoc + */ + Hub.prototype.traceHeaders = function () { + return this._callExtensionMethod('traceHeaders') + } + /** + * @inheritDoc + */ + Hub.prototype.startSession = function (context) { + // End existing session if there's one + this.endSession() + var _a = this.getStackTop(), + scope = _a.scope, + client = _a.client + var _b = (client && client.getOptions()) || {}, + release = _b.release, + environment = _b.environment + var session = new session_1.Session( + tslib_1.__assign( + tslib_1.__assign( + { release: release, environment: environment }, + scope && { user: scope.getUser() } + ), + context + ) + ) + if (scope) { + scope.setSession(session) + } + return session + } + /** + * @inheritDoc + */ + Hub.prototype.endSession = function () { + var _a = this.getStackTop(), + scope = _a.scope, + client = _a.client + if (!scope) return + var session = scope.getSession && scope.getSession() + if (session) { + session.close() + if (client && client.captureSession) { + client.captureSession(session) + } + scope.setSession() + } + } + /** + * Internal helper function to call a method on the top client if it exists. + * + * @param method The method to call on the client. + * @param args Arguments to pass to the client function. + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + Hub.prototype._invokeClient = function (method) { + var _a + var args = [] + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i] + } + var _b = this.getStackTop(), + scope = _b.scope, + client = _b.client + if (client && client[method]) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any + ;(_a = client)[method].apply(_a, tslib_1.__spread(args, [scope])) + } + } + /** + * Calls global extension method and binding current instance to the function call + */ + // @ts-ignore Function lacks ending return statement and return type does not include 'undefined'. ts(2366) + // eslint-disable-next-line @typescript-eslint/no-explicit-any + Hub.prototype._callExtensionMethod = function (method) { + var args = [] + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i] + } + var carrier = getMainCarrier() + var sentry = carrier.__SENTRY__ + if ( + sentry && + sentry.extensions && + typeof sentry.extensions[method] === 'function' + ) { + return sentry.extensions[method].apply(this, args) + } + utils_1.logger.warn( + 'Extension method ' + method + " couldn't be found, doing nothing." + ) + } + return Hub + })() + exports.Hub = Hub + /** Returns the global shim registry. */ + function getMainCarrier() { + var carrier = utils_1.getGlobalObject() + carrier.__SENTRY__ = carrier.__SENTRY__ || { + extensions: {}, + hub: undefined + } + return carrier + } + exports.getMainCarrier = getMainCarrier + /** + * Replaces the current main hub with the passed one on the global object + * + * @returns The old replaced hub + */ + function makeMain(hub) { + var registry = getMainCarrier() + var oldHub = getHubFromCarrier(registry) + setHubOnCarrier(registry, hub) + return oldHub + } + exports.makeMain = makeMain + /** + * Returns the default hub instance. + * + * If a hub is already registered in the global carrier but this module + * contains a more recent version, it replaces the registered version. + * Otherwise, the currently registered hub will be returned. + */ + function getCurrentHub() { + // Get main carrier (global for every environment) + var registry = getMainCarrier() + // If there's no hub, or its an old API, assign a new one + if ( + !hasHubOnCarrier(registry) || + getHubFromCarrier(registry).isOlderThan(exports.API_VERSION) + ) { + setHubOnCarrier(registry, new Hub()) + } + // Prefer domains over global if they are there (applicable only to Node environment) + if (utils_1.isNodeEnv()) { + return getHubFromActiveDomain(registry) + } + // Return hub that lives on a global object + return getHubFromCarrier(registry) + } + exports.getCurrentHub = getCurrentHub + /** + * Returns the active domain, if one exists + * + * @returns The domain, or undefined if there is no active domain + */ + function getActiveDomain() { + var sentry = getMainCarrier().__SENTRY__ + return ( + sentry && + sentry.extensions && + sentry.extensions.domain && + sentry.extensions.domain.active + ) + } + exports.getActiveDomain = getActiveDomain + /** + * Try to read the hub from an active domain, and fallback to the registry if one doesn't exist + * @returns discovered hub + */ + function getHubFromActiveDomain(registry) { + try { + var activeDomain = getActiveDomain() + // If there's no active domain, just return global hub + if (!activeDomain) { + return getHubFromCarrier(registry) + } + // If there's no hub on current domain, or it's an old API, assign a new one + if ( + !hasHubOnCarrier(activeDomain) || + getHubFromCarrier(activeDomain).isOlderThan(exports.API_VERSION) + ) { + var registryHubTopStack = getHubFromCarrier(registry).getStackTop() + setHubOnCarrier( + activeDomain, + new Hub( + registryHubTopStack.client, + scope_1.Scope.clone(registryHubTopStack.scope) + ) + ) + } + // Return hub that lives on a domain + return getHubFromCarrier(activeDomain) + } catch (_Oo) { + // Return hub that lives on a global object + return getHubFromCarrier(registry) + } + } + /** + * This will tell whether a carrier has a hub on it or not + * @param carrier object + */ + function hasHubOnCarrier(carrier) { + return !!(carrier && carrier.__SENTRY__ && carrier.__SENTRY__.hub) + } + /** + * This will create a new {@link Hub} and add to the passed object on + * __SENTRY__.hub. + * @param carrier object + * @hidden + */ + function getHubFromCarrier(carrier) { + if (carrier && carrier.__SENTRY__ && carrier.__SENTRY__.hub) + return carrier.__SENTRY__.hub + carrier.__SENTRY__ = carrier.__SENTRY__ || {} + carrier.__SENTRY__.hub = new Hub() + return carrier.__SENTRY__.hub + } + exports.getHubFromCarrier = getHubFromCarrier + /** + * This will set passed {@link Hub} on the passed object's __SENTRY__.hub attribute + * @param carrier object + * @param hub Hub + */ + function setHubOnCarrier(carrier, hub) { + if (!carrier) return false + carrier.__SENTRY__ = carrier.__SENTRY__ || {} + carrier.__SENTRY__.hub = hub + return true + } + exports.setHubOnCarrier = setHubOnCarrier + //# sourceMappingURL=hub.js.map + + /***/ + }, + + /***/ 6393: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var scope_1 = __webpack_require__(4213) + exports.addGlobalEventProcessor = scope_1.addGlobalEventProcessor + exports.Scope = scope_1.Scope + var session_1 = __webpack_require__(12474) + exports.Session = session_1.Session + var hub_1 = __webpack_require__(53536) + exports.getActiveDomain = hub_1.getActiveDomain + exports.getCurrentHub = hub_1.getCurrentHub + exports.getHubFromCarrier = hub_1.getHubFromCarrier + exports.getMainCarrier = hub_1.getMainCarrier + exports.Hub = hub_1.Hub + exports.makeMain = hub_1.makeMain + exports.setHubOnCarrier = hub_1.setHubOnCarrier + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 4213: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var tslib_1 = __webpack_require__(75636) + var utils_1 = __webpack_require__(1620) + /** + * Holds additional event information. {@link Scope.applyToEvent} will be + * called by the client before an event will be sent. + */ + var Scope = /** @class */ (function () { + function Scope() { + /** Flag if notifiying is happening. */ + this._notifyingListeners = false + /** Callback for client to receive scope changes. */ + this._scopeListeners = [] + /** Callback list that will be called after {@link applyToEvent}. */ + this._eventProcessors = [] + /** Array of breadcrumbs. */ + this._breadcrumbs = [] + /** User */ + this._user = {} + /** Tags */ + this._tags = {} + /** Extra */ + this._extra = {} + /** Contexts */ + this._contexts = {} + } + /** + * Inherit values from the parent scope. + * @param scope to clone. + */ + Scope.clone = function (scope) { + var newScope = new Scope() + if (scope) { + newScope._breadcrumbs = tslib_1.__spread(scope._breadcrumbs) + newScope._tags = tslib_1.__assign({}, scope._tags) + newScope._extra = tslib_1.__assign({}, scope._extra) + newScope._contexts = tslib_1.__assign({}, scope._contexts) + newScope._user = scope._user + newScope._level = scope._level + newScope._span = scope._span + newScope._session = scope._session + newScope._transactionName = scope._transactionName + newScope._fingerprint = scope._fingerprint + newScope._eventProcessors = tslib_1.__spread(scope._eventProcessors) + } + return newScope + } + /** + * Add internal on change listener. Used for sub SDKs that need to store the scope. + * @hidden + */ + Scope.prototype.addScopeListener = function (callback) { + this._scopeListeners.push(callback) + } + /** + * @inheritDoc + */ + Scope.prototype.addEventProcessor = function (callback) { + this._eventProcessors.push(callback) + return this + } + /** + * @inheritDoc + */ + Scope.prototype.setUser = function (user) { + this._user = user || {} + if (this._session) { + this._session.update({ user: user }) + } + this._notifyScopeListeners() + return this + } + /** + * @inheritDoc + */ + Scope.prototype.getUser = function () { + return this._user + } + /** + * @inheritDoc + */ + Scope.prototype.setTags = function (tags) { + this._tags = tslib_1.__assign(tslib_1.__assign({}, this._tags), tags) + this._notifyScopeListeners() + return this + } + /** + * @inheritDoc + */ + Scope.prototype.setTag = function (key, value) { + var _a + this._tags = tslib_1.__assign( + tslib_1.__assign({}, this._tags), + ((_a = {}), (_a[key] = value), _a) + ) + this._notifyScopeListeners() + return this + } + /** + * @inheritDoc + */ + Scope.prototype.setExtras = function (extras) { + this._extra = tslib_1.__assign( + tslib_1.__assign({}, this._extra), + extras + ) + this._notifyScopeListeners() + return this + } + /** + * @inheritDoc + */ + Scope.prototype.setExtra = function (key, extra) { + var _a + this._extra = tslib_1.__assign( + tslib_1.__assign({}, this._extra), + ((_a = {}), (_a[key] = extra), _a) + ) + this._notifyScopeListeners() + return this + } + /** + * @inheritDoc + */ + Scope.prototype.setFingerprint = function (fingerprint) { + this._fingerprint = fingerprint + this._notifyScopeListeners() + return this + } + /** + * @inheritDoc + */ + Scope.prototype.setLevel = function (level) { + this._level = level + this._notifyScopeListeners() + return this + } + /** + * @inheritDoc + */ + Scope.prototype.setTransactionName = function (name) { + this._transactionName = name + this._notifyScopeListeners() + return this + } + /** + * Can be removed in major version. + * @deprecated in favor of {@link this.setTransactionName} + */ + Scope.prototype.setTransaction = function (name) { + return this.setTransactionName(name) + } + /** + * @inheritDoc + */ + Scope.prototype.setContext = function (key, context) { + var _a + if (context === null) { + // eslint-disable-next-line @typescript-eslint/no-dynamic-delete + delete this._contexts[key] + } else { + this._contexts = tslib_1.__assign( + tslib_1.__assign({}, this._contexts), + ((_a = {}), (_a[key] = context), _a) + ) + } + this._notifyScopeListeners() + return this + } + /** + * @inheritDoc + */ + Scope.prototype.setSpan = function (span) { + this._span = span + this._notifyScopeListeners() + return this + } + /** + * @inheritDoc + */ + Scope.prototype.getSpan = function () { + return this._span + } + /** + * @inheritDoc + */ + Scope.prototype.getTransaction = function () { + var _a, _b, _c, _d + // often, this span will be a transaction, but it's not guaranteed to be + var span = this.getSpan() + // try it the new way first + if ((_a = span) === null || _a === void 0 ? void 0 : _a.transaction) { + return (_b = span) === null || _b === void 0 + ? void 0 + : _b.transaction + } + // fallback to the old way (known bug: this only finds transactions with sampled = true) + if ( + (_d = + (_c = span) === null || _c === void 0 + ? void 0 + : _c.spanRecorder) === null || _d === void 0 + ? void 0 + : _d.spans[0] + ) { + return span.spanRecorder.spans[0] + } + // neither way found a transaction + return undefined + } + /** + * @inheritDoc + */ + Scope.prototype.setSession = function (session) { + if (!session) { + delete this._session + } else { + this._session = session + } + this._notifyScopeListeners() + return this + } + /** + * @inheritDoc + */ + Scope.prototype.getSession = function () { + return this._session + } + /** + * @inheritDoc + */ + Scope.prototype.update = function (captureContext) { + if (!captureContext) { + return this + } + if (typeof captureContext === 'function') { + var updatedScope = captureContext(this) + return updatedScope instanceof Scope ? updatedScope : this + } + if (captureContext instanceof Scope) { + this._tags = tslib_1.__assign( + tslib_1.__assign({}, this._tags), + captureContext._tags + ) + this._extra = tslib_1.__assign( + tslib_1.__assign({}, this._extra), + captureContext._extra + ) + this._contexts = tslib_1.__assign( + tslib_1.__assign({}, this._contexts), + captureContext._contexts + ) + if ( + captureContext._user && + Object.keys(captureContext._user).length + ) { + this._user = captureContext._user + } + if (captureContext._level) { + this._level = captureContext._level + } + if (captureContext._fingerprint) { + this._fingerprint = captureContext._fingerprint + } + } else if (utils_1.isPlainObject(captureContext)) { + // eslint-disable-next-line no-param-reassign + captureContext = captureContext + this._tags = tslib_1.__assign( + tslib_1.__assign({}, this._tags), + captureContext.tags + ) + this._extra = tslib_1.__assign( + tslib_1.__assign({}, this._extra), + captureContext.extra + ) + this._contexts = tslib_1.__assign( + tslib_1.__assign({}, this._contexts), + captureContext.contexts + ) + if (captureContext.user) { + this._user = captureContext.user + } + if (captureContext.level) { + this._level = captureContext.level + } + if (captureContext.fingerprint) { + this._fingerprint = captureContext.fingerprint + } + } + return this + } + /** + * @inheritDoc + */ + Scope.prototype.clear = function () { + this._breadcrumbs = [] + this._tags = {} + this._extra = {} + this._user = {} + this._contexts = {} + this._level = undefined + this._transactionName = undefined + this._fingerprint = undefined + this._span = undefined + this._session = undefined + this._notifyScopeListeners() + return this + } + /** + * @inheritDoc + */ + Scope.prototype.addBreadcrumb = function (breadcrumb, maxBreadcrumbs) { + var mergedBreadcrumb = tslib_1.__assign( + { timestamp: utils_1.dateTimestampInSeconds() }, + breadcrumb + ) + this._breadcrumbs = + maxBreadcrumbs !== undefined && maxBreadcrumbs >= 0 + ? tslib_1 + .__spread(this._breadcrumbs, [mergedBreadcrumb]) + .slice(-maxBreadcrumbs) + : tslib_1.__spread(this._breadcrumbs, [mergedBreadcrumb]) + this._notifyScopeListeners() + return this + } + /** + * @inheritDoc + */ + Scope.prototype.clearBreadcrumbs = function () { + this._breadcrumbs = [] + this._notifyScopeListeners() + return this + } + /** + * Applies the current context and fingerprint to the event. + * Note that breadcrumbs will be added by the client. + * Also if the event has already breadcrumbs on it, we do not merge them. + * @param event Event + * @param hint May contain additional informartion about the original exception. + * @hidden + */ + Scope.prototype.applyToEvent = function (event, hint) { + var _a + if (this._extra && Object.keys(this._extra).length) { + event.extra = tslib_1.__assign( + tslib_1.__assign({}, this._extra), + event.extra + ) + } + if (this._tags && Object.keys(this._tags).length) { + event.tags = tslib_1.__assign( + tslib_1.__assign({}, this._tags), + event.tags + ) + } + if (this._user && Object.keys(this._user).length) { + event.user = tslib_1.__assign( + tslib_1.__assign({}, this._user), + event.user + ) + } + if (this._contexts && Object.keys(this._contexts).length) { + event.contexts = tslib_1.__assign( + tslib_1.__assign({}, this._contexts), + event.contexts + ) + } + if (this._level) { + event.level = this._level + } + if (this._transactionName) { + event.transaction = this._transactionName + } + // We want to set the trace context for normal events only if there isn't already + // a trace context on the event. There is a product feature in place where we link + // errors with transaction and it relys on that. + if (this._span) { + event.contexts = tslib_1.__assign( + { trace: this._span.getTraceContext() }, + event.contexts + ) + var transactionName = + (_a = this._span.transaction) === null || _a === void 0 + ? void 0 + : _a.name + if (transactionName) { + event.tags = tslib_1.__assign( + { transaction: transactionName }, + event.tags + ) + } + } + this._applyFingerprint(event) + event.breadcrumbs = tslib_1.__spread( + event.breadcrumbs || [], + this._breadcrumbs + ) + event.breadcrumbs = + event.breadcrumbs.length > 0 ? event.breadcrumbs : undefined + return this._notifyEventProcessors( + tslib_1.__spread(getGlobalEventProcessors(), this._eventProcessors), + event, + hint + ) + } + /** + * This will be called after {@link applyToEvent} is finished. + */ + Scope.prototype._notifyEventProcessors = function ( + processors, + event, + hint, + index + ) { + var _this = this + if (index === void 0) { + index = 0 + } + return new utils_1.SyncPromise(function (resolve, reject) { + var processor = processors[index] + if (event === null || typeof processor !== 'function') { + resolve(event) + } else { + var result = processor(tslib_1.__assign({}, event), hint) + if (utils_1.isThenable(result)) { + result + .then(function (final) { + return _this + ._notifyEventProcessors( + processors, + final, + hint, + index + 1 + ) + .then(resolve) + }) + .then(null, reject) + } else { + _this + ._notifyEventProcessors(processors, result, hint, index + 1) + .then(resolve) + .then(null, reject) + } + } + }) + } + /** + * This will be called on every set call. + */ + Scope.prototype._notifyScopeListeners = function () { + var _this = this + if (!this._notifyingListeners) { + this._notifyingListeners = true + setTimeout(function () { + _this._scopeListeners.forEach(function (callback) { + callback(_this) + }) + _this._notifyingListeners = false + }) + } + } + /** + * Applies fingerprint from the scope to the event if there's one, + * uses message if there's one instead or get rid of empty fingerprint + */ + Scope.prototype._applyFingerprint = function (event) { + // Make sure it's an array first and we actually have something in place + event.fingerprint = event.fingerprint + ? Array.isArray(event.fingerprint) + ? event.fingerprint + : [event.fingerprint] + : [] + // If we have something on the scope, then merge it with event + if (this._fingerprint) { + event.fingerprint = event.fingerprint.concat(this._fingerprint) + } + // If we have no data at all, remove empty array default + if (event.fingerprint && !event.fingerprint.length) { + delete event.fingerprint + } + } + return Scope + })() + exports.Scope = Scope + /** + * Retruns the global event processors. + */ + function getGlobalEventProcessors() { + var global = utils_1.getGlobalObject() + global.__SENTRY__ = global.__SENTRY__ || {} + global.__SENTRY__.globalEventProcessors = + global.__SENTRY__.globalEventProcessors || [] + return global.__SENTRY__.globalEventProcessors + } + /** + * Add a EventProcessor to be kept globally. + * @param callback EventProcessor to add + */ + function addGlobalEventProcessor(callback) { + getGlobalEventProcessors().push(callback) + } + exports.addGlobalEventProcessor = addGlobalEventProcessor + //# sourceMappingURL=scope.js.map + + /***/ + }, + + /***/ 12474: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var types_1 = __webpack_require__(83789) + var utils_1 = __webpack_require__(1620) + /** + * @inheritdoc + */ + var Session = /** @class */ (function () { + function Session(context) { + this.errors = 0 + this.sid = utils_1.uuid4() + this.timestamp = Date.now() + this.started = Date.now() + this.duration = 0 + this.status = types_1.SessionStatus.Ok + if (context) { + this.update(context) + } + } + /** JSDoc */ + // eslint-disable-next-line complexity + Session.prototype.update = function (context) { + if (context === void 0) { + context = {} + } + if (context.user) { + if (context.user.ip_address) { + this.ipAddress = context.user.ip_address + } + if (!context.did) { + this.did = + context.user.id || context.user.email || context.user.username + } + } + this.timestamp = context.timestamp || Date.now() + if (context.sid) { + // Good enough uuid validation. — Kamil + this.sid = context.sid.length === 32 ? context.sid : utils_1.uuid4() + } + if (context.did) { + this.did = '' + context.did + } + if (typeof context.started === 'number') { + this.started = context.started + } + if (typeof context.duration === 'number') { + this.duration = context.duration + } else { + this.duration = this.timestamp - this.started + } + if (context.release) { + this.release = context.release + } + if (context.environment) { + this.environment = context.environment + } + if (context.ipAddress) { + this.ipAddress = context.ipAddress + } + if (context.userAgent) { + this.userAgent = context.userAgent + } + if (typeof context.errors === 'number') { + this.errors = context.errors + } + if (context.status) { + this.status = context.status + } + } + /** JSDoc */ + Session.prototype.close = function (status) { + if (status) { + this.update({ status: status }) + } else if (this.status === types_1.SessionStatus.Ok) { + this.update({ status: types_1.SessionStatus.Exited }) + } else { + this.update() + } + } + /** JSDoc */ + Session.prototype.toJSON = function () { + return utils_1.dropUndefinedKeys({ + sid: '' + this.sid, + init: true, + started: new Date(this.started).toISOString(), + timestamp: new Date(this.timestamp).toISOString(), + status: this.status, + errors: this.errors, + did: + typeof this.did === 'number' || typeof this.did === 'string' + ? '' + this.did + : undefined, + duration: this.duration, + attrs: utils_1.dropUndefinedKeys({ + release: this.release, + environment: this.environment, + ip_address: this.ipAddress, + user_agent: this.userAgent + }) + }) + } + return Session + })() + exports.Session = Session + //# sourceMappingURL=session.js.map + + /***/ + }, + + /***/ 88649: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var tslib_1 = __webpack_require__(75636) + var utils_1 = __webpack_require__(1620) + // See https://github.com/angular/angular.js/blob/v1.4.7/src/minErr.js + var angularPattern = /^\[((?:[$a-zA-Z0-9]+:)?(?:[$a-zA-Z0-9]+))\] (.*?)\n?(\S+)$/ + /** + * AngularJS integration + * + * Provides an $exceptionHandler for AngularJS + */ + var Angular = /** @class */ (function () { + /** + * @inheritDoc + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function Angular(options) { + if (options === void 0) { + options = {} + } + /** + * @inheritDoc + */ + this.name = Angular.id + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access + this._angular = options.angular || utils_1.getGlobalObject().angular + if (!this._angular) { + utils_1.logger.error( + 'AngularIntegration is missing an Angular instance' + ) + return + } + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + this._module = this._angular.module(Angular.moduleName, []) + } + /** + * @inheritDoc + */ + Angular.prototype.setupOnce = function (_, getCurrentHub) { + var _this = this + if (!this._module) { + return + } + this._getCurrentHub = getCurrentHub + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + this._module.config([ + '$provide', + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function ($provide) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + $provide.decorator('$exceptionHandler', [ + '$delegate', + _this._$exceptionHandlerDecorator.bind(_this) + ]) + } + ]) + } + /** + * Angular's exceptionHandler for Sentry integration + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + Angular.prototype._$exceptionHandlerDecorator = function ($delegate) { + var _this = this + return function (exception, cause) { + var hub = _this._getCurrentHub && _this._getCurrentHub() + if (hub && hub.getIntegration(Angular)) { + hub.withScope(function (scope) { + if (cause) { + scope.setExtra('cause', cause) + } + scope.addEventProcessor(function (event) { + var ex = + event.exception && + event.exception.values && + event.exception.values[0] + if (ex) { + var matches = angularPattern.exec(ex.value || '') + if (matches) { + // This type now becomes something like: $rootScope:inprog + ex.type = matches[1] + ex.value = matches[2] + event.message = ex.type + ': ' + ex.value + // auto set a new tag specifically for the angular error url + event.extra = tslib_1.__assign( + tslib_1.__assign({}, event.extra), + { angularDocs: matches[3].substr(0, 250) } + ) + } + } + return event + }) + hub.captureException(exception) + }) + } + $delegate(exception, cause) + } + } + /** + * @inheritDoc + */ + Angular.id = 'AngularJS' + /** + * moduleName used in Angular's DI resolution algorithm + */ + Angular.moduleName = 'ngSentry' + return Angular + })() + exports.Angular = Angular + //# sourceMappingURL=angular.js.map + + /***/ + }, + + /***/ 55307: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var types_1 = __webpack_require__(83789) + var utils_1 = __webpack_require__(1620) + var global = utils_1.getGlobalObject() + /** Send Console API calls as Sentry Events */ + var CaptureConsole = /** @class */ (function () { + /** + * @inheritDoc + */ + function CaptureConsole(options) { + if (options === void 0) { + options = {} + } + /** + * @inheritDoc + */ + this.name = CaptureConsole.id + /** + * @inheritDoc + */ + this._levels = ['log', 'info', 'warn', 'error', 'debug', 'assert'] + if (options.levels) { + this._levels = options.levels + } + } + /** + * @inheritDoc + */ + CaptureConsole.prototype.setupOnce = function (_, getCurrentHub) { + if (!('console' in global)) { + return + } + this._levels.forEach(function (level) { + if (!(level in global.console)) { + return + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + utils_1.fill(global.console, level, function ( + originalConsoleLevel + ) { + return function () { + var args = [] + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i] + } + var hub = getCurrentHub() + if (hub.getIntegration(CaptureConsole)) { + hub.withScope(function (scope) { + scope.setLevel(types_1.Severity.fromString(level)) + scope.setExtra('arguments', args) + scope.addEventProcessor(function (event) { + event.logger = 'console' + return event + }) + var message = utils_1.safeJoin(args, ' ') + if (level === 'assert') { + if (args[0] === false) { + message = + 'Assertion failed: ' + + (utils_1.safeJoin(args.slice(1), ' ') || + 'console.assert') + scope.setExtra('arguments', args.slice(1)) + hub.captureMessage(message) + } + } else { + hub.captureMessage(message) + } + }) + } + // this fails for some browsers. :( + if (originalConsoleLevel) { + Function.prototype.apply.call( + originalConsoleLevel, + global.console, + args + ) + } + } + }) + }) + } + /** + * @inheritDoc + */ + CaptureConsole.id = 'CaptureConsole' + return CaptureConsole + })() + exports.CaptureConsole = CaptureConsole + //# sourceMappingURL=captureconsole.js.map + + /***/ + }, + + /***/ 56562: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var tslib_1 = __webpack_require__(75636) + var utils_1 = __webpack_require__(1620) + /** JSDoc */ + var Debug = /** @class */ (function () { + /** + * @inheritDoc + */ + function Debug(options) { + /** + * @inheritDoc + */ + this.name = Debug.id + this._options = tslib_1.__assign( + { debugger: false, stringify: false }, + options + ) + } + /** + * @inheritDoc + */ + Debug.prototype.setupOnce = function ( + addGlobalEventProcessor, + getCurrentHub + ) { + addGlobalEventProcessor(function (event, hint) { + var self = getCurrentHub().getIntegration(Debug) + if (self) { + if (self._options.debugger) { + // eslint-disable-next-line no-debugger + debugger + } + /* eslint-disable no-console */ + utils_1.consoleSandbox(function () { + if (self._options.stringify) { + console.log(JSON.stringify(event, null, 2)) + if (hint) { + console.log(JSON.stringify(hint, null, 2)) + } + } else { + console.log(event) + if (hint) { + console.log(hint) + } + } + }) + /* eslint-enable no-console */ + } + return event + }) + } + /** + * @inheritDoc + */ + Debug.id = 'Debug' + return Debug + })() + exports.Debug = Debug + //# sourceMappingURL=debug.js.map + + /***/ + }, + + /***/ 83235: /***/ (__unused_webpack_module, exports) => { + Object.defineProperty(exports, '__esModule', { value: true }) + /** Deduplication filter */ + var Dedupe = /** @class */ (function () { + function Dedupe() { + /** + * @inheritDoc + */ + this.name = Dedupe.id + } + /** + * @inheritDoc + */ + Dedupe.prototype.setupOnce = function ( + addGlobalEventProcessor, + getCurrentHub + ) { + addGlobalEventProcessor(function (currentEvent) { + var self = getCurrentHub().getIntegration(Dedupe) + if (self) { + // Juuust in case something goes wrong + try { + if (self._shouldDropEvent(currentEvent, self._previousEvent)) { + return null + } + } catch (_oO) { + return (self._previousEvent = currentEvent) + } + return (self._previousEvent = currentEvent) + } + return currentEvent + }) + } + /** JSDoc */ + Dedupe.prototype._shouldDropEvent = function ( + currentEvent, + previousEvent + ) { + if (!previousEvent) { + return false + } + if (this._isSameMessageEvent(currentEvent, previousEvent)) { + return true + } + if (this._isSameExceptionEvent(currentEvent, previousEvent)) { + return true + } + return false + } + /** JSDoc */ + Dedupe.prototype._isSameMessageEvent = function ( + currentEvent, + previousEvent + ) { + var currentMessage = currentEvent.message + var previousMessage = previousEvent.message + // If neither event has a message property, they were both exceptions, so bail out + if (!currentMessage && !previousMessage) { + return false + } + // If only one event has a stacktrace, but not the other one, they are not the same + if ( + (currentMessage && !previousMessage) || + (!currentMessage && previousMessage) + ) { + return false + } + if (currentMessage !== previousMessage) { + return false + } + if (!this._isSameFingerprint(currentEvent, previousEvent)) { + return false + } + if (!this._isSameStacktrace(currentEvent, previousEvent)) { + return false + } + return true + } + /** JSDoc */ + Dedupe.prototype._getFramesFromEvent = function (event) { + var exception = event.exception + if (exception) { + try { + // @ts-ignore Object could be undefined + return exception.values[0].stacktrace.frames + } catch (_oO) { + return undefined + } + } else if (event.stacktrace) { + return event.stacktrace.frames + } + return undefined + } + /** JSDoc */ + Dedupe.prototype._isSameStacktrace = function ( + currentEvent, + previousEvent + ) { + var currentFrames = this._getFramesFromEvent(currentEvent) + var previousFrames = this._getFramesFromEvent(previousEvent) + // If neither event has a stacktrace, they are assumed to be the same + if (!currentFrames && !previousFrames) { + return true + } + // If only one event has a stacktrace, but not the other one, they are not the same + if ( + (currentFrames && !previousFrames) || + (!currentFrames && previousFrames) + ) { + return false + } + currentFrames = currentFrames + previousFrames = previousFrames + // If number of frames differ, they are not the same + if (previousFrames.length !== currentFrames.length) { + return false + } + // Otherwise, compare the two + for (var i = 0; i < previousFrames.length; i++) { + var frameA = previousFrames[i] + var frameB = currentFrames[i] + if ( + frameA.filename !== frameB.filename || + frameA.lineno !== frameB.lineno || + frameA.colno !== frameB.colno || + frameA.function !== frameB.function + ) { + return false + } + } + return true + } + /** JSDoc */ + Dedupe.prototype._getExceptionFromEvent = function (event) { + return ( + event.exception && + event.exception.values && + event.exception.values[0] + ) + } + /** JSDoc */ + Dedupe.prototype._isSameExceptionEvent = function ( + currentEvent, + previousEvent + ) { + var previousException = this._getExceptionFromEvent(previousEvent) + var currentException = this._getExceptionFromEvent(currentEvent) + if (!previousException || !currentException) { + return false + } + if ( + previousException.type !== currentException.type || + previousException.value !== currentException.value + ) { + return false + } + if (!this._isSameFingerprint(currentEvent, previousEvent)) { + return false + } + if (!this._isSameStacktrace(currentEvent, previousEvent)) { + return false + } + return true + } + /** JSDoc */ + Dedupe.prototype._isSameFingerprint = function ( + currentEvent, + previousEvent + ) { + var currentFingerprint = currentEvent.fingerprint + var previousFingerprint = previousEvent.fingerprint + // If neither event has a fingerprint, they are assumed to be the same + if (!currentFingerprint && !previousFingerprint) { + return true + } + // If only one event has a fingerprint, but not the other one, they are not the same + if ( + (currentFingerprint && !previousFingerprint) || + (!currentFingerprint && previousFingerprint) + ) { + return false + } + currentFingerprint = currentFingerprint + previousFingerprint = previousFingerprint + // Otherwise, compare the two + try { + return !!( + currentFingerprint.join('') === previousFingerprint.join('') + ) + } catch (_oO) { + return false + } + } + /** + * @inheritDoc + */ + Dedupe.id = 'Dedupe' + return Dedupe + })() + exports.Dedupe = Dedupe + //# sourceMappingURL=dedupe.js.map + + /***/ + }, + + /***/ 55714: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var utils_1 = __webpack_require__(1620) + /** JSDoc */ + var Ember = /** @class */ (function () { + /** + * @inheritDoc + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function Ember(options) { + if (options === void 0) { + options = {} + } + /** + * @inheritDoc + */ + this.name = Ember.id + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access + this._Ember = options.Ember || utils_1.getGlobalObject().Ember + } + /** + * @inheritDoc + */ + Ember.prototype.setupOnce = function (_, getCurrentHub) { + var _this = this + if (!this._Ember) { + utils_1.logger.error( + 'EmberIntegration is missing an Ember instance' + ) + return + } + /* eslint-disable @typescript-eslint/no-unsafe-member-access */ + var oldOnError = this._Ember.onerror + this._Ember.onerror = function (error) { + if (getCurrentHub().getIntegration(Ember)) { + getCurrentHub().captureException(error, { + originalException: error + }) + } + if (typeof oldOnError === 'function') { + oldOnError.call(_this._Ember, error) + } else if (_this._Ember.testing) { + throw error + } + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._Ember.RSVP.on('error', function (reason) { + if (getCurrentHub().getIntegration(Ember)) { + getCurrentHub().withScope(function (scope) { + if (utils_1.isInstanceOf(reason, Error)) { + scope.setExtra('context', 'Unhandled Promise error detected') + getCurrentHub().captureException(reason, { + originalException: reason + }) + } else { + scope.setExtra('reason', reason) + getCurrentHub().captureMessage( + 'Unhandled Promise error detected' + ) + } + }) + } + }) + } + /** + * @inheritDoc + */ + Ember.id = 'Ember' + return Ember + })() + exports.Ember = Ember + //# sourceMappingURL=ember.js.map + + /***/ + }, + + /***/ 60326: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var tslib_1 = __webpack_require__(75636) + var utils_1 = __webpack_require__(1620) + /** Patch toString calls to return proper name for wrapped functions */ + var ExtraErrorData = /** @class */ (function () { + /** + * @inheritDoc + */ + function ExtraErrorData(_options) { + if (_options === void 0) { + _options = { depth: 3 } + } + this._options = _options + /** + * @inheritDoc + */ + this.name = ExtraErrorData.id + } + /** + * @inheritDoc + */ + ExtraErrorData.prototype.setupOnce = function ( + addGlobalEventProcessor, + getCurrentHub + ) { + addGlobalEventProcessor(function (event, hint) { + var self = getCurrentHub().getIntegration(ExtraErrorData) + if (!self) { + return event + } + return self.enhanceEventWithErrorData(event, hint) + }) + } + /** + * Attaches extracted information from the Error object to extra field in the Event + */ + ExtraErrorData.prototype.enhanceEventWithErrorData = function ( + event, + hint + ) { + var _a + if ( + !hint || + !hint.originalException || + !utils_1.isError(hint.originalException) + ) { + return event + } + var name = + hint.originalException.name || + hint.originalException.constructor.name + var errorData = this._extractErrorData(hint.originalException) + if (errorData) { + var contexts = tslib_1.__assign({}, event.contexts) + var normalizedErrorData = utils_1.normalize( + errorData, + this._options.depth + ) + if (utils_1.isPlainObject(normalizedErrorData)) { + contexts = tslib_1.__assign( + tslib_1.__assign({}, event.contexts), + ((_a = {}), + (_a[name] = tslib_1.__assign({}, normalizedErrorData)), + _a) + ) + } + return tslib_1.__assign(tslib_1.__assign({}, event), { + contexts: contexts + }) + } + return event + } + /** + * Extract extra information from the Error object + */ + ExtraErrorData.prototype._extractErrorData = function (error) { + var e_1, _a + var result = null + // We are trying to enhance already existing event, so no harm done if it won't succeed + try { + var nativeKeys_1 = [ + 'name', + 'message', + 'stack', + 'line', + 'column', + 'fileName', + 'lineNumber', + 'columnNumber' + ] + var errorKeys = Object.getOwnPropertyNames(error).filter(function ( + key + ) { + return nativeKeys_1.indexOf(key) === -1 + }) + if (errorKeys.length) { + var extraErrorInfo = {} + try { + for ( + var errorKeys_1 = tslib_1.__values(errorKeys), + errorKeys_1_1 = errorKeys_1.next(); + !errorKeys_1_1.done; + errorKeys_1_1 = errorKeys_1.next() + ) { + var key = errorKeys_1_1.value + var value = error[key] + if (utils_1.isError(value)) { + value = value.toString() + } + extraErrorInfo[key] = value + } + } catch (e_1_1) { + e_1 = { error: e_1_1 } + } finally { + try { + if ( + errorKeys_1_1 && + !errorKeys_1_1.done && + (_a = errorKeys_1.return) + ) + _a.call(errorKeys_1) + } finally { + if (e_1) throw e_1.error + } + } + result = extraErrorInfo + } + } catch (oO) { + utils_1.logger.error( + 'Unable to extract extra data from the Error object:', + oO + ) + } + return result + } + /** + * @inheritDoc + */ + ExtraErrorData.id = 'ExtraErrorData' + return ExtraErrorData + })() + exports.ExtraErrorData = ExtraErrorData + //# sourceMappingURL=extraerrordata.js.map + + /***/ + }, + + /***/ 25262: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var angular_1 = __webpack_require__(88649) + exports.Angular = angular_1.Angular + var captureconsole_1 = __webpack_require__(55307) + exports.CaptureConsole = captureconsole_1.CaptureConsole + var debug_1 = __webpack_require__(56562) + exports.Debug = debug_1.Debug + var dedupe_1 = __webpack_require__(83235) + exports.Dedupe = dedupe_1.Dedupe + var ember_1 = __webpack_require__(55714) + exports.Ember = ember_1.Ember + var extraerrordata_1 = __webpack_require__(60326) + exports.ExtraErrorData = extraerrordata_1.ExtraErrorData + var offline_1 = __webpack_require__(4827) + exports.Offline = offline_1.Offline + var reportingobserver_1 = __webpack_require__(85228) + exports.ReportingObserver = reportingobserver_1.ReportingObserver + var rewriteframes_1 = __webpack_require__(53394) + exports.RewriteFrames = rewriteframes_1.RewriteFrames + var sessiontiming_1 = __webpack_require__(33010) + exports.SessionTiming = sessiontiming_1.SessionTiming + var transaction_1 = __webpack_require__(49430) + exports.Transaction = transaction_1.Transaction + var vue_1 = __webpack_require__(20012) + exports.Vue = vue_1.Vue + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 4827: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var tslib_1 = __webpack_require__(75636) + var utils_1 = __webpack_require__(1620) + // eslint-disable-next-line @typescript-eslint/no-var-requires + var localForage = __webpack_require__(71345) + /** + * cache offline errors and send when connected + */ + var Offline = /** @class */ (function () { + /** + * @inheritDoc + */ + function Offline(options) { + if (options === void 0) { + options = {} + } + /** + * @inheritDoc + */ + this.name = Offline.id + // eslint-disable-next-line @typescript-eslint/no-explicit-any + this.global = utils_1.getGlobalObject() + this.maxStoredEvents = options.maxStoredEvents || 30 // set a reasonable default + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + this.offlineEventStore = localForage.createInstance({ + name: 'sentry/offlineEventStore' + }) + } + /** + * @inheritDoc + */ + Offline.prototype.setupOnce = function ( + addGlobalEventProcessor, + getCurrentHub + ) { + var _this = this + this.hub = getCurrentHub() + if ('addEventListener' in this.global) { + this.global.addEventListener('online', function () { + _this._sendEvents().catch(function () { + utils_1.logger.warn('could not send cached events') + }) + }) + } + addGlobalEventProcessor(function (event) { + if (_this.hub && _this.hub.getIntegration(Offline)) { + // cache if we are positively offline + if ( + 'navigator' in _this.global && + 'onLine' in _this.global.navigator && + !_this.global.navigator.onLine + ) { + _this + ._cacheEvent(event) + .then(function (_event) { + return _this._enforceMaxEvents() + }) + .catch(function (_error) { + utils_1.logger.warn('could not cache event while offline') + }) + // return null on success or failure, because being offline will still result in an error + return null + } + } + return event + }) + // if online now, send any events stored in a previous offline session + if ( + 'navigator' in this.global && + 'onLine' in this.global.navigator && + this.global.navigator.onLine + ) { + this._sendEvents().catch(function () { + utils_1.logger.warn('could not send cached events') + }) + } + } + /** + * cache an event to send later + * @param event an event + */ + Offline.prototype._cacheEvent = function (event) { + return tslib_1.__awaiter(this, void 0, void 0, function () { + return tslib_1.__generator(this, function (_a) { + return [ + 2 /*return*/, + this.offlineEventStore.setItem(utils_1.uuid4(), event) + ] + }) + }) + } + /** + * purge excess events if necessary + */ + Offline.prototype._enforceMaxEvents = function () { + return tslib_1.__awaiter(this, void 0, void 0, function () { + var events + var _this = this + return tslib_1.__generator(this, function (_a) { + events = [] + return [ + 2 /*return*/, + this.offlineEventStore + .iterate(function (event, cacheKey, _index) { + // aggregate events + events.push({ cacheKey: cacheKey, event: event }) + }) + .then(function () { + // this promise resolves when the iteration is finished + return _this._purgeEvents( + // purge all events past maxStoredEvents in reverse chronological order + events + .sort(function (a, b) { + return ( + (b.event.timestamp || 0) - (a.event.timestamp || 0) + ) + }) + .slice( + _this.maxStoredEvents < events.length + ? _this.maxStoredEvents + : events.length + ) + .map(function (event) { + return event.cacheKey + }) + ) + }) + .catch(function (_error) { + utils_1.logger.warn('could not enforce max events') + }) + ] + }) + }) + } + /** + * purge event from cache + */ + Offline.prototype._purgeEvent = function (cacheKey) { + return tslib_1.__awaiter(this, void 0, void 0, function () { + return tslib_1.__generator(this, function (_a) { + return [2 /*return*/, this.offlineEventStore.removeItem(cacheKey)] + }) + }) + } + /** + * purge events from cache + */ + Offline.prototype._purgeEvents = function (cacheKeys) { + return tslib_1.__awaiter(this, void 0, void 0, function () { + var _this = this + return tslib_1.__generator(this, function (_a) { + // trail with .then to ensure the return type as void and not void|void[] + return [ + 2 /*return*/, + Promise.all( + cacheKeys.map(function (cacheKey) { + return _this._purgeEvent(cacheKey) + }) + ).then() + ] + }) + }) + } + /** + * send all events + */ + Offline.prototype._sendEvents = function () { + return tslib_1.__awaiter(this, void 0, void 0, function () { + var _this = this + return tslib_1.__generator(this, function (_a) { + return [ + 2 /*return*/, + this.offlineEventStore.iterate(function ( + event, + cacheKey, + _index + ) { + if (_this.hub) { + _this.hub.captureEvent(event) + _this._purgeEvent(cacheKey).catch(function (_error) { + utils_1.logger.warn('could not purge event from cache') + }) + } else { + utils_1.logger.warn( + 'no hub found - could not send cached event' + ) + } + }) + ] + }) + }) + } + /** + * @inheritDoc + */ + Offline.id = 'Offline' + return Offline + })() + exports.Offline = Offline + //# sourceMappingURL=offline.js.map + + /***/ + }, + + /***/ 85228: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var tslib_1 = __webpack_require__(75636) + var utils_1 = __webpack_require__(1620) + /** JSDoc */ + var ReportTypes + ;(function (ReportTypes) { + /** JSDoc */ + ReportTypes['Crash'] = 'crash' + /** JSDoc */ + ReportTypes['Deprecation'] = 'deprecation' + /** JSDoc */ + ReportTypes['Intervention'] = 'intervention' + })(ReportTypes || (ReportTypes = {})) + /** Reporting API integration - https://w3c.github.io/reporting/ */ + var ReportingObserver = /** @class */ (function () { + /** + * @inheritDoc + */ + function ReportingObserver(_options) { + if (_options === void 0) { + _options = { + types: [ + ReportTypes.Crash, + ReportTypes.Deprecation, + ReportTypes.Intervention + ] + } + } + this._options = _options + /** + * @inheritDoc + */ + this.name = ReportingObserver.id + } + /** + * @inheritDoc + */ + ReportingObserver.prototype.setupOnce = function (_, getCurrentHub) { + if (!utils_1.supportsReportingObserver()) { + return + } + this._getCurrentHub = getCurrentHub + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + var observer = new (utils_1.getGlobalObject().ReportingObserver)( + this.handler.bind(this), + { + buffered: true, + types: this._options.types + } + ) + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + observer.observe() + } + /** + * @inheritDoc + */ + ReportingObserver.prototype.handler = function (reports) { + var e_1, _a + var hub = this._getCurrentHub && this._getCurrentHub() + if (!hub || !hub.getIntegration(ReportingObserver)) { + return + } + var _loop_1 = function (report) { + hub.withScope(function (scope) { + scope.setExtra('url', report.url) + var label = 'ReportingObserver [' + report.type + ']' + var details = 'No details available' + if (report.body) { + // Object.keys doesn't work on ReportBody, as all properties are inheirted + var plainBody = {} + // eslint-disable-next-line guard-for-in + for (var prop in report.body) { + plainBody[prop] = report.body[prop] + } + scope.setExtra('body', plainBody) + if (report.type === ReportTypes.Crash) { + var body = report.body + // A fancy way to create a message out of crashId OR reason OR both OR fallback + details = + [body.crashId || '', body.reason || ''].join(' ').trim() || + details + } else { + var body = report.body + details = body.message || details + } + } + hub.captureMessage(label + ': ' + details) + }) + } + try { + for ( + var reports_1 = tslib_1.__values(reports), + reports_1_1 = reports_1.next(); + !reports_1_1.done; + reports_1_1 = reports_1.next() + ) { + var report = reports_1_1.value + _loop_1(report) + } + } catch (e_1_1) { + e_1 = { error: e_1_1 } + } finally { + try { + if (reports_1_1 && !reports_1_1.done && (_a = reports_1.return)) + _a.call(reports_1) + } finally { + if (e_1) throw e_1.error + } + } + } + /** + * @inheritDoc + */ + ReportingObserver.id = 'ReportingObserver' + return ReportingObserver + })() + exports.ReportingObserver = ReportingObserver + //# sourceMappingURL=reportingobserver.js.map + + /***/ + }, + + /***/ 53394: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var tslib_1 = __webpack_require__(75636) + var utils_1 = __webpack_require__(1620) + /** Rewrite event frames paths */ + var RewriteFrames = /** @class */ (function () { + /** + * @inheritDoc + */ + function RewriteFrames(options) { + var _this = this + if (options === void 0) { + options = {} + } + /** + * @inheritDoc + */ + this.name = RewriteFrames.id + /** + * @inheritDoc + */ + this._iteratee = function (frame) { + if (!frame.filename) { + return frame + } + // Check if the frame filename begins with `/` or a Windows-style prefix such as `C:\` + var isWindowsFrame = /^[A-Z]:\\/.test(frame.filename) + var startsWithSlash = /^\//.test(frame.filename) + if (isWindowsFrame || startsWithSlash) { + var filename = isWindowsFrame + ? frame.filename + .replace(/^[A-Z]:/, '') // remove Windows-style prefix + .replace(/\\/g, '/') // replace all `\\` instances with `/` + : frame.filename + var base = _this._root + ? utils_1.relative(_this._root, filename) + : utils_1.basename(filename) + frame.filename = 'app:///' + base + } + return frame + } + if (options.root) { + this._root = options.root + } + if (options.iteratee) { + this._iteratee = options.iteratee + } + } + /** + * @inheritDoc + */ + RewriteFrames.prototype.setupOnce = function ( + addGlobalEventProcessor, + getCurrentHub + ) { + addGlobalEventProcessor(function (event) { + var self = getCurrentHub().getIntegration(RewriteFrames) + if (self) { + return self.process(event) + } + return event + }) + } + /** JSDoc */ + RewriteFrames.prototype.process = function (event) { + if (event.exception && Array.isArray(event.exception.values)) { + return this._processExceptionsEvent(event) + } + if (event.stacktrace) { + return this._processStacktraceEvent(event) + } + return event + } + /** JSDoc */ + RewriteFrames.prototype._processExceptionsEvent = function (event) { + var _this = this + try { + return tslib_1.__assign(tslib_1.__assign({}, event), { + exception: tslib_1.__assign( + tslib_1.__assign({}, event.exception), + { + // The check for this is performed inside `process` call itself, safe to skip here + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + values: event.exception.values.map(function (value) { + return tslib_1.__assign(tslib_1.__assign({}, value), { + stacktrace: _this._processStacktrace(value.stacktrace) + }) + }) + } + ) + }) + } catch (_oO) { + return event + } + } + /** JSDoc */ + RewriteFrames.prototype._processStacktraceEvent = function (event) { + try { + return tslib_1.__assign(tslib_1.__assign({}, event), { + stacktrace: this._processStacktrace(event.stacktrace) + }) + } catch (_oO) { + return event + } + } + /** JSDoc */ + RewriteFrames.prototype._processStacktrace = function (stacktrace) { + var _this = this + return tslib_1.__assign(tslib_1.__assign({}, stacktrace), { + frames: + stacktrace && + stacktrace.frames && + stacktrace.frames.map(function (f) { + return _this._iteratee(f) + }) + }) + } + /** + * @inheritDoc + */ + RewriteFrames.id = 'RewriteFrames' + return RewriteFrames + })() + exports.RewriteFrames = RewriteFrames + //# sourceMappingURL=rewriteframes.js.map + + /***/ + }, + + /***/ 33010: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var tslib_1 = __webpack_require__(75636) + /** This function adds duration since Sentry was initialized till the time event was sent */ + var SessionTiming = /** @class */ (function () { + function SessionTiming() { + /** + * @inheritDoc + */ + this.name = SessionTiming.id + /** Exact time Client was initialized expressed in milliseconds since Unix Epoch. */ + this._startTime = Date.now() + } + /** + * @inheritDoc + */ + SessionTiming.prototype.setupOnce = function ( + addGlobalEventProcessor, + getCurrentHub + ) { + addGlobalEventProcessor(function (event) { + var self = getCurrentHub().getIntegration(SessionTiming) + if (self) { + return self.process(event) + } + return event + }) + } + /** + * @inheritDoc + */ + SessionTiming.prototype.process = function (event) { + var _a + var now = Date.now() + return tslib_1.__assign(tslib_1.__assign({}, event), { + extra: tslib_1.__assign( + tslib_1.__assign({}, event.extra), + ((_a = {}), + (_a['session:start'] = this._startTime), + (_a['session:duration'] = now - this._startTime), + (_a['session:end'] = now), + _a) + ) + }) + } + /** + * @inheritDoc + */ + SessionTiming.id = 'SessionTiming' + return SessionTiming + })() + exports.SessionTiming = SessionTiming + //# sourceMappingURL=sessiontiming.js.map + + /***/ + }, + + /***/ 49430: /***/ (__unused_webpack_module, exports) => { + Object.defineProperty(exports, '__esModule', { value: true }) + /** Add node transaction to the event */ + var Transaction = /** @class */ (function () { + function Transaction() { + /** + * @inheritDoc + */ + this.name = Transaction.id + } + /** + * @inheritDoc + */ + Transaction.prototype.setupOnce = function ( + addGlobalEventProcessor, + getCurrentHub + ) { + addGlobalEventProcessor(function (event) { + var self = getCurrentHub().getIntegration(Transaction) + if (self) { + return self.process(event) + } + return event + }) + } + /** + * @inheritDoc + */ + Transaction.prototype.process = function (event) { + var frames = this._getFramesFromEvent(event) + // use for loop so we don't have to reverse whole frames array + for (var i = frames.length - 1; i >= 0; i--) { + var frame = frames[i] + if (frame.in_app === true) { + event.transaction = this._getTransaction(frame) + break + } + } + return event + } + /** JSDoc */ + Transaction.prototype._getFramesFromEvent = function (event) { + var exception = + event.exception && + event.exception.values && + event.exception.values[0] + return ( + (exception && + exception.stacktrace && + exception.stacktrace.frames) || + [] + ) + } + /** JSDoc */ + Transaction.prototype._getTransaction = function (frame) { + return frame.module || frame.function + ? (frame.module || '?') + '/' + (frame.function || '?') + : '' + } + /** + * @inheritDoc + */ + Transaction.id = 'Transaction' + return Transaction + })() + exports.Transaction = Transaction + //# sourceMappingURL=transaction.js.map + + /***/ + }, + + /***/ 20012: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var tslib_1 = __webpack_require__(75636) + var utils_1 = __webpack_require__(1620) + /** + * Used to extract Tracing integration from the current client, + * without the need to import `Tracing` itself from the @sentry/apm package. + * @deprecated as @sentry/tracing should be used over @sentry/apm. + */ + var TRACING_GETTER = { + id: 'Tracing' + } + /** + * Used to extract BrowserTracing integration from @sentry/tracing + */ + var BROWSER_TRACING_GETTER = { + id: 'BrowserTracing' + } + // Mappings from operation to corresponding lifecycle hook. + var HOOKS = { + activate: ['activated', 'deactivated'], + create: ['beforeCreate', 'created'], + destroy: ['beforeDestroy', 'destroyed'], + mount: ['beforeMount', 'mounted'], + update: ['beforeUpdate', 'updated'] + } + var COMPONENT_NAME_REGEXP = /(?:^|[-_/])(\w)/g + var ROOT_COMPONENT_NAME = 'root' + var ANONYMOUS_COMPONENT_NAME = 'anonymous component' + /** JSDoc */ + var Vue = /** @class */ (function () { + /** + * @inheritDoc + */ + function Vue(options) { + var _this = this + /** + * @inheritDoc + */ + this.name = Vue.id + /** + * Cache holding already processed component names + */ + this._componentsCache = {} + /** Keep it as attribute function, to keep correct `this` binding inside the hooks callbacks */ + // eslint-disable-next-line @typescript-eslint/typedef + this._applyTracingHooks = function (vm, getCurrentHub) { + // Don't attach twice, just in case + if (vm.$options.$_sentryPerfHook) { + return + } + vm.$options.$_sentryPerfHook = true + var name = _this._getComponentName(vm) + var rootMount = name === ROOT_COMPONENT_NAME + var spans = {} + // Render hook starts after once event is emitted, + // but it ends before the second event of the same type. + // + // Because of this, we start measuring inside the first event, + // but finish it before it triggers, to skip the event emitter timing itself. + var rootHandler = function (hook) { + var now = utils_1.timestampWithMs() + // On the first handler call (before), it'll be undefined, as `$once` will add it in the future. + // However, on the second call (after), it'll be already in place. + if (_this._rootSpan) { + _this._finishRootSpan(now, getCurrentHub) + } else { + vm.$once('hook:' + hook, function () { + // Create an activity on the first event call. There'll be no second call, as rootSpan will be in place, + // thus new event handler won't be attached. + // We do this whole dance with `TRACING_GETTER` to prevent `@sentry/apm` from becoming a peerDependency. + // We also need to ask for the `.constructor`, as `pushActivity` and `popActivity` are static, not instance methods. + /* eslint-disable @typescript-eslint/no-unsafe-member-access */ + // eslint-disable-next-line deprecation/deprecation + var tracingIntegration = getCurrentHub().getIntegration( + TRACING_GETTER + ) + if (tracingIntegration) { + _this._tracingActivity = tracingIntegration.constructor.pushActivity( + 'Vue Application Render' + ) + var transaction = tracingIntegration.constructor.getTransaction() + if (transaction) { + _this._rootSpan = transaction.startChild({ + description: 'Application Render', + op: 'Vue' + }) + } + // Use functionality from @sentry/tracing + } else { + var activeTransaction = getActiveTransaction( + getCurrentHub() + ) + if (activeTransaction) { + _this._rootSpan = activeTransaction.startChild({ + description: 'Application Render', + op: 'Vue' + }) + } + } + /* eslint-enable @typescript-eslint/no-unsafe-member-access */ + }) + } + } + var childHandler = function (hook, operation) { + // Skip components that we don't want to track to minimize the noise and give a more granular control to the user + var shouldTrack = Array.isArray( + _this._options.tracingOptions.trackComponents + ) + ? _this._options.tracingOptions.trackComponents.indexOf(name) > + -1 + : _this._options.tracingOptions.trackComponents + if (!_this._rootSpan || !shouldTrack) { + return + } + var now = utils_1.timestampWithMs() + var span = spans[operation] + // On the first handler call (before), it'll be undefined, as `$once` will add it in the future. + // However, on the second call (after), it'll be already in place. + if (span) { + span.finish() + _this._finishRootSpan(now, getCurrentHub) + } else { + vm.$once('hook:' + hook, function () { + if (_this._rootSpan) { + spans[operation] = _this._rootSpan.startChild({ + description: 'Vue <' + name + '>', + op: operation + }) + } + }) + } + } + // Each component has it's own scope, so all activities are only related to one of them + _this._options.tracingOptions.hooks.forEach(function (operation) { + // Retrieve corresponding hooks from Vue lifecycle. + // eg. mount => ['beforeMount', 'mounted'] + var internalHooks = HOOKS[operation] + if (!internalHooks) { + utils_1.logger.warn('Unknown hook: ' + operation) + return + } + internalHooks.forEach(function (internalHook) { + var handler = rootMount + ? rootHandler.bind(_this, internalHook) + : childHandler.bind(_this, internalHook, operation) + var currentValue = vm.$options[internalHook] + if (Array.isArray(currentValue)) { + vm.$options[internalHook] = tslib_1.__spread( + [handler], + currentValue + ) + } else if (typeof currentValue === 'function') { + vm.$options[internalHook] = [handler, currentValue] + } else { + vm.$options[internalHook] = [handler] + } + }) + }) + } + this._options = tslib_1.__assign( + tslib_1.__assign( + { + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + Vue: utils_1.getGlobalObject().Vue, + attachProps: true, + logErrors: false, + tracing: false + }, + options + ), + { + tracingOptions: tslib_1.__assign( + { + hooks: ['mount', 'update'], + timeout: 2000, + trackComponents: false + }, + options.tracingOptions + ) + } + ) + } + /** + * @inheritDoc + */ + Vue.prototype.setupOnce = function (_, getCurrentHub) { + if (!this._options.Vue) { + utils_1.logger.error('Vue integration is missing a Vue instance') + return + } + this._attachErrorHandler(getCurrentHub) + if (this._options.tracing) { + this._startTracing(getCurrentHub) + } + } + /** + * Extract component name from the ViewModel + */ + Vue.prototype._getComponentName = function (vm) { + // Such level of granularity is most likely not necessary, but better safe than sorry. — Kamil + if (!vm) { + return ANONYMOUS_COMPONENT_NAME + } + if (vm.$root === vm) { + return ROOT_COMPONENT_NAME + } + if (!vm.$options) { + return ANONYMOUS_COMPONENT_NAME + } + if (vm.$options.name) { + return vm.$options.name + } + if (vm.$options._componentTag) { + return vm.$options._componentTag + } + // injected by vue-loader + if (vm.$options.__file) { + var unifiedFile = vm.$options.__file + .replace(/^[a-zA-Z]:/, '') + .replace(/\\/g, '/') + var filename = utils_1.basename(unifiedFile, '.vue') + return ( + this._componentsCache[filename] || + (this._componentsCache[filename] = filename.replace( + COMPONENT_NAME_REGEXP, + function (_, c) { + return c ? c.toUpperCase() : '' + } + )) + ) + } + return ANONYMOUS_COMPONENT_NAME + } + /** Finish top-level span and activity with a debounce configured using `timeout` option */ + Vue.prototype._finishRootSpan = function (timestamp, getCurrentHub) { + var _this = this + if (this._rootSpanTimer) { + clearTimeout(this._rootSpanTimer) + } + this._rootSpanTimer = setTimeout(function () { + if (_this._tracingActivity) { + // We do this whole dance with `TRACING_GETTER` to prevent `@sentry/apm` from becoming a peerDependency. + // We also need to ask for the `.constructor`, as `pushActivity` and `popActivity` are static, not instance methods. + // eslint-disable-next-line deprecation/deprecation + var tracingIntegration = getCurrentHub().getIntegration( + TRACING_GETTER + ) + if (tracingIntegration) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + tracingIntegration.constructor.popActivity( + _this._tracingActivity + ) + } + } + // We should always finish the span, only should pop activity if using @sentry/apm + if (_this._rootSpan) { + _this._rootSpan.finish(timestamp) + } + }, this._options.tracingOptions.timeout) + } + /** Inject configured tracing hooks into Vue's component lifecycles */ + Vue.prototype._startTracing = function (getCurrentHub) { + var applyTracingHooks = this._applyTracingHooks + this._options.Vue.mixin({ + beforeCreate: function () { + // eslint-disable-next-line deprecation/deprecation + if ( + getCurrentHub().getIntegration(TRACING_GETTER) || + getCurrentHub().getIntegration(BROWSER_TRACING_GETTER) + ) { + // `this` points to currently rendered component + applyTracingHooks(this, getCurrentHub) + } else { + utils_1.logger.error( + 'Vue integration has tracing enabled, but Tracing integration is not configured' + ) + } + } + }) + } + /** Inject Sentry's handler into owns Vue's error handler */ + Vue.prototype._attachErrorHandler = function (getCurrentHub) { + var _this = this + // eslint-disable-next-line @typescript-eslint/unbound-method + var currentErrorHandler = this._options.Vue.config.errorHandler + this._options.Vue.config.errorHandler = function (error, vm, info) { + var metadata = {} + if (vm) { + try { + metadata.componentName = _this._getComponentName(vm) + if (_this._options.attachProps) { + metadata.propsData = vm.$options.propsData + } + } catch (_oO) { + utils_1.logger.warn( + 'Unable to extract metadata from Vue component.' + ) + } + } + if (info) { + metadata.lifecycleHook = info + } + if (getCurrentHub().getIntegration(Vue)) { + // Capture exception in the next event loop, to make sure that all breadcrumbs are recorded in time. + setTimeout(function () { + getCurrentHub().withScope(function (scope) { + scope.setContext('vue', metadata) + getCurrentHub().captureException(error) + }) + }) + } + if (typeof currentErrorHandler === 'function') { + currentErrorHandler.call(_this._options.Vue, error, vm, info) + } + if (_this._options.logErrors) { + if (_this._options.Vue.util) { + _this._options.Vue.util.warn( + 'Error in ' + info + ': "' + error.toString() + '"', + vm + ) + } + // eslint-disable-next-line no-console + console.error(error) + } + } + } + /** + * @inheritDoc + */ + Vue.id = 'Vue' + return Vue + })() + exports.Vue = Vue + /** Grabs active transaction off scope */ + function getActiveTransaction(hub) { + if (hub && hub.getScope) { + var scope = hub.getScope() + if (scope) { + return scope.getTransaction() + } + } + return undefined + } + exports.getActiveTransaction = getActiveTransaction + //# sourceMappingURL=vue.js.map + + /***/ + }, + + /***/ 88455: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var tslib_1 = __webpack_require__(75636) + var hub_1 = __webpack_require__(6393) + /** + * This calls a function on the current hub. + * @param method function to call on hub. + * @param args to pass to function. + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function callOnHub(method) { + var args = [] + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i] + } + var hub = hub_1.getCurrentHub() + if (hub && hub[method]) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return hub[method].apply(hub, tslib_1.__spread(args)) + } + throw new Error( + 'No hub defined or ' + + method + + ' was not found on the hub, please open a bug report.' + ) + } + /** + * Captures an exception event and sends it to Sentry. + * + * @param exception An exception-like object. + * @returns The generated eventId. + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types + function captureException(exception, captureContext) { + var syntheticException + try { + throw new Error('Sentry syntheticException') + } catch (exception) { + syntheticException = exception + } + return callOnHub('captureException', exception, { + captureContext: captureContext, + originalException: exception, + syntheticException: syntheticException + }) + } + exports.captureException = captureException + /** + * Captures a message event and sends it to Sentry. + * + * @param message The message to send to Sentry. + * @param level Define the level of the message. + * @returns The generated eventId. + */ + function captureMessage(message, captureContext) { + var syntheticException + try { + throw new Error(message) + } catch (exception) { + syntheticException = exception + } + // This is necessary to provide explicit scopes upgrade, without changing the original + // arity of the `captureMessage(message, level)` method. + var level = + typeof captureContext === 'string' ? captureContext : undefined + var context = + typeof captureContext !== 'string' + ? { captureContext: captureContext } + : undefined + return callOnHub( + 'captureMessage', + message, + level, + tslib_1.__assign( + { + originalException: message, + syntheticException: syntheticException + }, + context + ) + ) + } + exports.captureMessage = captureMessage + /** + * Captures a manually created event and sends it to Sentry. + * + * @param event The event to send to Sentry. + * @returns The generated eventId. + */ + function captureEvent(event) { + return callOnHub('captureEvent', event) + } + exports.captureEvent = captureEvent + /** + * Callback to set context information onto the scope. + * @param callback Callback function that receives Scope. + */ + function configureScope(callback) { + callOnHub('configureScope', callback) + } + exports.configureScope = configureScope + /** + * Records a new breadcrumb which will be attached to future events. + * + * Breadcrumbs will be added to subsequent events to provide more context on + * user's actions prior to an error or crash. + * + * @param breadcrumb The breadcrumb to record. + */ + function addBreadcrumb(breadcrumb) { + callOnHub('addBreadcrumb', breadcrumb) + } + exports.addBreadcrumb = addBreadcrumb + /** + * Sets context data with the given name. + * @param name of the context + * @param context Any kind of data. This data will be normalized. + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function setContext(name, context) { + callOnHub('setContext', name, context) + } + exports.setContext = setContext + /** + * Set an object that will be merged sent as extra data with the event. + * @param extras Extras object to merge into current context. + */ + function setExtras(extras) { + callOnHub('setExtras', extras) + } + exports.setExtras = setExtras + /** + * Set an object that will be merged sent as tags data with the event. + * @param tags Tags context object to merge into current context. + */ + function setTags(tags) { + callOnHub('setTags', tags) + } + exports.setTags = setTags + /** + * Set key:value that will be sent as extra data with the event. + * @param key String of extra + * @param extra Any kind of data. This data will be normalized. + */ + function setExtra(key, extra) { + callOnHub('setExtra', key, extra) + } + exports.setExtra = setExtra + /** + * Set key:value that will be sent as tags data with the event. + * @param key String key of tag + * @param value String value of tag + */ + function setTag(key, value) { + callOnHub('setTag', key, value) + } + exports.setTag = setTag + /** + * Updates user context information for future events. + * + * @param user User context object to be set in the current context. Pass `null` to unset the user. + */ + function setUser(user) { + callOnHub('setUser', user) + } + exports.setUser = setUser + /** + * Creates a new scope with and executes the given operation within. + * The scope is automatically removed once the operation + * finishes or throws. + * + * This is essentially a convenience function for: + * + * pushScope(); + * callback(); + * popScope(); + * + * @param callback that will be enclosed into push/popScope. + */ + function withScope(callback) { + callOnHub('withScope', callback) + } + exports.withScope = withScope + /** + * Calls a function on the latest client. Use this with caution, it's meant as + * in "internal" helper so we don't need to expose every possible function in + * the shim. It is not guaranteed that the client actually implements the + * function. + * + * @param method The method to call on the client/client. + * @param args Arguments to pass to the client/fontend. + * @hidden + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function _callOnClient(method) { + var args = [] + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i] + } + callOnHub.apply( + void 0, + tslib_1.__spread(['_invokeClient', method], args) + ) + } + exports._callOnClient = _callOnClient + /** + * Starts a new `Transaction` and returns it. This is the entry point to manual tracing instrumentation. + * + * A tree structure can be built by adding child spans to the transaction, and child spans to other spans. To start a + * new child span within the transaction or any span, call the respective `.startChild()` method. + * + * Every child span must be finished before the transaction is finished, otherwise the unfinished spans are discarded. + * + * The transaction must be finished with a call to its `.finish()` method, at which point the transaction with all its + * finished child spans will be sent to Sentry. + * + * @param context Properties of the new `Transaction`. + * @param customSamplingContext Information given to the transaction sampling function (along with context-dependent + * default values). See {@link Options.tracesSampler}. + * + * @returns The transaction which was just started + */ + function startTransaction(context, customSamplingContext) { + return callOnHub( + 'startTransaction', + tslib_1.__assign({}, context), + customSamplingContext + ) + } + exports.startTransaction = startTransaction + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 40508: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var tslib_1 = __webpack_require__(75636) + var core_1 = __webpack_require__(79212) + var types_1 = __webpack_require__(83789) + var utils_1 = __webpack_require__(1620) + var parsers_1 = __webpack_require__(19090) + var transports_1 = __webpack_require__(21437) + /** + * The Sentry Node SDK Backend. + * @hidden + */ + var NodeBackend = /** @class */ (function (_super) { + tslib_1.__extends(NodeBackend, _super) + function NodeBackend() { + return (_super !== null && _super.apply(this, arguments)) || this + } + /** + * @inheritDoc + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types + NodeBackend.prototype.eventFromException = function (exception, hint) { + var _this = this + // eslint-disable-next-line @typescript-eslint/no-explicit-any + var ex = exception + var mechanism = { + handled: true, + type: 'generic' + } + if (!utils_1.isError(exception)) { + if (utils_1.isPlainObject(exception)) { + // This will allow us to group events based on top-level keys + // which is much better than creating new group when any key/value change + var message = + 'Non-Error exception captured with keys: ' + + utils_1.extractExceptionKeysForMessage(exception) + core_1.getCurrentHub().configureScope(function (scope) { + scope.setExtra( + '__serialized__', + utils_1.normalizeToSize(exception) + ) + }) + ex = (hint && hint.syntheticException) || new Error(message) + ex.message = message + } else { + // This handles when someone does: `throw "something awesome";` + // We use synthesized Error here so we can extract a (rough) stack trace. + ex = (hint && hint.syntheticException) || new Error(exception) + ex.message = exception + } + mechanism.synthetic = true + } + return new utils_1.SyncPromise(function (resolve, reject) { + return parsers_1 + .parseError(ex, _this._options) + .then(function (event) { + utils_1.addExceptionTypeValue(event, undefined, undefined) + utils_1.addExceptionMechanism(event, mechanism) + resolve( + tslib_1.__assign(tslib_1.__assign({}, event), { + event_id: hint && hint.event_id + }) + ) + }) + .then(null, reject) + }) + } + /** + * @inheritDoc + */ + NodeBackend.prototype.eventFromMessage = function ( + message, + level, + hint + ) { + var _this = this + if (level === void 0) { + level = types_1.Severity.Info + } + var event = { + event_id: hint && hint.event_id, + level: level, + message: message + } + return new utils_1.SyncPromise(function (resolve) { + if ( + _this._options.attachStacktrace && + hint && + hint.syntheticException + ) { + var stack = hint.syntheticException + ? parsers_1.extractStackFromError(hint.syntheticException) + : [] + parsers_1 + .parseStack(stack, _this._options) + .then(function (frames) { + event.stacktrace = { + frames: parsers_1.prepareFramesForEvent(frames) + } + resolve(event) + }) + .then(null, function () { + resolve(event) + }) + } else { + resolve(event) + } + }) + } + /** + * @inheritDoc + */ + NodeBackend.prototype._setupTransport = function () { + if (!this._options.dsn) { + // We return the noop transport here in case there is no Dsn. + return _super.prototype._setupTransport.call(this) + } + var dsn = new utils_1.Dsn(this._options.dsn) + var transportOptions = tslib_1.__assign( + tslib_1.__assign( + tslib_1.__assign( + tslib_1.__assign( + tslib_1.__assign({}, this._options.transportOptions), + this._options.httpProxy && { + httpProxy: this._options.httpProxy + } + ), + this._options.httpsProxy && { + httpsProxy: this._options.httpsProxy + } + ), + this._options.caCerts && { caCerts: this._options.caCerts } + ), + { dsn: this._options.dsn } + ) + if (this._options.transport) { + return new this._options.transport(transportOptions) + } + if (dsn.protocol === 'http') { + return new transports_1.HTTPTransport(transportOptions) + } + return new transports_1.HTTPSTransport(transportOptions) + } + return NodeBackend + })(core_1.BaseBackend) + exports.NodeBackend = NodeBackend + //# sourceMappingURL=backend.js.map + + /***/ + }, + + /***/ 86147: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var tslib_1 = __webpack_require__(75636) + var core_1 = __webpack_require__(79212) + var backend_1 = __webpack_require__(40508) + var version_1 = __webpack_require__(31271) + /** + * The Sentry Node SDK Client. + * + * @see NodeOptions for documentation on configuration options. + * @see SentryClient for usage documentation. + */ + var NodeClient = /** @class */ (function (_super) { + tslib_1.__extends(NodeClient, _super) + /** + * Creates a new Node SDK instance. + * @param options Configuration options for this SDK. + */ + function NodeClient(options) { + return _super.call(this, backend_1.NodeBackend, options) || this + } + /** + * @inheritDoc + */ + NodeClient.prototype._prepareEvent = function (event, scope, hint) { + event.platform = event.platform || 'node' + event.sdk = tslib_1.__assign(tslib_1.__assign({}, event.sdk), { + name: version_1.SDK_NAME, + packages: tslib_1.__spread( + (event.sdk && event.sdk.packages) || [], + [ + { + name: 'npm:@sentry/node', + version: version_1.SDK_VERSION + } + ] + ), + version: version_1.SDK_VERSION + }) + if (this.getOptions().serverName) { + event.server_name = this.getOptions().serverName + } + return _super.prototype._prepareEvent.call(this, event, scope, hint) + } + return NodeClient + })(core_1.BaseClient) + exports.NodeClient = NodeClient + //# sourceMappingURL=client.js.map + + /***/ + }, + + /***/ 45400: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var tslib_1 = __webpack_require__(75636) + /* eslint-disable max-lines */ + /* eslint-disable @typescript-eslint/no-explicit-any */ + var core_1 = __webpack_require__(79212) + var tracing_1 = __webpack_require__(64358) + var utils_1 = __webpack_require__(1620) + var domain = __webpack_require__(85229) + var os = __webpack_require__(12087) + var url = __webpack_require__(78835) + var sdk_1 = __webpack_require__(38836) + var DEFAULT_SHUTDOWN_TIMEOUT = 2000 + /** + * Express-compatible tracing handler. + * @see Exposed as `Handlers.tracingHandler` + */ + function tracingHandler() { + return function sentryTracingMiddleware(req, res, next) { + // TODO: At this point `req.route.path` (which we use in `extractTransaction`) is not available + // but `req.path` or `req.url` should do the job as well. We could unify this here. + var reqMethod = (req.method || '').toUpperCase() + var reqUrl = req.url && utils_1.stripUrlQueryAndFragment(req.url) + // If there is a trace header set, we extract the data from it (parentSpanId, traceId, and sampling decision) + var traceparentData + if (req.headers && utils_1.isString(req.headers['sentry-trace'])) { + traceparentData = tracing_1.extractTraceparentData( + req.headers['sentry-trace'] + ) + } + var transaction = core_1.startTransaction( + tslib_1.__assign( + { name: reqMethod + ' ' + reqUrl, op: 'http.server' }, + traceparentData + ) + ) + // We put the transaction on the scope so users can attach children to it + core_1.getCurrentHub().configureScope(function (scope) { + scope.setSpan(transaction) + }) + // We also set __sentry_transaction on the response so people can grab the transaction there to add + // spans to it later. + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + res.__sentry_transaction = transaction + res.once('finish', function () { + // We schedule the immediate execution of the `finish` to let all the spans being closed first. + setImmediate(function () { + transaction.setHttpStatus(res.statusCode) + transaction.finish() + }) + }) + next() + } + } + exports.tracingHandler = tracingHandler + /** JSDoc */ + function extractTransaction(req, type) { + try { + // Express.js shape + var request = req + var routePath = void 0 + try { + routePath = url.parse(request.originalUrl || request.url).pathname + } catch (_oO) { + routePath = request.route.path + } + switch (type) { + case 'path': { + return routePath + } + case 'handler': { + return request.route.stack[0].name + } + case 'methodPath': + default: { + var method = request.method.toUpperCase() + return method + ' ' + routePath + } + } + } catch (_oO) { + return undefined + } + } + /** Default user keys that'll be used to extract data from the request */ + var DEFAULT_USER_KEYS = ['id', 'username', 'email'] + /** JSDoc */ + function extractUserData(user, keys) { + var extractedUser = {} + var attributes = Array.isArray(keys) ? keys : DEFAULT_USER_KEYS + attributes.forEach(function (key) { + if (user && key in user) { + extractedUser[key] = user[key] + } + }) + return extractedUser + } + /** + * Enriches passed event with request data. + * + * @param event Will be mutated and enriched with req data + * @param req Request object + * @param options object containing flags to enable functionality + * @hidden + */ + function parseRequest(event, req, options) { + // eslint-disable-next-line no-param-reassign + options = tslib_1.__assign( + { + ip: false, + request: true, + serverName: true, + transaction: true, + user: true, + version: true + }, + options + ) + if (options.version) { + event.contexts = tslib_1.__assign( + tslib_1.__assign({}, event.contexts), + { + runtime: { + name: 'node', + version: global.process.version + } + } + ) + } + if (options.request) { + // if the option value is `true`, use the default set of keys by not passing anything to `extractNodeRequestData()` + var extractedRequestData = Array.isArray(options.request) + ? utils_1.extractNodeRequestData(req, options.request) + : utils_1.extractNodeRequestData(req) + event.request = tslib_1.__assign( + tslib_1.__assign({}, event.request), + extractedRequestData + ) + } + if (options.serverName && !event.server_name) { + event.server_name = global.process.env.SENTRY_NAME || os.hostname() + } + if (options.user) { + var extractedUser = + req.user && utils_1.isPlainObject(req.user) + ? extractUserData(req.user, options.user) + : {} + if (Object.keys(extractedUser)) { + event.user = tslib_1.__assign( + tslib_1.__assign({}, event.user), + extractedUser + ) + } + } + // client ip: + // node: req.connection.remoteAddress + // express, koa: req.ip + if (options.ip) { + var ip = req.ip || (req.connection && req.connection.remoteAddress) + if (ip) { + event.user = tslib_1.__assign(tslib_1.__assign({}, event.user), { + ip_address: ip + }) + } + } + if (options.transaction && !event.transaction) { + var transaction = extractTransaction(req, options.transaction) + if (transaction) { + event.transaction = transaction + } + } + return event + } + exports.parseRequest = parseRequest + /** + * Express compatible request handler. + * @see Exposed as `Handlers.requestHandler` + */ + function requestHandler(options) { + return function sentryRequestMiddleware(req, res, next) { + if (options && options.flushTimeout && options.flushTimeout > 0) { + // eslint-disable-next-line @typescript-eslint/unbound-method + var _end_1 = res.end + res.end = function (chunk, encoding, cb) { + var _this = this + sdk_1 + .flush(options.flushTimeout) + .then(function () { + _end_1.call(_this, chunk, encoding, cb) + }) + .then(null, function (e) { + utils_1.logger.error(e) + }) + } + } + var local = domain.create() + local.add(req) + local.add(res) + local.on('error', next) + local.run(function () { + core_1.getCurrentHub().configureScope(function (scope) { + return scope.addEventProcessor(function (event) { + return parseRequest(event, req, options) + }) + }) + next() + }) + } + } + exports.requestHandler = requestHandler + /** JSDoc */ + function getStatusCodeFromResponse(error) { + var statusCode = + error.status || + error.statusCode || + error.status_code || + (error.output && error.output.statusCode) + return statusCode ? parseInt(statusCode, 10) : 500 + } + /** Returns true if response code is internal server error */ + function defaultShouldHandleError(error) { + var status = getStatusCodeFromResponse(error) + return status >= 500 + } + /** + * Express compatible error handler. + * @see Exposed as `Handlers.errorHandler` + */ + function errorHandler(options) { + return function sentryErrorMiddleware(error, _req, res, next) { + // eslint-disable-next-line @typescript-eslint/unbound-method + var shouldHandleError = + (options && options.shouldHandleError) || defaultShouldHandleError + if (shouldHandleError(error)) { + core_1.withScope(function (_scope) { + // For some reason we need to set the transaction on the scope again + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + var transaction = res.__sentry_transaction + if (transaction && _scope.getSpan() === undefined) { + _scope.setSpan(transaction) + } + var eventId = core_1.captureException(error) + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + res.sentry = eventId + next(error) + }) + return + } + next(error) + } + } + exports.errorHandler = errorHandler + /** + * @hidden + */ + function logAndExitProcess(error) { + // eslint-disable-next-line no-console + console.error(error && error.stack ? error.stack : error) + var client = core_1.getCurrentHub().getClient() + if (client === undefined) { + utils_1.logger.warn( + 'No NodeClient was defined, we are exiting the process now.' + ) + global.process.exit(1) + return + } + var options = client.getOptions() + var timeout = + (options && + options.shutdownTimeout && + options.shutdownTimeout > 0 && + options.shutdownTimeout) || + DEFAULT_SHUTDOWN_TIMEOUT + utils_1.forget( + client.close(timeout).then(function (result) { + if (!result) { + utils_1.logger.warn( + 'We reached the timeout for emptying the request buffer, still exiting now!' + ) + } + global.process.exit(1) + }) + ) + } + exports.logAndExitProcess = logAndExitProcess + //# sourceMappingURL=handlers.js.map + + /***/ + }, + + /***/ 22783: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var tslib_1 = __webpack_require__(75636) + var types_1 = __webpack_require__(83789) + exports.Severity = types_1.Severity + exports.Status = types_1.Status + var core_1 = __webpack_require__(79212) + exports.addGlobalEventProcessor = core_1.addGlobalEventProcessor + exports.addBreadcrumb = core_1.addBreadcrumb + exports.captureException = core_1.captureException + exports.captureEvent = core_1.captureEvent + exports.captureMessage = core_1.captureMessage + exports.configureScope = core_1.configureScope + exports.getHubFromCarrier = core_1.getHubFromCarrier + exports.getCurrentHub = core_1.getCurrentHub + exports.Hub = core_1.Hub + exports.makeMain = core_1.makeMain + exports.Scope = core_1.Scope + exports.startTransaction = core_1.startTransaction + exports.setContext = core_1.setContext + exports.setExtra = core_1.setExtra + exports.setExtras = core_1.setExtras + exports.setTag = core_1.setTag + exports.setTags = core_1.setTags + exports.setUser = core_1.setUser + exports.withScope = core_1.withScope + var backend_1 = __webpack_require__(40508) + exports.NodeBackend = backend_1.NodeBackend + var client_1 = __webpack_require__(86147) + exports.NodeClient = client_1.NodeClient + var sdk_1 = __webpack_require__(38836) + exports.defaultIntegrations = sdk_1.defaultIntegrations + exports.init = sdk_1.init + exports.lastEventId = sdk_1.lastEventId + exports.flush = sdk_1.flush + exports.close = sdk_1.close + var version_1 = __webpack_require__(31271) + exports.SDK_NAME = version_1.SDK_NAME + exports.SDK_VERSION = version_1.SDK_VERSION + var core_2 = __webpack_require__(79212) + var hub_1 = __webpack_require__(6393) + var domain = __webpack_require__(85229) + var Handlers = __webpack_require__(45400) + exports.Handlers = Handlers + var NodeIntegrations = __webpack_require__(72310) + var Transports = __webpack_require__(21437) + exports.Transports = Transports + var INTEGRATIONS = tslib_1.__assign( + tslib_1.__assign({}, core_2.Integrations), + NodeIntegrations + ) + exports.Integrations = INTEGRATIONS + // We need to patch domain on the global __SENTRY__ object to make it work for node in cross-platform packages like + // @sentry/hub. If we don't do this, browser bundlers will have troubles resolving `require('domain')`. + var carrier = hub_1.getMainCarrier() + if (carrier.__SENTRY__) { + carrier.__SENTRY__.extensions = carrier.__SENTRY__.extensions || {} + carrier.__SENTRY__.extensions.domain = + carrier.__SENTRY__.extensions.domain || domain + } + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 29552: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var tslib_1 = __webpack_require__(75636) + var core_1 = __webpack_require__(79212) + var types_1 = __webpack_require__(83789) + var utils_1 = __webpack_require__(1620) + var util = __webpack_require__(31669) + /** Console module integration */ + var Console = /** @class */ (function () { + function Console() { + /** + * @inheritDoc + */ + this.name = Console.id + } + /** + * @inheritDoc + */ + Console.prototype.setupOnce = function () { + var e_1, _a + var consoleModule = __webpack_require__(57082) + try { + for ( + var _b = tslib_1.__values([ + 'debug', + 'info', + 'warn', + 'error', + 'log' + ]), + _c = _b.next(); + !_c.done; + _c = _b.next() + ) { + var level = _c.value + utils_1.fill(consoleModule, level, createConsoleWrapper(level)) + } + } catch (e_1_1) { + e_1 = { error: e_1_1 } + } finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b) + } finally { + if (e_1) throw e_1.error + } + } + } + /** + * @inheritDoc + */ + Console.id = 'Console' + return Console + })() + exports.Console = Console + /** + * Wrapper function that'll be used for every console level + */ + function createConsoleWrapper(level) { + return function consoleWrapper(originalConsoleMethod) { + var sentryLevel + switch (level) { + case 'debug': + sentryLevel = types_1.Severity.Debug + break + case 'error': + sentryLevel = types_1.Severity.Error + break + case 'info': + sentryLevel = types_1.Severity.Info + break + case 'warn': + sentryLevel = types_1.Severity.Warning + break + default: + sentryLevel = types_1.Severity.Log + } + return function () { + if (core_1.getCurrentHub().getIntegration(Console)) { + core_1.getCurrentHub().addBreadcrumb( + { + category: 'console', + level: sentryLevel, + message: util.format.apply(undefined, arguments) + }, + { + input: tslib_1.__spread(arguments), + level: level + } + ) + } + originalConsoleMethod.apply(this, arguments) + } + } + } + //# sourceMappingURL=console.js.map + + /***/ + }, + + /***/ 76280: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var core_1 = __webpack_require__(79212) + var utils_1 = __webpack_require__(1620) + var NODE_VERSION = utils_1.parseSemver(process.versions.node) + /** http module integration */ + var Http = /** @class */ (function () { + /** + * @inheritDoc + */ + function Http(options) { + if (options === void 0) { + options = {} + } + /** + * @inheritDoc + */ + this.name = Http.id + this._breadcrumbs = + typeof options.breadcrumbs === 'undefined' + ? true + : options.breadcrumbs + this._tracing = + typeof options.tracing === 'undefined' ? false : options.tracing + } + /** + * @inheritDoc + */ + Http.prototype.setupOnce = function () { + // No need to instrument if we don't want to track anything + if (!this._breadcrumbs && !this._tracing) { + return + } + var wrappedHandlerMaker = _createWrappedHandlerMaker( + this._breadcrumbs, + this._tracing + ) + var httpModule = __webpack_require__(98605) + utils_1.fill(httpModule, 'get', wrappedHandlerMaker) + utils_1.fill(httpModule, 'request', wrappedHandlerMaker) + // NOTE: Prior to Node 9, `https` used internals of `http` module, thus we don't patch it. + // If we do, we'd get double breadcrumbs and double spans for `https` calls. + // It has been changed in Node 9, so for all versions equal and above, we patch `https` separately. + if (NODE_VERSION.major && NODE_VERSION.major > 8) { + var httpsModule = __webpack_require__(57211) + utils_1.fill(httpsModule, 'get', wrappedHandlerMaker) + utils_1.fill(httpsModule, 'request', wrappedHandlerMaker) + } + } + /** + * @inheritDoc + */ + Http.id = 'Http' + return Http + })() + exports.Http = Http + /** + * Function which creates a function which creates wrapped versions of internal `request` and `get` calls within `http` + * and `https` modules. (NB: Not a typo - this is a creator^2!) + * + * @param breadcrumbsEnabled Whether or not to record outgoing requests as breadcrumbs + * @param tracingEnabled Whether or not to record outgoing requests as tracing spans + * + * @returns A function which accepts the exiting handler and returns a wrapped handler + */ + function _createWrappedHandlerMaker(breadcrumbsEnabled, tracingEnabled) { + return function wrappedHandlerMaker(originalHandler) { + return function wrappedHandler(options) { + var requestUrl = extractUrl(options) + // we don't want to record requests to Sentry as either breadcrumbs or spans, so just use the original handler + if (isSentryRequest(requestUrl)) { + return originalHandler.apply(this, arguments) + } + var span + var transaction + var scope = core_1.getCurrentHub().getScope() + if (scope && tracingEnabled) { + transaction = scope.getTransaction() + if (transaction) { + span = transaction.startChild({ + description: + (typeof options === 'string' || !options.method + ? 'GET' + : options.method) + + ' ' + + requestUrl, + op: 'request' + }) + } + } + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + return originalHandler + .apply(this, arguments) + .once('response', function (res) { + if (breadcrumbsEnabled) { + addRequestBreadcrumb('response', requestUrl, this, res) + } + if (tracingEnabled && span) { + span.setHttpStatus(res.statusCode) + cleanDescription(options, this, span) + span.finish() + } + }) + .once('error', function () { + if (breadcrumbsEnabled) { + addRequestBreadcrumb('error', requestUrl, this) + } + if (tracingEnabled && span) { + span.setHttpStatus(500) + cleanDescription(options, this, span) + span.finish() + } + }) + } + } + } + /** + * Captures Breadcrumb based on provided request/response pair + */ + function addRequestBreadcrumb(event, url, req, res) { + if (!core_1.getCurrentHub().getIntegration(Http)) { + return + } + core_1.getCurrentHub().addBreadcrumb( + { + category: 'http', + data: { + method: req.method, + status_code: res && res.statusCode, + url: url + }, + type: 'http' + }, + { + event: event, + request: req, + response: res + } + ) + } + /** + * Assemble a URL to be used for breadcrumbs and spans. + * + * @param url URL string or object containing the component parts + * @returns Fully-formed URL + */ + function extractUrl(url) { + if (typeof url === 'string') { + return url + } + var protocol = url.protocol || '' + var hostname = url.hostname || url.host || '' + // Don't log standard :80 (http) and :443 (https) ports to reduce the noise + var port = + !url.port || url.port === 80 || url.port === 443 ? '' : ':' + url.port + var path = url.path ? url.path : '/' + // internal routes end up with too many slashes + return (protocol + '//' + hostname + port + path).replace('///', '/') + } + exports.extractUrl = extractUrl + /** + * Handle an edge case with urls in the span description. Runs just before the span closes because it relies on + * data from the response object. + * + * @param requestOptions Configuration data for the request + * @param response Response object + * @param span Span representing the request + */ + function cleanDescription(requestOptions, response, span) { + // There are some libraries which don't pass the request protocol in the options object, so attempt to retrieve it + // from the response and run the URL processing again. We only do this in the presence of a (non-empty) host value, + // because if we're missing both, it's likely we're dealing with an internal route, in which case we don't want to be + // jamming a random `http:` on the front of it. + if ( + typeof requestOptions !== 'string' && + !Object.keys(requestOptions).includes('protocol') && + requestOptions.host + ) { + // Neither http.IncomingMessage nor any of its ancestors have an `agent` property in their type definitions, and + // http.Agent doesn't have a `protocol` property in its type definition. Nonetheless, at least one request library + // (superagent) arranges things that way, so might as well give it a shot. + try { + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any + requestOptions.protocol = response.agent.protocol + span.description = + (requestOptions.method || 'GET') + + ' ' + + extractUrl(requestOptions) + } catch (error) { + // well, we tried + } + } + } + /** + * Checks whether given url points to Sentry server + * @param url url to verify + */ + function isSentryRequest(url) { + var client = core_1.getCurrentHub().getClient() + if (!url || !client) { + return false + } + var dsn = client.getDsn() + if (!dsn) { + return false + } + return url.indexOf(dsn.host) !== -1 + } + //# sourceMappingURL=http.js.map + + /***/ + }, + + /***/ 72310: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var console_1 = __webpack_require__(29552) + exports.Console = console_1.Console + var http_1 = __webpack_require__(76280) + exports.Http = http_1.Http + var onuncaughtexception_1 = __webpack_require__(50443) + exports.OnUncaughtException = onuncaughtexception_1.OnUncaughtException + var onunhandledrejection_1 = __webpack_require__(87344) + exports.OnUnhandledRejection = onunhandledrejection_1.OnUnhandledRejection + var linkederrors_1 = __webpack_require__(70208) + exports.LinkedErrors = linkederrors_1.LinkedErrors + var modules_1 = __webpack_require__(90046) + exports.Modules = modules_1.Modules + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 70208: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var tslib_1 = __webpack_require__(75636) + var core_1 = __webpack_require__(79212) + var utils_1 = __webpack_require__(1620) + var parsers_1 = __webpack_require__(19090) + var DEFAULT_KEY = 'cause' + var DEFAULT_LIMIT = 5 + /** Adds SDK info to an event. */ + var LinkedErrors = /** @class */ (function () { + /** + * @inheritDoc + */ + function LinkedErrors(options) { + if (options === void 0) { + options = {} + } + /** + * @inheritDoc + */ + this.name = LinkedErrors.id + this._key = options.key || DEFAULT_KEY + this._limit = options.limit || DEFAULT_LIMIT + } + /** + * @inheritDoc + */ + LinkedErrors.prototype.setupOnce = function () { + core_1.addGlobalEventProcessor(function (event, hint) { + var self = core_1.getCurrentHub().getIntegration(LinkedErrors) + if (self) { + var handler = self._handler && self._handler.bind(self) + return typeof handler === 'function' + ? handler(event, hint) + : event + } + return event + }) + } + /** + * @inheritDoc + */ + LinkedErrors.prototype._handler = function (event, hint) { + var _this = this + if ( + !event.exception || + !event.exception.values || + !hint || + !utils_1.isInstanceOf(hint.originalException, Error) + ) { + return utils_1.SyncPromise.resolve(event) + } + return new utils_1.SyncPromise(function (resolve) { + _this + ._walkErrorTree(hint.originalException, _this._key) + .then(function (linkedErrors) { + if (event && event.exception && event.exception.values) { + event.exception.values = tslib_1.__spread( + linkedErrors, + event.exception.values + ) + } + resolve(event) + }) + .then(null, function () { + resolve(event) + }) + }) + } + /** + * @inheritDoc + */ + LinkedErrors.prototype._walkErrorTree = function (error, key, stack) { + var _this = this + if (stack === void 0) { + stack = [] + } + if ( + !utils_1.isInstanceOf(error[key], Error) || + stack.length + 1 >= this._limit + ) { + return utils_1.SyncPromise.resolve(stack) + } + return new utils_1.SyncPromise(function (resolve, reject) { + parsers_1 + .getExceptionFromError(error[key]) + .then(function (exception) { + _this + ._walkErrorTree( + error[key], + key, + tslib_1.__spread([exception], stack) + ) + .then(resolve) + .then(null, function () { + reject() + }) + }) + .then(null, function () { + reject() + }) + }) + } + /** + * @inheritDoc + */ + LinkedErrors.id = 'LinkedErrors' + return LinkedErrors + })() + exports.LinkedErrors = LinkedErrors + //# sourceMappingURL=linkederrors.js.map + + /***/ + }, + + /***/ 90046: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var tslib_1 = __webpack_require__(75636) + var fs_1 = __webpack_require__(35747) + var path_1 = __webpack_require__(85622) + var moduleCache + /** Extract information about package.json modules */ + function collectModules() { + var mainPaths = (require.main && require.main.paths) || [] + var paths = require.cache ? Object.keys(require.cache) : [] + var infos = {} + var seen = {} + paths.forEach(function (path) { + var dir = path + /** Traverse directories upward in the search of package.json file */ + var updir = function () { + var orig = dir + dir = path_1.dirname(orig) + if (!dir || orig === dir || seen[orig]) { + return undefined + } + if (mainPaths.indexOf(dir) < 0) { + return updir() + } + var pkgfile = path_1.join(orig, 'package.json') + seen[orig] = true + if (!fs_1.existsSync(pkgfile)) { + return updir() + } + try { + var info = JSON.parse(fs_1.readFileSync(pkgfile, 'utf8')) + infos[info.name] = info.version + } catch (_oO) { + // no-empty + } + } + updir() + }) + return infos + } + /** Add node modules / packages to the event */ + var Modules = /** @class */ (function () { + function Modules() { + /** + * @inheritDoc + */ + this.name = Modules.id + } + /** + * @inheritDoc + */ + Modules.prototype.setupOnce = function ( + addGlobalEventProcessor, + getCurrentHub + ) { + var _this = this + addGlobalEventProcessor(function (event) { + if (!getCurrentHub().getIntegration(Modules)) { + return event + } + return tslib_1.__assign(tslib_1.__assign({}, event), { + modules: _this._getModules() + }) + }) + } + /** Fetches the list of modules and the versions loaded by the entry file for your node.js app. */ + Modules.prototype._getModules = function () { + if (!moduleCache) { + moduleCache = collectModules() + } + return moduleCache + } + /** + * @inheritDoc + */ + Modules.id = 'Modules' + return Modules + })() + exports.Modules = Modules + //# sourceMappingURL=modules.js.map + + /***/ + }, + + /***/ 50443: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var core_1 = __webpack_require__(79212) + var types_1 = __webpack_require__(83789) + var utils_1 = __webpack_require__(1620) + var handlers_1 = __webpack_require__(45400) + /** Global Promise Rejection handler */ + var OnUncaughtException = /** @class */ (function () { + /** + * @inheritDoc + */ + function OnUncaughtException(_options) { + if (_options === void 0) { + _options = {} + } + this._options = _options + /** + * @inheritDoc + */ + this.name = OnUncaughtException.id + /** + * @inheritDoc + */ + this.handler = this._makeErrorHandler() + } + /** + * @inheritDoc + */ + OnUncaughtException.prototype.setupOnce = function () { + global.process.on('uncaughtException', this.handler.bind(this)) + } + /** + * @hidden + */ + OnUncaughtException.prototype._makeErrorHandler = function () { + var _this = this + var timeout = 2000 + var caughtFirstError = false + var caughtSecondError = false + var calledFatalError = false + var firstError + return function (error) { + var onFatalError = handlers_1.logAndExitProcess + var client = core_1.getCurrentHub().getClient() + if (_this._options.onFatalError) { + // eslint-disable-next-line @typescript-eslint/unbound-method + onFatalError = _this._options.onFatalError + } else if (client && client.getOptions().onFatalError) { + // eslint-disable-next-line @typescript-eslint/unbound-method + onFatalError = client.getOptions().onFatalError + } + if (!caughtFirstError) { + var hub_1 = core_1.getCurrentHub() + // this is the first uncaught error and the ultimate reason for shutting down + // we want to do absolutely everything possible to ensure it gets captured + // also we want to make sure we don't go recursion crazy if more errors happen after this one + firstError = error + caughtFirstError = true + if (hub_1.getIntegration(OnUncaughtException)) { + hub_1.withScope(function (scope) { + scope.setLevel(types_1.Severity.Fatal) + hub_1.captureException(error, { originalException: error }) + if (!calledFatalError) { + calledFatalError = true + onFatalError(error) + } + }) + } else { + if (!calledFatalError) { + calledFatalError = true + onFatalError(error) + } + } + } else if (calledFatalError) { + // we hit an error *after* calling onFatalError - pretty boned at this point, just shut it down + utils_1.logger.warn( + 'uncaught exception after calling fatal error shutdown callback - this is bad! forcing shutdown' + ) + handlers_1.logAndExitProcess(error) + } else if (!caughtSecondError) { + // two cases for how we can hit this branch: + // - capturing of first error blew up and we just caught the exception from that + // - quit trying to capture, proceed with shutdown + // - a second independent error happened while waiting for first error to capture + // - want to avoid causing premature shutdown before first error capture finishes + // it's hard to immediately tell case 1 from case 2 without doing some fancy/questionable domain stuff + // so let's instead just delay a bit before we proceed with our action here + // in case 1, we just wait a bit unnecessarily but ultimately do the same thing + // in case 2, the delay hopefully made us wait long enough for the capture to finish + // two potential nonideal outcomes: + // nonideal case 1: capturing fails fast, we sit around for a few seconds unnecessarily before proceeding correctly by calling onFatalError + // nonideal case 2: case 2 happens, 1st error is captured but slowly, timeout completes before capture and we treat second error as the sendErr of (nonexistent) failure from trying to capture first error + // note that after hitting this branch, we might catch more errors where (caughtSecondError && !calledFatalError) + // we ignore them - they don't matter to us, we're just waiting for the second error timeout to finish + caughtSecondError = true + setTimeout(function () { + if (!calledFatalError) { + // it was probably case 1, let's treat err as the sendErr and call onFatalError + calledFatalError = true + onFatalError(firstError, error) + } else { + // it was probably case 2, our first error finished capturing while we waited, cool, do nothing + } + }, timeout) // capturing could take at least sendTimeout to fail, plus an arbitrary second for how long it takes to collect surrounding source etc + } + } + } + /** + * @inheritDoc + */ + OnUncaughtException.id = 'OnUncaughtException' + return OnUncaughtException + })() + exports.OnUncaughtException = OnUncaughtException + //# sourceMappingURL=onuncaughtexception.js.map + + /***/ + }, + + /***/ 87344: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var core_1 = __webpack_require__(79212) + var utils_1 = __webpack_require__(1620) + var handlers_1 = __webpack_require__(45400) + /** Global Promise Rejection handler */ + var OnUnhandledRejection = /** @class */ (function () { + /** + * @inheritDoc + */ + function OnUnhandledRejection(_options) { + if (_options === void 0) { + _options = { mode: 'warn' } + } + this._options = _options + /** + * @inheritDoc + */ + this.name = OnUnhandledRejection.id + } + /** + * @inheritDoc + */ + OnUnhandledRejection.prototype.setupOnce = function () { + global.process.on( + 'unhandledRejection', + this.sendUnhandledPromise.bind(this) + ) + } + /** + * Send an exception with reason + * @param reason string + * @param promise promise + */ + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any + OnUnhandledRejection.prototype.sendUnhandledPromise = function ( + reason, + promise + ) { + var hub = core_1.getCurrentHub() + if (!hub.getIntegration(OnUnhandledRejection)) { + this._handleRejection(reason) + return + } + /* eslint-disable @typescript-eslint/no-unsafe-member-access */ + var context = (promise.domain && promise.domain.sentryContext) || {} + hub.withScope(function (scope) { + scope.setExtra('unhandledPromiseRejection', true) + // Preserve backwards compatibility with raven-node for now + if (context.user) { + scope.setUser(context.user) + } + if (context.tags) { + scope.setTags(context.tags) + } + if (context.extra) { + scope.setExtras(context.extra) + } + hub.captureException(reason, { originalException: promise }) + }) + /* eslint-disable @typescript-eslint/no-unsafe-member-access */ + this._handleRejection(reason) + } + /** + * Handler for `mode` option + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + OnUnhandledRejection.prototype._handleRejection = function (reason) { + // https://github.com/nodejs/node/blob/7cf6f9e964aa00772965391c23acda6d71972a9a/lib/internal/process/promises.js#L234-L240 + var rejectionWarning = + 'This error originated either by ' + + 'throwing inside of an async function without a catch block, ' + + 'or by rejecting a promise which was not handled with .catch().' + + ' The promise rejected with the reason:' + /* eslint-disable no-console */ + if (this._options.mode === 'warn') { + utils_1.consoleSandbox(function () { + console.warn(rejectionWarning) + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + console.error(reason && reason.stack ? reason.stack : reason) + }) + } else if (this._options.mode === 'strict') { + utils_1.consoleSandbox(function () { + console.warn(rejectionWarning) + }) + handlers_1.logAndExitProcess(reason) + } + /* eslint-enable no-console */ + } + /** + * @inheritDoc + */ + OnUnhandledRejection.id = 'OnUnhandledRejection' + return OnUnhandledRejection + })() + exports.OnUnhandledRejection = OnUnhandledRejection + //# sourceMappingURL=onunhandledrejection.js.map + + /***/ + }, + + /***/ 19090: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var utils_1 = __webpack_require__(1620) + var fs_1 = __webpack_require__(35747) + var lru_map_1 = __webpack_require__(18424) + var stacktrace = __webpack_require__(46276) + var DEFAULT_LINES_OF_CONTEXT = 7 + var FILE_CONTENT_CACHE = new lru_map_1.LRUMap(100) + /** + * Resets the file cache. Exists for testing purposes. + * @hidden + */ + function resetFileContentCache() { + FILE_CONTENT_CACHE.clear() + } + exports.resetFileContentCache = resetFileContentCache + /** JSDoc */ + function getFunction(frame) { + try { + return ( + frame.functionName || + frame.typeName + '.' + (frame.methodName || '') + ) + } catch (e) { + // This seems to happen sometimes when using 'use strict', + // stemming from `getTypeName`. + // [TypeError: Cannot read property 'constructor' of undefined] + return '' + } + } + var mainModule = + ((require.main && + require.main.filename && + utils_1.dirname(require.main.filename)) || + global.process.cwd()) + '/' + /** JSDoc */ + function getModule(filename, base) { + if (!base) { + // eslint-disable-next-line no-param-reassign + base = mainModule + } + // It's specifically a module + var file = utils_1.basename(filename, '.js') + // eslint-disable-next-line no-param-reassign + filename = utils_1.dirname(filename) + var n = filename.lastIndexOf('/node_modules/') + if (n > -1) { + // /node_modules/ is 14 chars + return filename.substr(n + 14).replace(/\//g, '.') + ':' + file + } + // Let's see if it's a part of the main module + // To be a part of main module, it has to share the same base + n = (filename + '/').lastIndexOf(base, 0) + if (n === 0) { + var moduleName = filename.substr(base.length).replace(/\//g, '.') + if (moduleName) { + moduleName += ':' + } + moduleName += file + return moduleName + } + return file + } + /** + * This function reads file contents and caches them in a global LRU cache. + * Returns a Promise filepath => content array for all files that we were able to read. + * + * @param filenames Array of filepaths to read content from. + */ + function readSourceFiles(filenames) { + // we're relying on filenames being de-duped already + if (filenames.length === 0) { + return utils_1.SyncPromise.resolve({}) + } + return new utils_1.SyncPromise(function (resolve) { + var sourceFiles = {} + var count = 0 + var _loop_1 = function (i) { + var filename = filenames[i] + var cache = FILE_CONTENT_CACHE.get(filename) + // We have a cache hit + if (cache !== undefined) { + // If it's not null (which means we found a file and have a content) + // we set the content and return it later. + if (cache !== null) { + sourceFiles[filename] = cache + } + // eslint-disable-next-line no-plusplus + count++ + // In any case we want to skip here then since we have a content already or we couldn't + // read the file and don't want to try again. + if (count === filenames.length) { + resolve(sourceFiles) + } + return 'continue' + } + fs_1.readFile(filename, function (err, data) { + var content = err ? null : data.toString() + sourceFiles[filename] = content + // We always want to set the cache, even to null which means there was an error reading the file. + // We do not want to try to read the file again. + FILE_CONTENT_CACHE.set(filename, content) + // eslint-disable-next-line no-plusplus + count++ + if (count === filenames.length) { + resolve(sourceFiles) + } + }) + } + // eslint-disable-next-line @typescript-eslint/prefer-for-of + for (var i = 0; i < filenames.length; i++) { + _loop_1(i) + } + }) + } + /** + * @hidden + */ + function extractStackFromError(error) { + var stack = stacktrace.parse(error) + if (!stack) { + return [] + } + return stack + } + exports.extractStackFromError = extractStackFromError + /** + * @hidden + */ + function parseStack(stack, options) { + var filesToRead = [] + var linesOfContext = + options && options.frameContextLines !== undefined + ? options.frameContextLines + : DEFAULT_LINES_OF_CONTEXT + var frames = stack.map(function (frame) { + var parsedFrame = { + colno: frame.columnNumber, + filename: frame.fileName || '', + function: getFunction(frame), + lineno: frame.lineNumber + } + var isInternal = + frame.native || + (parsedFrame.filename && + !parsedFrame.filename.startsWith('/') && + !parsedFrame.filename.startsWith('.') && + parsedFrame.filename.indexOf(':\\') !== 1) + // in_app is all that's not an internal Node function or a module within node_modules + // note that isNative appears to return true even for node core libraries + // see https://github.com/getsentry/raven-node/issues/176 + parsedFrame.in_app = + !isInternal && + parsedFrame.filename !== undefined && + parsedFrame.filename.indexOf('node_modules/') === -1 + // Extract a module name based on the filename + if (parsedFrame.filename) { + parsedFrame.module = getModule(parsedFrame.filename) + if ( + !isInternal && + linesOfContext > 0 && + filesToRead.indexOf(parsedFrame.filename) === -1 + ) { + filesToRead.push(parsedFrame.filename) + } + } + return parsedFrame + }) + // We do an early return if we do not want to fetch context liens + if (linesOfContext <= 0) { + return utils_1.SyncPromise.resolve(frames) + } + try { + return addPrePostContext(filesToRead, frames, linesOfContext) + } catch (_) { + // This happens in electron for example where we are not able to read files from asar. + // So it's fine, we recover be just returning all frames without pre/post context. + return utils_1.SyncPromise.resolve(frames) + } + } + exports.parseStack = parseStack + /** + * This function tries to read the source files + adding pre and post context (source code) + * to a frame. + * @param filesToRead string[] of filepaths + * @param frames StackFrame[] containg all frames + */ + function addPrePostContext(filesToRead, frames, linesOfContext) { + return new utils_1.SyncPromise(function (resolve) { + return readSourceFiles(filesToRead).then(function (sourceFiles) { + var result = frames.map(function (frame) { + if (frame.filename && sourceFiles[frame.filename]) { + try { + var lines = sourceFiles[frame.filename].split('\n') + utils_1.addContextToFrame(lines, frame, linesOfContext) + } catch (e) { + // anomaly, being defensive in case + // unlikely to ever happen in practice but can definitely happen in theory + } + } + return frame + }) + resolve(result) + }) + }) + } + /** + * @hidden + */ + function getExceptionFromError(error, options) { + var name = error.name || error.constructor.name + var stack = extractStackFromError(error) + return new utils_1.SyncPromise(function (resolve) { + return parseStack(stack, options).then(function (frames) { + var result = { + stacktrace: { + frames: prepareFramesForEvent(frames) + }, + type: name, + value: error.message + } + resolve(result) + }) + }) + } + exports.getExceptionFromError = getExceptionFromError + /** + * @hidden + */ + function parseError(error, options) { + return new utils_1.SyncPromise(function (resolve) { + return getExceptionFromError(error, options).then(function ( + exception + ) { + resolve({ + exception: { + values: [exception] + } + }) + }) + }) + } + exports.parseError = parseError + /** + * @hidden + */ + function prepareFramesForEvent(stack) { + if (!stack || !stack.length) { + return [] + } + var localStack = stack + var firstFrameFunction = localStack[0].function || '' + if ( + firstFrameFunction.indexOf('captureMessage') !== -1 || + firstFrameFunction.indexOf('captureException') !== -1 + ) { + localStack = localStack.slice(1) + } + // The frame where the crash happened, should be the last entry in the array + return localStack.reverse() + } + exports.prepareFramesForEvent = prepareFramesForEvent + //# sourceMappingURL=parsers.js.map + + /***/ + }, + + /***/ 38836: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var tslib_1 = __webpack_require__(75636) + var core_1 = __webpack_require__(79212) + var hub_1 = __webpack_require__(6393) + var utils_1 = __webpack_require__(1620) + var domain = __webpack_require__(85229) + var client_1 = __webpack_require__(86147) + var integrations_1 = __webpack_require__(72310) + exports.defaultIntegrations = [ + // Common + new core_1.Integrations.InboundFilters(), + new core_1.Integrations.FunctionToString(), + // Native Wrappers + new integrations_1.Console(), + new integrations_1.Http(), + // Global Handlers + new integrations_1.OnUncaughtException(), + new integrations_1.OnUnhandledRejection(), + // Misc + new integrations_1.LinkedErrors() + ] + /** + * The Sentry Node SDK Client. + * + * To use this SDK, call the {@link init} function as early as possible in the + * main entry module. To set context information or send manual events, use the + * provided methods. + * + * @example + * ``` + * + * const { init } = require('@sentry/node'); + * + * init({ + * dsn: '__DSN__', + * // ... + * }); + * ``` + * + * @example + * ``` + * + * const { configureScope } = require('@sentry/node'); + * configureScope((scope: Scope) => { + * scope.setExtra({ battery: 0.7 }); + * scope.setTag({ user_mode: 'admin' }); + * scope.setUser({ id: '4711' }); + * }); + * ``` + * + * @example + * ``` + * + * const { addBreadcrumb } = require('@sentry/node'); + * addBreadcrumb({ + * message: 'My Breadcrumb', + * // ... + * }); + * ``` + * + * @example + * ``` + * + * const Sentry = require('@sentry/node'); + * Sentry.captureMessage('Hello, world!'); + * Sentry.captureException(new Error('Good bye')); + * Sentry.captureEvent({ + * message: 'Manual', + * stacktrace: [ + * // ... + * ], + * }); + * ``` + * + * @see {@link NodeOptions} for documentation on configuration options. + */ + function init(options) { + if (options === void 0) { + options = {} + } + if (options.defaultIntegrations === undefined) { + options.defaultIntegrations = exports.defaultIntegrations + } + if (options.dsn === undefined && process.env.SENTRY_DSN) { + options.dsn = process.env.SENTRY_DSN + } + if (options.release === undefined) { + var global_1 = utils_1.getGlobalObject() + // Prefer env var over global + if (process.env.SENTRY_RELEASE) { + options.release = process.env.SENTRY_RELEASE + } + // This supports the variable that sentry-webpack-plugin injects + else if (global_1.SENTRY_RELEASE && global_1.SENTRY_RELEASE.id) { + options.release = global_1.SENTRY_RELEASE.id + } + } + if ( + options.environment === undefined && + process.env.SENTRY_ENVIRONMENT + ) { + options.environment = process.env.SENTRY_ENVIRONMENT + } + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any + if (domain.active) { + hub_1.setHubOnCarrier(hub_1.getMainCarrier(), core_1.getCurrentHub()) + } + core_1.initAndBind(client_1.NodeClient, options) + } + exports.init = init + /** + * This is the getter for lastEventId. + * + * @returns The last event id of a captured event. + */ + function lastEventId() { + return core_1.getCurrentHub().lastEventId() + } + exports.lastEventId = lastEventId + /** + * A promise that resolves when all current events have been sent. + * If you provide a timeout and the queue takes longer to drain the promise returns false. + * + * @param timeout Maximum time in ms the client should wait. + */ + function flush(timeout) { + return tslib_1.__awaiter(this, void 0, void 0, function () { + var client + return tslib_1.__generator(this, function (_a) { + client = core_1.getCurrentHub().getClient() + if (client) { + return [2 /*return*/, client.flush(timeout)] + } + return [2 /*return*/, Promise.reject(false)] + }) + }) + } + exports.flush = flush + /** + * A promise that resolves when all current events have been sent. + * If you provide a timeout and the queue takes longer to drain the promise returns false. + * + * @param timeout Maximum time in ms the client should wait. + */ + function close(timeout) { + return tslib_1.__awaiter(this, void 0, void 0, function () { + var client + return tslib_1.__generator(this, function (_a) { + client = core_1.getCurrentHub().getClient() + if (client) { + return [2 /*return*/, client.close(timeout)] + } + return [2 /*return*/, Promise.reject(false)] + }) + }) + } + exports.close = close + //# sourceMappingURL=sdk.js.map + + /***/ + }, + + /***/ 46276: /***/ (__unused_webpack_module, exports) => { + /** + * stack-trace - Parses node.js stack traces + * + * This was originally forked to fix this issue: + * https://github.com/felixge/node-stack-trace/issues/31 + * + * Mar 19,2019 - #4fd379e + * + * https://github.com/felixge/node-stack-trace/ + * @license MIT + */ + Object.defineProperty(exports, '__esModule', { value: true }) + /** Extracts StackFrames fron the Error */ + function parse(err) { + if (!err.stack) { + return [] + } + var lines = err.stack.split('\n').slice(1) + return lines + .map(function (line) { + if (line.match(/^\s*[-]{4,}$/)) { + return { + columnNumber: null, + fileName: line, + functionName: null, + lineNumber: null, + methodName: null, + native: null, + typeName: null + } + } + var lineMatch = line.match( + /at (?:(.+?)\s+\()?(?:(.+?):(\d+)(?::(\d+))?|([^)]+))\)?/ + ) + if (!lineMatch) { + return undefined + } + var object = null + var method = null + var functionName = null + var typeName = null + var methodName = null + var isNative = lineMatch[5] === 'native' + if (lineMatch[1]) { + functionName = lineMatch[1] + var methodStart = functionName.lastIndexOf('.') + if (functionName[methodStart - 1] === '.') { + // eslint-disable-next-line no-plusplus + methodStart-- + } + if (methodStart > 0) { + object = functionName.substr(0, methodStart) + method = functionName.substr(methodStart + 1) + var objectEnd = object.indexOf('.Module') + if (objectEnd > 0) { + functionName = functionName.substr(objectEnd + 1) + object = object.substr(0, objectEnd) + } + } + typeName = null + } + if (method) { + typeName = object + methodName = method + } + if (method === '') { + methodName = null + functionName = null + } + var properties = { + columnNumber: parseInt(lineMatch[4], 10) || null, + fileName: lineMatch[2] || null, + functionName: functionName, + lineNumber: parseInt(lineMatch[3], 10) || null, + methodName: methodName, + native: isNative, + typeName: typeName + } + return properties + }) + .filter(function (callSite) { + return !!callSite + }) + } + exports.parse = parse + //# sourceMappingURL=stacktrace.js.map + + /***/ + }, + + /***/ 43240: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var tslib_1 = __webpack_require__(75636) + var core_1 = __webpack_require__(79212) + var types_1 = __webpack_require__(83789) + var utils_1 = __webpack_require__(1620) + var fs = __webpack_require__(35747) + var url = __webpack_require__(78835) + var version_1 = __webpack_require__(31271) + /** Base Transport class implementation */ + var BaseTransport = /** @class */ (function () { + /** Create instance and set this.dsn */ + function BaseTransport(options) { + this.options = options + /** A simple buffer holding all requests. */ + this._buffer = new utils_1.PromiseBuffer(30) + /** Locks transport after receiving 429 response */ + this._disabledUntil = new Date(Date.now()) + this._api = new core_1.API(options.dsn) + } + /** + * @inheritDoc + */ + BaseTransport.prototype.sendEvent = function (_) { + throw new utils_1.SentryError( + 'Transport Class has to implement `sendEvent` method.' + ) + } + /** + * @inheritDoc + */ + BaseTransport.prototype.close = function (timeout) { + return this._buffer.drain(timeout) + } + /** Returns a build request option object used by request */ + BaseTransport.prototype._getRequestOptions = function (uri) { + var headers = tslib_1.__assign( + tslib_1.__assign( + {}, + this._api.getRequestHeaders( + version_1.SDK_NAME, + version_1.SDK_VERSION + ) + ), + this.options.headers + ) + var hostname = uri.hostname, + pathname = uri.pathname, + port = uri.port, + protocol = uri.protocol + // See https://github.com/nodejs/node/blob/38146e717fed2fabe3aacb6540d839475e0ce1c6/lib/internal/url.js#L1268-L1290 + // We ignore the query string on purpose + var path = '' + pathname + return tslib_1.__assign( + { + agent: this.client, + headers: headers, + hostname: hostname, + method: 'POST', + path: path, + port: port, + protocol: protocol + }, + this.options.caCerts && { + ca: fs.readFileSync(this.options.caCerts) + } + ) + } + /** JSDoc */ + BaseTransport.prototype._sendWithModule = function (httpModule, event) { + return tslib_1.__awaiter(this, void 0, void 0, function () { + var _this = this + return tslib_1.__generator(this, function (_a) { + if (new Date(Date.now()) < this._disabledUntil) { + return [ + 2 /*return*/, + Promise.reject( + new utils_1.SentryError( + 'Transport locked till ' + + this._disabledUntil + + ' due to too many requests.' + ) + ) + ] + } + if (!this._buffer.isReady()) { + return [ + 2 /*return*/, + Promise.reject( + new utils_1.SentryError( + 'Not adding Promise due to buffer limit reached.' + ) + ) + ] + } + return [ + 2 /*return*/, + this._buffer.add( + new Promise(function (resolve, reject) { + var sentryReq = core_1.eventToSentryRequest( + event, + _this._api + ) + var options = _this._getRequestOptions( + new url.URL(sentryReq.url) + ) + var req = httpModule.request(options, function (res) { + var statusCode = res.statusCode || 500 + var status = types_1.Status.fromHttpCode(statusCode) + res.setEncoding('utf8') + if (status === types_1.Status.Success) { + resolve({ status: status }) + } else { + if (status === types_1.Status.RateLimit) { + var now = Date.now() + /** + * "Key-value pairs of header names and values. Header names are lower-cased." + * https://nodejs.org/api/http.html#http_message_headers + */ + var retryAfterHeader = res.headers + ? res.headers['retry-after'] + : '' + retryAfterHeader = Array.isArray(retryAfterHeader) + ? retryAfterHeader[0] + : retryAfterHeader + _this._disabledUntil = new Date( + now + + utils_1.parseRetryAfterHeader( + now, + retryAfterHeader + ) + ) + utils_1.logger.warn( + 'Too many requests, backing off till: ' + + _this._disabledUntil + ) + } + var rejectionMessage = 'HTTP Error (' + statusCode + ')' + if (res.headers && res.headers['x-sentry-error']) { + rejectionMessage += + ': ' + res.headers['x-sentry-error'] + } + reject(new utils_1.SentryError(rejectionMessage)) + } + // Force the socket to drain + res.on('data', function () { + // Drain + }) + res.on('end', function () { + // Drain + }) + }) + req.on('error', reject) + req.end(sentryReq.body) + }) + ) + ] + }) + }) + } + return BaseTransport + })() + exports.BaseTransport = BaseTransport + //# sourceMappingURL=base.js.map + + /***/ + }, + + /***/ 84490: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var tslib_1 = __webpack_require__(75636) + var utils_1 = __webpack_require__(1620) + var http = __webpack_require__(98605) + var base_1 = __webpack_require__(43240) + /** Node http module transport */ + var HTTPTransport = /** @class */ (function (_super) { + tslib_1.__extends(HTTPTransport, _super) + /** Create a new instance and set this.agent */ + function HTTPTransport(options) { + var _this = _super.call(this, options) || this + _this.options = options + var proxy = options.httpProxy || process.env.http_proxy + _this.module = http + _this.client = proxy + ? new (__webpack_require__(77219))(proxy) + : new http.Agent({ + keepAlive: false, + maxSockets: 30, + timeout: 2000 + }) + return _this + } + /** + * @inheritDoc + */ + HTTPTransport.prototype.sendEvent = function (event) { + if (!this.module) { + throw new utils_1.SentryError( + 'No module available in HTTPTransport' + ) + } + return this._sendWithModule(this.module, event) + } + return HTTPTransport + })(base_1.BaseTransport) + exports.HTTPTransport = HTTPTransport + //# sourceMappingURL=http.js.map + + /***/ + }, + + /***/ 68621: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var tslib_1 = __webpack_require__(75636) + var utils_1 = __webpack_require__(1620) + var https = __webpack_require__(57211) + var base_1 = __webpack_require__(43240) + /** Node https module transport */ + var HTTPSTransport = /** @class */ (function (_super) { + tslib_1.__extends(HTTPSTransport, _super) + /** Create a new instance and set this.agent */ + function HTTPSTransport(options) { + var _this = _super.call(this, options) || this + _this.options = options + var proxy = + options.httpsProxy || + options.httpProxy || + process.env.https_proxy || + process.env.http_proxy + _this.module = https + _this.client = proxy + ? new (__webpack_require__(77219))(proxy) + : new https.Agent({ + keepAlive: false, + maxSockets: 30, + timeout: 2000 + }) + return _this + } + /** + * @inheritDoc + */ + HTTPSTransport.prototype.sendEvent = function (event) { + if (!this.module) { + throw new utils_1.SentryError( + 'No module available in HTTPSTransport' + ) + } + return this._sendWithModule(this.module, event) + } + return HTTPSTransport + })(base_1.BaseTransport) + exports.HTTPSTransport = HTTPSTransport + //# sourceMappingURL=https.js.map + + /***/ + }, + + /***/ 21437: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var base_1 = __webpack_require__(43240) + exports.BaseTransport = base_1.BaseTransport + var http_1 = __webpack_require__(84490) + exports.HTTPTransport = http_1.HTTPTransport + var https_1 = __webpack_require__(68621) + exports.HTTPSTransport = https_1.HTTPSTransport + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 31271: /***/ (__unused_webpack_module, exports) => { + Object.defineProperty(exports, '__esModule', { value: true }) + exports.SDK_NAME = 'sentry.javascript.node' + exports.SDK_VERSION = '5.27.3' + //# sourceMappingURL=version.js.map + + /***/ + }, + + /***/ 81867: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var utils_1 = __webpack_require__(1620) + var spanstatus_1 = __webpack_require__(58522) + var utils_2 = __webpack_require__(31386) + var global = utils_1.getGlobalObject() + /** + * Add a listener that cancels and finishes a transaction when the global + * document is hidden. + */ + function registerBackgroundTabDetection() { + if (global && global.document) { + global.document.addEventListener('visibilitychange', function () { + var activeTransaction = utils_2.getActiveTransaction() + if (global.document.hidden && activeTransaction) { + utils_1.logger.log( + '[Tracing] Transaction: ' + + spanstatus_1.SpanStatus.Cancelled + + ' -> since tab moved to the background, op: ' + + activeTransaction.op + ) + // We should not set status if it is already set, this prevent important statuses like + // error or data loss from being overwritten on transaction. + if (!activeTransaction.status) { + activeTransaction.setStatus(spanstatus_1.SpanStatus.Cancelled) + } + activeTransaction.setTag('visibilitychange', 'document.hidden') + activeTransaction.finish() + } + }) + } else { + utils_1.logger.warn( + '[Tracing] Could not set up background tab detection due to lack of global document' + ) + } + } + exports.registerBackgroundTabDetection = registerBackgroundTabDetection + //# sourceMappingURL=backgroundtab.js.map + + /***/ + }, + + /***/ 33577: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var tslib_1 = __webpack_require__(75636) + var utils_1 = __webpack_require__(1620) + var hubextensions_1 = __webpack_require__(31409) + var idletransaction_1 = __webpack_require__(2171) + var spanstatus_1 = __webpack_require__(58522) + var utils_2 = __webpack_require__(31386) + var backgroundtab_1 = __webpack_require__(81867) + var metrics_1 = __webpack_require__(68451) + var request_1 = __webpack_require__(27854) + var router_1 = __webpack_require__(40348) + exports.DEFAULT_MAX_TRANSACTION_DURATION_SECONDS = 600 + var DEFAULT_BROWSER_TRACING_OPTIONS = tslib_1.__assign( + { + idleTimeout: idletransaction_1.DEFAULT_IDLE_TIMEOUT, + markBackgroundTransactions: true, + maxTransactionDuration: + exports.DEFAULT_MAX_TRANSACTION_DURATION_SECONDS, + routingInstrumentation: router_1.defaultRoutingInstrumentation, + startTransactionOnLocationChange: true, + startTransactionOnPageLoad: true + }, + request_1.defaultRequestInstrumentionOptions + ) + /** + * The Browser Tracing integration automatically instruments browser pageload/navigation + * actions as transactions, and captures requests, metrics and errors as spans. + * + * The integration can be configured with a variety of options, and can be extended to use + * any routing library. This integration uses {@see IdleTransaction} to create transactions. + */ + var BrowserTracing = /** @class */ (function () { + function BrowserTracing(_options) { + /** + * @inheritDoc + */ + this.name = BrowserTracing.id + this._metrics = new metrics_1.MetricsInstrumentation() + this._emitOptionsWarning = false + var tracingOrigins = + request_1.defaultRequestInstrumentionOptions.tracingOrigins + // NOTE: Logger doesn't work in constructors, as it's initialized after integrations instances + if ( + _options && + _options.tracingOrigins && + Array.isArray(_options.tracingOrigins) && + _options.tracingOrigins.length !== 0 + ) { + tracingOrigins = _options.tracingOrigins + } else { + this._emitOptionsWarning = true + } + this.options = tslib_1.__assign( + tslib_1.__assign( + tslib_1.__assign({}, DEFAULT_BROWSER_TRACING_OPTIONS), + _options + ), + { tracingOrigins: tracingOrigins } + ) + } + /** + * @inheritDoc + */ + BrowserTracing.prototype.setupOnce = function (_, getCurrentHub) { + var _this = this + this._getCurrentHub = getCurrentHub + if (this._emitOptionsWarning) { + utils_1.logger.warn( + '[Tracing] You need to define `tracingOrigins` in the options. Set an array of urls or patterns to trace.' + ) + utils_1.logger.warn( + '[Tracing] We added a reasonable default for you: ' + + request_1.defaultRequestInstrumentionOptions.tracingOrigins + ) + } + // eslint-disable-next-line @typescript-eslint/unbound-method + var _a = this.options, + routingInstrumentation = _a.routingInstrumentation, + startTransactionOnLocationChange = + _a.startTransactionOnLocationChange, + startTransactionOnPageLoad = _a.startTransactionOnPageLoad, + markBackgroundTransactions = _a.markBackgroundTransactions, + traceFetch = _a.traceFetch, + traceXHR = _a.traceXHR, + tracingOrigins = _a.tracingOrigins, + shouldCreateSpanForRequest = _a.shouldCreateSpanForRequest + routingInstrumentation( + function (context) { + return _this._createRouteTransaction(context) + }, + startTransactionOnPageLoad, + startTransactionOnLocationChange + ) + if (markBackgroundTransactions) { + backgroundtab_1.registerBackgroundTabDetection() + } + request_1.registerRequestInstrumentation({ + traceFetch: traceFetch, + traceXHR: traceXHR, + tracingOrigins: tracingOrigins, + shouldCreateSpanForRequest: shouldCreateSpanForRequest + }) + } + /** Create routing idle transaction. */ + BrowserTracing.prototype._createRouteTransaction = function (context) { + var _this = this + if (!this._getCurrentHub) { + utils_1.logger.warn( + '[Tracing] Did not create ' + + context.op + + ' transaction because _getCurrentHub is invalid.' + ) + return undefined + } + // eslint-disable-next-line @typescript-eslint/unbound-method + var _a = this.options, + beforeNavigate = _a.beforeNavigate, + idleTimeout = _a.idleTimeout, + maxTransactionDuration = _a.maxTransactionDuration + var parentContextFromHeader = + context.op === 'pageload' ? getHeaderContext() : undefined + var expandedContext = tslib_1.__assign( + tslib_1.__assign( + tslib_1.__assign({}, context), + parentContextFromHeader + ), + { trimEnd: true } + ) + var modifiedContext = + typeof beforeNavigate === 'function' + ? beforeNavigate(expandedContext) + : expandedContext + // For backwards compatibility reasons, beforeNavigate can return undefined to "drop" the transaction (prevent it + // from being sent to Sentry). + var finalContext = + modifiedContext === undefined + ? tslib_1.__assign(tslib_1.__assign({}, expandedContext), { + sampled: false + }) + : modifiedContext + if (finalContext.sampled === false) { + utils_1.logger.log( + '[Tracing] Will not send ' + + finalContext.op + + ' transaction because of beforeNavigate.' + ) + } + var hub = this._getCurrentHub() + var idleTransaction = hubextensions_1.startIdleTransaction( + hub, + finalContext, + idleTimeout, + true + ) + utils_1.logger.log( + '[Tracing] Starting ' + finalContext.op + ' transaction on scope' + ) + idleTransaction.registerBeforeFinishCallback(function ( + transaction, + endTimestamp + ) { + _this._metrics.addPerformanceEntries(transaction) + adjustTransactionDuration( + utils_2.secToMs(maxTransactionDuration), + transaction, + endTimestamp + ) + }) + return idleTransaction + } + /** + * @inheritDoc + */ + BrowserTracing.id = 'BrowserTracing' + return BrowserTracing + })() + exports.BrowserTracing = BrowserTracing + /** + * Gets transaction context from a sentry-trace meta. + * + * @returns Transaction context data from the header or undefined if there's no header or the header is malformed + */ + function getHeaderContext() { + var header = getMetaContent('sentry-trace') + if (header) { + return utils_2.extractTraceparentData(header) + } + return undefined + } + exports.getHeaderContext = getHeaderContext + /** Returns the value of a meta tag */ + function getMetaContent(metaName) { + var el = document.querySelector('meta[name=' + metaName + ']') + return el ? el.getAttribute('content') : null + } + exports.getMetaContent = getMetaContent + /** Adjusts transaction value based on max transaction duration */ + function adjustTransactionDuration( + maxDuration, + transaction, + endTimestamp + ) { + var diff = endTimestamp - transaction.startTimestamp + var isOutdatedTransaction = + endTimestamp && (diff > maxDuration || diff < 0) + if (isOutdatedTransaction) { + transaction.setStatus(spanstatus_1.SpanStatus.DeadlineExceeded) + transaction.setTag('maxTransactionDurationExceeded', 'true') + } + } + //# sourceMappingURL=browsertracing.js.map + + /***/ + }, + + /***/ 71425: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var browsertracing_1 = __webpack_require__(33577) + exports.BrowserTracing = browsertracing_1.BrowserTracing + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 68451: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var tslib_1 = __webpack_require__(75636) + var utils_1 = __webpack_require__(1620) + var utils_2 = __webpack_require__(31386) + var getCLS_1 = __webpack_require__(56982) + var getFID_1 = __webpack_require__(82496) + var getLCP_1 = __webpack_require__(99382) + var getTTFB_1 = __webpack_require__(55909) + var getFirstHidden_1 = __webpack_require__(88493) + var global = utils_1.getGlobalObject() + /** Class tracking metrics */ + var MetricsInstrumentation = /** @class */ (function () { + function MetricsInstrumentation() { + this._measurements = {} + this._performanceCursor = 0 + if (global && global.performance) { + if (global.performance.mark) { + global.performance.mark('sentry-tracing-init') + } + this._trackCLS() + this._trackLCP() + this._trackFID() + this._trackTTFB() + } + } + /** Add performance related spans to a transaction */ + MetricsInstrumentation.prototype.addPerformanceEntries = function ( + transaction + ) { + var _this = this + if ( + !global || + !global.performance || + !global.performance.getEntries || + !utils_1.browserPerformanceTimeOrigin + ) { + // Gatekeeper if performance API not available + return + } + utils_1.logger.log( + '[Tracing] Adding & adjusting spans using Performance API' + ) + var timeOrigin = utils_2.msToSec(utils_1.browserPerformanceTimeOrigin) + var entryScriptSrc + if (global.document) { + // eslint-disable-next-line @typescript-eslint/prefer-for-of + for (var i = 0; i < document.scripts.length; i++) { + // We go through all scripts on the page and look for 'data-entry' + // We remember the name and measure the time between this script finished loading and + // our mark 'sentry-tracing-init' + if (document.scripts[i].dataset.entry === 'true') { + entryScriptSrc = document.scripts[i].src + break + } + } + } + var entryScriptStartTimestamp + var tracingInitMarkStartTime + global.performance + .getEntries() + .slice(this._performanceCursor) + .forEach(function (entry) { + var startTime = utils_2.msToSec(entry.startTime) + var duration = utils_2.msToSec(entry.duration) + if ( + transaction.op === 'navigation' && + timeOrigin + startTime < transaction.startTimestamp + ) { + return + } + switch (entry.entryType) { + case 'navigation': + addNavigationSpans(transaction, entry, timeOrigin) + break + case 'mark': + case 'paint': + case 'measure': { + var startTimestamp = addMeasureSpans( + transaction, + entry, + startTime, + duration, + timeOrigin + ) + if ( + tracingInitMarkStartTime === undefined && + entry.name === 'sentry-tracing-init' + ) { + tracingInitMarkStartTime = startTimestamp + } + // capture web vitals + var firstHidden = getFirstHidden_1.getFirstHidden() + // Only report if the page wasn't hidden prior to the web vital. + var shouldRecord = entry.startTime < firstHidden.timeStamp + if (entry.name === 'first-paint' && shouldRecord) { + utils_1.logger.log('[Measurements] Adding FP') + _this._measurements['fp'] = { value: entry.startTime } + _this._measurements['mark.fp'] = { value: startTimestamp } + } + if (entry.name === 'first-contentful-paint' && shouldRecord) { + utils_1.logger.log('[Measurements] Adding FCP') + _this._measurements['fcp'] = { value: entry.startTime } + _this._measurements['mark.fcp'] = { value: startTimestamp } + } + break + } + case 'resource': { + var resourceName = entry.name.replace( + window.location.origin, + '' + ) + var endTimestamp = addResourceSpans( + transaction, + entry, + resourceName, + startTime, + duration, + timeOrigin + ) + // We remember the entry script end time to calculate the difference to the first init mark + if ( + entryScriptStartTimestamp === undefined && + (entryScriptSrc || '').indexOf(resourceName) > -1 + ) { + entryScriptStartTimestamp = endTimestamp + } + break + } + default: + // Ignore other entry types. + } + }) + if ( + entryScriptStartTimestamp !== undefined && + tracingInitMarkStartTime !== undefined + ) { + _startChild(transaction, { + description: 'evaluation', + endTimestamp: tracingInitMarkStartTime, + op: 'script', + startTimestamp: entryScriptStartTimestamp + }) + } + this._performanceCursor = Math.max( + performance.getEntries().length - 1, + 0 + ) + this._trackNavigator(transaction) + // Measurements are only available for pageload transactions + if (transaction.op === 'pageload') { + // normalize applicable web vital values to be relative to transaction.startTimestamp + var timeOrigin_1 = utils_2.msToSec(performance.timeOrigin) + ;['fcp', 'fp', 'lcp', 'ttfb'].forEach(function (name) { + if ( + !_this._measurements[name] || + timeOrigin_1 >= transaction.startTimestamp + ) { + return + } + // The web vitals, fcp, fp, lcp, and ttfb, all measure relative to timeOrigin. + // Unfortunately, timeOrigin is not captured within the transaction span data, so these web vitals will need + // to be adjusted to be relative to transaction.startTimestamp. + var oldValue = _this._measurements[name].value + var measurementTimestamp = + timeOrigin_1 + utils_2.msToSec(oldValue) + // normalizedValue should be in milliseconds + var normalizedValue = + (measurementTimestamp - transaction.startTimestamp) * 1000 + var delta = normalizedValue - oldValue + utils_1.logger.log( + '[Measurements] Normalized ' + + name + + ' from ' + + _this._measurements[name].value + + ' to ' + + normalizedValue + + ' (' + + delta + + ')' + ) + _this._measurements[name].value = normalizedValue + }) + if (this._measurements['mark.fid'] && this._measurements['fid']) { + // create span for FID + _startChild(transaction, { + description: 'first input delay', + endTimestamp: + this._measurements['mark.fid'].value + + utils_2.msToSec(this._measurements['fid'].value), + op: 'web.vitals', + startTimestamp: this._measurements['mark.fid'].value + }) + } + transaction.setMeasurements(this._measurements) + } + } + /** Starts tracking the Cumulative Layout Shift on the current page. */ + MetricsInstrumentation.prototype._trackCLS = function () { + var _this = this + getCLS_1.getCLS(function (metric) { + var entry = metric.entries.pop() + if (!entry) { + return + } + utils_1.logger.log('[Measurements] Adding CLS') + _this._measurements['cls'] = { value: metric.value } + }) + } + /** + * Capture the information of the user agent. + */ + MetricsInstrumentation.prototype._trackNavigator = function ( + transaction + ) { + var navigator = global.navigator + if (!navigator) { + return + } + // track network connectivity + var connection = navigator.connection + if (connection) { + if (connection.effectiveType) { + transaction.setTag( + 'effectiveConnectionType', + connection.effectiveType + ) + } + if (connection.type) { + transaction.setTag('connectionType', connection.type) + } + if (isMeasurementValue(connection.rtt)) { + this._measurements['connection.rtt'] = { value: connection.rtt } + } + if (isMeasurementValue(connection.downlink)) { + this._measurements['connection.downlink'] = { + value: connection.downlink + } + } + } + if (isMeasurementValue(navigator.deviceMemory)) { + transaction.setTag('deviceMemory', String(navigator.deviceMemory)) + } + if (isMeasurementValue(navigator.hardwareConcurrency)) { + transaction.setTag( + 'hardwareConcurrency', + String(navigator.hardwareConcurrency) + ) + } + } + /** Starts tracking the Largest Contentful Paint on the current page. */ + MetricsInstrumentation.prototype._trackLCP = function () { + var _this = this + getLCP_1.getLCP(function (metric) { + var entry = metric.entries.pop() + if (!entry) { + return + } + var timeOrigin = utils_2.msToSec(performance.timeOrigin) + var startTime = utils_2.msToSec(entry.startTime) + utils_1.logger.log('[Measurements] Adding LCP') + _this._measurements['lcp'] = { value: metric.value } + _this._measurements['mark.lcp'] = { value: timeOrigin + startTime } + }) + } + /** Starts tracking the First Input Delay on the current page. */ + MetricsInstrumentation.prototype._trackFID = function () { + var _this = this + getFID_1.getFID(function (metric) { + var entry = metric.entries.pop() + if (!entry) { + return + } + var timeOrigin = utils_2.msToSec(performance.timeOrigin) + var startTime = utils_2.msToSec(entry.startTime) + utils_1.logger.log('[Measurements] Adding FID') + _this._measurements['fid'] = { value: metric.value } + _this._measurements['mark.fid'] = { value: timeOrigin + startTime } + }) + } + /** Starts tracking the Time to First Byte on the current page. */ + MetricsInstrumentation.prototype._trackTTFB = function () { + var _this = this + getTTFB_1.getTTFB(function (metric) { + var _a + var entry = metric.entries.pop() + if (!entry) { + return + } + utils_1.logger.log('[Measurements] Adding TTFB') + _this._measurements['ttfb'] = { value: metric.value } + // Capture the time spent making the request and receiving the first byte of the response + var requestTime = + metric.value - + ((_a = metric.entries[0]), + _a !== null && _a !== void 0 ? _a : entry).requestStart + _this._measurements['ttfb.requestTime'] = { value: requestTime } + }) + } + return MetricsInstrumentation + })() + exports.MetricsInstrumentation = MetricsInstrumentation + /** Instrument navigation entries */ + function addNavigationSpans(transaction, entry, timeOrigin) { + addPerformanceNavigationTiming( + transaction, + entry, + 'unloadEvent', + timeOrigin + ) + addPerformanceNavigationTiming( + transaction, + entry, + 'redirect', + timeOrigin + ) + addPerformanceNavigationTiming( + transaction, + entry, + 'domContentLoadedEvent', + timeOrigin + ) + addPerformanceNavigationTiming( + transaction, + entry, + 'loadEvent', + timeOrigin + ) + addPerformanceNavigationTiming( + transaction, + entry, + 'connect', + timeOrigin + ) + addPerformanceNavigationTiming( + transaction, + entry, + 'secureConnection', + timeOrigin, + 'connectEnd' + ) + addPerformanceNavigationTiming( + transaction, + entry, + 'fetch', + timeOrigin, + 'domainLookupStart' + ) + addPerformanceNavigationTiming( + transaction, + entry, + 'domainLookup', + timeOrigin + ) + addRequest(transaction, entry, timeOrigin) + } + /** Create measure related spans */ + function addMeasureSpans( + transaction, + entry, + startTime, + duration, + timeOrigin + ) { + var measureStartTimestamp = timeOrigin + startTime + var measureEndTimestamp = measureStartTimestamp + duration + _startChild(transaction, { + description: entry.name, + endTimestamp: measureEndTimestamp, + op: entry.entryType, + startTimestamp: measureStartTimestamp + }) + return measureStartTimestamp + } + /** Create resource related spans */ + function addResourceSpans( + transaction, + entry, + resourceName, + startTime, + duration, + timeOrigin + ) { + // we already instrument based on fetch and xhr, so we don't need to + // duplicate spans here. + if ( + entry.initiatorType === 'xmlhttprequest' || + entry.initiatorType === 'fetch' + ) { + return undefined + } + var data = {} + if ('transferSize' in entry) { + data['Transfer Size'] = entry.transferSize + } + if ('encodedBodySize' in entry) { + data['Encoded Body Size'] = entry.encodedBodySize + } + if ('decodedBodySize' in entry) { + data['Decoded Body Size'] = entry.decodedBodySize + } + var startTimestamp = timeOrigin + startTime + var endTimestamp = startTimestamp + duration + _startChild(transaction, { + description: resourceName, + endTimestamp: endTimestamp, + op: entry.initiatorType + ? 'resource.' + entry.initiatorType + : 'resource', + startTimestamp: startTimestamp, + data: data + }) + return endTimestamp + } + exports.addResourceSpans = addResourceSpans + /** Create performance navigation related spans */ + function addPerformanceNavigationTiming( + transaction, + entry, + event, + timeOrigin, + eventEnd + ) { + var end = eventEnd ? entry[eventEnd] : entry[event + 'End'] + var start = entry[event + 'Start'] + if (!start || !end) { + return + } + _startChild(transaction, { + description: event, + endTimestamp: timeOrigin + utils_2.msToSec(end), + op: 'browser', + startTimestamp: timeOrigin + utils_2.msToSec(start) + }) + } + /** Create request and response related spans */ + function addRequest(transaction, entry, timeOrigin) { + _startChild(transaction, { + description: 'request', + endTimestamp: timeOrigin + utils_2.msToSec(entry.responseEnd), + op: 'browser', + startTimestamp: timeOrigin + utils_2.msToSec(entry.requestStart) + }) + _startChild(transaction, { + description: 'response', + endTimestamp: timeOrigin + utils_2.msToSec(entry.responseEnd), + op: 'browser', + startTimestamp: timeOrigin + utils_2.msToSec(entry.responseStart) + }) + } + /** + * Helper function to start child on transactions. This function will make sure that the transaction will + * use the start timestamp of the created child span if it is earlier than the transactions actual + * start timestamp. + */ + function _startChild(transaction, _a) { + var startTimestamp = _a.startTimestamp, + ctx = tslib_1.__rest(_a, ['startTimestamp']) + if (startTimestamp && transaction.startTimestamp > startTimestamp) { + transaction.startTimestamp = startTimestamp + } + return transaction.startChild( + tslib_1.__assign({ startTimestamp: startTimestamp }, ctx) + ) + } + exports._startChild = _startChild + /** + * Checks if a given value is a valid measurement value. + */ + function isMeasurementValue(value) { + return typeof value === 'number' && isFinite(value) + } + //# sourceMappingURL=metrics.js.map + + /***/ + }, + + /***/ 27854: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var tslib_1 = __webpack_require__(75636) + var hub_1 = __webpack_require__(6393) + var utils_1 = __webpack_require__(1620) + var utils_2 = __webpack_require__(31386) + exports.DEFAULT_TRACING_ORIGINS = ['localhost', /^\//] + exports.defaultRequestInstrumentionOptions = { + traceFetch: true, + traceXHR: true, + tracingOrigins: exports.DEFAULT_TRACING_ORIGINS + } + /** Registers span creators for xhr and fetch requests */ + function registerRequestInstrumentation(_options) { + // eslint-disable-next-line @typescript-eslint/unbound-method + var _a = tslib_1.__assign( + tslib_1.__assign({}, exports.defaultRequestInstrumentionOptions), + _options + ), + traceFetch = _a.traceFetch, + traceXHR = _a.traceXHR, + tracingOrigins = _a.tracingOrigins, + shouldCreateSpanForRequest = _a.shouldCreateSpanForRequest + // We should cache url -> decision so that we don't have to compute + // regexp everytime we create a request. + var urlMap = {} + var defaultShouldCreateSpan = function (url) { + if (urlMap[url]) { + return urlMap[url] + } + var origins = tracingOrigins + urlMap[url] = + origins.some(function (origin) { + return utils_1.isMatchingPattern(url, origin) + }) && !utils_1.isMatchingPattern(url, 'sentry_key') + return urlMap[url] + } + // We want that our users don't have to re-implement shouldCreateSpanForRequest themselves + // That's why we filter out already unwanted Spans from tracingOrigins + var shouldCreateSpan = defaultShouldCreateSpan + if (typeof shouldCreateSpanForRequest === 'function') { + shouldCreateSpan = function (url) { + return ( + defaultShouldCreateSpan(url) && shouldCreateSpanForRequest(url) + ) + } + } + var spans = {} + if (traceFetch) { + utils_1.addInstrumentationHandler({ + callback: function (handlerData) { + fetchCallback(handlerData, shouldCreateSpan, spans) + }, + type: 'fetch' + }) + } + if (traceXHR) { + utils_1.addInstrumentationHandler({ + callback: function (handlerData) { + xhrCallback(handlerData, shouldCreateSpan, spans) + }, + type: 'xhr' + }) + } + } + exports.registerRequestInstrumentation = registerRequestInstrumentation + /** + * Create and track fetch request spans + */ + function fetchCallback(handlerData, shouldCreateSpan, spans) { + var _a + var currentClientOptions = + (_a = hub_1.getCurrentHub().getClient()) === null || _a === void 0 + ? void 0 + : _a.getOptions() + if ( + !( + currentClientOptions && + utils_2.hasTracingEnabled(currentClientOptions) + ) || + !( + handlerData.fetchData && shouldCreateSpan(handlerData.fetchData.url) + ) + ) { + return + } + if (handlerData.endTimestamp && handlerData.fetchData.__span) { + var span = spans[handlerData.fetchData.__span] + if (span) { + var response = handlerData.response + if (response) { + // TODO (kmclb) remove this once types PR goes through + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + span.setHttpStatus(response.status) + } + span.finish() + // eslint-disable-next-line @typescript-eslint/no-dynamic-delete + delete spans[handlerData.fetchData.__span] + } + return + } + var activeTransaction = utils_2.getActiveTransaction() + if (activeTransaction) { + var span = activeTransaction.startChild({ + data: tslib_1.__assign( + tslib_1.__assign({}, handlerData.fetchData), + { type: 'fetch' } + ), + description: + handlerData.fetchData.method + ' ' + handlerData.fetchData.url, + op: 'http' + }) + handlerData.fetchData.__span = span.spanId + spans[span.spanId] = span + var request = (handlerData.args[0] = handlerData.args[0]) + // eslint-disable-next-line @typescript-eslint/no-explicit-any + var options = (handlerData.args[1] = handlerData.args[1] || {}) + var headers = options.headers + if (utils_1.isInstanceOf(request, Request)) { + headers = request.headers + } + if (headers) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + if (typeof headers.append === 'function') { + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + headers.append('sentry-trace', span.toTraceparent()) + } else if (Array.isArray(headers)) { + headers = tslib_1.__spread(headers, [ + ['sentry-trace', span.toTraceparent()] + ]) + } else { + headers = tslib_1.__assign(tslib_1.__assign({}, headers), { + 'sentry-trace': span.toTraceparent() + }) + } + } else { + headers = { 'sentry-trace': span.toTraceparent() } + } + options.headers = headers + } + } + exports.fetchCallback = fetchCallback + /** + * Create and track xhr request spans + */ + function xhrCallback(handlerData, shouldCreateSpan, spans) { + var _a + var currentClientOptions = + (_a = hub_1.getCurrentHub().getClient()) === null || _a === void 0 + ? void 0 + : _a.getOptions() + if ( + !( + currentClientOptions && + utils_2.hasTracingEnabled(currentClientOptions) + ) || + !( + handlerData.xhr && + handlerData.xhr.__sentry_xhr__ && + shouldCreateSpan(handlerData.xhr.__sentry_xhr__.url) + ) || + handlerData.xhr.__sentry_own_request__ + ) { + return + } + var xhr = handlerData.xhr.__sentry_xhr__ + // check first if the request has finished and is tracked by an existing span which should now end + if ( + handlerData.endTimestamp && + handlerData.xhr.__sentry_xhr_span_id__ + ) { + var span = spans[handlerData.xhr.__sentry_xhr_span_id__] + if (span) { + span.setHttpStatus(xhr.status_code) + span.finish() + // eslint-disable-next-line @typescript-eslint/no-dynamic-delete + delete spans[handlerData.xhr.__sentry_xhr_span_id__] + } + return + } + // if not, create a new span to track it + var activeTransaction = utils_2.getActiveTransaction() + if (activeTransaction) { + var span = activeTransaction.startChild({ + data: tslib_1.__assign(tslib_1.__assign({}, xhr.data), { + type: 'xhr', + method: xhr.method, + url: xhr.url + }), + description: xhr.method + ' ' + xhr.url, + op: 'http' + }) + handlerData.xhr.__sentry_xhr_span_id__ = span.spanId + spans[handlerData.xhr.__sentry_xhr_span_id__] = span + if (handlerData.xhr.setRequestHeader) { + try { + handlerData.xhr.setRequestHeader( + 'sentry-trace', + span.toTraceparent() + ) + } catch (_) { + // Error: InvalidStateError: Failed to execute 'setRequestHeader' on 'XMLHttpRequest': The object's state must be OPENED. + } + } + } + } + exports.xhrCallback = xhrCallback + //# sourceMappingURL=request.js.map + + /***/ + }, + + /***/ 40348: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var utils_1 = __webpack_require__(1620) + var global = utils_1.getGlobalObject() + /** + * Default function implementing pageload and navigation transactions + */ + function defaultRoutingInstrumentation( + startTransaction, + startTransactionOnPageLoad, + startTransactionOnLocationChange + ) { + if (startTransactionOnPageLoad === void 0) { + startTransactionOnPageLoad = true + } + if (startTransactionOnLocationChange === void 0) { + startTransactionOnLocationChange = true + } + if (!global || !global.location) { + utils_1.logger.warn( + 'Could not initialize routing instrumentation due to invalid location' + ) + return + } + var startingUrl = global.location.href + var activeTransaction + if (startTransactionOnPageLoad) { + activeTransaction = startTransaction({ + name: global.location.pathname, + op: 'pageload' + }) + } + if (startTransactionOnLocationChange) { + utils_1.addInstrumentationHandler({ + callback: function (_a) { + var to = _a.to, + from = _a.from + /** + * This early return is there to account for some cases where a navigation transaction starts right after + * long-running pageload. We make sure that if `from` is undefined and a valid `startingURL` exists, we don't + * create an uneccessary navigation transaction. + * + * This was hard to duplicate, but this behavior stopped as soon as this fix was applied. This issue might also + * only be caused in certain development environments where the usage of a hot module reloader is causing + * errors. + */ + if ( + from === undefined && + startingUrl && + startingUrl.indexOf(to) !== -1 + ) { + startingUrl = undefined + return + } + if (from !== to) { + startingUrl = undefined + if (activeTransaction) { + utils_1.logger.log( + '[Tracing] Finishing current transaction with op: ' + + activeTransaction.op + ) + // If there's an open transaction on the scope, we need to finish it before creating an new one. + activeTransaction.finish() + } + activeTransaction = startTransaction({ + name: global.location.pathname, + op: 'navigation' + }) + } + }, + type: 'history' + }) + } + } + exports.defaultRoutingInstrumentation = defaultRoutingInstrumentation + //# sourceMappingURL=router.js.map + + /***/ + }, + + /***/ 56982: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + /* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + var bindReporter_1 = __webpack_require__(54592) + var initMetric_1 = __webpack_require__(45300) + var observe_1 = __webpack_require__(17984) + var onHidden_1 = __webpack_require__(9658) + exports.getCLS = function (onReport, reportAllChanges) { + if (reportAllChanges === void 0) { + reportAllChanges = false + } + var metric = initMetric_1.initMetric('CLS', 0) + var report + var entryHandler = function (entry) { + // Only count layout shifts without recent user input. + if (!entry.hadRecentInput) { + metric.value += entry.value + metric.entries.push(entry) + report() + } + } + var po = observe_1.observe('layout-shift', entryHandler) + if (po) { + report = bindReporter_1.bindReporter( + onReport, + metric, + po, + reportAllChanges + ) + onHidden_1.onHidden(function (_a) { + var isUnloading = _a.isUnloading + po.takeRecords().map(entryHandler) + if (isUnloading) { + metric.isFinal = true + } + report() + }) + } + } + //# sourceMappingURL=getCLS.js.map + + /***/ + }, + + /***/ 82496: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + /* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + var bindReporter_1 = __webpack_require__(54592) + var getFirstHidden_1 = __webpack_require__(88493) + var initMetric_1 = __webpack_require__(45300) + var observe_1 = __webpack_require__(17984) + var onHidden_1 = __webpack_require__(9658) + exports.getFID = function (onReport) { + var metric = initMetric_1.initMetric('FID') + var firstHidden = getFirstHidden_1.getFirstHidden() + var entryHandler = function (entry) { + // Only report if the page wasn't hidden prior to the first input. + if (entry.startTime < firstHidden.timeStamp) { + metric.value = entry.processingStart - entry.startTime + metric.entries.push(entry) + metric.isFinal = true + report() + } + } + var po = observe_1.observe('first-input', entryHandler) + var report = bindReporter_1.bindReporter(onReport, metric, po) + if (po) { + onHidden_1.onHidden(function () { + po.takeRecords().map(entryHandler) + po.disconnect() + }, true) + } else { + if (window.perfMetrics && window.perfMetrics.onFirstInputDelay) { + window.perfMetrics.onFirstInputDelay(function (value, event) { + // Only report if the page wasn't hidden prior to the first input. + if (event.timeStamp < firstHidden.timeStamp) { + metric.value = value + metric.isFinal = true + metric.entries = [ + { + entryType: 'first-input', + name: event.type, + target: event.target, + cancelable: event.cancelable, + startTime: event.timeStamp, + processingStart: event.timeStamp + value + } + ] + report() + } + }) + } + } + } + //# sourceMappingURL=getFID.js.map + + /***/ + }, + + /***/ 99382: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + /* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + var bindReporter_1 = __webpack_require__(54592) + var getFirstHidden_1 = __webpack_require__(88493) + var initMetric_1 = __webpack_require__(45300) + var observe_1 = __webpack_require__(17984) + var onHidden_1 = __webpack_require__(9658) + var whenInput_1 = __webpack_require__(45181) + exports.getLCP = function (onReport, reportAllChanges) { + if (reportAllChanges === void 0) { + reportAllChanges = false + } + var metric = initMetric_1.initMetric('LCP') + var firstHidden = getFirstHidden_1.getFirstHidden() + var report + var entryHandler = function (entry) { + // The startTime attribute returns the value of the renderTime if it is not 0, + // and the value of the loadTime otherwise. + var value = entry.startTime + // If the page was hidden prior to paint time of the entry, + // ignore it and mark the metric as final, otherwise add the entry. + if (value < firstHidden.timeStamp) { + metric.value = value + metric.entries.push(entry) + } else { + metric.isFinal = true + } + report() + } + var po = observe_1.observe('largest-contentful-paint', entryHandler) + if (po) { + report = bindReporter_1.bindReporter( + onReport, + metric, + po, + reportAllChanges + ) + var onFinal = function () { + if (!metric.isFinal) { + po.takeRecords().map(entryHandler) + metric.isFinal = true + report() + } + } + void whenInput_1.whenInput().then(onFinal) + onHidden_1.onHidden(onFinal, true) + } + } + //# sourceMappingURL=getLCP.js.map + + /***/ + }, + + /***/ 55909: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + /* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + var utils_1 = __webpack_require__(1620) + var initMetric_1 = __webpack_require__(45300) + var global = utils_1.getGlobalObject() + var afterLoad = function (callback) { + if (document.readyState === 'complete') { + // Queue a task so the callback runs after `loadEventEnd`. + setTimeout(callback, 0) + } else { + // Use `pageshow` so the callback runs after `loadEventEnd`. + addEventListener('pageshow', callback) + } + } + var getNavigationEntryFromPerformanceTiming = function () { + // Really annoying that TypeScript errors when using `PerformanceTiming`. + // Note: browsers that do not support navigation entries will fall back to using performance.timing + // (with the timestamps converted from epoch time to DOMHighResTimeStamp). + // eslint-disable-next-line deprecation/deprecation + var timing = global.performance.timing + var navigationEntry = { + entryType: 'navigation', + startTime: 0 + } + for (var key in timing) { + if (key !== 'navigationStart' && key !== 'toJSON') { + navigationEntry[key] = Math.max( + timing[key] - timing.navigationStart, + 0 + ) + } + } + return navigationEntry + } + exports.getTTFB = function (onReport) { + var metric = initMetric_1.initMetric('TTFB') + afterLoad(function () { + try { + // Use the NavigationTiming L2 entry if available. + var navigationEntry = + global.performance.getEntriesByType('navigation')[0] || + getNavigationEntryFromPerformanceTiming() + metric.value = metric.delta = navigationEntry.responseStart + metric.entries = [navigationEntry] + metric.isFinal = true + onReport(metric) + } catch (error) { + // Do nothing. + } + }) + } + //# sourceMappingURL=getTTFB.js.map + + /***/ + }, + + /***/ 54592: /***/ (__unused_webpack_module, exports) => { + /* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.bindReporter = function ( + callback, + metric, + po, + observeAllUpdates + ) { + var prevValue + return function () { + if (po && metric.isFinal) { + po.disconnect() + } + if (metric.value >= 0) { + if ( + observeAllUpdates || + metric.isFinal || + document.visibilityState === 'hidden' + ) { + metric.delta = metric.value - (prevValue || 0) + // Report the metric if there's a non-zero delta, if the metric is + // final, or if no previous value exists (which can happen in the case + // of the document becoming hidden when the metric value is 0). + // See: https://github.com/GoogleChrome/web-vitals/issues/14 + if (metric.delta || metric.isFinal || prevValue === undefined) { + callback(metric) + prevValue = metric.value + } + } + } + } + } + //# sourceMappingURL=bindReporter.js.map + + /***/ + }, + + /***/ 70093: /***/ (__unused_webpack_module, exports) => { + /* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + /** + * Performantly generate a unique, 27-char string by combining the current + * timestamp with a 13-digit random number. + * @return {string} + */ + exports.generateUniqueID = function () { + return ( + Date.now() + '-' + (Math.floor(Math.random() * (9e12 - 1)) + 1e12) + ) + } + //# sourceMappingURL=generateUniqueID.js.map + + /***/ + }, + + /***/ 88493: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + /* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + var onHidden_1 = __webpack_require__(9658) + var firstHiddenTime + exports.getFirstHidden = function () { + if (firstHiddenTime === undefined) { + // If the document is hidden when this code runs, assume it was hidden + // since navigation start. This isn't a perfect heuristic, but it's the + // best we can do until an API is available to support querying past + // visibilityState. + firstHiddenTime = document.visibilityState === 'hidden' ? 0 : Infinity + // Update the time if/when the document becomes hidden. + onHidden_1.onHidden(function (_a) { + var timeStamp = _a.timeStamp + return (firstHiddenTime = timeStamp) + }, true) + } + return { + get timeStamp() { + return firstHiddenTime + } + } + } + //# sourceMappingURL=getFirstHidden.js.map + + /***/ + }, + + /***/ 45300: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + /* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + var generateUniqueID_1 = __webpack_require__(70093) + exports.initMetric = function (name, value) { + if (value === void 0) { + value = -1 + } + return { + name: name, + value: value, + delta: 0, + entries: [], + id: generateUniqueID_1.generateUniqueID(), + isFinal: false + } + } + //# sourceMappingURL=initMetric.js.map + + /***/ + }, + + /***/ 17984: /***/ (__unused_webpack_module, exports) => { + /* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + /** + * Takes a performance entry type and a callback function, and creates a + * `PerformanceObserver` instance that will observe the specified entry type + * with buffering enabled and call the callback _for each entry_. + * + * This function also feature-detects entry support and wraps the logic in a + * try/catch to avoid errors in unsupporting browsers. + */ + exports.observe = function (type, callback) { + try { + if (PerformanceObserver.supportedEntryTypes.includes(type)) { + var po = new PerformanceObserver(function (l) { + return l.getEntries().map(callback) + }) + po.observe({ type: type, buffered: true }) + return po + } + } catch (e) { + // Do nothing. + } + return + } + //# sourceMappingURL=observe.js.map + + /***/ + }, + + /***/ 9658: /***/ (__unused_webpack_module, exports) => { + /* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + var isUnloading = false + var listenersAdded = false + var onPageHide = function (event) { + isUnloading = !event.persisted + } + var addListeners = function () { + addEventListener('pagehide', onPageHide) + // `beforeunload` is needed to fix this bug: + // https://bugs.chromium.org/p/chromium/issues/detail?id=987409 + // eslint-disable-next-line @typescript-eslint/no-empty-function + addEventListener('beforeunload', function () {}) + } + exports.onHidden = function (cb, once) { + if (once === void 0) { + once = false + } + if (!listenersAdded) { + addListeners() + listenersAdded = true + } + addEventListener( + 'visibilitychange', + function (_a) { + var timeStamp = _a.timeStamp + if (document.visibilityState === 'hidden') { + cb({ timeStamp: timeStamp, isUnloading: isUnloading }) + } + }, + { capture: true, once: once } + ) + } + //# sourceMappingURL=onHidden.js.map + + /***/ + }, + + /***/ 45181: /***/ (__unused_webpack_module, exports) => { + /* + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + var inputPromise + exports.whenInput = function () { + if (!inputPromise) { + inputPromise = new Promise(function (r) { + return ['scroll', 'keydown', 'pointerdown'].map(function (type) { + addEventListener(type, r, { + once: true, + passive: true, + capture: true + }) + }) + }) + } + return inputPromise + } + //# sourceMappingURL=whenInput.js.map + + /***/ + }, + + /***/ 47906: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var utils_1 = __webpack_require__(1620) + var spanstatus_1 = __webpack_require__(58522) + var utils_2 = __webpack_require__(31386) + /** + * Configures global error listeners + */ + function registerErrorInstrumentation() { + utils_1.addInstrumentationHandler({ + callback: errorCallback, + type: 'error' + }) + utils_1.addInstrumentationHandler({ + callback: errorCallback, + type: 'unhandledrejection' + }) + } + exports.registerErrorInstrumentation = registerErrorInstrumentation + /** + * If an error or unhandled promise occurs, we mark the active transaction as failed + */ + function errorCallback() { + var activeTransaction = utils_2.getActiveTransaction() + if (activeTransaction) { + utils_1.logger.log( + '[Tracing] Transaction: ' + + spanstatus_1.SpanStatus.InternalError + + ' -> Global error occured' + ) + activeTransaction.setStatus(spanstatus_1.SpanStatus.InternalError) + } + } + //# sourceMappingURL=errors.js.map + + /***/ + }, + + /***/ 31409: /***/ (module, exports, __webpack_require__) => { + /* module decorator */ module = __webpack_require__.nmd(module) + Object.defineProperty(exports, '__esModule', { value: true }) + var tslib_1 = __webpack_require__(75636) + var hub_1 = __webpack_require__(6393) + var utils_1 = __webpack_require__(1620) + var errors_1 = __webpack_require__(47906) + var idletransaction_1 = __webpack_require__(2171) + var transaction_1 = __webpack_require__(8186) + var utils_2 = __webpack_require__(31386) + /** Returns all trace headers that are currently on the top scope. */ + function traceHeaders() { + var scope = this.getScope() + if (scope) { + var span = scope.getSpan() + if (span) { + return { + 'sentry-trace': span.toTraceparent() + } + } + } + return {} + } + /** + * Implements sampling inheritance and falls back to user-provided static rate if no parent decision is available. + * + * @param parentSampled: The parent transaction's sampling decision, if any. + * @param givenRate: The rate to use if no parental decision is available. + * + * @returns The parent's sampling decision (if one exists), or the provided static rate + */ + function _inheritOrUseGivenRate(parentSampled, givenRate) { + return parentSampled !== undefined ? parentSampled : givenRate + } + /** + * Makes a sampling decision for the given transaction and stores it on the transaction. + * + * Called every time a transaction is created. Only transactions which emerge with a `sampled` value of `true` will be + * sent to Sentry. + * + * @param hub: The hub off of which to read config options + * @param transaction: The transaction needing a sampling decision + * @param samplingContext: Default and user-provided data which may be used to help make the decision + * + * @returns The given transaction with its `sampled` value set + */ + function sample(hub, transaction, samplingContext) { + var _a + var client = hub.getClient() + var options = (client && client.getOptions()) || {} + // nothing to do if there's no client or if tracing is disabled + if (!client || !utils_2.hasTracingEnabled(options)) { + transaction.sampled = false + return transaction + } + // if the user has forced a sampling decision by passing a `sampled` value in their transaction context, go with that + if (transaction.sampled !== undefined) { + return transaction + } + // we would have bailed already if neither `tracesSampler` nor `tracesSampleRate` were defined, so one of these should + // work; prefer the hook if so + var sampleRate = + typeof options.tracesSampler === 'function' + ? options.tracesSampler(samplingContext) + : _inheritOrUseGivenRate( + samplingContext.parentSampled, + options.tracesSampleRate + ) + // Since this is coming from the user (or from a function provided by the user), who knows what we might get. (The + // only valid values are booleans or numbers between 0 and 1.) + if (!isValidSampleRate(sampleRate)) { + utils_1.logger.warn( + '[Tracing] Discarding transaction because of invalid sample rate.' + ) + transaction.sampled = false + return transaction + } + // if the function returned 0 (or false), or if `tracesSampleRate` is 0, it's a sign the transaction should be dropped + if (!sampleRate) { + utils_1.logger.log( + '[Tracing] Discarding transaction because ' + + (typeof options.tracesSampler === 'function' + ? 'tracesSampler returned 0 or false' + : 'tracesSampleRate is set to 0') + ) + transaction.sampled = false + return transaction + } + // Now we roll the dice. Math.random is inclusive of 0, but not of 1, so strict < is safe here. In case sampleRate is + // a boolean, the < comparison will cause it to be automatically cast to 1 if it's true and 0 if it's false. + transaction.sampled = Math.random() < sampleRate + // if we're not going to keep it, we're done + if (!transaction.sampled) { + utils_1.logger.log( + "[Tracing] Discarding transaction because it's not included in the random sample (sampling rate = " + + Number(sampleRate) + + ')' + ) + return transaction + } + // at this point we know we're keeping the transaction, whether because of an inherited decision or because it got + // lucky with the dice roll + transaction.initSpanRecorder( + (_a = options._experiments) === null || _a === void 0 + ? void 0 + : _a.maxSpans + ) + utils_1.logger.log( + '[Tracing] starting ' + + transaction.op + + ' transaction - ' + + transaction.name + ) + return transaction + } + /** + * Gets the correct context to pass to the tracesSampler, based on the environment (i.e., which SDK is being used) + * + * @returns The default sample context + */ + function getDefaultSamplingContext(transactionContext) { + // promote parent sampling decision (if any) for easy access + var parentSampled = transactionContext.parentSampled + var defaultSamplingContext = { + transactionContext: transactionContext, + parentSampled: parentSampled + } + if (utils_1.isNodeEnv()) { + var domain = hub_1.getActiveDomain() + if (domain) { + // for all node servers that we currently support, we store the incoming request object (which is an instance of + // http.IncomingMessage) on the domain + // the domain members are stored as an array, so our only way to find the request is to iterate through the array + // and compare types + var nodeHttpModule = utils_1.dynamicRequire(module, 'http') + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + var requestType_1 = nodeHttpModule.IncomingMessage + // eslint-disable-next-line @typescript-eslint/no-explicit-any + var request = domain.members.find(function (member) { + return utils_1.isInstanceOf(member, requestType_1) + }) + if (request) { + defaultSamplingContext.request = utils_1.extractNodeRequestData( + request + ) + } + } + } + // we must be in browser-js (or some derivative thereof) + else { + // we use `getGlobalObject()` rather than `window` since service workers also have a `location` property on `self` + var globalObject = utils_1.getGlobalObject() + if ('location' in globalObject) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any + defaultSamplingContext.location = tslib_1.__assign( + {}, + globalObject.location + ) + } + } + return defaultSamplingContext + } + /** + * Checks the given sample rate to make sure it is valid type and value (a boolean, or a number between 0 and 1). + */ + function isValidSampleRate(rate) { + // we need to check NaN explicitly because it's of type 'number' and therefore wouldn't get caught by this typecheck + // eslint-disable-next-line @typescript-eslint/no-explicit-any + if ( + isNaN(rate) || + !(typeof rate === 'number' || typeof rate === 'boolean') + ) { + utils_1.logger.warn( + '[Tracing] Given sample rate is invalid. Sample rate must be a boolean or a number between 0 and 1. Got ' + + JSON.stringify(rate) + + ' of type ' + + JSON.stringify(typeof rate) + + '.' + ) + return false + } + // in case sampleRate is a boolean, it will get automatically cast to 1 if it's true and 0 if it's false + if (rate < 0 || rate > 1) { + utils_1.logger.warn( + '[Tracing] Given sample rate is invalid. Sample rate must be between 0 and 1. Got ' + + rate + + '.' + ) + return false + } + return true + } + /** + * Creates a new transaction and adds a sampling decision if it doesn't yet have one. + * + * The Hub.startTransaction method delegates to this method to do its work, passing the Hub instance in as `this`, as if + * it had been called on the hub directly. Exists as a separate function so that it can be injected into the class as an + * "extension method." + * + * @param this: The Hub starting the transaction + * @param transactionContext: Data used to configure the transaction + * @param CustomSamplingContext: Optional data to be provided to the `tracesSampler` function (if any) + * + * @returns The new transaction + * + * @see {@link Hub.startTransaction} + */ + function _startTransaction(transactionContext, customSamplingContext) { + var transaction = new transaction_1.Transaction( + transactionContext, + this + ) + return sample( + this, + transaction, + tslib_1.__assign( + tslib_1.__assign({}, getDefaultSamplingContext(transactionContext)), + customSamplingContext + ) + ) + } + /** + * Create new idle transaction. + */ + function startIdleTransaction( + hub, + transactionContext, + idleTimeout, + onScope + ) { + var transaction = new idletransaction_1.IdleTransaction( + transactionContext, + hub, + idleTimeout, + onScope + ) + return sample( + hub, + transaction, + getDefaultSamplingContext(transactionContext) + ) + } + exports.startIdleTransaction = startIdleTransaction + /** + * @private + */ + function _addTracingExtensions() { + var carrier = hub_1.getMainCarrier() + if (carrier.__SENTRY__) { + carrier.__SENTRY__.extensions = carrier.__SENTRY__.extensions || {} + if (!carrier.__SENTRY__.extensions.startTransaction) { + carrier.__SENTRY__.extensions.startTransaction = _startTransaction + } + if (!carrier.__SENTRY__.extensions.traceHeaders) { + carrier.__SENTRY__.extensions.traceHeaders = traceHeaders + } + } + } + exports._addTracingExtensions = _addTracingExtensions + /** + * This patches the global object and injects the Tracing extensions methods + */ + function addExtensionMethods() { + _addTracingExtensions() + // If an error happens globally, we should make sure transaction status is set to error. + errors_1.registerErrorInstrumentation() + } + exports.addExtensionMethods = addExtensionMethods + //# sourceMappingURL=hubextensions.js.map + + /***/ + }, + + /***/ 2171: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var tslib_1 = __webpack_require__(75636) + var utils_1 = __webpack_require__(1620) + var span_1 = __webpack_require__(64655) + var spanstatus_1 = __webpack_require__(58522) + var transaction_1 = __webpack_require__(8186) + exports.DEFAULT_IDLE_TIMEOUT = 1000 + /** + * @inheritDoc + */ + var IdleTransactionSpanRecorder = /** @class */ (function (_super) { + tslib_1.__extends(IdleTransactionSpanRecorder, _super) + function IdleTransactionSpanRecorder( + _pushActivity, + _popActivity, + transactionSpanId, + maxlen + ) { + if (transactionSpanId === void 0) { + transactionSpanId = '' + } + var _this = _super.call(this, maxlen) || this + _this._pushActivity = _pushActivity + _this._popActivity = _popActivity + _this.transactionSpanId = transactionSpanId + return _this + } + /** + * @inheritDoc + */ + IdleTransactionSpanRecorder.prototype.add = function (span) { + var _this = this + // We should make sure we do not push and pop activities for + // the transaction that this span recorder belongs to. + if (span.spanId !== this.transactionSpanId) { + // We patch span.finish() to pop an activity after setting an endTimestamp. + span.finish = function (endTimestamp) { + span.endTimestamp = + typeof endTimestamp === 'number' + ? endTimestamp + : utils_1.timestampWithMs() + _this._popActivity(span.spanId) + } + // We should only push new activities if the span does not have an end timestamp. + if (span.endTimestamp === undefined) { + this._pushActivity(span.spanId) + } + } + _super.prototype.add.call(this, span) + } + return IdleTransactionSpanRecorder + })(span_1.SpanRecorder) + exports.IdleTransactionSpanRecorder = IdleTransactionSpanRecorder + /** + * An IdleTransaction is a transaction that automatically finishes. It does this by tracking child spans as activities. + * You can have multiple IdleTransactions active, but if the `onScope` option is specified, the idle transaction will + * put itself on the scope on creation. + */ + var IdleTransaction = /** @class */ (function (_super) { + tslib_1.__extends(IdleTransaction, _super) + function IdleTransaction( + transactionContext, + _idleHub, + // The time to wait in ms until the idle transaction will be finished. Default: 1000 + _idleTimeout, + // If an idle transaction should be put itself on and off the scope automatically. + _onScope + ) { + if (_idleTimeout === void 0) { + _idleTimeout = exports.DEFAULT_IDLE_TIMEOUT + } + if (_onScope === void 0) { + _onScope = false + } + var _this = _super.call(this, transactionContext, _idleHub) || this + _this._idleHub = _idleHub + _this._idleTimeout = _idleTimeout + _this._onScope = _onScope + // Activities store a list of active spans + _this.activities = {} + // Stores reference to the timeout that calls _beat(). + _this._heartbeatTimer = 0 + // Amount of times heartbeat has counted. Will cause transaction to finish after 3 beats. + _this._heartbeatCounter = 0 + // We should not use heartbeat if we finished a transaction + _this._finished = false + _this._beforeFinishCallbacks = [] + if (_idleHub && _onScope) { + // There should only be one active transaction on the scope + clearActiveTransaction(_idleHub) + // We set the transaction here on the scope so error events pick up the trace + // context and attach it to the error. + utils_1.logger.log( + 'Setting idle transaction on scope. Span ID: ' + _this.spanId + ) + _idleHub.configureScope(function (scope) { + return scope.setSpan(_this) + }) + } + return _this + } + /** {@inheritDoc} */ + IdleTransaction.prototype.finish = function (endTimestamp) { + var e_1, _a + var _this = this + if (endTimestamp === void 0) { + endTimestamp = utils_1.timestampWithMs() + } + this._finished = true + this.activities = {} + if (this.spanRecorder) { + utils_1.logger.log( + '[Tracing] finishing IdleTransaction', + new Date(endTimestamp * 1000).toISOString(), + this.op + ) + try { + for ( + var _b = tslib_1.__values(this._beforeFinishCallbacks), + _c = _b.next(); + !_c.done; + _c = _b.next() + ) { + var callback = _c.value + callback(this, endTimestamp) + } + } catch (e_1_1) { + e_1 = { error: e_1_1 } + } finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b) + } finally { + if (e_1) throw e_1.error + } + } + this.spanRecorder.spans = this.spanRecorder.spans.filter(function ( + span + ) { + // If we are dealing with the transaction itself, we just return it + if (span.spanId === _this.spanId) { + return true + } + // We cancel all pending spans with status "cancelled" to indicate the idle transaction was finished early + if (!span.endTimestamp) { + span.endTimestamp = endTimestamp + span.setStatus(spanstatus_1.SpanStatus.Cancelled) + utils_1.logger.log( + '[Tracing] cancelling span since transaction ended early', + JSON.stringify(span, undefined, 2) + ) + } + var keepSpan = span.startTimestamp < endTimestamp + if (!keepSpan) { + utils_1.logger.log( + '[Tracing] discarding Span since it happened after Transaction was finished', + JSON.stringify(span, undefined, 2) + ) + } + return keepSpan + }) + // this._onScope is true if the transaction was previously on the scope. + if (this._onScope) { + clearActiveTransaction(this._idleHub) + } + utils_1.logger.log('[Tracing] flushing IdleTransaction') + } else { + utils_1.logger.log('[Tracing] No active IdleTransaction') + } + return _super.prototype.finish.call(this, endTimestamp) + } + /** + * Register a callback function that gets excecuted before the transaction finishes. + * Useful for cleanup or if you want to add any additional spans based on current context. + * + * This is exposed because users have no other way of running something before an idle transaction + * finishes. + */ + IdleTransaction.prototype.registerBeforeFinishCallback = function ( + callback + ) { + this._beforeFinishCallbacks.push(callback) + } + /** + * @inheritDoc + */ + IdleTransaction.prototype.initSpanRecorder = function (maxlen) { + var _this = this + if (!this.spanRecorder) { + this._initTimeout = setTimeout(function () { + if (!_this._finished) { + _this.finish() + } + }, this._idleTimeout) + var pushActivity = function (id) { + if (_this._finished) { + return + } + _this._pushActivity(id) + } + var popActivity = function (id) { + if (_this._finished) { + return + } + _this._popActivity(id) + } + this.spanRecorder = new IdleTransactionSpanRecorder( + pushActivity, + popActivity, + this.spanId, + maxlen + ) + // Start heartbeat so that transactions do not run forever. + utils_1.logger.log('Starting heartbeat') + this._pingHeartbeat() + } + this.spanRecorder.add(this) + } + /** + * Start tracking a specific activity. + * @param spanId The span id that represents the activity + */ + IdleTransaction.prototype._pushActivity = function (spanId) { + if (this._initTimeout) { + clearTimeout(this._initTimeout) + this._initTimeout = undefined + } + utils_1.logger.log('[Tracing] pushActivity: ' + spanId) + this.activities[spanId] = true + utils_1.logger.log( + '[Tracing] new activities count', + Object.keys(this.activities).length + ) + } + /** + * Remove an activity from usage + * @param spanId The span id that represents the activity + */ + IdleTransaction.prototype._popActivity = function (spanId) { + var _this = this + if (this.activities[spanId]) { + utils_1.logger.log('[Tracing] popActivity ' + spanId) + // eslint-disable-next-line @typescript-eslint/no-dynamic-delete + delete this.activities[spanId] + utils_1.logger.log( + '[Tracing] new activities count', + Object.keys(this.activities).length + ) + } + if (Object.keys(this.activities).length === 0) { + var timeout = this._idleTimeout + // We need to add the timeout here to have the real endtimestamp of the transaction + // Remember timestampWithMs is in seconds, timeout is in ms + var end_1 = utils_1.timestampWithMs() + timeout / 1000 + setTimeout(function () { + if (!_this._finished) { + _this.finish(end_1) + } + }, timeout) + } + } + /** + * Checks when entries of this.activities are not changing for 3 beats. + * If this occurs we finish the transaction. + */ + IdleTransaction.prototype._beat = function () { + clearTimeout(this._heartbeatTimer) + // We should not be running heartbeat if the idle transaction is finished. + if (this._finished) { + return + } + var keys = Object.keys(this.activities) + var heartbeatString = keys.length + ? keys.reduce(function (prev, current) { + return prev + current + }) + : '' + if (heartbeatString === this._prevHeartbeatString) { + this._heartbeatCounter += 1 + } else { + this._heartbeatCounter = 1 + } + this._prevHeartbeatString = heartbeatString + if (this._heartbeatCounter >= 3) { + utils_1.logger.log( + '[Tracing] Transaction finished because of no change for 3 heart beats' + ) + this.setStatus(spanstatus_1.SpanStatus.DeadlineExceeded) + this.setTag('heartbeat', 'failed') + this.finish() + } else { + this._pingHeartbeat() + } + } + /** + * Pings the heartbeat + */ + IdleTransaction.prototype._pingHeartbeat = function () { + var _this = this + utils_1.logger.log( + 'pinging Heartbeat -> current counter: ' + this._heartbeatCounter + ) + this._heartbeatTimer = setTimeout(function () { + _this._beat() + }, 5000) + } + return IdleTransaction + })(transaction_1.Transaction) + exports.IdleTransaction = IdleTransaction + /** + * Reset active transaction on scope + */ + function clearActiveTransaction(hub) { + if (hub) { + var scope = hub.getScope() + if (scope) { + var transaction = scope.getTransaction() + if (transaction) { + scope.setSpan(undefined) + } + } + } + } + //# sourceMappingURL=idletransaction.js.map + + /***/ + }, + + /***/ 64358: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var tslib_1 = __webpack_require__(75636) + var browser_1 = __webpack_require__(71425) + var hubextensions_1 = __webpack_require__(31409) + exports.addExtensionMethods = hubextensions_1.addExtensionMethods + var TracingIntegrations = __webpack_require__(28502) + var Integrations = tslib_1.__assign( + tslib_1.__assign({}, TracingIntegrations), + { BrowserTracing: browser_1.BrowserTracing } + ) + exports.Integrations = Integrations + var span_1 = __webpack_require__(64655) + exports.Span = span_1.Span + var transaction_1 = __webpack_require__(8186) + exports.Transaction = transaction_1.Transaction + var spanstatus_1 = __webpack_require__(58522) + exports.SpanStatus = spanstatus_1.SpanStatus + // We are patching the global object with our hub extension methods + hubextensions_1.addExtensionMethods() + var utils_1 = __webpack_require__(31386) + exports.extractTraceparentData = utils_1.extractTraceparentData + exports.getActiveTransaction = utils_1.getActiveTransaction + exports.hasTracingEnabled = utils_1.hasTracingEnabled + exports.stripUrlQueryAndFragment = utils_1.stripUrlQueryAndFragment + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 96221: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var utils_1 = __webpack_require__(1620) + /** + * Express integration + * + * Provides an request and error handler for Express framework + * as well as tracing capabilities + */ + var Express = /** @class */ (function () { + /** + * @inheritDoc + */ + function Express(options) { + if (options === void 0) { + options = {} + } + /** + * @inheritDoc + */ + this.name = Express.id + this._app = options.app + this._methods = options.methods + } + /** + * @inheritDoc + */ + Express.prototype.setupOnce = function () { + if (!this._app) { + utils_1.logger.error( + 'ExpressIntegration is missing an Express instance' + ) + return + } + instrumentMiddlewares(this._app) + routeMiddlewares(this._app, this._methods) + } + /** + * @inheritDoc + */ + Express.id = 'Express' + return Express + })() + exports.Express = Express + /** + * Wraps original middleware function in a tracing call, which stores the info about the call as a span, + * and finishes it once the middleware is done invoking. + * + * Express middlewares have 3 various forms, thus we have to take care of all of them: + * // sync + * app.use(function (req, res) { ... }) + * // async + * app.use(function (req, res, next) { ... }) + * // error handler + * app.use(function (err, req, res, next) { ... }) + */ + // eslint-disable-next-line @typescript-eslint/ban-types + function wrap(fn) { + var arity = fn.length + switch (arity) { + case 2: { + return function (_req, res) { + var transaction = res.__sentry_transaction + if (transaction) { + var span_1 = transaction.startChild({ + description: fn.name, + op: 'middleware' + }) + res.once('finish', function () { + span_1.finish() + }) + } + // eslint-disable-next-line prefer-rest-params + return fn.apply(this, arguments) + } + } + case 3: { + return function (req, res, next) { + var transaction = res.__sentry_transaction + var span = + transaction && + transaction.startChild({ + description: fn.name, + op: 'middleware' + }) + fn.call(this, req, res, function () { + if (span) { + span.finish() + } + // eslint-disable-next-line prefer-rest-params + return next.apply(this, arguments) + }) + } + } + case 4: { + return function (err, req, res, next) { + var transaction = res.__sentry_transaction + var span = + transaction && + transaction.startChild({ + description: fn.name, + op: 'middleware' + }) + fn.call(this, err, req, res, function () { + if (span) { + span.finish() + } + // eslint-disable-next-line prefer-rest-params + return next.apply(this, arguments) + }) + } + } + default: { + throw new Error( + 'Express middleware takes 2-4 arguments. Got: ' + arity + ) + } + } + } + /** + * Takes all the function arguments passed to the original `app.use` call + * and wraps every function, as well as array of functions with a call to our `wrap` method. + * We have to take care of the arrays as well as iterate over all of the arguments, + * as `app.use` can accept middlewares in few various forms. + * + * app.use([], ) + * app.use([], , ...) + * app.use([], ...[]) + */ + function wrapUseArgs(args) { + return Array.from(args).map(function (arg) { + if (typeof arg === 'function') { + return wrap(arg) + } + if (Array.isArray(arg)) { + return arg.map(function (a) { + if (typeof a === 'function') { + return wrap(a) + } + return a + }) + } + return arg + }) + } + /** + * Patches original App to utilize our tracing functionality + */ + function patchMiddleware(app, method) { + var originalAppCallback = app[method] + app[method] = function () { + // eslint-disable-next-line prefer-rest-params + return originalAppCallback.apply(this, wrapUseArgs(arguments)) + } + return app + } + /** + * Patches original app.use + */ + function instrumentMiddlewares(app) { + patchMiddleware(app, 'use') + } + /** + * Patches original app.METHOD + */ + function routeMiddlewares(app, methods) { + if (methods === void 0) { + methods = [] + } + methods.forEach(function (method) { + patchMiddleware(app, method) + }) + } + //# sourceMappingURL=express.js.map + + /***/ + }, + + /***/ 28502: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var express_1 = __webpack_require__(96221) + exports.Express = express_1.Express + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 64655: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var tslib_1 = __webpack_require__(75636) + var utils_1 = __webpack_require__(1620) + var spanstatus_1 = __webpack_require__(58522) + /** + * Keeps track of finished spans for a given transaction + * @internal + * @hideconstructor + * @hidden + */ + var SpanRecorder = /** @class */ (function () { + function SpanRecorder(maxlen) { + if (maxlen === void 0) { + maxlen = 1000 + } + this.spans = [] + this._maxlen = maxlen + } + /** + * This is just so that we don't run out of memory while recording a lot + * of spans. At some point we just stop and flush out the start of the + * trace tree (i.e.the first n spans with the smallest + * start_timestamp). + */ + SpanRecorder.prototype.add = function (span) { + if (this.spans.length > this._maxlen) { + span.spanRecorder = undefined + } else { + this.spans.push(span) + } + } + return SpanRecorder + })() + exports.SpanRecorder = SpanRecorder + /** + * Span contains all data about a span + */ + var Span = /** @class */ (function () { + /** + * You should never call the constructor manually, always use `Sentry.startTransaction()` + * or call `startChild()` on an existing span. + * @internal + * @hideconstructor + * @hidden + */ + function Span(spanContext) { + /** + * @inheritDoc + */ + this.traceId = utils_1.uuid4() + /** + * @inheritDoc + */ + this.spanId = utils_1.uuid4().substring(16) + /** + * Timestamp in seconds when the span was created. + */ + this.startTimestamp = utils_1.timestampWithMs() + /** + * @inheritDoc + */ + this.tags = {} + /** + * @inheritDoc + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + this.data = {} + if (!spanContext) { + return this + } + if (spanContext.traceId) { + this.traceId = spanContext.traceId + } + if (spanContext.spanId) { + this.spanId = spanContext.spanId + } + if (spanContext.parentSpanId) { + this.parentSpanId = spanContext.parentSpanId + } + // We want to include booleans as well here + if ('sampled' in spanContext) { + this.sampled = spanContext.sampled + } + if (spanContext.op) { + this.op = spanContext.op + } + if (spanContext.description) { + this.description = spanContext.description + } + if (spanContext.data) { + this.data = spanContext.data + } + if (spanContext.tags) { + this.tags = spanContext.tags + } + if (spanContext.status) { + this.status = spanContext.status + } + if (spanContext.startTimestamp) { + this.startTimestamp = spanContext.startTimestamp + } + if (spanContext.endTimestamp) { + this.endTimestamp = spanContext.endTimestamp + } + } + /** + * @inheritDoc + * @deprecated + */ + Span.prototype.child = function (spanContext) { + return this.startChild(spanContext) + } + /** + * @inheritDoc + */ + Span.prototype.startChild = function (spanContext) { + var childSpan = new Span( + tslib_1.__assign(tslib_1.__assign({}, spanContext), { + parentSpanId: this.spanId, + sampled: this.sampled, + traceId: this.traceId + }) + ) + childSpan.spanRecorder = this.spanRecorder + if (childSpan.spanRecorder) { + childSpan.spanRecorder.add(childSpan) + } + childSpan.transaction = this.transaction + return childSpan + } + /** + * @inheritDoc + */ + Span.prototype.setTag = function (key, value) { + var _a + this.tags = tslib_1.__assign( + tslib_1.__assign({}, this.tags), + ((_a = {}), (_a[key] = value), _a) + ) + return this + } + /** + * @inheritDoc + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types + Span.prototype.setData = function (key, value) { + var _a + this.data = tslib_1.__assign( + tslib_1.__assign({}, this.data), + ((_a = {}), (_a[key] = value), _a) + ) + return this + } + /** + * @inheritDoc + */ + Span.prototype.setStatus = function (value) { + this.status = value + return this + } + /** + * @inheritDoc + */ + Span.prototype.setHttpStatus = function (httpStatus) { + this.setTag('http.status_code', String(httpStatus)) + var spanStatus = spanstatus_1.SpanStatus.fromHttpCode(httpStatus) + if (spanStatus !== spanstatus_1.SpanStatus.UnknownError) { + this.setStatus(spanStatus) + } + return this + } + /** + * @inheritDoc + */ + Span.prototype.isSuccess = function () { + return this.status === spanstatus_1.SpanStatus.Ok + } + /** + * @inheritDoc + */ + Span.prototype.finish = function (endTimestamp) { + this.endTimestamp = + typeof endTimestamp === 'number' + ? endTimestamp + : utils_1.timestampWithMs() + } + /** + * @inheritDoc + */ + Span.prototype.toTraceparent = function () { + var sampledString = '' + if (this.sampled !== undefined) { + sampledString = this.sampled ? '-1' : '-0' + } + return this.traceId + '-' + this.spanId + sampledString + } + /** + * @inheritDoc + */ + Span.prototype.getTraceContext = function () { + return utils_1.dropUndefinedKeys({ + data: Object.keys(this.data).length > 0 ? this.data : undefined, + description: this.description, + op: this.op, + parent_span_id: this.parentSpanId, + span_id: this.spanId, + status: this.status, + tags: Object.keys(this.tags).length > 0 ? this.tags : undefined, + trace_id: this.traceId + }) + } + /** + * @inheritDoc + */ + Span.prototype.toJSON = function () { + return utils_1.dropUndefinedKeys({ + data: Object.keys(this.data).length > 0 ? this.data : undefined, + description: this.description, + op: this.op, + parent_span_id: this.parentSpanId, + span_id: this.spanId, + start_timestamp: this.startTimestamp, + status: this.status, + tags: Object.keys(this.tags).length > 0 ? this.tags : undefined, + timestamp: this.endTimestamp, + trace_id: this.traceId + }) + } + return Span + })() + exports.Span = Span + //# sourceMappingURL=span.js.map + + /***/ + }, + + /***/ 58522: /***/ (__unused_webpack_module, exports) => { + Object.defineProperty(exports, '__esModule', { value: true }) + /** The status of an Span. */ + // eslint-disable-next-line import/export + var SpanStatus + ;(function (SpanStatus) { + /** The operation completed successfully. */ + SpanStatus['Ok'] = 'ok' + /** Deadline expired before operation could complete. */ + SpanStatus['DeadlineExceeded'] = 'deadline_exceeded' + /** 401 Unauthorized (actually does mean unauthenticated according to RFC 7235) */ + SpanStatus['Unauthenticated'] = 'unauthenticated' + /** 403 Forbidden */ + SpanStatus['PermissionDenied'] = 'permission_denied' + /** 404 Not Found. Some requested entity (file or directory) was not found. */ + SpanStatus['NotFound'] = 'not_found' + /** 429 Too Many Requests */ + SpanStatus['ResourceExhausted'] = 'resource_exhausted' + /** Client specified an invalid argument. 4xx. */ + SpanStatus['InvalidArgument'] = 'invalid_argument' + /** 501 Not Implemented */ + SpanStatus['Unimplemented'] = 'unimplemented' + /** 503 Service Unavailable */ + SpanStatus['Unavailable'] = 'unavailable' + /** Other/generic 5xx. */ + SpanStatus['InternalError'] = 'internal_error' + /** Unknown. Any non-standard HTTP status code. */ + SpanStatus['UnknownError'] = 'unknown_error' + /** The operation was cancelled (typically by the user). */ + SpanStatus['Cancelled'] = 'cancelled' + /** Already exists (409) */ + SpanStatus['AlreadyExists'] = 'already_exists' + /** Operation was rejected because the system is not in a state required for the operation's */ + SpanStatus['FailedPrecondition'] = 'failed_precondition' + /** The operation was aborted, typically due to a concurrency issue. */ + SpanStatus['Aborted'] = 'aborted' + /** Operation was attempted past the valid range. */ + SpanStatus['OutOfRange'] = 'out_of_range' + /** Unrecoverable data loss or corruption */ + SpanStatus['DataLoss'] = 'data_loss' + })((SpanStatus = exports.SpanStatus || (exports.SpanStatus = {}))) + // eslint-disable-next-line @typescript-eslint/no-namespace, import/export + ;(function (SpanStatus) { + /** + * Converts a HTTP status code into a {@link SpanStatus}. + * + * @param httpStatus The HTTP response status code. + * @returns The span status or {@link SpanStatus.UnknownError}. + */ + function fromHttpCode(httpStatus) { + if (httpStatus < 400) { + return SpanStatus.Ok + } + if (httpStatus >= 400 && httpStatus < 500) { + switch (httpStatus) { + case 401: + return SpanStatus.Unauthenticated + case 403: + return SpanStatus.PermissionDenied + case 404: + return SpanStatus.NotFound + case 409: + return SpanStatus.AlreadyExists + case 413: + return SpanStatus.FailedPrecondition + case 429: + return SpanStatus.ResourceExhausted + default: + return SpanStatus.InvalidArgument + } + } + if (httpStatus >= 500 && httpStatus < 600) { + switch (httpStatus) { + case 501: + return SpanStatus.Unimplemented + case 503: + return SpanStatus.Unavailable + case 504: + return SpanStatus.DeadlineExceeded + default: + return SpanStatus.InternalError + } + } + return SpanStatus.UnknownError + } + SpanStatus.fromHttpCode = fromHttpCode + })((SpanStatus = exports.SpanStatus || (exports.SpanStatus = {}))) + //# sourceMappingURL=spanstatus.js.map + + /***/ + }, + + /***/ 8186: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var tslib_1 = __webpack_require__(75636) + var hub_1 = __webpack_require__(6393) + var utils_1 = __webpack_require__(1620) + var span_1 = __webpack_require__(64655) + /** JSDoc */ + var Transaction = /** @class */ (function (_super) { + tslib_1.__extends(Transaction, _super) + /** + * This constructor should never be called manually. Those instrumenting tracing should use + * `Sentry.startTransaction()`, and internal methods should use `hub.startTransaction()`. + * @internal + * @hideconstructor + * @hidden + */ + function Transaction(transactionContext, hub) { + var _this = _super.call(this, transactionContext) || this + _this._measurements = {} + /** + * The reference to the current hub. + */ + _this._hub = hub_1.getCurrentHub() + if (utils_1.isInstanceOf(hub, hub_1.Hub)) { + _this._hub = hub + } + _this.name = transactionContext.name ? transactionContext.name : '' + _this._trimEnd = transactionContext.trimEnd + // this is because transactions are also spans, and spans have a transaction pointer + _this.transaction = _this + return _this + } + /** + * JSDoc + */ + Transaction.prototype.setName = function (name) { + this.name = name + } + /** + * Attaches SpanRecorder to the span itself + * @param maxlen maximum number of spans that can be recorded + */ + Transaction.prototype.initSpanRecorder = function (maxlen) { + if (maxlen === void 0) { + maxlen = 1000 + } + if (!this.spanRecorder) { + this.spanRecorder = new span_1.SpanRecorder(maxlen) + } + this.spanRecorder.add(this) + } + /** + * Set observed measurements for this transaction. + * @hidden + */ + Transaction.prototype.setMeasurements = function (measurements) { + this._measurements = tslib_1.__assign({}, measurements) + } + /** + * @inheritDoc + */ + Transaction.prototype.finish = function (endTimestamp) { + var _this = this + // This transaction is already finished, so we should not flush it again. + if (this.endTimestamp !== undefined) { + return undefined + } + if (!this.name) { + utils_1.logger.warn( + 'Transaction has no name, falling back to ``.' + ) + this.name = '' + } + // just sets the end timestamp + _super.prototype.finish.call(this, endTimestamp) + if (this.sampled !== true) { + // At this point if `sampled !== true` we want to discard the transaction. + utils_1.logger.log( + '[Tracing] Discarding transaction because its trace was not chosen to be sampled.' + ) + return undefined + } + var finishedSpans = this.spanRecorder + ? this.spanRecorder.spans.filter(function (s) { + return s !== _this && s.endTimestamp + }) + : [] + if (this._trimEnd && finishedSpans.length > 0) { + this.endTimestamp = finishedSpans.reduce(function (prev, current) { + if (prev.endTimestamp && current.endTimestamp) { + return prev.endTimestamp > current.endTimestamp ? prev : current + } + return prev + }).endTimestamp + } + var transaction = { + contexts: { + trace: this.getTraceContext() + }, + spans: finishedSpans, + start_timestamp: this.startTimestamp, + tags: this.tags, + timestamp: this.endTimestamp, + transaction: this.name, + type: 'transaction' + } + var hasMeasurements = Object.keys(this._measurements).length > 0 + if (hasMeasurements) { + utils_1.logger.log( + '[Measurements] Adding measurements to transaction', + JSON.stringify(this._measurements, undefined, 2) + ) + transaction.measurements = this._measurements + } + return this._hub.captureEvent(transaction) + } + return Transaction + })(span_1.Span) + exports.Transaction = Transaction + //# sourceMappingURL=transaction.js.map + + /***/ + }, + + /***/ 31386: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var hub_1 = __webpack_require__(6393) + exports.TRACEPARENT_REGEXP = new RegExp( + '^[ \\t]*' + // whitespace + '([0-9a-f]{32})?' + // trace_id + '-?([0-9a-f]{16})?' + // span_id + '-?([01])?' + // sampled + '[ \\t]*$' + ) + /** + * Determines if tracing is currently enabled. + * + * Tracing is enabled when at least one of `tracesSampleRate` and `tracesSampler` is defined in the SDK config. + */ + function hasTracingEnabled(options) { + return 'tracesSampleRate' in options || 'tracesSampler' in options + } + exports.hasTracingEnabled = hasTracingEnabled + /** + * Extract transaction context data from a `sentry-trace` header. + * + * @param traceparent Traceparent string + * + * @returns Object containing data from the header, or undefined if traceparent string is malformed + */ + function extractTraceparentData(traceparent) { + var matches = traceparent.match(exports.TRACEPARENT_REGEXP) + if (matches) { + var parentSampled = void 0 + if (matches[3] === '1') { + parentSampled = true + } else if (matches[3] === '0') { + parentSampled = false + } + return { + traceId: matches[1], + parentSampled: parentSampled, + parentSpanId: matches[2] + } + } + return undefined + } + exports.extractTraceparentData = extractTraceparentData + /** Grabs active transaction off scope, if any */ + function getActiveTransaction(hub) { + if (hub === void 0) { + hub = hub_1.getCurrentHub() + } + var _a, _b + return (_b = + (_a = hub) === null || _a === void 0 ? void 0 : _a.getScope()) === + null || _b === void 0 + ? void 0 + : _b.getTransaction() + } + exports.getActiveTransaction = getActiveTransaction + /** + * Converts from milliseconds to seconds + * @param time time in ms + */ + function msToSec(time) { + return time / 1000 + } + exports.msToSec = msToSec + /** + * Converts from seconds to milliseconds + * @param time time in seconds + */ + function secToMs(time) { + return time * 1000 + } + exports.secToMs = secToMs + // so it can be used in manual instrumentation without necessitating a hard dependency on @sentry/utils + var utils_1 = __webpack_require__(1620) + exports.stripUrlQueryAndFragment = utils_1.stripUrlQueryAndFragment + //# sourceMappingURL=utils.js.map + + /***/ + }, + + /***/ 83789: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var loglevel_1 = __webpack_require__(6853) + exports.LogLevel = loglevel_1.LogLevel + var session_1 = __webpack_require__(84954) + exports.SessionStatus = session_1.SessionStatus + var severity_1 = __webpack_require__(94124) + exports.Severity = severity_1.Severity + var status_1 = __webpack_require__(61277) + exports.Status = status_1.Status + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 6853: /***/ (__unused_webpack_module, exports) => { + Object.defineProperty(exports, '__esModule', { value: true }) + /** Console logging verbosity for the SDK. */ + var LogLevel + ;(function (LogLevel) { + /** No logs will be generated. */ + LogLevel[(LogLevel['None'] = 0)] = 'None' + /** Only SDK internal errors will be logged. */ + LogLevel[(LogLevel['Error'] = 1)] = 'Error' + /** Information useful for debugging the SDK will be logged. */ + LogLevel[(LogLevel['Debug'] = 2)] = 'Debug' + /** All SDK actions will be logged. */ + LogLevel[(LogLevel['Verbose'] = 3)] = 'Verbose' + })((LogLevel = exports.LogLevel || (exports.LogLevel = {}))) + //# sourceMappingURL=loglevel.js.map + + /***/ + }, + + /***/ 84954: /***/ (__unused_webpack_module, exports) => { + Object.defineProperty(exports, '__esModule', { value: true }) + /** + * Session Status + */ + var SessionStatus + ;(function (SessionStatus) { + /** JSDoc */ + SessionStatus['Ok'] = 'ok' + /** JSDoc */ + SessionStatus['Exited'] = 'exited' + /** JSDoc */ + SessionStatus['Crashed'] = 'crashed' + /** JSDoc */ + SessionStatus['Abnormal'] = 'abnormal' + })( + (SessionStatus = exports.SessionStatus || (exports.SessionStatus = {})) + ) + //# sourceMappingURL=session.js.map + + /***/ + }, + + /***/ 94124: /***/ (__unused_webpack_module, exports) => { + Object.defineProperty(exports, '__esModule', { value: true }) + /** JSDoc */ + // eslint-disable-next-line import/export + var Severity + ;(function (Severity) { + /** JSDoc */ + Severity['Fatal'] = 'fatal' + /** JSDoc */ + Severity['Error'] = 'error' + /** JSDoc */ + Severity['Warning'] = 'warning' + /** JSDoc */ + Severity['Log'] = 'log' + /** JSDoc */ + Severity['Info'] = 'info' + /** JSDoc */ + Severity['Debug'] = 'debug' + /** JSDoc */ + Severity['Critical'] = 'critical' + })((Severity = exports.Severity || (exports.Severity = {}))) + // eslint-disable-next-line @typescript-eslint/no-namespace, import/export + ;(function (Severity) { + /** + * Converts a string-based level into a {@link Severity}. + * + * @param level string representation of Severity + * @returns Severity + */ + function fromString(level) { + switch (level) { + case 'debug': + return Severity.Debug + case 'info': + return Severity.Info + case 'warn': + case 'warning': + return Severity.Warning + case 'error': + return Severity.Error + case 'fatal': + return Severity.Fatal + case 'critical': + return Severity.Critical + case 'log': + default: + return Severity.Log + } + } + Severity.fromString = fromString + })((Severity = exports.Severity || (exports.Severity = {}))) + //# sourceMappingURL=severity.js.map + + /***/ + }, + + /***/ 61277: /***/ (__unused_webpack_module, exports) => { + Object.defineProperty(exports, '__esModule', { value: true }) + /** The status of an event. */ + // eslint-disable-next-line import/export + var Status + ;(function (Status) { + /** The status could not be determined. */ + Status['Unknown'] = 'unknown' + /** The event was skipped due to configuration or callbacks. */ + Status['Skipped'] = 'skipped' + /** The event was sent to Sentry successfully. */ + Status['Success'] = 'success' + /** The client is currently rate limited and will try again later. */ + Status['RateLimit'] = 'rate_limit' + /** The event could not be processed. */ + Status['Invalid'] = 'invalid' + /** A server-side error ocurred during submission. */ + Status['Failed'] = 'failed' + })((Status = exports.Status || (exports.Status = {}))) + // eslint-disable-next-line @typescript-eslint/no-namespace, import/export + ;(function (Status) { + /** + * Converts a HTTP status code into a {@link Status}. + * + * @param code The HTTP response status code. + * @returns The send status or {@link Status.Unknown}. + */ + function fromHttpCode(code) { + if (code >= 200 && code < 300) { + return Status.Success + } + if (code === 429) { + return Status.RateLimit + } + if (code >= 400 && code < 500) { + return Status.Invalid + } + if (code >= 500) { + return Status.Failed + } + return Status.Unknown + } + Status.fromHttpCode = fromHttpCode + })((Status = exports.Status || (exports.Status = {}))) + //# sourceMappingURL=status.js.map + + /***/ + }, + + /***/ 58343: /***/ (__unused_webpack_module, exports) => { + Object.defineProperty(exports, '__esModule', { value: true }) + /** + * Consumes the promise and logs the error when it rejects. + * @param promise A promise to forget. + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function forget(promise) { + promise.then(null, function (e) { + // TODO: Use a better logging mechanism + // eslint-disable-next-line no-console + console.error(e) + }) + } + exports.forget = forget + //# sourceMappingURL=async.js.map + + /***/ + }, + + /***/ 30597: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var is_1 = __webpack_require__(92757) + /** + * Given a child DOM element, returns a query-selector statement describing that + * and its ancestors + * e.g. [HTMLElement] => body > div > input#foo.btn[name=baz] + * @returns generated DOM path + */ + function htmlTreeAsString(elem) { + // try/catch both: + // - accessing event.target (see getsentry/raven-js#838, #768) + // - `htmlTreeAsString` because it's complex, and just accessing the DOM incorrectly + // - can throw an exception in some circumstances. + try { + var currentElem = elem + var MAX_TRAVERSE_HEIGHT = 5 + var MAX_OUTPUT_LEN = 80 + var out = [] + var height = 0 + var len = 0 + var separator = ' > ' + var sepLength = separator.length + var nextStr = void 0 + // eslint-disable-next-line no-plusplus + while (currentElem && height++ < MAX_TRAVERSE_HEIGHT) { + nextStr = _htmlElementAsString(currentElem) + // bail out if + // - nextStr is the 'html' element + // - the length of the string that would be created exceeds MAX_OUTPUT_LEN + // (ignore this limit if we are on the first iteration) + if ( + nextStr === 'html' || + (height > 1 && + len + out.length * sepLength + nextStr.length >= MAX_OUTPUT_LEN) + ) { + break + } + out.push(nextStr) + len += nextStr.length + currentElem = currentElem.parentNode + } + return out.reverse().join(separator) + } catch (_oO) { + return '' + } + } + exports.htmlTreeAsString = htmlTreeAsString + /** + * Returns a simple, query-selector representation of a DOM element + * e.g. [HTMLElement] => input#foo.btn[name=baz] + * @returns generated DOM path + */ + function _htmlElementAsString(el) { + var elem = el + var out = [] + var className + var classes + var key + var attr + var i + if (!elem || !elem.tagName) { + return '' + } + out.push(elem.tagName.toLowerCase()) + if (elem.id) { + out.push('#' + elem.id) + } + // eslint-disable-next-line prefer-const + className = elem.className + if (className && is_1.isString(className)) { + classes = className.split(/\s+/) + for (i = 0; i < classes.length; i++) { + out.push('.' + classes[i]) + } + } + var allowedAttrs = ['type', 'name', 'title', 'alt'] + for (i = 0; i < allowedAttrs.length; i++) { + key = allowedAttrs[i] + attr = elem.getAttribute(key) + if (attr) { + out.push('[' + key + '="' + attr + '"]') + } + } + return out.join('') + } + //# sourceMappingURL=browser.js.map + + /***/ + }, + + /***/ 3275: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var tslib_1 = __webpack_require__(75636) + var error_1 = __webpack_require__(66238) + /** Regular expression used to parse a Dsn. */ + var DSN_REGEX = /^(?:(\w+):)\/\/(?:(\w+)(?::(\w+))?@)([\w.-]+)(?::(\d+))?\/(.+)/ + /** Error message */ + var ERROR_MESSAGE = 'Invalid Dsn' + /** The Sentry Dsn, identifying a Sentry instance and project. */ + var Dsn = /** @class */ (function () { + /** Creates a new Dsn component */ + function Dsn(from) { + if (typeof from === 'string') { + this._fromString(from) + } else { + this._fromComponents(from) + } + this._validate() + } + /** + * Renders the string representation of this Dsn. + * + * By default, this will render the public representation without the password + * component. To get the deprecated private representation, set `withPassword` + * to true. + * + * @param withPassword When set to true, the password will be included. + */ + Dsn.prototype.toString = function (withPassword) { + if (withPassword === void 0) { + withPassword = false + } + var _a = this, + host = _a.host, + path = _a.path, + pass = _a.pass, + port = _a.port, + projectId = _a.projectId, + protocol = _a.protocol, + user = _a.user + return ( + protocol + + '://' + + user + + (withPassword && pass ? ':' + pass : '') + + ('@' + + host + + (port ? ':' + port : '') + + '/' + + (path ? path + '/' : path) + + projectId) + ) + } + /** Parses a string into this Dsn. */ + Dsn.prototype._fromString = function (str) { + var match = DSN_REGEX.exec(str) + if (!match) { + throw new error_1.SentryError(ERROR_MESSAGE) + } + var _a = tslib_1.__read(match.slice(1), 6), + protocol = _a[0], + user = _a[1], + _b = _a[2], + pass = _b === void 0 ? '' : _b, + host = _a[3], + _c = _a[4], + port = _c === void 0 ? '' : _c, + lastPath = _a[5] + var path = '' + var projectId = lastPath + var split = projectId.split('/') + if (split.length > 1) { + path = split.slice(0, -1).join('/') + projectId = split.pop() + } + if (projectId) { + var projectMatch = projectId.match(/^\d+/) + if (projectMatch) { + projectId = projectMatch[0] + } + } + this._fromComponents({ + host: host, + pass: pass, + path: path, + projectId: projectId, + port: port, + protocol: protocol, + user: user + }) + } + /** Maps Dsn components into this instance. */ + Dsn.prototype._fromComponents = function (components) { + this.protocol = components.protocol + this.user = components.user + this.pass = components.pass || '' + this.host = components.host + this.port = components.port || '' + this.path = components.path || '' + this.projectId = components.projectId + } + /** Validates this Dsn and throws on error. */ + Dsn.prototype._validate = function () { + var _this = this + ;['protocol', 'user', 'host', 'projectId'].forEach(function ( + component + ) { + if (!_this[component]) { + throw new error_1.SentryError( + ERROR_MESSAGE + ': ' + component + ' missing' + ) + } + }) + if (!this.projectId.match(/^\d+$/)) { + throw new error_1.SentryError( + ERROR_MESSAGE + ': Invalid projectId ' + this.projectId + ) + } + if (this.protocol !== 'http' && this.protocol !== 'https') { + throw new error_1.SentryError( + ERROR_MESSAGE + ': Invalid protocol ' + this.protocol + ) + } + if (this.port && isNaN(parseInt(this.port, 10))) { + throw new error_1.SentryError( + ERROR_MESSAGE + ': Invalid port ' + this.port + ) + } + } + return Dsn + })() + exports.Dsn = Dsn + //# sourceMappingURL=dsn.js.map + + /***/ + }, + + /***/ 66238: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var tslib_1 = __webpack_require__(75636) + var polyfill_1 = __webpack_require__(1243) + /** An error emitted by Sentry SDKs and related utilities. */ + var SentryError = /** @class */ (function (_super) { + tslib_1.__extends(SentryError, _super) + function SentryError(message) { + var _newTarget = this.constructor + var _this = _super.call(this, message) || this + _this.message = message + _this.name = _newTarget.prototype.constructor.name + polyfill_1.setPrototypeOf(_this, _newTarget.prototype) + return _this + } + return SentryError + })(Error) + exports.SentryError = SentryError + //# sourceMappingURL=error.js.map + + /***/ + }, + + /***/ 1620: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var tslib_1 = __webpack_require__(75636) + tslib_1.__exportStar(__webpack_require__(58343), exports) + tslib_1.__exportStar(__webpack_require__(30597), exports) + tslib_1.__exportStar(__webpack_require__(3275), exports) + tslib_1.__exportStar(__webpack_require__(66238), exports) + tslib_1.__exportStar(__webpack_require__(65474), exports) + tslib_1.__exportStar(__webpack_require__(92757), exports) + tslib_1.__exportStar(__webpack_require__(15577), exports) + tslib_1.__exportStar(__webpack_require__(49515), exports) + tslib_1.__exportStar(__webpack_require__(32154), exports) + tslib_1.__exportStar(__webpack_require__(16411), exports) + tslib_1.__exportStar(__webpack_require__(69249), exports) + tslib_1.__exportStar(__webpack_require__(39188), exports) + tslib_1.__exportStar(__webpack_require__(31811), exports) + tslib_1.__exportStar(__webpack_require__(5986), exports) + tslib_1.__exportStar(__webpack_require__(66538), exports) + tslib_1.__exportStar(__webpack_require__(88714), exports) + tslib_1.__exportStar(__webpack_require__(87833), exports) + tslib_1.__exportStar(__webpack_require__(1735), exports) + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 65474: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var tslib_1 = __webpack_require__(75636) + var is_1 = __webpack_require__(92757) + var logger_1 = __webpack_require__(15577) + var misc_1 = __webpack_require__(32154) + var object_1 = __webpack_require__(69249) + var stacktrace_1 = __webpack_require__(5986) + var supports_1 = __webpack_require__(88714) + var global = misc_1.getGlobalObject() + /** + * Instrument native APIs to call handlers that can be used to create breadcrumbs, APM spans etc. + * - Console API + * - Fetch API + * - XHR API + * - History API + * - DOM API (click/typing) + * - Error API + * - UnhandledRejection API + */ + var handlers = {} + var instrumented = {} + /** Instruments given API */ + function instrument(type) { + if (instrumented[type]) { + return + } + instrumented[type] = true + switch (type) { + case 'console': + instrumentConsole() + break + case 'dom': + instrumentDOM() + break + case 'xhr': + instrumentXHR() + break + case 'fetch': + instrumentFetch() + break + case 'history': + instrumentHistory() + break + case 'error': + instrumentError() + break + case 'unhandledrejection': + instrumentUnhandledRejection() + break + default: + logger_1.logger.warn('unknown instrumentation type:', type) + } + } + /** + * Add handler that will be called when given type of instrumentation triggers. + * Use at your own risk, this might break without changelog notice, only used internally. + * @hidden + */ + function addInstrumentationHandler(handler) { + if ( + !handler || + typeof handler.type !== 'string' || + typeof handler.callback !== 'function' + ) { + return + } + handlers[handler.type] = handlers[handler.type] || [] + handlers[handler.type].push(handler.callback) + instrument(handler.type) + } + exports.addInstrumentationHandler = addInstrumentationHandler + /** JSDoc */ + function triggerHandlers(type, data) { + var e_1, _a + if (!type || !handlers[type]) { + return + } + try { + for ( + var _b = tslib_1.__values(handlers[type] || []), _c = _b.next(); + !_c.done; + _c = _b.next() + ) { + var handler = _c.value + try { + handler(data) + } catch (e) { + logger_1.logger.error( + 'Error while triggering instrumentation handler.\nType: ' + + type + + '\nName: ' + + stacktrace_1.getFunctionName(handler) + + '\nError: ' + + e + ) + } + } + } catch (e_1_1) { + e_1 = { error: e_1_1 } + } finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b) + } finally { + if (e_1) throw e_1.error + } + } + } + /** JSDoc */ + function instrumentConsole() { + if (!('console' in global)) { + return + } + ;['debug', 'info', 'warn', 'error', 'log', 'assert'].forEach(function ( + level + ) { + if (!(level in global.console)) { + return + } + object_1.fill(global.console, level, function (originalConsoleLevel) { + return function () { + var args = [] + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i] + } + triggerHandlers('console', { args: args, level: level }) + // this fails for some browsers. :( + if (originalConsoleLevel) { + Function.prototype.apply.call( + originalConsoleLevel, + global.console, + args + ) + } + } + }) + }) + } + /** JSDoc */ + function instrumentFetch() { + if (!supports_1.supportsNativeFetch()) { + return + } + object_1.fill(global, 'fetch', function (originalFetch) { + return function () { + var args = [] + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i] + } + var handlerData = { + args: args, + fetchData: { + method: getFetchMethod(args), + url: getFetchUrl(args) + }, + startTimestamp: Date.now() + } + triggerHandlers('fetch', tslib_1.__assign({}, handlerData)) + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + return originalFetch.apply(global, args).then( + function (response) { + triggerHandlers( + 'fetch', + tslib_1.__assign(tslib_1.__assign({}, handlerData), { + endTimestamp: Date.now(), + response: response + }) + ) + return response + }, + function (error) { + triggerHandlers( + 'fetch', + tslib_1.__assign(tslib_1.__assign({}, handlerData), { + endTimestamp: Date.now(), + error: error + }) + ) + // NOTE: If you are a Sentry user, and you are seeing this stack frame, + // it means the sentry.javascript SDK caught an error invoking your application code. + // This is expected behavior and NOT indicative of a bug with sentry.javascript. + throw error + } + ) + } + }) + } + /* eslint-disable @typescript-eslint/no-unsafe-member-access */ + /** Extract `method` from fetch call arguments */ + function getFetchMethod(fetchArgs) { + if (fetchArgs === void 0) { + fetchArgs = [] + } + if ( + 'Request' in global && + is_1.isInstanceOf(fetchArgs[0], Request) && + fetchArgs[0].method + ) { + return String(fetchArgs[0].method).toUpperCase() + } + if (fetchArgs[1] && fetchArgs[1].method) { + return String(fetchArgs[1].method).toUpperCase() + } + return 'GET' + } + /** Extract `url` from fetch call arguments */ + function getFetchUrl(fetchArgs) { + if (fetchArgs === void 0) { + fetchArgs = [] + } + if (typeof fetchArgs[0] === 'string') { + return fetchArgs[0] + } + if ('Request' in global && is_1.isInstanceOf(fetchArgs[0], Request)) { + return fetchArgs[0].url + } + return String(fetchArgs[0]) + } + /* eslint-enable @typescript-eslint/no-unsafe-member-access */ + /** JSDoc */ + function instrumentXHR() { + if (!('XMLHttpRequest' in global)) { + return + } + // Poor man's implementation of ES6 `Map`, tracking and keeping in sync key and value separately. + var requestKeys = [] + var requestValues = [] + var xhrproto = XMLHttpRequest.prototype + object_1.fill(xhrproto, 'open', function (originalOpen) { + return function () { + var args = [] + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i] + } + // eslint-disable-next-line @typescript-eslint/no-this-alias + var xhr = this + var url = args[1] + xhr.__sentry_xhr__ = { + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + method: is_1.isString(args[0]) ? args[0].toUpperCase() : args[0], + url: args[1] + } + // if Sentry key appears in URL, don't capture it as a request + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + if ( + is_1.isString(url) && + xhr.__sentry_xhr__.method === 'POST' && + url.match(/sentry_key/) + ) { + xhr.__sentry_own_request__ = true + } + var onreadystatechangeHandler = function () { + if (xhr.readyState === 4) { + try { + // touching statusCode in some platforms throws + // an exception + if (xhr.__sentry_xhr__) { + xhr.__sentry_xhr__.status_code = xhr.status + } + } catch (e) { + /* do nothing */ + } + try { + var requestPos = requestKeys.indexOf(xhr) + if (requestPos !== -1) { + // Make sure to pop both key and value to keep it in sync. + requestKeys.splice(requestPos) + var args_1 = requestValues.splice(requestPos)[0] + if (xhr.__sentry_xhr__ && args_1[0] !== undefined) { + xhr.__sentry_xhr__.body = args_1[0] + } + } + } catch (e) { + /* do nothing */ + } + triggerHandlers('xhr', { + args: args, + endTimestamp: Date.now(), + startTimestamp: Date.now(), + xhr: xhr + }) + } + } + if ( + 'onreadystatechange' in xhr && + typeof xhr.onreadystatechange === 'function' + ) { + object_1.fill(xhr, 'onreadystatechange', function (original) { + return function () { + var readyStateArgs = [] + for (var _i = 0; _i < arguments.length; _i++) { + readyStateArgs[_i] = arguments[_i] + } + onreadystatechangeHandler() + return original.apply(xhr, readyStateArgs) + } + }) + } else { + xhr.addEventListener( + 'readystatechange', + onreadystatechangeHandler + ) + } + return originalOpen.apply(xhr, args) + } + }) + object_1.fill(xhrproto, 'send', function (originalSend) { + return function () { + var args = [] + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i] + } + requestKeys.push(this) + requestValues.push(args) + triggerHandlers('xhr', { + args: args, + startTimestamp: Date.now(), + xhr: this + }) + return originalSend.apply(this, args) + } + }) + } + var lastHref + /** JSDoc */ + function instrumentHistory() { + if (!supports_1.supportsHistory()) { + return + } + var oldOnPopState = global.onpopstate + global.onpopstate = function () { + var args = [] + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i] + } + var to = global.location.href + // keep track of the current URL state, as we always receive only the updated state + var from = lastHref + lastHref = to + triggerHandlers('history', { + from: from, + to: to + }) + if (oldOnPopState) { + return oldOnPopState.apply(this, args) + } + } + /** @hidden */ + function historyReplacementFunction(originalHistoryFunction) { + return function () { + var args = [] + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i] + } + var url = args.length > 2 ? args[2] : undefined + if (url) { + // coerce to string (this is what pushState does) + var from = lastHref + var to = String(url) + // keep track of the current URL state, as we always receive only the updated state + lastHref = to + triggerHandlers('history', { + from: from, + to: to + }) + } + return originalHistoryFunction.apply(this, args) + } + } + object_1.fill(global.history, 'pushState', historyReplacementFunction) + object_1.fill( + global.history, + 'replaceState', + historyReplacementFunction + ) + } + /** JSDoc */ + function instrumentDOM() { + if (!('document' in global)) { + return + } + // Capture breadcrumbs from any click that is unhandled / bubbled up all the way + // to the document. Do this before we instrument addEventListener. + global.document.addEventListener( + 'click', + domEventHandler('click', triggerHandlers.bind(null, 'dom')), + false + ) + global.document.addEventListener( + 'keypress', + keypressEventHandler(triggerHandlers.bind(null, 'dom')), + false + ) + // After hooking into document bubbled up click and keypresses events, we also hook into user handled click & keypresses. + ;['EventTarget', 'Node'].forEach(function (target) { + /* eslint-disable @typescript-eslint/no-unsafe-member-access */ + var proto = global[target] && global[target].prototype + // eslint-disable-next-line no-prototype-builtins + if ( + !proto || + !proto.hasOwnProperty || + !proto.hasOwnProperty('addEventListener') + ) { + return + } + /* eslint-enable @typescript-eslint/no-unsafe-member-access */ + object_1.fill(proto, 'addEventListener', function (original) { + return function (eventName, fn, options) { + if (fn && fn.handleEvent) { + if (eventName === 'click') { + object_1.fill(fn, 'handleEvent', function (innerOriginal) { + return function (event) { + domEventHandler( + 'click', + triggerHandlers.bind(null, 'dom') + )(event) + return innerOriginal.call(this, event) + } + }) + } + if (eventName === 'keypress') { + object_1.fill(fn, 'handleEvent', function (innerOriginal) { + return function (event) { + keypressEventHandler(triggerHandlers.bind(null, 'dom'))( + event + ) + return innerOriginal.call(this, event) + } + }) + } + } else { + if (eventName === 'click') { + domEventHandler( + 'click', + triggerHandlers.bind(null, 'dom'), + true + )(this) + } + if (eventName === 'keypress') { + keypressEventHandler(triggerHandlers.bind(null, 'dom'))(this) + } + } + return original.call(this, eventName, fn, options) + } + }) + object_1.fill(proto, 'removeEventListener', function (original) { + return function (eventName, fn, options) { + try { + original.call(this, eventName, fn.__sentry_wrapped__, options) + } catch (e) { + // ignore, accessing __sentry_wrapped__ will throw in some Selenium environments + } + return original.call(this, eventName, fn, options) + } + }) + }) + } + var debounceDuration = 1000 + var debounceTimer = 0 + var keypressTimeout + var lastCapturedEvent + /** + * Wraps addEventListener to capture UI breadcrumbs + * @param name the event name (e.g. "click") + * @param handler function that will be triggered + * @param debounce decides whether it should wait till another event loop + * @returns wrapped breadcrumb events handler + * @hidden + */ + function domEventHandler(name, handler, debounce) { + if (debounce === void 0) { + debounce = false + } + return function (event) { + // reset keypress timeout; e.g. triggering a 'click' after + // a 'keypress' will reset the keypress debounce so that a new + // set of keypresses can be recorded + keypressTimeout = undefined + // It's possible this handler might trigger multiple times for the same + // event (e.g. event propagation through node ancestors). Ignore if we've + // already captured the event. + if (!event || lastCapturedEvent === event) { + return + } + lastCapturedEvent = event + if (debounceTimer) { + clearTimeout(debounceTimer) + } + if (debounce) { + debounceTimer = setTimeout(function () { + handler({ event: event, name: name }) + }) + } else { + handler({ event: event, name: name }) + } + } + } + /** + * Wraps addEventListener to capture keypress UI events + * @param handler function that will be triggered + * @returns wrapped keypress events handler + * @hidden + */ + function keypressEventHandler(handler) { + // TODO: if somehow user switches keypress target before + // debounce timeout is triggered, we will only capture + // a single breadcrumb from the FIRST target (acceptable?) + return function (event) { + var target + try { + target = event.target + } catch (e) { + // just accessing event properties can throw an exception in some rare circumstances + // see: https://github.com/getsentry/raven-js/issues/838 + return + } + var tagName = target && target.tagName + // only consider keypress events on actual input elements + // this will disregard keypresses targeting body (e.g. tabbing + // through elements, hotkeys, etc) + if ( + !tagName || + (tagName !== 'INPUT' && + tagName !== 'TEXTAREA' && + !target.isContentEditable) + ) { + return + } + // record first keypress in a series, but ignore subsequent + // keypresses until debounce clears + if (!keypressTimeout) { + domEventHandler('input', handler)(event) + } + clearTimeout(keypressTimeout) + keypressTimeout = setTimeout(function () { + keypressTimeout = undefined + }, debounceDuration) + } + } + var _oldOnErrorHandler = null + /** JSDoc */ + function instrumentError() { + _oldOnErrorHandler = global.onerror + global.onerror = function (msg, url, line, column, error) { + triggerHandlers('error', { + column: column, + error: error, + line: line, + msg: msg, + url: url + }) + if (_oldOnErrorHandler) { + // eslint-disable-next-line prefer-rest-params + return _oldOnErrorHandler.apply(this, arguments) + } + return false + } + } + var _oldOnUnhandledRejectionHandler = null + /** JSDoc */ + function instrumentUnhandledRejection() { + _oldOnUnhandledRejectionHandler = global.onunhandledrejection + global.onunhandledrejection = function (e) { + triggerHandlers('unhandledrejection', e) + if (_oldOnUnhandledRejectionHandler) { + // eslint-disable-next-line prefer-rest-params + return _oldOnUnhandledRejectionHandler.apply(this, arguments) + } + return true + } + } + //# sourceMappingURL=instrument.js.map + + /***/ + }, + + /***/ 92757: /***/ (__unused_webpack_module, exports) => { + Object.defineProperty(exports, '__esModule', { value: true }) + /* eslint-disable @typescript-eslint/no-explicit-any */ + /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ + /** + * Checks whether given value's type is one of a few Error or Error-like + * {@link isError}. + * + * @param wat A value to be checked. + * @returns A boolean representing the result. + */ + function isError(wat) { + switch (Object.prototype.toString.call(wat)) { + case '[object Error]': + return true + case '[object Exception]': + return true + case '[object DOMException]': + return true + default: + return isInstanceOf(wat, Error) + } + } + exports.isError = isError + /** + * Checks whether given value's type is ErrorEvent + * {@link isErrorEvent}. + * + * @param wat A value to be checked. + * @returns A boolean representing the result. + */ + function isErrorEvent(wat) { + return Object.prototype.toString.call(wat) === '[object ErrorEvent]' + } + exports.isErrorEvent = isErrorEvent + /** + * Checks whether given value's type is DOMError + * {@link isDOMError}. + * + * @param wat A value to be checked. + * @returns A boolean representing the result. + */ + function isDOMError(wat) { + return Object.prototype.toString.call(wat) === '[object DOMError]' + } + exports.isDOMError = isDOMError + /** + * Checks whether given value's type is DOMException + * {@link isDOMException}. + * + * @param wat A value to be checked. + * @returns A boolean representing the result. + */ + function isDOMException(wat) { + return Object.prototype.toString.call(wat) === '[object DOMException]' + } + exports.isDOMException = isDOMException + /** + * Checks whether given value's type is a string + * {@link isString}. + * + * @param wat A value to be checked. + * @returns A boolean representing the result. + */ + function isString(wat) { + return Object.prototype.toString.call(wat) === '[object String]' + } + exports.isString = isString + /** + * Checks whether given value's is a primitive (undefined, null, number, boolean, string) + * {@link isPrimitive}. + * + * @param wat A value to be checked. + * @returns A boolean representing the result. + */ + function isPrimitive(wat) { + return ( + wat === null || (typeof wat !== 'object' && typeof wat !== 'function') + ) + } + exports.isPrimitive = isPrimitive + /** + * Checks whether given value's type is an object literal + * {@link isPlainObject}. + * + * @param wat A value to be checked. + * @returns A boolean representing the result. + */ + function isPlainObject(wat) { + return Object.prototype.toString.call(wat) === '[object Object]' + } + exports.isPlainObject = isPlainObject + /** + * Checks whether given value's type is an Event instance + * {@link isEvent}. + * + * @param wat A value to be checked. + * @returns A boolean representing the result. + */ + function isEvent(wat) { + return typeof Event !== 'undefined' && isInstanceOf(wat, Event) + } + exports.isEvent = isEvent + /** + * Checks whether given value's type is an Element instance + * {@link isElement}. + * + * @param wat A value to be checked. + * @returns A boolean representing the result. + */ + function isElement(wat) { + return typeof Element !== 'undefined' && isInstanceOf(wat, Element) + } + exports.isElement = isElement + /** + * Checks whether given value's type is an regexp + * {@link isRegExp}. + * + * @param wat A value to be checked. + * @returns A boolean representing the result. + */ + function isRegExp(wat) { + return Object.prototype.toString.call(wat) === '[object RegExp]' + } + exports.isRegExp = isRegExp + /** + * Checks whether given value has a then function. + * @param wat A value to be checked. + */ + function isThenable(wat) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + return Boolean(wat && wat.then && typeof wat.then === 'function') + } + exports.isThenable = isThenable + /** + * Checks whether given value's type is a SyntheticEvent + * {@link isSyntheticEvent}. + * + * @param wat A value to be checked. + * @returns A boolean representing the result. + */ + function isSyntheticEvent(wat) { + return ( + isPlainObject(wat) && + 'nativeEvent' in wat && + 'preventDefault' in wat && + 'stopPropagation' in wat + ) + } + exports.isSyntheticEvent = isSyntheticEvent + /** + * Checks whether given value's type is an instance of provided constructor. + * {@link isInstanceOf}. + * + * @param wat A value to be checked. + * @param base A constructor to be used in a check. + * @returns A boolean representing the result. + */ + function isInstanceOf(wat, base) { + try { + return wat instanceof base + } catch (_e) { + return false + } + } + exports.isInstanceOf = isInstanceOf + //# sourceMappingURL=is.js.map + + /***/ + }, + + /***/ 15577: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + /* eslint-disable @typescript-eslint/no-explicit-any */ + var misc_1 = __webpack_require__(32154) + // TODO: Implement different loggers for different environments + var global = misc_1.getGlobalObject() + /** Prefix for logging strings */ + var PREFIX = 'Sentry Logger ' + /** JSDoc */ + var Logger = /** @class */ (function () { + /** JSDoc */ + function Logger() { + this._enabled = false + } + /** JSDoc */ + Logger.prototype.disable = function () { + this._enabled = false + } + /** JSDoc */ + Logger.prototype.enable = function () { + this._enabled = true + } + /** JSDoc */ + Logger.prototype.log = function () { + var args = [] + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i] + } + if (!this._enabled) { + return + } + misc_1.consoleSandbox(function () { + global.console.log(PREFIX + '[Log]: ' + args.join(' ')) + }) + } + /** JSDoc */ + Logger.prototype.warn = function () { + var args = [] + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i] + } + if (!this._enabled) { + return + } + misc_1.consoleSandbox(function () { + global.console.warn(PREFIX + '[Warn]: ' + args.join(' ')) + }) + } + /** JSDoc */ + Logger.prototype.error = function () { + var args = [] + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i] + } + if (!this._enabled) { + return + } + misc_1.consoleSandbox(function () { + global.console.error(PREFIX + '[Error]: ' + args.join(' ')) + }) + } + return Logger + })() + // Ensure we only have a single logger instance, even if multiple versions of @sentry/utils are being used + global.__SENTRY__ = global.__SENTRY__ || {} + var logger = + global.__SENTRY__.logger || (global.__SENTRY__.logger = new Logger()) + exports.logger = logger + //# sourceMappingURL=logger.js.map + + /***/ + }, + + /***/ 49515: /***/ (__unused_webpack_module, exports) => { + Object.defineProperty(exports, '__esModule', { value: true }) + /* eslint-disable @typescript-eslint/no-unsafe-member-access */ + /* eslint-disable @typescript-eslint/no-explicit-any */ + /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ + /** + * Memo class used for decycle json objects. Uses WeakSet if available otherwise array. + */ + var Memo = /** @class */ (function () { + function Memo() { + this._hasWeakSet = typeof WeakSet === 'function' + this._inner = this._hasWeakSet ? new WeakSet() : [] + } + /** + * Sets obj to remember. + * @param obj Object to remember + */ + Memo.prototype.memoize = function (obj) { + if (this._hasWeakSet) { + if (this._inner.has(obj)) { + return true + } + this._inner.add(obj) + return false + } + // eslint-disable-next-line @typescript-eslint/prefer-for-of + for (var i = 0; i < this._inner.length; i++) { + var value = this._inner[i] + if (value === obj) { + return true + } + } + this._inner.push(obj) + return false + } + /** + * Removes object from internal storage. + * @param obj Object to forget + */ + Memo.prototype.unmemoize = function (obj) { + if (this._hasWeakSet) { + this._inner.delete(obj) + } else { + for (var i = 0; i < this._inner.length; i++) { + if (this._inner[i] === obj) { + this._inner.splice(i, 1) + break + } + } + } + } + return Memo + })() + exports.Memo = Memo + //# sourceMappingURL=memo.js.map + + /***/ + }, + + /***/ 32154: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var node_1 = __webpack_require__(16411) + var string_1 = __webpack_require__(66538) + var fallbackGlobalObject = {} + /** + * Safely get global scope object + * + * @returns Global scope object + */ + function getGlobalObject() { + return node_1.isNodeEnv() + ? global + : typeof window !== 'undefined' + ? window + : typeof self !== 'undefined' + ? self + : fallbackGlobalObject + } + exports.getGlobalObject = getGlobalObject + /** + * UUID4 generator + * + * @returns string Generated UUID4. + */ + function uuid4() { + var global = getGlobalObject() + var crypto = global.crypto || global.msCrypto + if (!(crypto === void 0) && crypto.getRandomValues) { + // Use window.crypto API if available + var arr = new Uint16Array(8) + crypto.getRandomValues(arr) + // set 4 in byte 7 + // eslint-disable-next-line no-bitwise + arr[3] = (arr[3] & 0xfff) | 0x4000 + // set 2 most significant bits of byte 9 to '10' + // eslint-disable-next-line no-bitwise + arr[4] = (arr[4] & 0x3fff) | 0x8000 + var pad = function (num) { + var v = num.toString(16) + while (v.length < 4) { + v = '0' + v + } + return v + } + return ( + pad(arr[0]) + + pad(arr[1]) + + pad(arr[2]) + + pad(arr[3]) + + pad(arr[4]) + + pad(arr[5]) + + pad(arr[6]) + + pad(arr[7]) + ) + } + // http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#2117523 + return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function ( + c + ) { + // eslint-disable-next-line no-bitwise + var r = (Math.random() * 16) | 0 + // eslint-disable-next-line no-bitwise + var v = c === 'x' ? r : (r & 0x3) | 0x8 + return v.toString(16) + }) + } + exports.uuid4 = uuid4 + /** + * Parses string form of URL into an object + * // borrowed from https://tools.ietf.org/html/rfc3986#appendix-B + * // intentionally using regex and not href parsing trick because React Native and other + * // environments where DOM might not be available + * @returns parsed URL object + */ + function parseUrl(url) { + if (!url) { + return {} + } + var match = url.match( + /^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/ + ) + if (!match) { + return {} + } + // coerce to undefined values to empty string so we don't get 'undefined' + var query = match[6] || '' + var fragment = match[8] || '' + return { + host: match[4], + path: match[5], + protocol: match[2], + relative: match[5] + query + fragment + } + } + exports.parseUrl = parseUrl + /** + * Extracts either message or type+value from an event that can be used for user-facing logs + * @returns event's description + */ + function getEventDescription(event) { + if (event.message) { + return event.message + } + if ( + event.exception && + event.exception.values && + event.exception.values[0] + ) { + var exception = event.exception.values[0] + if (exception.type && exception.value) { + return exception.type + ': ' + exception.value + } + return ( + exception.type || exception.value || event.event_id || '' + ) + } + return event.event_id || '' + } + exports.getEventDescription = getEventDescription + /** JSDoc */ + function consoleSandbox(callback) { + var global = getGlobalObject() + var levels = ['debug', 'info', 'warn', 'error', 'log', 'assert'] + if (!('console' in global)) { + return callback() + } + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + var originalConsole = global.console + var wrappedLevels = {} + // Restore all wrapped console methods + levels.forEach(function (level) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + if ( + level in global.console && + originalConsole[level].__sentry_original__ + ) { + wrappedLevels[level] = originalConsole[level] + originalConsole[level] = originalConsole[level].__sentry_original__ + } + }) + // Perform callback manipulations + var result = callback() + // Revert restoration to wrapped state + Object.keys(wrappedLevels).forEach(function (level) { + originalConsole[level] = wrappedLevels[level] + }) + return result + } + exports.consoleSandbox = consoleSandbox + /** + * Adds exception values, type and value to an synthetic Exception. + * @param event The event to modify. + * @param value Value of the exception. + * @param type Type of the exception. + * @hidden + */ + function addExceptionTypeValue(event, value, type) { + event.exception = event.exception || {} + event.exception.values = event.exception.values || [] + event.exception.values[0] = event.exception.values[0] || {} + event.exception.values[0].value = + event.exception.values[0].value || value || '' + event.exception.values[0].type = + event.exception.values[0].type || type || 'Error' + } + exports.addExceptionTypeValue = addExceptionTypeValue + /** + * Adds exception mechanism to a given event. + * @param event The event to modify. + * @param mechanism Mechanism of the mechanism. + * @hidden + */ + function addExceptionMechanism(event, mechanism) { + if (mechanism === void 0) { + mechanism = {} + } + // TODO: Use real type with `keyof Mechanism` thingy and maybe make it better? + try { + // @ts-ignore Type 'Mechanism | {}' is not assignable to type 'Mechanism | undefined' + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + event.exception.values[0].mechanism = + event.exception.values[0].mechanism || {} + Object.keys(mechanism).forEach(function (key) { + // @ts-ignore Mechanism has no index signature + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + event.exception.values[0].mechanism[key] = mechanism[key] + }) + } catch (_oO) { + // no-empty + } + } + exports.addExceptionMechanism = addExceptionMechanism + /** + * A safe form of location.href + */ + function getLocationHref() { + try { + return document.location.href + } catch (oO) { + return '' + } + } + exports.getLocationHref = getLocationHref + // https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string + var SEMVER_REGEXP = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/ + /** + * Parses input into a SemVer interface + * @param input string representation of a semver version + */ + function parseSemver(input) { + var match = input.match(SEMVER_REGEXP) || [] + var major = parseInt(match[1], 10) + var minor = parseInt(match[2], 10) + var patch = parseInt(match[3], 10) + return { + buildmetadata: match[5], + major: isNaN(major) ? undefined : major, + minor: isNaN(minor) ? undefined : minor, + patch: isNaN(patch) ? undefined : patch, + prerelease: match[4] + } + } + exports.parseSemver = parseSemver + var defaultRetryAfter = 60 * 1000 // 60 seconds + /** + * Extracts Retry-After value from the request header or returns default value + * @param now current unix timestamp + * @param header string representation of 'Retry-After' header + */ + function parseRetryAfterHeader(now, header) { + if (!header) { + return defaultRetryAfter + } + var headerDelay = parseInt('' + header, 10) + if (!isNaN(headerDelay)) { + return headerDelay * 1000 + } + var headerDate = Date.parse('' + header) + if (!isNaN(headerDate)) { + return headerDate - now + } + return defaultRetryAfter + } + exports.parseRetryAfterHeader = parseRetryAfterHeader + /** + * This function adds context (pre/post/line) lines to the provided frame + * + * @param lines string[] containing all lines + * @param frame StackFrame that will be mutated + * @param linesOfContext number of context lines we want to add pre/post + */ + function addContextToFrame(lines, frame, linesOfContext) { + if (linesOfContext === void 0) { + linesOfContext = 5 + } + var lineno = frame.lineno || 0 + var maxLines = lines.length + var sourceLine = Math.max(Math.min(maxLines, lineno - 1), 0) + frame.pre_context = lines + .slice(Math.max(0, sourceLine - linesOfContext), sourceLine) + .map(function (line) { + return string_1.snipLine(line, 0) + }) + frame.context_line = string_1.snipLine( + lines[Math.min(maxLines - 1, sourceLine)], + frame.colno || 0 + ) + frame.post_context = lines + .slice( + Math.min(sourceLine + 1, maxLines), + sourceLine + 1 + linesOfContext + ) + .map(function (line) { + return string_1.snipLine(line, 0) + }) + } + exports.addContextToFrame = addContextToFrame + /** + * Strip the query string and fragment off of a given URL or path (if present) + * + * @param urlPath Full URL or path, including possible query string and/or fragment + * @returns URL or path without query string or fragment + */ + function stripUrlQueryAndFragment(urlPath) { + // eslint-disable-next-line no-useless-escape + return urlPath.split(/[\?#]/, 1)[0] + } + exports.stripUrlQueryAndFragment = stripUrlQueryAndFragment + //# sourceMappingURL=misc.js.map + + /***/ + }, + + /***/ 16411: /***/ (module, exports, __webpack_require__) => { + /* module decorator */ module = __webpack_require__.nmd(module) + Object.defineProperty(exports, '__esModule', { value: true }) + var is_1 = __webpack_require__(92757) + var object_1 = __webpack_require__(69249) + /** + * Checks whether we're in the Node.js or Browser environment + * + * @returns Answer to given question + */ + function isNodeEnv() { + return ( + Object.prototype.toString.call( + typeof process !== 'undefined' ? process : 0 + ) === '[object process]' + ) + } + exports.isNodeEnv = isNodeEnv + /** + * Requires a module which is protected against bundler minification. + * + * @param request The module path to resolve + */ + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types + function dynamicRequire(mod, request) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + return mod.require(request) + } + exports.dynamicRequire = dynamicRequire + /** Default request keys that'll be used to extract data from the request */ + var DEFAULT_REQUEST_KEYS = [ + 'cookies', + 'data', + 'headers', + 'method', + 'query_string', + 'url' + ] + /** + * Normalizes data from the request object, accounting for framework differences. + * + * @param req The request object from which to extract data + * @param keys An optional array of keys to include in the normalized data. Defaults to DEFAULT_REQUEST_KEYS if not + * provided. + * @returns An object containing normalized request data + */ + function extractNodeRequestData(req, keys) { + if (keys === void 0) { + keys = DEFAULT_REQUEST_KEYS + } + // make sure we can safely use dynamicRequire below + if (!isNodeEnv()) { + throw new Error( + "Can't get node request data outside of a node environment" + ) + } + var requestData = {} + // headers: + // node, express: req.headers + // koa: req.header + var headers = req.headers || req.header || {} + // method: + // node, express, koa: req.method + var method = req.method + // host: + // express: req.hostname in > 4 and req.host in < 4 + // koa: req.host + // node: req.headers.host + var host = req.hostname || req.host || headers.host || '' + // protocol: + // node: + // express, koa: req.protocol + var protocol = + req.protocol === 'https' || req.secure || (req.socket || {}).encrypted + ? 'https' + : 'http' + // url (including path and query string): + // node, express: req.originalUrl + // koa: req.url + var originalUrl = req.originalUrl || req.url || '' + // absolute url + var absoluteUrl = protocol + '://' + host + originalUrl + keys.forEach(function (key) { + switch (key) { + case 'headers': + requestData.headers = headers + break + case 'method': + requestData.method = method + break + case 'url': + requestData.url = absoluteUrl + break + case 'cookies': + // cookies: + // node, express, koa: req.headers.cookie + // vercel, sails.js, express (w/ cookie middleware): req.cookies + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + requestData.cookies = + req.cookies || + dynamicRequire(module, 'cookie').parse(headers.cookie || '') + break + case 'query_string': + // query string: + // node: req.url (raw) + // express, koa: req.query + // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + requestData.query_string = dynamicRequire(module, 'url').parse( + originalUrl || '', + false + ).query + break + case 'data': + if (method === 'GET' || method === 'HEAD') { + break + } + // body data: + // node, express, koa: req.body + if (req.body !== undefined) { + requestData.data = is_1.isString(req.body) + ? req.body + : JSON.stringify(object_1.normalize(req.body)) + } + break + default: + if ({}.hasOwnProperty.call(req, key)) { + requestData[key] = req[key] + } + } + }) + return requestData + } + exports.extractNodeRequestData = extractNodeRequestData + //# sourceMappingURL=node.js.map + + /***/ + }, + + /***/ 69249: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var tslib_1 = __webpack_require__(75636) + var browser_1 = __webpack_require__(30597) + var is_1 = __webpack_require__(92757) + var memo_1 = __webpack_require__(49515) + var stacktrace_1 = __webpack_require__(5986) + var string_1 = __webpack_require__(66538) + /** + * Wrap a given object method with a higher-order function + * + * @param source An object that contains a method to be wrapped. + * @param name A name of method to be wrapped. + * @param replacement A function that should be used to wrap a given method. + * @returns void + */ + function fill(source, name, replacement) { + if (!(name in source)) { + return + } + var original = source[name] + var wrapped = replacement(original) + // Make sure it's a function first, as we need to attach an empty prototype for `defineProperties` to work + // otherwise it'll throw "TypeError: Object.defineProperties called on non-object" + if (typeof wrapped === 'function') { + try { + wrapped.prototype = wrapped.prototype || {} + Object.defineProperties(wrapped, { + __sentry_original__: { + enumerable: false, + value: original + } + }) + } catch (_Oo) { + // This can throw if multiple fill happens on a global object like XMLHttpRequest + // Fixes https://github.com/getsentry/sentry-javascript/issues/2043 + } + } + source[name] = wrapped + } + exports.fill = fill + /** + * Encodes given object into url-friendly format + * + * @param object An object that contains serializable values + * @returns string Encoded + */ + function urlEncode(object) { + return Object.keys(object) + .map(function (key) { + return ( + encodeURIComponent(key) + '=' + encodeURIComponent(object[key]) + ) + }) + .join('&') + } + exports.urlEncode = urlEncode + /** + * Transforms any object into an object literal with all it's attributes + * attached to it. + * + * @param value Initial source that we have to transform in order to be usable by the serializer + */ + function getWalkSource(value) { + if (is_1.isError(value)) { + var error = value + var err = { + message: error.message, + name: error.name, + stack: error.stack + } + for (var i in error) { + if (Object.prototype.hasOwnProperty.call(error, i)) { + err[i] = error[i] + } + } + return err + } + if (is_1.isEvent(value)) { + var event_1 = value + var source = {} + source.type = event_1.type + // Accessing event.target can throw (see getsentry/raven-js#838, #768) + try { + source.target = is_1.isElement(event_1.target) + ? browser_1.htmlTreeAsString(event_1.target) + : Object.prototype.toString.call(event_1.target) + } catch (_oO) { + source.target = '' + } + try { + source.currentTarget = is_1.isElement(event_1.currentTarget) + ? browser_1.htmlTreeAsString(event_1.currentTarget) + : Object.prototype.toString.call(event_1.currentTarget) + } catch (_oO) { + source.currentTarget = '' + } + if ( + typeof CustomEvent !== 'undefined' && + is_1.isInstanceOf(value, CustomEvent) + ) { + source.detail = event_1.detail + } + for (var i in event_1) { + if (Object.prototype.hasOwnProperty.call(event_1, i)) { + source[i] = event_1 + } + } + return source + } + return value + } + /** Calculates bytes size of input string */ + function utf8Length(value) { + // eslint-disable-next-line no-bitwise + return ~-encodeURI(value).split(/%..|./).length + } + /** Calculates bytes size of input object */ + function jsonSize(value) { + return utf8Length(JSON.stringify(value)) + } + /** JSDoc */ + function normalizeToSize( + object, + // Default Node.js REPL depth + depth, + // 100kB, as 200kB is max payload size, so half sounds reasonable + maxSize + ) { + if (depth === void 0) { + depth = 3 + } + if (maxSize === void 0) { + maxSize = 100 * 1024 + } + var serialized = normalize(object, depth) + if (jsonSize(serialized) > maxSize) { + return normalizeToSize(object, depth - 1, maxSize) + } + return serialized + } + exports.normalizeToSize = normalizeToSize + /** Transforms any input value into a string form, either primitive value or a type of the input */ + function serializeValue(value) { + var type = Object.prototype.toString.call(value) + // Node.js REPL notation + if (typeof value === 'string') { + return value + } + if (type === '[object Object]') { + return '[Object]' + } + if (type === '[object Array]') { + return '[Array]' + } + var normalized = normalizeValue(value) + return is_1.isPrimitive(normalized) ? normalized : type + } + /** + * normalizeValue() + * + * Takes unserializable input and make it serializable friendly + * + * - translates undefined/NaN values to "[undefined]"/"[NaN]" respectively, + * - serializes Error objects + * - filter global objects + */ + function normalizeValue(value, key) { + if ( + key === 'domain' && + value && + typeof value === 'object' && + value._events + ) { + return '[Domain]' + } + if (key === 'domainEmitter') { + return '[DomainEmitter]' + } + if (typeof global !== 'undefined' && value === global) { + return '[Global]' + } + if (typeof window !== 'undefined' && value === window) { + return '[Window]' + } + if (typeof document !== 'undefined' && value === document) { + return '[Document]' + } + // React's SyntheticEvent thingy + if (is_1.isSyntheticEvent(value)) { + return '[SyntheticEvent]' + } + if (typeof value === 'number' && value !== value) { + return '[NaN]' + } + if (value === void 0) { + return '[undefined]' + } + if (typeof value === 'function') { + return '[Function: ' + stacktrace_1.getFunctionName(value) + ']' + } + return value + } + /** + * Walks an object to perform a normalization on it + * + * @param key of object that's walked in current iteration + * @param value object to be walked + * @param depth Optional number indicating how deep should walking be performed + * @param memo Optional Memo class handling decycling + */ + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types + function walk(key, value, depth, memo) { + if (depth === void 0) { + depth = +Infinity + } + if (memo === void 0) { + memo = new memo_1.Memo() + } + // If we reach the maximum depth, serialize whatever has left + if (depth === 0) { + return serializeValue(value) + } + /* eslint-disable @typescript-eslint/no-unsafe-member-access */ + // If value implements `toJSON` method, call it and return early + if ( + value !== null && + value !== undefined && + typeof value.toJSON === 'function' + ) { + return value.toJSON() + } + /* eslint-enable @typescript-eslint/no-unsafe-member-access */ + // If normalized value is a primitive, there are no branches left to walk, so we can just bail out, as theres no point in going down that branch any further + var normalized = normalizeValue(value, key) + if (is_1.isPrimitive(normalized)) { + return normalized + } + // Create source that we will use for next itterations, either objectified error object (Error type with extracted keys:value pairs) or the input itself + var source = getWalkSource(value) + // Create an accumulator that will act as a parent for all future itterations of that branch + var acc = Array.isArray(value) ? [] : {} + // If we already walked that branch, bail out, as it's circular reference + if (memo.memoize(value)) { + return '[Circular ~]' + } + // Walk all keys of the source + for (var innerKey in source) { + // Avoid iterating over fields in the prototype if they've somehow been exposed to enumeration. + if (!Object.prototype.hasOwnProperty.call(source, innerKey)) { + continue + } + // Recursively walk through all the child nodes + acc[innerKey] = walk(innerKey, source[innerKey], depth - 1, memo) + } + // Once walked through all the branches, remove the parent from memo storage + memo.unmemoize(value) + // Return accumulated values + return acc + } + exports.walk = walk + /** + * normalize() + * + * - Creates a copy to prevent original input mutation + * - Skip non-enumerablers + * - Calls `toJSON` if implemented + * - Removes circular references + * - Translates non-serializeable values (undefined/NaN/Functions) to serializable format + * - Translates known global objects/Classes to a string representations + * - Takes care of Error objects serialization + * - Optionally limit depth of final output + */ + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types + function normalize(input, depth) { + try { + return JSON.parse( + JSON.stringify(input, function (key, value) { + return walk(key, value, depth) + }) + ) + } catch (_oO) { + return '**non-serializable**' + } + } + exports.normalize = normalize + /** + * Given any captured exception, extract its keys and create a sorted + * and truncated list that will be used inside the event message. + * eg. `Non-error exception captured with keys: foo, bar, baz` + */ + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types + function extractExceptionKeysForMessage(exception, maxLength) { + if (maxLength === void 0) { + maxLength = 40 + } + var keys = Object.keys(getWalkSource(exception)) + keys.sort() + if (!keys.length) { + return '[object has no keys]' + } + if (keys[0].length >= maxLength) { + return string_1.truncate(keys[0], maxLength) + } + for (var includedKeys = keys.length; includedKeys > 0; includedKeys--) { + var serialized = keys.slice(0, includedKeys).join(', ') + if (serialized.length > maxLength) { + continue + } + if (includedKeys === keys.length) { + return serialized + } + return string_1.truncate(serialized, maxLength) + } + return '' + } + exports.extractExceptionKeysForMessage = extractExceptionKeysForMessage + /** + * Given any object, return the new object with removed keys that value was `undefined`. + * Works recursively on objects and arrays. + */ + function dropUndefinedKeys(val) { + var e_1, _a + if (is_1.isPlainObject(val)) { + var obj = val + var rv = {} + try { + for ( + var _b = tslib_1.__values(Object.keys(obj)), _c = _b.next(); + !_c.done; + _c = _b.next() + ) { + var key = _c.value + if (typeof obj[key] !== 'undefined') { + rv[key] = dropUndefinedKeys(obj[key]) + } + } + } catch (e_1_1) { + e_1 = { error: e_1_1 } + } finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b) + } finally { + if (e_1) throw e_1.error + } + } + return rv + } + if (Array.isArray(val)) { + return val.map(dropUndefinedKeys) + } + return val + } + exports.dropUndefinedKeys = dropUndefinedKeys + //# sourceMappingURL=object.js.map + + /***/ + }, + + /***/ 39188: /***/ (__unused_webpack_module, exports) => { + // Slightly modified (no IE8 support, ES6) and transcribed to TypeScript + // https://raw.githubusercontent.com/calvinmetcalf/rollup-plugin-node-builtins/master/src/es6/path.js + Object.defineProperty(exports, '__esModule', { value: true }) + /** JSDoc */ + function normalizeArray(parts, allowAboveRoot) { + // if the path tries to go above the root, `up` ends up > 0 + var up = 0 + for (var i = parts.length - 1; i >= 0; i--) { + var last = parts[i] + if (last === '.') { + parts.splice(i, 1) + } else if (last === '..') { + parts.splice(i, 1) + // eslint-disable-next-line no-plusplus + up++ + } else if (up) { + parts.splice(i, 1) + // eslint-disable-next-line no-plusplus + up-- + } + } + // if the path is allowed to go above the root, restore leading ..s + if (allowAboveRoot) { + // eslint-disable-next-line no-plusplus + for (; up--; up) { + parts.unshift('..') + } + } + return parts + } + // Split a filename into [root, dir, basename, ext], unix version + // 'root' is just a slash, or nothing. + var splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^/]+?|)(\.[^./]*|))(?:[/]*)$/ + /** JSDoc */ + function splitPath(filename) { + var parts = splitPathRe.exec(filename) + return parts ? parts.slice(1) : [] + } + // path.resolve([from ...], to) + // posix version + /** JSDoc */ + function resolve() { + var args = [] + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i] + } + var resolvedPath = '' + var resolvedAbsolute = false + for (var i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) { + var path = i >= 0 ? args[i] : '/' + // Skip empty entries + if (!path) { + continue + } + resolvedPath = path + '/' + resolvedPath + resolvedAbsolute = path.charAt(0) === '/' + } + // At this point the path should be resolved to a full absolute path, but + // handle relative paths to be safe (might happen when process.cwd() fails) + // Normalize the path + resolvedPath = normalizeArray( + resolvedPath.split('/').filter(function (p) { + return !!p + }), + !resolvedAbsolute + ).join('/') + return (resolvedAbsolute ? '/' : '') + resolvedPath || '.' + } + exports.resolve = resolve + /** JSDoc */ + function trim(arr) { + var start = 0 + for (; start < arr.length; start++) { + if (arr[start] !== '') { + break + } + } + var end = arr.length - 1 + for (; end >= 0; end--) { + if (arr[end] !== '') { + break + } + } + if (start > end) { + return [] + } + return arr.slice(start, end - start + 1) + } + // path.relative(from, to) + // posix version + /** JSDoc */ + function relative(from, to) { + /* eslint-disable no-param-reassign */ + from = resolve(from).substr(1) + to = resolve(to).substr(1) + /* eslint-enable no-param-reassign */ + var fromParts = trim(from.split('/')) + var toParts = trim(to.split('/')) + var length = Math.min(fromParts.length, toParts.length) + var samePartsLength = length + for (var i = 0; i < length; i++) { + if (fromParts[i] !== toParts[i]) { + samePartsLength = i + break + } + } + var outputParts = [] + for (var i = samePartsLength; i < fromParts.length; i++) { + outputParts.push('..') + } + outputParts = outputParts.concat(toParts.slice(samePartsLength)) + return outputParts.join('/') + } + exports.relative = relative + // path.normalize(path) + // posix version + /** JSDoc */ + function normalizePath(path) { + var isPathAbsolute = isAbsolute(path) + var trailingSlash = path.substr(-1) === '/' + // Normalize the path + var normalizedPath = normalizeArray( + path.split('/').filter(function (p) { + return !!p + }), + !isPathAbsolute + ).join('/') + if (!normalizedPath && !isPathAbsolute) { + normalizedPath = '.' + } + if (normalizedPath && trailingSlash) { + normalizedPath += '/' + } + return (isPathAbsolute ? '/' : '') + normalizedPath + } + exports.normalizePath = normalizePath + // posix version + /** JSDoc */ + function isAbsolute(path) { + return path.charAt(0) === '/' + } + exports.isAbsolute = isAbsolute + // posix version + /** JSDoc */ + function join() { + var args = [] + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i] + } + return normalizePath(args.join('/')) + } + exports.join = join + /** JSDoc */ + function dirname(path) { + var result = splitPath(path) + var root = result[0] + var dir = result[1] + if (!root && !dir) { + // No dirname whatsoever + return '.' + } + if (dir) { + // It has a dirname, strip trailing slash + dir = dir.substr(0, dir.length - 1) + } + return root + dir + } + exports.dirname = dirname + /** JSDoc */ + function basename(path, ext) { + var f = splitPath(path)[2] + if (ext && f.substr(ext.length * -1) === ext) { + f = f.substr(0, f.length - ext.length) + } + return f + } + exports.basename = basename + //# sourceMappingURL=path.js.map + + /***/ + }, + + /***/ 1243: /***/ (__unused_webpack_module, exports) => { + Object.defineProperty(exports, '__esModule', { value: true }) + exports.setPrototypeOf = + Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array ? setProtoOf : mixinProperties) + /** + * setPrototypeOf polyfill using __proto__ + */ + // eslint-disable-next-line @typescript-eslint/ban-types + function setProtoOf(obj, proto) { + // @ts-ignore __proto__ does not exist on obj + obj.__proto__ = proto + return obj + } + /** + * setPrototypeOf polyfill using mixin + */ + // eslint-disable-next-line @typescript-eslint/ban-types + function mixinProperties(obj, proto) { + for (var prop in proto) { + // eslint-disable-next-line no-prototype-builtins + if (!obj.hasOwnProperty(prop)) { + // @ts-ignore typescript complains about indexing so we remove + obj[prop] = proto[prop] + } + } + return obj + } + //# sourceMappingURL=polyfill.js.map + + /***/ + }, + + /***/ 31811: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var error_1 = __webpack_require__(66238) + var syncpromise_1 = __webpack_require__(87833) + /** A simple queue that holds promises. */ + var PromiseBuffer = /** @class */ (function () { + function PromiseBuffer(_limit) { + this._limit = _limit + /** Internal set of queued Promises */ + this._buffer = [] + } + /** + * Says if the buffer is ready to take more requests + */ + PromiseBuffer.prototype.isReady = function () { + return this._limit === undefined || this.length() < this._limit + } + /** + * Add a promise to the queue. + * + * @param task Can be any PromiseLike + * @returns The original promise. + */ + PromiseBuffer.prototype.add = function (task) { + var _this = this + if (!this.isReady()) { + return syncpromise_1.SyncPromise.reject( + new error_1.SentryError( + 'Not adding Promise due to buffer limit reached.' + ) + ) + } + if (this._buffer.indexOf(task) === -1) { + this._buffer.push(task) + } + task + .then(function () { + return _this.remove(task) + }) + .then(null, function () { + return _this.remove(task).then(null, function () { + // We have to add this catch here otherwise we have an unhandledPromiseRejection + // because it's a new Promise chain. + }) + }) + return task + } + /** + * Remove a promise to the queue. + * + * @param task Can be any PromiseLike + * @returns Removed promise. + */ + PromiseBuffer.prototype.remove = function (task) { + var removedTask = this._buffer.splice( + this._buffer.indexOf(task), + 1 + )[0] + return removedTask + } + /** + * This function returns the number of unresolved promises in the queue. + */ + PromiseBuffer.prototype.length = function () { + return this._buffer.length + } + /** + * This will drain the whole queue, returns true if queue is empty or drained. + * If timeout is provided and the queue takes longer to drain, the promise still resolves but with false. + * + * @param timeout Number in ms to wait until it resolves with false. + */ + PromiseBuffer.prototype.drain = function (timeout) { + var _this = this + return new syncpromise_1.SyncPromise(function (resolve) { + var capturedSetTimeout = setTimeout(function () { + if (timeout && timeout > 0) { + resolve(false) + } + }, timeout) + syncpromise_1.SyncPromise.all(_this._buffer) + .then(function () { + clearTimeout(capturedSetTimeout) + resolve(true) + }) + .then(null, function () { + resolve(true) + }) + }) + } + return PromiseBuffer + })() + exports.PromiseBuffer = PromiseBuffer + //# sourceMappingURL=promisebuffer.js.map + + /***/ + }, + + /***/ 5986: /***/ (__unused_webpack_module, exports) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var defaultFunctionName = '' + /** + * Safely extract function name from itself + */ + function getFunctionName(fn) { + try { + if (!fn || typeof fn !== 'function') { + return defaultFunctionName + } + return fn.name || defaultFunctionName + } catch (e) { + // Just accessing custom props in some Selenium environments + // can cause a "Permission denied" exception (see raven-js#495). + return defaultFunctionName + } + } + exports.getFunctionName = getFunctionName + //# sourceMappingURL=stacktrace.js.map + + /***/ + }, + + /***/ 66538: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var is_1 = __webpack_require__(92757) + /** + * Truncates given string to the maximum characters count + * + * @param str An object that contains serializable values + * @param max Maximum number of characters in truncated string + * @returns string Encoded + */ + function truncate(str, max) { + if (max === void 0) { + max = 0 + } + if (typeof str !== 'string' || max === 0) { + return str + } + return str.length <= max ? str : str.substr(0, max) + '...' + } + exports.truncate = truncate + /** + * This is basically just `trim_line` from + * https://github.com/getsentry/sentry/blob/master/src/sentry/lang/javascript/processor.py#L67 + * + * @param str An object that contains serializable values + * @param max Maximum number of characters in truncated string + * @returns string Encoded + */ + function snipLine(line, colno) { + var newLine = line + var ll = newLine.length + if (ll <= 150) { + return newLine + } + if (colno > ll) { + // eslint-disable-next-line no-param-reassign + colno = ll + } + var start = Math.max(colno - 60, 0) + if (start < 5) { + start = 0 + } + var end = Math.min(start + 140, ll) + if (end > ll - 5) { + end = ll + } + if (end === ll) { + start = Math.max(end - 140, 0) + } + newLine = newLine.slice(start, end) + if (start > 0) { + newLine = "'{snip} " + newLine + } + if (end < ll) { + newLine += ' {snip}' + } + return newLine + } + exports.snipLine = snipLine + /** + * Join values in array + * @param input array of values to be joined together + * @param delimiter string to be placed in-between values + * @returns Joined values + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function safeJoin(input, delimiter) { + if (!Array.isArray(input)) { + return '' + } + var output = [] + // eslint-disable-next-line @typescript-eslint/prefer-for-of + for (var i = 0; i < input.length; i++) { + var value = input[i] + try { + output.push(String(value)) + } catch (e) { + output.push('[value cannot be serialized]') + } + } + return output.join(delimiter) + } + exports.safeJoin = safeJoin + /** + * Checks if the value matches a regex or includes the string + * @param value The string value to be checked against + * @param pattern Either a regex or a string that must be contained in value + */ + function isMatchingPattern(value, pattern) { + if (!is_1.isString(value)) { + return false + } + if (is_1.isRegExp(pattern)) { + return pattern.test(value) + } + if (typeof pattern === 'string') { + return value.indexOf(pattern) !== -1 + } + return false + } + exports.isMatchingPattern = isMatchingPattern + //# sourceMappingURL=string.js.map + + /***/ + }, + + /***/ 88714: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + var logger_1 = __webpack_require__(15577) + var misc_1 = __webpack_require__(32154) + /** + * Tells whether current environment supports ErrorEvent objects + * {@link supportsErrorEvent}. + * + * @returns Answer to the given question. + */ + function supportsErrorEvent() { + try { + new ErrorEvent('') + return true + } catch (e) { + return false + } + } + exports.supportsErrorEvent = supportsErrorEvent + /** + * Tells whether current environment supports DOMError objects + * {@link supportsDOMError}. + * + * @returns Answer to the given question. + */ + function supportsDOMError() { + try { + // Chrome: VM89:1 Uncaught TypeError: Failed to construct 'DOMError': + // 1 argument required, but only 0 present. + // @ts-ignore It really needs 1 argument, not 0. + new DOMError('') + return true + } catch (e) { + return false + } + } + exports.supportsDOMError = supportsDOMError + /** + * Tells whether current environment supports DOMException objects + * {@link supportsDOMException}. + * + * @returns Answer to the given question. + */ + function supportsDOMException() { + try { + new DOMException('') + return true + } catch (e) { + return false + } + } + exports.supportsDOMException = supportsDOMException + /** + * Tells whether current environment supports Fetch API + * {@link supportsFetch}. + * + * @returns Answer to the given question. + */ + function supportsFetch() { + if (!('fetch' in misc_1.getGlobalObject())) { + return false + } + try { + new Headers() + new Request('') + new Response() + return true + } catch (e) { + return false + } + } + exports.supportsFetch = supportsFetch + /** + * isNativeFetch checks if the given function is a native implementation of fetch() + */ + // eslint-disable-next-line @typescript-eslint/ban-types + function isNativeFetch(func) { + return ( + func && + /^function fetch\(\)\s+\{\s+\[native code\]\s+\}$/.test( + func.toString() + ) + ) + } + /** + * Tells whether current environment supports Fetch API natively + * {@link supportsNativeFetch}. + * + * @returns true if `window.fetch` is natively implemented, false otherwise + */ + function supportsNativeFetch() { + if (!supportsFetch()) { + return false + } + var global = misc_1.getGlobalObject() + // Fast path to avoid DOM I/O + // eslint-disable-next-line @typescript-eslint/unbound-method + if (isNativeFetch(global.fetch)) { + return true + } + // window.fetch is implemented, but is polyfilled or already wrapped (e.g: by a chrome extension) + // so create a "pure" iframe to see if that has native fetch + var result = false + var doc = global.document + // eslint-disable-next-line deprecation/deprecation + if (doc && typeof doc.createElement === 'function') { + try { + var sandbox = doc.createElement('iframe') + sandbox.hidden = true + doc.head.appendChild(sandbox) + if (sandbox.contentWindow && sandbox.contentWindow.fetch) { + // eslint-disable-next-line @typescript-eslint/unbound-method + result = isNativeFetch(sandbox.contentWindow.fetch) + } + doc.head.removeChild(sandbox) + } catch (err) { + logger_1.logger.warn( + 'Could not create sandbox iframe for pure fetch check, bailing to window.fetch: ', + err + ) + } + } + return result + } + exports.supportsNativeFetch = supportsNativeFetch + /** + * Tells whether current environment supports ReportingObserver API + * {@link supportsReportingObserver}. + * + * @returns Answer to the given question. + */ + function supportsReportingObserver() { + return 'ReportingObserver' in misc_1.getGlobalObject() + } + exports.supportsReportingObserver = supportsReportingObserver + /** + * Tells whether current environment supports Referrer Policy API + * {@link supportsReferrerPolicy}. + * + * @returns Answer to the given question. + */ + function supportsReferrerPolicy() { + // Despite all stars in the sky saying that Edge supports old draft syntax, aka 'never', 'always', 'origin' and 'default + // https://caniuse.com/#feat=referrer-policy + // It doesn't. And it throw exception instead of ignoring this parameter... + // REF: https://github.com/getsentry/raven-js/issues/1233 + if (!supportsFetch()) { + return false + } + try { + new Request('_', { + referrerPolicy: 'origin' + }) + return true + } catch (e) { + return false + } + } + exports.supportsReferrerPolicy = supportsReferrerPolicy + /** + * Tells whether current environment supports History API + * {@link supportsHistory}. + * + * @returns Answer to the given question. + */ + function supportsHistory() { + // NOTE: in Chrome App environment, touching history.pushState, *even inside + // a try/catch block*, will cause Chrome to output an error to console.error + // borrowed from: https://github.com/angular/angular.js/pull/13945/files + var global = misc_1.getGlobalObject() + /* eslint-disable @typescript-eslint/no-unsafe-member-access */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + var chrome = global.chrome + var isChromePackagedApp = chrome && chrome.app && chrome.app.runtime + /* eslint-enable @typescript-eslint/no-unsafe-member-access */ + var hasHistoryApi = + 'history' in global && + !!global.history.pushState && + !!global.history.replaceState + return !isChromePackagedApp && hasHistoryApi + } + exports.supportsHistory = supportsHistory + //# sourceMappingURL=supports.js.map + + /***/ + }, + + /***/ 87833: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + Object.defineProperty(exports, '__esModule', { value: true }) + /* eslint-disable @typescript-eslint/explicit-function-return-type */ + /* eslint-disable @typescript-eslint/typedef */ + /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ + /* eslint-disable @typescript-eslint/no-explicit-any */ + var is_1 = __webpack_require__(92757) + /** SyncPromise internal states */ + var States + ;(function (States) { + /** Pending */ + States['PENDING'] = 'PENDING' + /** Resolved / OK */ + States['RESOLVED'] = 'RESOLVED' + /** Rejected / Error */ + States['REJECTED'] = 'REJECTED' + })(States || (States = {})) + /** + * Thenable class that behaves like a Promise and follows it's interface + * but is not async internally + */ + var SyncPromise = /** @class */ (function () { + function SyncPromise(executor) { + var _this = this + this._state = States.PENDING + this._handlers = [] + /** JSDoc */ + this._resolve = function (value) { + _this._setResult(States.RESOLVED, value) + } + /** JSDoc */ + this._reject = function (reason) { + _this._setResult(States.REJECTED, reason) + } + /** JSDoc */ + this._setResult = function (state, value) { + if (_this._state !== States.PENDING) { + return + } + if (is_1.isThenable(value)) { + value.then(_this._resolve, _this._reject) + return + } + _this._state = state + _this._value = value + _this._executeHandlers() + } + // TODO: FIXME + /** JSDoc */ + this._attachHandler = function (handler) { + _this._handlers = _this._handlers.concat(handler) + _this._executeHandlers() + } + /** JSDoc */ + this._executeHandlers = function () { + if (_this._state === States.PENDING) { + return + } + var cachedHandlers = _this._handlers.slice() + _this._handlers = [] + cachedHandlers.forEach(function (handler) { + if (handler.done) { + return + } + if (_this._state === States.RESOLVED) { + if (handler.onfulfilled) { + // eslint-disable-next-line @typescript-eslint/no-floating-promises + handler.onfulfilled(_this._value) + } + } + if (_this._state === States.REJECTED) { + if (handler.onrejected) { + handler.onrejected(_this._value) + } + } + handler.done = true + }) + } + try { + executor(this._resolve, this._reject) + } catch (e) { + this._reject(e) + } + } + /** JSDoc */ + SyncPromise.resolve = function (value) { + return new SyncPromise(function (resolve) { + resolve(value) + }) + } + /** JSDoc */ + SyncPromise.reject = function (reason) { + return new SyncPromise(function (_, reject) { + reject(reason) + }) + } + /** JSDoc */ + SyncPromise.all = function (collection) { + return new SyncPromise(function (resolve, reject) { + if (!Array.isArray(collection)) { + reject(new TypeError('Promise.all requires an array as input.')) + return + } + if (collection.length === 0) { + resolve([]) + return + } + var counter = collection.length + var resolvedCollection = [] + collection.forEach(function (item, index) { + SyncPromise.resolve(item) + .then(function (value) { + resolvedCollection[index] = value + counter -= 1 + if (counter !== 0) { + return + } + resolve(resolvedCollection) + }) + .then(null, reject) + }) + }) + } + /** JSDoc */ + SyncPromise.prototype.then = function (onfulfilled, onrejected) { + var _this = this + return new SyncPromise(function (resolve, reject) { + _this._attachHandler({ + done: false, + onfulfilled: function (result) { + if (!onfulfilled) { + // TODO: ¯\_(ツ)_/¯ + // TODO: FIXME + resolve(result) + return + } + try { + resolve(onfulfilled(result)) + return + } catch (e) { + reject(e) + return + } + }, + onrejected: function (reason) { + if (!onrejected) { + reject(reason) + return + } + try { + resolve(onrejected(reason)) + return + } catch (e) { + reject(e) + return + } + } + }) + }) + } + /** JSDoc */ + SyncPromise.prototype.catch = function (onrejected) { + return this.then(function (val) { + return val + }, onrejected) + } + /** JSDoc */ + SyncPromise.prototype.finally = function (onfinally) { + var _this = this + return new SyncPromise(function (resolve, reject) { + var val + var isRejected + return _this + .then( + function (value) { + isRejected = false + val = value + if (onfinally) { + onfinally() + } + }, + function (reason) { + isRejected = true + val = reason + if (onfinally) { + onfinally() + } + } + ) + .then(function () { + if (isRejected) { + reject(val) + return + } + resolve(val) + }) + }) + } + /** JSDoc */ + SyncPromise.prototype.toString = function () { + return '[object SyncPromise]' + } + return SyncPromise + })() + exports.SyncPromise = SyncPromise + //# sourceMappingURL=syncpromise.js.map + + /***/ + }, + + /***/ 1735: /***/ (module, exports, __webpack_require__) => { + /* module decorator */ module = __webpack_require__.nmd(module) + Object.defineProperty(exports, '__esModule', { value: true }) + var misc_1 = __webpack_require__(32154) + var node_1 = __webpack_require__(16411) + /** + * A TimestampSource implementation for environments that do not support the Performance Web API natively. + * + * Note that this TimestampSource does not use a monotonic clock. A call to `nowSeconds` may return a timestamp earlier + * than a previously returned value. We do not try to emulate a monotonic behavior in order to facilitate debugging. It + * is more obvious to explain "why does my span have negative duration" than "why my spans have zero duration". + */ + var dateTimestampSource = { + nowSeconds: function () { + return Date.now() / 1000 + } + } + /** + * Returns a wrapper around the native Performance API browser implementation, or undefined for browsers that do not + * support the API. + * + * Wrapping the native API works around differences in behavior from different browsers. + */ + function getBrowserPerformance() { + var performance = misc_1.getGlobalObject().performance + if (!performance || !performance.now) { + return undefined + } + // Replace performance.timeOrigin with our own timeOrigin based on Date.now(). + // + // This is a partial workaround for browsers reporting performance.timeOrigin such that performance.timeOrigin + + // performance.now() gives a date arbitrarily in the past. + // + // Additionally, computing timeOrigin in this way fills the gap for browsers where performance.timeOrigin is + // undefined. + // + // The assumption that performance.timeOrigin + performance.now() ~= Date.now() is flawed, but we depend on it to + // interact with data coming out of performance entries. + // + // Note that despite recommendations against it in the spec, browsers implement the Performance API with a clock that + // might stop when the computer is asleep (and perhaps under other circumstances). Such behavior causes + // performance.timeOrigin + performance.now() to have an arbitrary skew over Date.now(). In laptop computers, we have + // observed skews that can be as long as days, weeks or months. + // + // See https://github.com/getsentry/sentry-javascript/issues/2590. + // + // BUG: despite our best intentions, this workaround has its limitations. It mostly addresses timings of pageload + // transactions, but ignores the skew built up over time that can aversely affect timestamps of navigation + // transactions of long-lived web pages. + var timeOrigin = Date.now() - performance.now() + return { + now: function () { + return performance.now() + }, + timeOrigin: timeOrigin + } + } + /** + * Returns the native Performance API implementation from Node.js. Returns undefined in old Node.js versions that don't + * implement the API. + */ + function getNodePerformance() { + try { + var perfHooks = node_1.dynamicRequire(module, 'perf_hooks') + return perfHooks.performance + } catch (_) { + return undefined + } + } + /** + * The Performance API implementation for the current platform, if available. + */ + var platformPerformance = node_1.isNodeEnv() + ? getNodePerformance() + : getBrowserPerformance() + var timestampSource = + platformPerformance === undefined + ? dateTimestampSource + : { + nowSeconds: function () { + return ( + (platformPerformance.timeOrigin + platformPerformance.now()) / + 1000 + ) + } + } + /** + * Returns a timestamp in seconds since the UNIX epoch using the Date API. + */ + exports.dateTimestampInSeconds = dateTimestampSource.nowSeconds.bind( + dateTimestampSource + ) + /** + * Returns a timestamp in seconds since the UNIX epoch using either the Performance or Date APIs, depending on the + * availability of the Performance API. + * + * See `usingPerformanceAPI` to test whether the Performance API is used. + * + * BUG: Note that because of how browsers implement the Performance API, the clock might stop when the computer is + * asleep. This creates a skew between `dateTimestampInSeconds` and `timestampInSeconds`. The + * skew can grow to arbitrary amounts like days, weeks or months. + * See https://github.com/getsentry/sentry-javascript/issues/2590. + */ + exports.timestampInSeconds = timestampSource.nowSeconds.bind( + timestampSource + ) + // Re-exported with an old name for backwards-compatibility. + exports.timestampWithMs = exports.timestampInSeconds + /** + * A boolean that is true when timestampInSeconds uses the Performance API to produce monotonic timestamps. + */ + exports.usingPerformanceAPI = platformPerformance !== undefined + /** + * The number of milliseconds since the UNIX epoch. This value is only usable in a browser, and only when the + * performance API is available. + */ + exports.browserPerformanceTimeOrigin = (function () { + var performance = misc_1.getGlobalObject().performance + if (!performance) { + return undefined + } + if (performance.timeOrigin) { + return performance.timeOrigin + } + // While performance.timing.navigationStart is deprecated in favor of performance.timeOrigin, performance.timeOrigin + // is not as widely supported. Namely, performance.timeOrigin is undefined in Safari as of writing. + // Also as of writing, performance.timing is not available in Web Workers in mainstream browsers, so it is not always + // a valid fallback. In the absence of an initial time provided by the browser, fallback to the current time from the + // Date API. + // eslint-disable-next-line deprecation/deprecation + return ( + (performance.timing && performance.timing.navigationStart) || + Date.now() + ) + })() + //# sourceMappingURL=time.js.map + + /***/ + }, + + /***/ 81040: /***/ module => { + 'use strict' + + function noop() {} + function once(emitter, name) { + const o = once.spread(emitter, name) + const r = o.then(args => args[0]) + r.cancel = o.cancel + return r + } + ;(function (once) { + function spread(emitter, name) { + let c = null + const p = new Promise((resolve, reject) => { + function cancel() { + emitter.removeListener(name, onEvent) + emitter.removeListener('error', onError) + p.cancel = noop + } + function onEvent(...args) { + cancel() + resolve(args) + } + function onError(err) { + cancel() + reject(err) + } + c = cancel + emitter.on(name, onEvent) + emitter.on('error', onError) + }) + if (!c) { + throw new TypeError('Could not get `cancel()` function') + } + p.cancel = c + return p + } + once.spread = spread + })(once || (once = {})) + module.exports = once + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 32699: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + Object.defineProperty(exports, '__esModule', { value: true }) + const tslib_1 = __webpack_require__(75636) + tslib_1.__exportStar(__webpack_require__(6892), exports) + tslib_1.__exportStar(__webpack_require__(12610), exports) + tslib_1.__exportStar(__webpack_require__(93411), exports) + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 6892: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + Object.defineProperty(exports, '__esModule', { value: true }) + exports.i18 = exports.locales = void 0 + const tslib_1 = __webpack_require__(75636) + const i18next_1 = tslib_1.__importDefault(__webpack_require__(8813)) + const Backend = __webpack_require__(82399) + class Localizer { + constructor() { + this.locales = __webpack_require__.ab + 'locales' + this.localize = i18next_1.default + this.t = (input, options) => { + if (!options) options = {} + if (!options.replace) options.replace = [] + options.replace.push('what', input) + return this.localize.t( + [input, 'error.unspecific.localize'], + options + ) + } + this.localize.on('initialized', options => { + console.log( + `Localisation has started. Current language is ${options.lng}` + ) + }) + this.localize.on('onLanguageChanged', lng => { + console.log(`Localisation has changed to ${lng}`) + }) + this.localize.on('onLanguageChanged', (lngs, namespace, key, res) => { + console.log( + `${this.t( + 'error.unspecific.localize' + )}: ${lngs}/${namespace}/${key}` + ) + }) + this.localize.use(Backend).init({ + lng: 'en', + backend: { + loadPath: `${this.locales}/{{lng}}.json`, + addPath: `${this.locales}/{{lng}}.missing.json` + }, + fallbackLng: { + 'de-CH': ['fr', 'it'], + 'zh-Hant': ['zh-Hans', 'en'], + es: ['fr'], + default: ['en'] + }, + supportedLngs: [ + 'es', + 'ja', + 'fr', + 'it', + 'en', + 'zh', + 'ko', + 'en-GB', + 'en-US', + 'de-CH', + 'zh-Hant', + 'zh-Hans' + ], + saveMissing: true, + saveMissingTo: 'current', + returnEmptyString: false, + returnNull: false, + initImmediate: false + }) + } + } + exports.locales = new Localizer() + exports.i18 = { + t: (input, options) => exports.locales.t(input, options), + exists: exports.locales.localize.exists, + getFixedT: exports.locales.localize.getFixedT, + changeLanguage: exports.locales.localize.changeLanguage, + language: exports.locales.localize.language, + languages: exports.locales.localize.languages, + loadNamespaces: exports.locales.localize.loadNamespaces, + loadlanguages: exports.locales.localize.loadLanguages, + reloadResources: exports.locales.localize.reloadResources, + setDefaultNamespace: exports.locales.localize.setDefaultNamespace, + dir: exports.locales.localize.dir, + format: exports.locales.localize.format + } + //# sourceMappingURL=localize.js.map + + /***/ + }, + + /***/ 12610: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + Object.defineProperty(exports, '__esModule', { value: true }) + exports.Log = exports.style = void 0 + const tslib_1 = __webpack_require__(75636) + const logging_1 = __webpack_require__(9341) + const integrations_1 = __webpack_require__(25262) + const Sentry = tslib_1.__importStar(__webpack_require__(22783)) + const fs = tslib_1.__importStar(__webpack_require__(35747)) + const localize_1 = __webpack_require__(6892) + const chalk = __webpack_require__(78818) + global.__rootdir__ = __dirname || process.cwd() + /** + * Configures Chalk + * @author TGTGamer + * @since 1.0.0-alpha + */ + exports.style = { + brand: { + videndumPurple: chalk.hex('4B428E') + }, + log: { + default: chalk.inverse, + debug: chalk.grey, + info: chalk.green, + notice: chalk.green, + warn: chalk.white, + error: chalk.yellow, + critical: chalk.yellow, + alert: chalk.red, + emergency: chalk.red // (800) One or more systems are unusable. + } + } + /** + * Main class used for package + * @author TGTGamer + * @since 1.0.0-alpha + */ + class Log { + constructor(constructData) { + this.gcp = new logging_1.Logging() + this.loglevel = 1 + this.sentry = Sentry + this.loglevels = [ + 'default', + 'debug', + 'info', + 'notice', + 'warn', + 'error', + 'critical', + 'alert', + 'emergency' // (800) One or more systems are unusable. + ] + this.constructorLogs = [] + this.configured = false + this.constructData = constructData + if (process.env.LOGLEVEL) this.loglevel = +process.env.LOGLEVEL + this.configureLogger(constructData) + } + async configureLogger(constructData) { + var _a, _b, _c + if ( + (_a = constructData.gcp) === null || _a === void 0 + ? void 0 + : _a.enabled + ) + await this.configureGCP(constructData.gcp) + if ( + (_b = constructData.sentry) === null || _b === void 0 + ? void 0 + : _b.enabled + ) + await this.configureSentry(constructData.sentry) + if ( + (_c = constructData.file) === null || _c === void 0 + ? void 0 + : _c.enabled + ) + await this.configureFile(constructData.file) + await this.constructorLogs.forEach(log => { + this.log({ name: log.data }, log.level) + }) + this.configured = true + } + configureGCP(gcpData) { + this.constructorLogs.push({ + data: 'logging.gcp.constructor', + level: 1 + }) + this.gcp = new logging_1.Logging({ projectId: gcpData.projectid }) + this.gcpLogger = this.gcp.log(gcpData.logname) + } + configureSentry(SentryData) { + this.constructorLogs.push({ + data: 'logging.sentry.constructor', + level: 1 + }) + try { + this.sentry.init( + Object.assign(Object.assign({}, SentryData.config), { + integrations: [ + new integrations_1.RewriteFrames({ root: global.__rootdir__ }) + ] + }) + ) + this.sentry.configureScope(scope => { + var _a, _b, _c + if ( + (_a = SentryData.extras) === null || _a === void 0 + ? void 0 + : _a.user + ) + scope.setUser(SentryData.extras.user) + if ( + (_b = SentryData.extras) === null || _b === void 0 + ? void 0 + : _b.tags + ) + SentryData.extras.tags.forEach(tag => { + scope.setTag(tag.key, tag.value) + }) + if ( + (_c = SentryData.extras) === null || _c === void 0 + ? void 0 + : _c.context + ) + SentryData.extras.context.forEach(context => { + scope.setContext(context.name, context.data) + }) + }) + } catch (_) { + this.constructorLogs.push({ + data: 'logging.sentry.error' + _, + level: 6 + }) + } + } + /** + * Sets up local logging to file + * @author TGTGamer + * @since 1.0.0-alpha + */ + configureFile(fileData) { + this.constructorLogs.push({ + data: 'logging.file.constructor', + level: 1 + }) + fs.access(fileData.config.logDirectory, fs.constants.F_OK, err => { + if (!err) { + return + } else { + this.constructorLogs.push({ + data: 'errors.fileDirectory.caught' + err, + level: 6 + }) + fs.mkdir( + fileData.config.logDirectory, + { recursive: false }, + async err => { + if (err) + this.constructorLogs.push({ + data: 'errors.fileDirectory.thrown' + err, + level: 6 + }) + else + this.constructorLogs.push({ + data: `errors.fileDirectory.solved`, + level: 3 + }) + } + ) + return + } + }) + } + /** + * Change the logging level. + * @param {number | string} level - Logging level to use. + */ + setloglevel(level) { + if (typeof level == 'string') { + if (this.loglevels.indexOf(level) != -1) { + this.loglevel = this.loglevels.indexOf(level) + } else { + this.loglevel = 2 + } + } else { + this.loglevel = level + } + } + /** + * Log your information or error to all platforms + * @param {loggingData} loggingData + * @param {number | string} type Optional types. Accepts both Numbers & String values. 1=debug, 2=info, 3=notice, 4=warn, 5=error, 6=critical, 7=alert, 8=emergency + * @example + * try { + * core.user.getUserID(core.license.license_holder_email) + * } catch(response){ + * core.log(response, 1) + * } + * @return logs data to console, sentry and log file as appropriate + */ + async log(loggingData, type) { + var _a, _b, _c, _d, _e, _f + // Meta for Cloud Logging + let metadata = { + resource: { + type: 'global' + }, + severity: 'INFO' + } + let data + if (loggingData.error) data = loggingData.error + else if (loggingData.name) + data = localize_1.i18.t(loggingData.name, loggingData.translate) + else if (loggingData.raw) data = loggingData.raw + else { + this.log({ name: 'errors.logging' }) + return false + } + // Defines log type + if (type && typeof type == 'string') { + if (this.loglevels.indexOf(type) != -1) { + metadata.severity = type.toUpperCase() + type = this.loglevels.indexOf(type) + } else { + metadata.severity = 'DEFAULT' + type = 0 + } + } else if (typeof type == 'number' && type < this.loglevels.length) { + metadata.severity = this.loglevels[type].toUpperCase() + type = type + } else { + metadata.severity = `DEFAULT` + type = 0 + } + // log to cloud logger + if ( + (_a = this.constructData.gcp) === null || _a === void 0 + ? void 0 + : _a.enabled + ) { + let entry = this.gcpLogger.entry(metadata, data) + try { + await this.gcpLogger.write(entry) + } catch (err) { + this.log({ raw: `Thrown error: ${err}` }, 5) + this.constructData.gcp.enabled = false + } + } + // Translate the metadata + metadata.severity = await this.translate( + `logging.${metadata.severity.toLowerCase()}` + ) + // add spacing + if (metadata.severity.length < 15) { + for (let i = metadata.severity.length; i < 15; i++) { + metadata.severity += ' ' + } + } + if ( + type >= this.loglevel || + process.env.DEBUG == 'true' || + type == 1 + ) { + // Log to local logger + if ( + (_b = this.constructData.file) === null || _b === void 0 + ? void 0 + : _b.enabled + ) { + try { + fs.appendFile( + `${ + (_c = this.constructData.file) === null || _c === void 0 + ? void 0 + : _c.config.logDirectory + }/${ + (_d = this.constructData.file) === null || _d === void 0 + ? void 0 + : _d.config.fileNamePattern + }`, + `${metadata.severity} ` + data + '\r\n', + err => { + if (err) throw new Error(err.message) + } + ) + } catch (err) { + this.log({ error: err }, 5) + this.constructData.file.enabled = false + } + } + // @ts-expect-error Colorise + metadata.severity = exports.style.log[`${this.loglevels[type]}`]( + metadata.severity + ) + if ( + !!((_e = this.constructData.console) === null || _e === void 0 + ? void 0 + : _e.enabled) + ) + console.log(`${metadata.severity} ` + data) + // Log to sentry + if ( + type > 4 && + ((_f = this.constructData.sentry) === null || _f === void 0 + ? void 0 + : _f.enabled) + ) { + try { + const t = type + this.sentry.withScope(scope => { + if (t == 5) scope.setLevel(this.sentry.Severity.Error) + else if (t > 6) scope.setLevel(this.sentry.Severity.Fatal) + this.sentry.captureMessage(data) + }) + } catch (_) { + this.log({ error: _ }, 5) + this.constructData.sentry.enabled = false + } + } + } + return true + } + translate(name) { + return localize_1.i18.t(name) + } + /** + * Used to shutdown logging - to ensure that all logs are processed + * @author TGTGamer + * @since 1.0.0-alpha + */ + shutdown() { + return new Promise((resolve, reject) => { + this.sentry + .close(2000) + .then(async () => { + await this.log( + { + raw: + 'Logger successfully shutdown - safe to end all processes' + }, + 2 + ) + resolve() + }) + .catch(_ => reject(_)) + }) + } + } + exports.Log = Log + //# sourceMappingURL=logging.js.map + + /***/ + }, + + /***/ 93411: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + Object.defineProperty(exports, '__esModule', { value: true }) + //# sourceMappingURL=types.js.map + + /***/ + }, + + /***/ 61659: /***/ (module, exports, __webpack_require__) => { + 'use strict' + /** + * @author Toru Nagashima + * See LICENSE file in root directory for full license. + */ + + Object.defineProperty(exports, '__esModule', { value: true }) + + var eventTargetShim = __webpack_require__(84697) + + /** + * The signal class. + * @see https://dom.spec.whatwg.org/#abortsignal + */ + class AbortSignal extends eventTargetShim.EventTarget { + /** + * AbortSignal cannot be constructed directly. + */ + constructor() { + super() + throw new TypeError('AbortSignal cannot be constructed directly') + } + /** + * Returns `true` if this `AbortSignal`'s `AbortController` has signaled to abort, and `false` otherwise. + */ + get aborted() { + const aborted = abortedFlags.get(this) + if (typeof aborted !== 'boolean') { + throw new TypeError( + `Expected 'this' to be an 'AbortSignal' object, but got ${ + this === null ? 'null' : typeof this + }` + ) + } + return aborted + } + } + eventTargetShim.defineEventAttribute(AbortSignal.prototype, 'abort') + /** + * Create an AbortSignal object. + */ + function createAbortSignal() { + const signal = Object.create(AbortSignal.prototype) + eventTargetShim.EventTarget.call(signal) + abortedFlags.set(signal, false) + return signal + } + /** + * Abort a given signal. + */ + function abortSignal(signal) { + if (abortedFlags.get(signal) !== false) { + return + } + abortedFlags.set(signal, true) + signal.dispatchEvent({ type: 'abort' }) + } + /** + * Aborted flag for each instances. + */ + const abortedFlags = new WeakMap() + // Properties should be enumerable. + Object.defineProperties(AbortSignal.prototype, { + aborted: { enumerable: true } + }) + // `toString()` should return `"[object AbortSignal]"` + if ( + typeof Symbol === 'function' && + typeof Symbol.toStringTag === 'symbol' + ) { + Object.defineProperty(AbortSignal.prototype, Symbol.toStringTag, { + configurable: true, + value: 'AbortSignal' + }) + } + + /** + * The AbortController. + * @see https://dom.spec.whatwg.org/#abortcontroller + */ + class AbortController { + /** + * Initialize this controller. + */ + constructor() { + signals.set(this, createAbortSignal()) + } + /** + * Returns the `AbortSignal` object associated with this object. + */ + get signal() { + return getSignal(this) + } + /** + * Abort and signal to any observers that the associated activity is to be aborted. + */ + abort() { + abortSignal(getSignal(this)) + } + } + /** + * Associated signals. + */ + const signals = new WeakMap() + /** + * Get the associated signal of a given controller. + */ + function getSignal(controller) { + const signal = signals.get(controller) + if (signal == null) { + throw new TypeError( + `Expected 'this' to be an 'AbortController' object, but got ${ + controller === null ? 'null' : typeof controller + }` + ) + } + return signal + } + // Properties should be enumerable. + Object.defineProperties(AbortController.prototype, { + signal: { enumerable: true }, + abort: { enumerable: true } + }) + if ( + typeof Symbol === 'function' && + typeof Symbol.toStringTag === 'symbol' + ) { + Object.defineProperty(AbortController.prototype, Symbol.toStringTag, { + configurable: true, + value: 'AbortController' + }) + } + + exports.AbortController = AbortController + exports.AbortSignal = AbortSignal + exports.default = AbortController + + module.exports = AbortController + module.exports.AbortController = module.exports.default = AbortController + module.exports.AbortSignal = AbortSignal + //# sourceMappingURL=abort-controller.js.map + + /***/ + }, + + /***/ 49690: /***/ function ( + module, + __unused_webpack_exports, + __webpack_require__ + ) { + 'use strict' + + var __importDefault = + (this && this.__importDefault) || + function (mod) { + return mod && mod.__esModule ? mod : { default: mod } + } + const events_1 = __webpack_require__(28614) + const debug_1 = __importDefault(__webpack_require__(38237)) + const promisify_1 = __importDefault(__webpack_require__(66570)) + const debug = debug_1.default('agent-base') + function isAgent(v) { + return Boolean(v) && typeof v.addRequest === 'function' + } + function isSecureEndpoint() { + const { stack } = new Error() + if (typeof stack !== 'string') return false + return stack + .split('\n') + .some( + l => + l.indexOf('(https.js:') !== -1 || l.indexOf('node:https:') !== -1 + ) + } + function createAgent(callback, opts) { + return new createAgent.Agent(callback, opts) + } + ;(function (createAgent) { + /** + * Base `http.Agent` implementation. + * No pooling/keep-alive is implemented by default. + * + * @param {Function} callback + * @api public + */ + class Agent extends events_1.EventEmitter { + constructor(callback, _opts) { + super() + let opts = _opts + if (typeof callback === 'function') { + this.callback = callback + } else if (callback) { + opts = callback + } + // Timeout for the socket to be returned from the callback + this.timeout = null + if (opts && typeof opts.timeout === 'number') { + this.timeout = opts.timeout + } + // These aren't actually used by `agent-base`, but are required + // for the TypeScript definition files in `@types/node` :/ + this.maxFreeSockets = 1 + this.maxSockets = 1 + this.maxTotalSockets = Infinity + this.sockets = {} + this.freeSockets = {} + this.requests = {} + this.options = {} + } + get defaultPort() { + if (typeof this.explicitDefaultPort === 'number') { + return this.explicitDefaultPort + } + return isSecureEndpoint() ? 443 : 80 + } + set defaultPort(v) { + this.explicitDefaultPort = v + } + get protocol() { + if (typeof this.explicitProtocol === 'string') { + return this.explicitProtocol + } + return isSecureEndpoint() ? 'https:' : 'http:' + } + set protocol(v) { + this.explicitProtocol = v + } + callback(req, opts, fn) { + throw new Error( + '"agent-base" has no default implementation, you must subclass and override `callback()`' + ) + } + /** + * Called by node-core's "_http_client.js" module when creating + * a new HTTP request with this Agent instance. + * + * @api public + */ + addRequest(req, _opts) { + const opts = Object.assign({}, _opts) + if (typeof opts.secureEndpoint !== 'boolean') { + opts.secureEndpoint = isSecureEndpoint() + } + if (opts.host == null) { + opts.host = 'localhost' + } + if (opts.port == null) { + opts.port = opts.secureEndpoint ? 443 : 80 + } + if (opts.protocol == null) { + opts.protocol = opts.secureEndpoint ? 'https:' : 'http:' + } + if (opts.host && opts.path) { + // If both a `host` and `path` are specified then it's most + // likely the result of a `url.parse()` call... we need to + // remove the `path` portion so that `net.connect()` doesn't + // attempt to open that as a unix socket file. + delete opts.path + } + delete opts.agent + delete opts.hostname + delete opts._defaultAgent + delete opts.defaultPort + delete opts.createConnection + // Hint to use "Connection: close" + // XXX: non-documented `http` module API :( + req._last = true + req.shouldKeepAlive = false + let timedOut = false + let timeoutId = null + const timeoutMs = opts.timeout || this.timeout + const onerror = err => { + if (req._hadError) return + req.emit('error', err) + // For Safety. Some additional errors might fire later on + // and we need to make sure we don't double-fire the error event. + req._hadError = true + } + const ontimeout = () => { + timeoutId = null + timedOut = true + const err = new Error( + `A "socket" was not created for HTTP request before ${timeoutMs}ms` + ) + err.code = 'ETIMEOUT' + onerror(err) + } + const callbackError = err => { + if (timedOut) return + if (timeoutId !== null) { + clearTimeout(timeoutId) + timeoutId = null + } + onerror(err) + } + const onsocket = socket => { + if (timedOut) return + if (timeoutId != null) { + clearTimeout(timeoutId) + timeoutId = null + } + if (isAgent(socket)) { + // `socket` is actually an `http.Agent` instance, so + // relinquish responsibility for this `req` to the Agent + // from here on + debug( + 'Callback returned another Agent instance %o', + socket.constructor.name + ) + socket.addRequest(req, opts) + return + } + if (socket) { + socket.once('free', () => { + this.freeSocket(socket, opts) + }) + req.onSocket(socket) + return + } + const err = new Error( + `no Duplex stream was returned to agent-base for \`${req.method} ${req.path}\`` + ) + onerror(err) + } + if (typeof this.callback !== 'function') { + onerror(new Error('`callback` is not defined')) + return + } + if (!this.promisifiedCallback) { + if (this.callback.length >= 3) { + debug('Converting legacy callback function to promise') + this.promisifiedCallback = promisify_1.default(this.callback) + } else { + this.promisifiedCallback = this.callback + } + } + if (typeof timeoutMs === 'number' && timeoutMs > 0) { + timeoutId = setTimeout(ontimeout, timeoutMs) + } + if ('port' in opts && typeof opts.port !== 'number') { + opts.port = Number(opts.port) + } + try { + debug( + 'Resolving socket for %o request: %o', + opts.protocol, + `${req.method} ${req.path}` + ) + Promise.resolve(this.promisifiedCallback(req, opts)).then( + onsocket, + callbackError + ) + } catch (err) { + Promise.reject(err).catch(callbackError) + } + } + freeSocket(socket, opts) { + debug('Freeing socket %o %o', socket.constructor.name, opts) + socket.destroy() + } + destroy() { + debug('Destroying agent %o', this.constructor.name) + } + } + createAgent.Agent = Agent + // So that `instanceof` works correctly + createAgent.prototype = createAgent.Agent.prototype + })(createAgent || (createAgent = {})) + module.exports = createAgent + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 66570: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + Object.defineProperty(exports, '__esModule', { value: true }) + function promisify(fn) { + return function (req, opts) { + return new Promise((resolve, reject) => { + fn.call(this, req, opts, (err, rtn) => { + if (err) { + reject(err) + } else { + resolve(rtn) + } + }) + }) + } + } + exports.default = promisify + //# sourceMappingURL=promisify.js.map + + /***/ + }, + + /***/ 64941: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + 'use strict' + + var compileSchema = __webpack_require__(875), + resolve = __webpack_require__(63896), + Cache = __webpack_require__(93679), + SchemaObject = __webpack_require__(37605), + stableStringify = __webpack_require__(30969), + formats = __webpack_require__(66627), + rules = __webpack_require__(68561), + $dataMetaSchema = __webpack_require__(21412), + util = __webpack_require__(76578) + + module.exports = Ajv + + Ajv.prototype.validate = validate + Ajv.prototype.compile = compile + Ajv.prototype.addSchema = addSchema + Ajv.prototype.addMetaSchema = addMetaSchema + Ajv.prototype.validateSchema = validateSchema + Ajv.prototype.getSchema = getSchema + Ajv.prototype.removeSchema = removeSchema + Ajv.prototype.addFormat = addFormat + Ajv.prototype.errorsText = errorsText + + Ajv.prototype._addSchema = _addSchema + Ajv.prototype._compile = _compile + + Ajv.prototype.compileAsync = __webpack_require__(80890) + var customKeyword = __webpack_require__(53297) + Ajv.prototype.addKeyword = customKeyword.add + Ajv.prototype.getKeyword = customKeyword.get + Ajv.prototype.removeKeyword = customKeyword.remove + Ajv.prototype.validateKeyword = customKeyword.validate + + var errorClasses = __webpack_require__(25726) + Ajv.ValidationError = errorClasses.Validation + Ajv.MissingRefError = errorClasses.MissingRef + Ajv.$dataMetaSchema = $dataMetaSchema + + var META_SCHEMA_ID = 'http://json-schema.org/draft-07/schema' + + var META_IGNORE_OPTIONS = [ + 'removeAdditional', + 'useDefaults', + 'coerceTypes', + 'strictDefaults' + ] + var META_SUPPORT_DATA = ['/properties'] + + /** + * Creates validator instance. + * Usage: `Ajv(opts)` + * @param {Object} opts optional options + * @return {Object} ajv instance + */ + function Ajv(opts) { + if (!(this instanceof Ajv)) return new Ajv(opts) + opts = this._opts = util.copy(opts) || {} + setLogger(this) + this._schemas = {} + this._refs = {} + this._fragments = {} + this._formats = formats(opts.format) + + this._cache = opts.cache || new Cache() + this._loadingSchemas = {} + this._compilations = [] + this.RULES = rules() + this._getId = chooseGetId(opts) + + opts.loopRequired = opts.loopRequired || Infinity + if (opts.errorDataPath == 'property') opts._errorDataPathProperty = true + if (opts.serialize === undefined) opts.serialize = stableStringify + this._metaOpts = getMetaSchemaOptions(this) + + if (opts.formats) addInitialFormats(this) + if (opts.keywords) addInitialKeywords(this) + addDefaultMetaSchema(this) + if (typeof opts.meta == 'object') this.addMetaSchema(opts.meta) + if (opts.nullable) + this.addKeyword('nullable', { metaSchema: { type: 'boolean' } }) + addInitialSchemas(this) + } + + /** + * Validate data using schema + * Schema will be compiled and cached (using serialized JSON as key. [fast-json-stable-stringify](https://github.com/epoberezkin/fast-json-stable-stringify) is used to serialize. + * @this Ajv + * @param {String|Object} schemaKeyRef key, ref or schema object + * @param {Any} data to be validated + * @return {Boolean} validation result. Errors from the last validation will be available in `ajv.errors` (and also in compiled schema: `schema.errors`). + */ + function validate(schemaKeyRef, data) { + var v + if (typeof schemaKeyRef == 'string') { + v = this.getSchema(schemaKeyRef) + if (!v) + throw new Error('no schema with key or ref "' + schemaKeyRef + '"') + } else { + var schemaObj = this._addSchema(schemaKeyRef) + v = schemaObj.validate || this._compile(schemaObj) + } + + var valid = v(data) + if (v.$async !== true) this.errors = v.errors + return valid + } + + /** + * Create validating function for passed schema. + * @this Ajv + * @param {Object} schema schema object + * @param {Boolean} _meta true if schema is a meta-schema. Used internally to compile meta schemas of custom keywords. + * @return {Function} validating function + */ + function compile(schema, _meta) { + var schemaObj = this._addSchema(schema, undefined, _meta) + return schemaObj.validate || this._compile(schemaObj) + } + + /** + * Adds schema to the instance. + * @this Ajv + * @param {Object|Array} schema schema or array of schemas. If array is passed, `key` and other parameters will be ignored. + * @param {String} key Optional schema key. Can be passed to `validate` method instead of schema object or id/ref. One schema per instance can have empty `id` and `key`. + * @param {Boolean} _skipValidation true to skip schema validation. Used internally, option validateSchema should be used instead. + * @param {Boolean} _meta true if schema is a meta-schema. Used internally, addMetaSchema should be used instead. + * @return {Ajv} this for method chaining + */ + function addSchema(schema, key, _skipValidation, _meta) { + if (Array.isArray(schema)) { + for (var i = 0; i < schema.length; i++) + this.addSchema(schema[i], undefined, _skipValidation, _meta) + return this + } + var id = this._getId(schema) + if (id !== undefined && typeof id != 'string') + throw new Error('schema id must be string') + key = resolve.normalizeId(key || id) + checkUnique(this, key) + this._schemas[key] = this._addSchema( + schema, + _skipValidation, + _meta, + true + ) + return this + } + + /** + * Add schema that will be used to validate other schemas + * options in META_IGNORE_OPTIONS are alway set to false + * @this Ajv + * @param {Object} schema schema object + * @param {String} key optional schema key + * @param {Boolean} skipValidation true to skip schema validation, can be used to override validateSchema option for meta-schema + * @return {Ajv} this for method chaining + */ + function addMetaSchema(schema, key, skipValidation) { + this.addSchema(schema, key, skipValidation, true) + return this + } + + /** + * Validate schema + * @this Ajv + * @param {Object} schema schema to validate + * @param {Boolean} throwOrLogError pass true to throw (or log) an error if invalid + * @return {Boolean} true if schema is valid + */ + function validateSchema(schema, throwOrLogError) { + var $schema = schema.$schema + if ($schema !== undefined && typeof $schema != 'string') + throw new Error('$schema must be a string') + $schema = $schema || this._opts.defaultMeta || defaultMeta(this) + if (!$schema) { + this.logger.warn('meta-schema not available') + this.errors = null + return true + } + var valid = this.validate($schema, schema) + if (!valid && throwOrLogError) { + var message = 'schema is invalid: ' + this.errorsText() + if (this._opts.validateSchema == 'log') this.logger.error(message) + else throw new Error(message) + } + return valid + } + + function defaultMeta(self) { + var meta = self._opts.meta + self._opts.defaultMeta = + typeof meta == 'object' + ? self._getId(meta) || meta + : self.getSchema(META_SCHEMA_ID) + ? META_SCHEMA_ID + : undefined + return self._opts.defaultMeta + } + + /** + * Get compiled schema from the instance by `key` or `ref`. + * @this Ajv + * @param {String} keyRef `key` that was passed to `addSchema` or full schema reference (`schema.id` or resolved id). + * @return {Function} schema validating function (with property `schema`). + */ + function getSchema(keyRef) { + var schemaObj = _getSchemaObj(this, keyRef) + switch (typeof schemaObj) { + case 'object': + return schemaObj.validate || this._compile(schemaObj) + case 'string': + return this.getSchema(schemaObj) + case 'undefined': + return _getSchemaFragment(this, keyRef) + } + } + + function _getSchemaFragment(self, ref) { + var res = resolve.schema.call(self, { schema: {} }, ref) + if (res) { + var schema = res.schema, + root = res.root, + baseId = res.baseId + var v = compileSchema.call(self, schema, root, undefined, baseId) + self._fragments[ref] = new SchemaObject({ + ref: ref, + fragment: true, + schema: schema, + root: root, + baseId: baseId, + validate: v + }) + return v + } + } + + function _getSchemaObj(self, keyRef) { + keyRef = resolve.normalizeId(keyRef) + return ( + self._schemas[keyRef] || self._refs[keyRef] || self._fragments[keyRef] + ) + } + + /** + * Remove cached schema(s). + * If no parameter is passed all schemas but meta-schemas are removed. + * If RegExp is passed all schemas with key/id matching pattern but meta-schemas are removed. + * Even if schema is referenced by other schemas it still can be removed as other schemas have local references. + * @this Ajv + * @param {String|Object|RegExp} schemaKeyRef key, ref, pattern to match key/ref or schema object + * @return {Ajv} this for method chaining + */ + function removeSchema(schemaKeyRef) { + if (schemaKeyRef instanceof RegExp) { + _removeAllSchemas(this, this._schemas, schemaKeyRef) + _removeAllSchemas(this, this._refs, schemaKeyRef) + return this + } + switch (typeof schemaKeyRef) { + case 'undefined': + _removeAllSchemas(this, this._schemas) + _removeAllSchemas(this, this._refs) + this._cache.clear() + return this + case 'string': + var schemaObj = _getSchemaObj(this, schemaKeyRef) + if (schemaObj) this._cache.del(schemaObj.cacheKey) + delete this._schemas[schemaKeyRef] + delete this._refs[schemaKeyRef] + return this + case 'object': + var serialize = this._opts.serialize + var cacheKey = serialize ? serialize(schemaKeyRef) : schemaKeyRef + this._cache.del(cacheKey) + var id = this._getId(schemaKeyRef) + if (id) { + id = resolve.normalizeId(id) + delete this._schemas[id] + delete this._refs[id] + } + } + return this + } + + function _removeAllSchemas(self, schemas, regex) { + for (var keyRef in schemas) { + var schemaObj = schemas[keyRef] + if (!schemaObj.meta && (!regex || regex.test(keyRef))) { + self._cache.del(schemaObj.cacheKey) + delete schemas[keyRef] + } + } + } + + /* @this Ajv */ + function _addSchema(schema, skipValidation, meta, shouldAddSchema) { + if (typeof schema != 'object' && typeof schema != 'boolean') + throw new Error('schema should be object or boolean') + var serialize = this._opts.serialize + var cacheKey = serialize ? serialize(schema) : schema + var cached = this._cache.get(cacheKey) + if (cached) return cached + + shouldAddSchema = shouldAddSchema || this._opts.addUsedSchema !== false + + var id = resolve.normalizeId(this._getId(schema)) + if (id && shouldAddSchema) checkUnique(this, id) + + var willValidate = + this._opts.validateSchema !== false && !skipValidation + var recursiveMeta + if ( + willValidate && + !(recursiveMeta = id && id == resolve.normalizeId(schema.$schema)) + ) + this.validateSchema(schema, true) + + var localRefs = resolve.ids.call(this, schema) + + var schemaObj = new SchemaObject({ + id: id, + schema: schema, + localRefs: localRefs, + cacheKey: cacheKey, + meta: meta + }) + + if (id[0] != '#' && shouldAddSchema) this._refs[id] = schemaObj + this._cache.put(cacheKey, schemaObj) + + if (willValidate && recursiveMeta) this.validateSchema(schema, true) + + return schemaObj + } + + /* @this Ajv */ + function _compile(schemaObj, root) { + if (schemaObj.compiling) { + schemaObj.validate = callValidate + callValidate.schema = schemaObj.schema + callValidate.errors = null + callValidate.root = root ? root : callValidate + if (schemaObj.schema.$async === true) callValidate.$async = true + return callValidate + } + schemaObj.compiling = true + + var currentOpts + if (schemaObj.meta) { + currentOpts = this._opts + this._opts = this._metaOpts + } + + var v + try { + v = compileSchema.call( + this, + schemaObj.schema, + root, + schemaObj.localRefs + ) + } catch (e) { + delete schemaObj.validate + throw e + } finally { + schemaObj.compiling = false + if (schemaObj.meta) this._opts = currentOpts + } + + schemaObj.validate = v + schemaObj.refs = v.refs + schemaObj.refVal = v.refVal + schemaObj.root = v.root + return v + + /* @this {*} - custom context, see passContext option */ + function callValidate() { + /* jshint validthis: true */ + var _validate = schemaObj.validate + var result = _validate.apply(this, arguments) + callValidate.errors = _validate.errors + return result + } + } + + function chooseGetId(opts) { + switch (opts.schemaId) { + case 'auto': + return _get$IdOrId + case 'id': + return _getId + default: + return _get$Id + } + } + + /* @this Ajv */ + function _getId(schema) { + if (schema.$id) this.logger.warn('schema $id ignored', schema.$id) + return schema.id + } + + /* @this Ajv */ + function _get$Id(schema) { + if (schema.id) this.logger.warn('schema id ignored', schema.id) + return schema.$id + } + + function _get$IdOrId(schema) { + if (schema.$id && schema.id && schema.$id != schema.id) + throw new Error('schema $id is different from id') + return schema.$id || schema.id + } + + /** + * Convert array of error message objects to string + * @this Ajv + * @param {Array} errors optional array of validation errors, if not passed errors from the instance are used. + * @param {Object} options optional options with properties `separator` and `dataVar`. + * @return {String} human readable string with all errors descriptions + */ + function errorsText(errors, options) { + errors = errors || this.errors + if (!errors) return 'No errors' + options = options || {} + var separator = + options.separator === undefined ? ', ' : options.separator + var dataVar = options.dataVar === undefined ? 'data' : options.dataVar + + var text = '' + for (var i = 0; i < errors.length; i++) { + var e = errors[i] + if (e) text += dataVar + e.dataPath + ' ' + e.message + separator + } + return text.slice(0, -separator.length) + } + + /** + * Add custom format + * @this Ajv + * @param {String} name format name + * @param {String|RegExp|Function} format string is converted to RegExp; function should return boolean (true when valid) + * @return {Ajv} this for method chaining + */ + function addFormat(name, format) { + if (typeof format == 'string') format = new RegExp(format) + this._formats[name] = format + return this + } + + function addDefaultMetaSchema(self) { + var $dataSchema + if (self._opts.$data) { + $dataSchema = __webpack_require__(66835) + self.addMetaSchema($dataSchema, $dataSchema.$id, true) + } + if (self._opts.meta === false) return + var metaSchema = __webpack_require__(40038) + if (self._opts.$data) + metaSchema = $dataMetaSchema(metaSchema, META_SUPPORT_DATA) + self.addMetaSchema(metaSchema, META_SCHEMA_ID, true) + self._refs['http://json-schema.org/schema'] = META_SCHEMA_ID + } + + function addInitialSchemas(self) { + var optsSchemas = self._opts.schemas + if (!optsSchemas) return + if (Array.isArray(optsSchemas)) self.addSchema(optsSchemas) + else for (var key in optsSchemas) self.addSchema(optsSchemas[key], key) + } + + function addInitialFormats(self) { + for (var name in self._opts.formats) { + var format = self._opts.formats[name] + self.addFormat(name, format) + } + } + + function addInitialKeywords(self) { + for (var name in self._opts.keywords) { + var keyword = self._opts.keywords[name] + self.addKeyword(name, keyword) + } + } + + function checkUnique(self, id) { + if (self._schemas[id] || self._refs[id]) + throw new Error('schema with key or id "' + id + '" already exists') + } + + function getMetaSchemaOptions(self) { + var metaOpts = util.copy(self._opts) + for (var i = 0; i < META_IGNORE_OPTIONS.length; i++) + delete metaOpts[META_IGNORE_OPTIONS[i]] + return metaOpts + } + + function setLogger(self) { + var logger = self._opts.logger + if (logger === false) { + self.logger = { log: noop, warn: noop, error: noop } + } else { + if (logger === undefined) logger = console + if ( + !( + typeof logger == 'object' && + logger.log && + logger.warn && + logger.error + ) + ) + throw new Error('logger must implement log, warn and error methods') + self.logger = logger + } + } + + function noop() {} + + /***/ + }, + + /***/ 93679: /***/ module => { + 'use strict' + + var Cache = (module.exports = function Cache() { + this._cache = {} + }) + + Cache.prototype.put = function Cache_put(key, value) { + this._cache[key] = value + } + + Cache.prototype.get = function Cache_get(key) { + return this._cache[key] + } + + Cache.prototype.del = function Cache_del(key) { + delete this._cache[key] + } + + Cache.prototype.clear = function Cache_clear() { + this._cache = {} + } + + /***/ + }, + + /***/ 80890: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + 'use strict' + + var MissingRefError = __webpack_require__(25726).MissingRef + + module.exports = compileAsync + + /** + * Creates validating function for passed schema with asynchronous loading of missing schemas. + * `loadSchema` option should be a function that accepts schema uri and returns promise that resolves with the schema. + * @this Ajv + * @param {Object} schema schema object + * @param {Boolean} meta optional true to compile meta-schema; this parameter can be skipped + * @param {Function} callback an optional node-style callback, it is called with 2 parameters: error (or null) and validating function. + * @return {Promise} promise that resolves with a validating function. + */ + function compileAsync(schema, meta, callback) { + /* eslint no-shadow: 0 */ + /* global Promise */ + /* jshint validthis: true */ + var self = this + if (typeof this._opts.loadSchema != 'function') + throw new Error('options.loadSchema should be a function') + + if (typeof meta == 'function') { + callback = meta + meta = undefined + } + + var p = loadMetaSchemaOf(schema).then(function () { + var schemaObj = self._addSchema(schema, undefined, meta) + return schemaObj.validate || _compileAsync(schemaObj) + }) + + if (callback) { + p.then(function (v) { + callback(null, v) + }, callback) + } + + return p + + function loadMetaSchemaOf(sch) { + var $schema = sch.$schema + return $schema && !self.getSchema($schema) + ? compileAsync.call(self, { $ref: $schema }, true) + : Promise.resolve() + } + + function _compileAsync(schemaObj) { + try { + return self._compile(schemaObj) + } catch (e) { + if (e instanceof MissingRefError) return loadMissingSchema(e) + throw e + } + + function loadMissingSchema(e) { + var ref = e.missingSchema + if (added(ref)) + throw new Error( + 'Schema ' + + ref + + ' is loaded but ' + + e.missingRef + + ' cannot be resolved' + ) + + var schemaPromise = self._loadingSchemas[ref] + if (!schemaPromise) { + schemaPromise = self._loadingSchemas[ref] = self._opts.loadSchema( + ref + ) + schemaPromise.then(removePromise, removePromise) + } + + return schemaPromise + .then(function (sch) { + if (!added(ref)) { + return loadMetaSchemaOf(sch).then(function () { + if (!added(ref)) self.addSchema(sch, ref, undefined, meta) + }) + } + }) + .then(function () { + return _compileAsync(schemaObj) + }) + + function removePromise() { + delete self._loadingSchemas[ref] + } + + function added(ref) { + return self._refs[ref] || self._schemas[ref] + } + } + } + } + + /***/ + }, + + /***/ 25726: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + 'use strict' + + var resolve = __webpack_require__(63896) + + module.exports = { + Validation: errorSubclass(ValidationError), + MissingRef: errorSubclass(MissingRefError) + } + + function ValidationError(errors) { + this.message = 'validation failed' + this.errors = errors + this.ajv = this.validation = true + } + + MissingRefError.message = function (baseId, ref) { + return "can't resolve reference " + ref + ' from id ' + baseId + } + + function MissingRefError(baseId, ref, message) { + this.message = message || MissingRefError.message(baseId, ref) + this.missingRef = resolve.url(baseId, ref) + this.missingSchema = resolve.normalizeId( + resolve.fullPath(this.missingRef) + ) + } + + function errorSubclass(Subclass) { + Subclass.prototype = Object.create(Error.prototype) + Subclass.prototype.constructor = Subclass + return Subclass + } + + /***/ + }, + + /***/ 66627: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + 'use strict' + + var util = __webpack_require__(76578) + + var DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/ + var DAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] + var TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i + var HOSTNAME = /^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i + var URI = /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i + var URIREF = /^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i + // uri-template: https://tools.ietf.org/html/rfc6570 + var URITEMPLATE = /^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i + // For the source: https://gist.github.com/dperini/729294 + // For test cases: https://mathiasbynens.be/demo/url-regex + // @todo Delete current URL in favour of the commented out URL rule when this issue is fixed https://github.com/eslint/eslint/issues/7983. + // var URL = /^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu; + var URL = /^(?:(?:http[s\u017F]?|ftp):\/\/)(?:(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+(?::(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?@)?(?:(?!10(?:\.[0-9]{1,3}){3})(?!127(?:\.[0-9]{1,3}){3})(?!169\.254(?:\.[0-9]{1,3}){2})(?!192\.168(?:\.[0-9]{1,3}){2})(?!172\.(?:1[6-9]|2[0-9]|3[01])(?:\.[0-9]{1,3}){2})(?:[1-9][0-9]?|1[0-9][0-9]|2[01][0-9]|22[0-3])(?:\.(?:1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])){2}(?:\.(?:[1-9][0-9]?|1[0-9][0-9]|2[0-4][0-9]|25[0-4]))|(?:(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)(?:\.(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)*(?:\.(?:(?:[a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]){2,})))(?::[0-9]{2,5})?(?:\/(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?$/i + var UUID = /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i + var JSON_POINTER = /^(?:\/(?:[^~/]|~0|~1)*)*$/ + var JSON_POINTER_URI_FRAGMENT = /^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i + var RELATIVE_JSON_POINTER = /^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/ + + module.exports = formats + + function formats(mode) { + mode = mode == 'full' ? 'full' : 'fast' + return util.copy(formats[mode]) + } + + formats.fast = { + // date: http://tools.ietf.org/html/rfc3339#section-5.6 + date: /^\d\d\d\d-[0-1]\d-[0-3]\d$/, + // date-time: http://tools.ietf.org/html/rfc3339#section-5.6 + time: /^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i, + 'date-time': /^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i, + // uri: https://github.com/mafintosh/is-my-json-valid/blob/master/formats.js + uri: /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i, + 'uri-reference': /^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i, + 'uri-template': URITEMPLATE, + url: URL, + // email (sources from jsen validator): + // http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address#answer-8829363 + // http://www.w3.org/TR/html5/forms.html#valid-e-mail-address (search for 'willful violation') + email: /^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i, + hostname: HOSTNAME, + // optimized https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9780596802837/ch07s16.html + ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/, + // optimized http://stackoverflow.com/questions/53497/regular-expression-that-matches-valid-ipv6-addresses + ipv6: /^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i, + regex: regex, + // uuid: http://tools.ietf.org/html/rfc4122 + uuid: UUID, + // JSON-pointer: https://tools.ietf.org/html/rfc6901 + // uri fragment: https://tools.ietf.org/html/rfc3986#appendix-A + 'json-pointer': JSON_POINTER, + 'json-pointer-uri-fragment': JSON_POINTER_URI_FRAGMENT, + // relative JSON-pointer: http://tools.ietf.org/html/draft-luff-relative-json-pointer-00 + 'relative-json-pointer': RELATIVE_JSON_POINTER + } + + formats.full = { + date: date, + time: time, + 'date-time': date_time, + uri: uri, + 'uri-reference': URIREF, + 'uri-template': URITEMPLATE, + url: URL, + email: /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i, + hostname: HOSTNAME, + ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/, + ipv6: /^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i, + regex: regex, + uuid: UUID, + 'json-pointer': JSON_POINTER, + 'json-pointer-uri-fragment': JSON_POINTER_URI_FRAGMENT, + 'relative-json-pointer': RELATIVE_JSON_POINTER + } + + function isLeapYear(year) { + // https://tools.ietf.org/html/rfc3339#appendix-C + return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0) + } + + function date(str) { + // full-date from http://tools.ietf.org/html/rfc3339#section-5.6 + var matches = str.match(DATE) + if (!matches) return false + + var year = +matches[1] + var month = +matches[2] + var day = +matches[3] + + return ( + month >= 1 && + month <= 12 && + day >= 1 && + day <= (month == 2 && isLeapYear(year) ? 29 : DAYS[month]) + ) + } + + function time(str, full) { + var matches = str.match(TIME) + if (!matches) return false + + var hour = matches[1] + var minute = matches[2] + var second = matches[3] + var timeZone = matches[5] + return ( + ((hour <= 23 && minute <= 59 && second <= 59) || + (hour == 23 && minute == 59 && second == 60)) && + (!full || timeZone) + ) + } + + var DATE_TIME_SEPARATOR = /t|\s/i + function date_time(str) { + // http://tools.ietf.org/html/rfc3339#section-5.6 + var dateTime = str.split(DATE_TIME_SEPARATOR) + return ( + dateTime.length == 2 && date(dateTime[0]) && time(dateTime[1], true) + ) + } + + var NOT_URI_FRAGMENT = /\/|:/ + function uri(str) { + // http://jmrware.com/articles/2009/uri_regexp/URI_regex.html + optional protocol + required "." + return NOT_URI_FRAGMENT.test(str) && URI.test(str) + } + + var Z_ANCHOR = /[^\\]\\Z/ + function regex(str) { + if (Z_ANCHOR.test(str)) return false + try { + new RegExp(str) + return true + } catch (e) { + return false + } + } + + /***/ + }, + + /***/ 875: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + 'use strict' + + var resolve = __webpack_require__(63896), + util = __webpack_require__(76578), + errorClasses = __webpack_require__(25726), + stableStringify = __webpack_require__(30969) + + var validateGenerator = __webpack_require__(49585) + + /** + * Functions below are used inside compiled validations function + */ + + var ucs2length = util.ucs2length + var equal = __webpack_require__(28206) + + // this error is thrown by async schemas to return validation errors via exception + var ValidationError = errorClasses.Validation + + module.exports = compile + + /** + * Compiles schema to validation function + * @this Ajv + * @param {Object} schema schema object + * @param {Object} root object with information about the root schema for this schema + * @param {Object} localRefs the hash of local references inside the schema (created by resolve.id), used for inline resolution + * @param {String} baseId base ID for IDs in the schema + * @return {Function} validation function + */ + function compile(schema, root, localRefs, baseId) { + /* jshint validthis: true, evil: true */ + /* eslint no-shadow: 0 */ + var self = this, + opts = this._opts, + refVal = [undefined], + refs = {}, + patterns = [], + patternsHash = {}, + defaults = [], + defaultsHash = {}, + customRules = [] + + root = root || { schema: schema, refVal: refVal, refs: refs } + + var c = checkCompiling.call(this, schema, root, baseId) + var compilation = this._compilations[c.index] + if (c.compiling) return (compilation.callValidate = callValidate) + + var formats = this._formats + var RULES = this.RULES + + try { + var v = localCompile(schema, root, localRefs, baseId) + compilation.validate = v + var cv = compilation.callValidate + if (cv) { + cv.schema = v.schema + cv.errors = null + cv.refs = v.refs + cv.refVal = v.refVal + cv.root = v.root + cv.$async = v.$async + if (opts.sourceCode) cv.source = v.source + } + return v + } finally { + endCompiling.call(this, schema, root, baseId) + } + + /* @this {*} - custom context, see passContext option */ + function callValidate() { + /* jshint validthis: true */ + var validate = compilation.validate + var result = validate.apply(this, arguments) + callValidate.errors = validate.errors + return result + } + + function localCompile(_schema, _root, localRefs, baseId) { + var isRoot = !_root || (_root && _root.schema == _schema) + if (_root.schema != root.schema) + return compile.call(self, _schema, _root, localRefs, baseId) + + var $async = _schema.$async === true + + var sourceCode = validateGenerator({ + isTop: true, + schema: _schema, + isRoot: isRoot, + baseId: baseId, + root: _root, + schemaPath: '', + errSchemaPath: '#', + errorPath: '""', + MissingRefError: errorClasses.MissingRef, + RULES: RULES, + validate: validateGenerator, + util: util, + resolve: resolve, + resolveRef: resolveRef, + usePattern: usePattern, + useDefault: useDefault, + useCustomRule: useCustomRule, + opts: opts, + formats: formats, + logger: self.logger, + self: self + }) + + sourceCode = + vars(refVal, refValCode) + + vars(patterns, patternCode) + + vars(defaults, defaultCode) + + vars(customRules, customRuleCode) + + sourceCode + + if (opts.processCode) + sourceCode = opts.processCode(sourceCode, _schema) + // console.log('\n\n\n *** \n', JSON.stringify(sourceCode)); + var validate + try { + var makeValidate = new Function( + 'self', + 'RULES', + 'formats', + 'root', + 'refVal', + 'defaults', + 'customRules', + 'equal', + 'ucs2length', + 'ValidationError', + sourceCode + ) + + validate = makeValidate( + self, + RULES, + formats, + root, + refVal, + defaults, + customRules, + equal, + ucs2length, + ValidationError + ) + + refVal[0] = validate + } catch (e) { + self.logger.error( + 'Error compiling schema, function code:', + sourceCode + ) + throw e + } + + validate.schema = _schema + validate.errors = null + validate.refs = refs + validate.refVal = refVal + validate.root = isRoot ? validate : _root + if ($async) validate.$async = true + if (opts.sourceCode === true) { + validate.source = { + code: sourceCode, + patterns: patterns, + defaults: defaults + } + } + + return validate + } + + function resolveRef(baseId, ref, isRoot) { + ref = resolve.url(baseId, ref) + var refIndex = refs[ref] + var _refVal, refCode + if (refIndex !== undefined) { + _refVal = refVal[refIndex] + refCode = 'refVal[' + refIndex + ']' + return resolvedRef(_refVal, refCode) + } + if (!isRoot && root.refs) { + var rootRefId = root.refs[ref] + if (rootRefId !== undefined) { + _refVal = root.refVal[rootRefId] + refCode = addLocalRef(ref, _refVal) + return resolvedRef(_refVal, refCode) + } + } + + refCode = addLocalRef(ref) + var v = resolve.call(self, localCompile, root, ref) + if (v === undefined) { + var localSchema = localRefs && localRefs[ref] + if (localSchema) { + v = resolve.inlineRef(localSchema, opts.inlineRefs) + ? localSchema + : compile.call(self, localSchema, root, localRefs, baseId) + } + } + + if (v === undefined) { + removeLocalRef(ref) + } else { + replaceLocalRef(ref, v) + return resolvedRef(v, refCode) + } + } + + function addLocalRef(ref, v) { + var refId = refVal.length + refVal[refId] = v + refs[ref] = refId + return 'refVal' + refId + } + + function removeLocalRef(ref) { + delete refs[ref] + } + + function replaceLocalRef(ref, v) { + var refId = refs[ref] + refVal[refId] = v + } + + function resolvedRef(refVal, code) { + return typeof refVal == 'object' || typeof refVal == 'boolean' + ? { code: code, schema: refVal, inline: true } + : { code: code, $async: refVal && !!refVal.$async } + } + + function usePattern(regexStr) { + var index = patternsHash[regexStr] + if (index === undefined) { + index = patternsHash[regexStr] = patterns.length + patterns[index] = regexStr + } + return 'pattern' + index + } + + function useDefault(value) { + switch (typeof value) { + case 'boolean': + case 'number': + return '' + value + case 'string': + return util.toQuotedString(value) + case 'object': + if (value === null) return 'null' + var valueStr = stableStringify(value) + var index = defaultsHash[valueStr] + if (index === undefined) { + index = defaultsHash[valueStr] = defaults.length + defaults[index] = value + } + return 'default' + index + } + } + + function useCustomRule(rule, schema, parentSchema, it) { + if (self._opts.validateSchema !== false) { + var deps = rule.definition.dependencies + if ( + deps && + !deps.every(function (keyword) { + return Object.prototype.hasOwnProperty.call( + parentSchema, + keyword + ) + }) + ) + throw new Error( + 'parent schema must have all required keywords: ' + + deps.join(',') + ) + + var validateSchema = rule.definition.validateSchema + if (validateSchema) { + var valid = validateSchema(schema) + if (!valid) { + var message = + 'keyword schema is invalid: ' + + self.errorsText(validateSchema.errors) + if (self._opts.validateSchema == 'log') + self.logger.error(message) + else throw new Error(message) + } + } + } + + var compile = rule.definition.compile, + inline = rule.definition.inline, + macro = rule.definition.macro + + var validate + if (compile) { + validate = compile.call(self, schema, parentSchema, it) + } else if (macro) { + validate = macro.call(self, schema, parentSchema, it) + if (opts.validateSchema !== false) + self.validateSchema(validate, true) + } else if (inline) { + validate = inline.call(self, it, rule.keyword, schema, parentSchema) + } else { + validate = rule.definition.validate + if (!validate) return + } + + if (validate === undefined) + throw new Error( + 'custom keyword "' + rule.keyword + '"failed to compile' + ) + + var index = customRules.length + customRules[index] = validate + + return { + code: 'customRule' + index, + validate: validate + } + } + } + + /** + * Checks if the schema is currently compiled + * @this Ajv + * @param {Object} schema schema to compile + * @param {Object} root root object + * @param {String} baseId base schema ID + * @return {Object} object with properties "index" (compilation index) and "compiling" (boolean) + */ + function checkCompiling(schema, root, baseId) { + /* jshint validthis: true */ + var index = compIndex.call(this, schema, root, baseId) + if (index >= 0) return { index: index, compiling: true } + index = this._compilations.length + this._compilations[index] = { + schema: schema, + root: root, + baseId: baseId + } + return { index: index, compiling: false } + } + + /** + * Removes the schema from the currently compiled list + * @this Ajv + * @param {Object} schema schema to compile + * @param {Object} root root object + * @param {String} baseId base schema ID + */ + function endCompiling(schema, root, baseId) { + /* jshint validthis: true */ + var i = compIndex.call(this, schema, root, baseId) + if (i >= 0) this._compilations.splice(i, 1) + } + + /** + * Index of schema compilation in the currently compiled list + * @this Ajv + * @param {Object} schema schema to compile + * @param {Object} root root object + * @param {String} baseId base schema ID + * @return {Integer} compilation index + */ + function compIndex(schema, root, baseId) { + /* jshint validthis: true */ + for (var i = 0; i < this._compilations.length; i++) { + var c = this._compilations[i] + if (c.schema == schema && c.root == root && c.baseId == baseId) + return i + } + return -1 + } + + function patternCode(i, patterns) { + return ( + 'var pattern' + + i + + ' = new RegExp(' + + util.toQuotedString(patterns[i]) + + ');' + ) + } + + function defaultCode(i) { + return 'var default' + i + ' = defaults[' + i + '];' + } + + function refValCode(i, refVal) { + return refVal[i] === undefined + ? '' + : 'var refVal' + i + ' = refVal[' + i + '];' + } + + function customRuleCode(i) { + return 'var customRule' + i + ' = customRules[' + i + '];' + } + + function vars(arr, statement) { + if (!arr.length) return '' + var code = '' + for (var i = 0; i < arr.length; i++) code += statement(i, arr) + return code + } + + /***/ + }, + + /***/ 63896: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + 'use strict' + + var URI = __webpack_require__(70020), + equal = __webpack_require__(28206), + util = __webpack_require__(76578), + SchemaObject = __webpack_require__(37605), + traverse = __webpack_require__(52533) + + module.exports = resolve + + resolve.normalizeId = normalizeId + resolve.fullPath = getFullPath + resolve.url = resolveUrl + resolve.ids = resolveIds + resolve.inlineRef = inlineRef + resolve.schema = resolveSchema + + /** + * [resolve and compile the references ($ref)] + * @this Ajv + * @param {Function} compile reference to schema compilation funciton (localCompile) + * @param {Object} root object with information about the root schema for the current schema + * @param {String} ref reference to resolve + * @return {Object|Function} schema object (if the schema can be inlined) or validation function + */ + function resolve(compile, root, ref) { + /* jshint validthis: true */ + var refVal = this._refs[ref] + if (typeof refVal == 'string') { + if (this._refs[refVal]) refVal = this._refs[refVal] + else return resolve.call(this, compile, root, refVal) + } + + refVal = refVal || this._schemas[ref] + if (refVal instanceof SchemaObject) { + return inlineRef(refVal.schema, this._opts.inlineRefs) + ? refVal.schema + : refVal.validate || this._compile(refVal) + } + + var res = resolveSchema.call(this, root, ref) + var schema, v, baseId + if (res) { + schema = res.schema + root = res.root + baseId = res.baseId + } + + if (schema instanceof SchemaObject) { + v = + schema.validate || + compile.call(this, schema.schema, root, undefined, baseId) + } else if (schema !== undefined) { + v = inlineRef(schema, this._opts.inlineRefs) + ? schema + : compile.call(this, schema, root, undefined, baseId) + } + + return v + } + + /** + * Resolve schema, its root and baseId + * @this Ajv + * @param {Object} root root object with properties schema, refVal, refs + * @param {String} ref reference to resolve + * @return {Object} object with properties schema, root, baseId + */ + function resolveSchema(root, ref) { + /* jshint validthis: true */ + var p = URI.parse(ref), + refPath = _getFullPath(p), + baseId = getFullPath(this._getId(root.schema)) + if (Object.keys(root.schema).length === 0 || refPath !== baseId) { + var id = normalizeId(refPath) + var refVal = this._refs[id] + if (typeof refVal == 'string') { + return resolveRecursive.call(this, root, refVal, p) + } else if (refVal instanceof SchemaObject) { + if (!refVal.validate) this._compile(refVal) + root = refVal + } else { + refVal = this._schemas[id] + if (refVal instanceof SchemaObject) { + if (!refVal.validate) this._compile(refVal) + if (id == normalizeId(ref)) + return { schema: refVal, root: root, baseId: baseId } + root = refVal + } else { + return + } + } + if (!root.schema) return + baseId = getFullPath(this._getId(root.schema)) + } + return getJsonPointer.call(this, p, baseId, root.schema, root) + } + + /* @this Ajv */ + function resolveRecursive(root, ref, parsedRef) { + /* jshint validthis: true */ + var res = resolveSchema.call(this, root, ref) + if (res) { + var schema = res.schema + var baseId = res.baseId + root = res.root + var id = this._getId(schema) + if (id) baseId = resolveUrl(baseId, id) + return getJsonPointer.call(this, parsedRef, baseId, schema, root) + } + } + + var PREVENT_SCOPE_CHANGE = util.toHash([ + 'properties', + 'patternProperties', + 'enum', + 'dependencies', + 'definitions' + ]) + /* @this Ajv */ + function getJsonPointer(parsedRef, baseId, schema, root) { + /* jshint validthis: true */ + parsedRef.fragment = parsedRef.fragment || '' + if (parsedRef.fragment.slice(0, 1) != '/') return + var parts = parsedRef.fragment.split('/') + + for (var i = 1; i < parts.length; i++) { + var part = parts[i] + if (part) { + part = util.unescapeFragment(part) + schema = schema[part] + if (schema === undefined) break + var id + if (!PREVENT_SCOPE_CHANGE[part]) { + id = this._getId(schema) + if (id) baseId = resolveUrl(baseId, id) + if (schema.$ref) { + var $ref = resolveUrl(baseId, schema.$ref) + var res = resolveSchema.call(this, root, $ref) + if (res) { + schema = res.schema + root = res.root + baseId = res.baseId + } + } + } + } + } + if (schema !== undefined && schema !== root.schema) + return { schema: schema, root: root, baseId: baseId } + } + + var SIMPLE_INLINED = util.toHash([ + 'type', + 'format', + 'pattern', + 'maxLength', + 'minLength', + 'maxProperties', + 'minProperties', + 'maxItems', + 'minItems', + 'maximum', + 'minimum', + 'uniqueItems', + 'multipleOf', + 'required', + 'enum' + ]) + function inlineRef(schema, limit) { + if (limit === false) return false + if (limit === undefined || limit === true) return checkNoRef(schema) + else if (limit) return countKeys(schema) <= limit + } + + function checkNoRef(schema) { + var item + if (Array.isArray(schema)) { + for (var i = 0; i < schema.length; i++) { + item = schema[i] + if (typeof item == 'object' && !checkNoRef(item)) return false + } + } else { + for (var key in schema) { + if (key == '$ref') return false + item = schema[key] + if (typeof item == 'object' && !checkNoRef(item)) return false + } + } + return true + } + + function countKeys(schema) { + var count = 0, + item + if (Array.isArray(schema)) { + for (var i = 0; i < schema.length; i++) { + item = schema[i] + if (typeof item == 'object') count += countKeys(item) + if (count == Infinity) return Infinity + } + } else { + for (var key in schema) { + if (key == '$ref') return Infinity + if (SIMPLE_INLINED[key]) { + count++ + } else { + item = schema[key] + if (typeof item == 'object') count += countKeys(item) + 1 + if (count == Infinity) return Infinity + } + } + } + return count + } + + function getFullPath(id, normalize) { + if (normalize !== false) id = normalizeId(id) + var p = URI.parse(id) + return _getFullPath(p) + } + + function _getFullPath(p) { + return URI.serialize(p).split('#')[0] + '#' + } + + var TRAILING_SLASH_HASH = /#\/?$/ + function normalizeId(id) { + return id ? id.replace(TRAILING_SLASH_HASH, '') : '' + } + + function resolveUrl(baseId, id) { + id = normalizeId(id) + return URI.resolve(baseId, id) + } + + /* @this Ajv */ + function resolveIds(schema) { + var schemaId = normalizeId(this._getId(schema)) + var baseIds = { '': schemaId } + var fullPaths = { '': getFullPath(schemaId, false) } + var localRefs = {} + var self = this + + traverse(schema, { allKeys: true }, function ( + sch, + jsonPtr, + rootSchema, + parentJsonPtr, + parentKeyword, + parentSchema, + keyIndex + ) { + if (jsonPtr === '') return + var id = self._getId(sch) + var baseId = baseIds[parentJsonPtr] + var fullPath = fullPaths[parentJsonPtr] + '/' + parentKeyword + if (keyIndex !== undefined) + fullPath += + '/' + + (typeof keyIndex == 'number' + ? keyIndex + : util.escapeFragment(keyIndex)) + + if (typeof id == 'string') { + id = baseId = normalizeId(baseId ? URI.resolve(baseId, id) : id) + + var refVal = self._refs[id] + if (typeof refVal == 'string') refVal = self._refs[refVal] + if (refVal && refVal.schema) { + if (!equal(sch, refVal.schema)) + throw new Error( + 'id "' + id + '" resolves to more than one schema' + ) + } else if (id != normalizeId(fullPath)) { + if (id[0] == '#') { + if (localRefs[id] && !equal(sch, localRefs[id])) + throw new Error( + 'id "' + id + '" resolves to more than one schema' + ) + localRefs[id] = sch + } else { + self._refs[id] = fullPath + } + } + } + baseIds[jsonPtr] = baseId + fullPaths[jsonPtr] = fullPath + }) + + return localRefs + } + + /***/ + }, + + /***/ 68561: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + 'use strict' + + var ruleModules = __webpack_require__(85810), + toHash = __webpack_require__(76578).toHash + + module.exports = function rules() { + var RULES = [ + { + type: 'number', + rules: [ + { maximum: ['exclusiveMaximum'] }, + { minimum: ['exclusiveMinimum'] }, + 'multipleOf', + 'format' + ] + }, + { + type: 'string', + rules: ['maxLength', 'minLength', 'pattern', 'format'] + }, + { + type: 'array', + rules: ['maxItems', 'minItems', 'items', 'contains', 'uniqueItems'] + }, + { + type: 'object', + rules: [ + 'maxProperties', + 'minProperties', + 'required', + 'dependencies', + 'propertyNames', + { properties: ['additionalProperties', 'patternProperties'] } + ] + }, + { + rules: [ + '$ref', + 'const', + 'enum', + 'not', + 'anyOf', + 'oneOf', + 'allOf', + 'if' + ] + } + ] + + var ALL = ['type', '$comment'] + var KEYWORDS = [ + '$schema', + '$id', + 'id', + '$data', + '$async', + 'title', + 'description', + 'default', + 'definitions', + 'examples', + 'readOnly', + 'writeOnly', + 'contentMediaType', + 'contentEncoding', + 'additionalItems', + 'then', + 'else' + ] + var TYPES = [ + 'number', + 'integer', + 'string', + 'array', + 'object', + 'boolean', + 'null' + ] + RULES.all = toHash(ALL) + RULES.types = toHash(TYPES) + + RULES.forEach(function (group) { + group.rules = group.rules.map(function (keyword) { + var implKeywords + if (typeof keyword == 'object') { + var key = Object.keys(keyword)[0] + implKeywords = keyword[key] + keyword = key + implKeywords.forEach(function (k) { + ALL.push(k) + RULES.all[k] = true + }) + } + ALL.push(keyword) + var rule = (RULES.all[keyword] = { + keyword: keyword, + code: ruleModules[keyword], + implements: implKeywords + }) + return rule + }) + + RULES.all.$comment = { + keyword: '$comment', + code: ruleModules.$comment + } + + if (group.type) RULES.types[group.type] = group + }) + + RULES.keywords = toHash(ALL.concat(KEYWORDS)) + RULES.custom = {} + + return RULES + } + + /***/ + }, + + /***/ 37605: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + 'use strict' + + var util = __webpack_require__(76578) + + module.exports = SchemaObject + + function SchemaObject(obj) { + util.copy(obj, this) + } + + /***/ + }, + + /***/ 64580: /***/ module => { + 'use strict' + + // https://mathiasbynens.be/notes/javascript-encoding + // https://github.com/bestiejs/punycode.js - punycode.ucs2.decode + module.exports = function ucs2length(str) { + var length = 0, + len = str.length, + pos = 0, + value + while (pos < len) { + length++ + value = str.charCodeAt(pos++) + if (value >= 0xd800 && value <= 0xdbff && pos < len) { + // high surrogate, and there is a next character + value = str.charCodeAt(pos) + if ((value & 0xfc00) == 0xdc00) pos++ // low surrogate + } + } + return length + } + + /***/ + }, + + /***/ 76578: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + 'use strict' + + module.exports = { + copy: copy, + checkDataType: checkDataType, + checkDataTypes: checkDataTypes, + coerceToTypes: coerceToTypes, + toHash: toHash, + getProperty: getProperty, + escapeQuotes: escapeQuotes, + equal: __webpack_require__(28206), + ucs2length: __webpack_require__(64580), + varOccurences: varOccurences, + varReplace: varReplace, + schemaHasRules: schemaHasRules, + schemaHasRulesExcept: schemaHasRulesExcept, + schemaUnknownRules: schemaUnknownRules, + toQuotedString: toQuotedString, + getPathExpr: getPathExpr, + getPath: getPath, + getData: getData, + unescapeFragment: unescapeFragment, + unescapeJsonPointer: unescapeJsonPointer, + escapeFragment: escapeFragment, + escapeJsonPointer: escapeJsonPointer + } + + function copy(o, to) { + to = to || {} + for (var key in o) to[key] = o[key] + return to + } + + function checkDataType(dataType, data, strictNumbers, negate) { + var EQUAL = negate ? ' !== ' : ' === ', + AND = negate ? ' || ' : ' && ', + OK = negate ? '!' : '', + NOT = negate ? '' : '!' + switch (dataType) { + case 'null': + return data + EQUAL + 'null' + case 'array': + return OK + 'Array.isArray(' + data + ')' + case 'object': + return ( + '(' + + OK + + data + + AND + + 'typeof ' + + data + + EQUAL + + '"object"' + + AND + + NOT + + 'Array.isArray(' + + data + + '))' + ) + case 'integer': + return ( + '(typeof ' + + data + + EQUAL + + '"number"' + + AND + + NOT + + '(' + + data + + ' % 1)' + + AND + + data + + EQUAL + + data + + (strictNumbers ? AND + OK + 'isFinite(' + data + ')' : '') + + ')' + ) + case 'number': + return ( + '(typeof ' + + data + + EQUAL + + '"' + + dataType + + '"' + + (strictNumbers ? AND + OK + 'isFinite(' + data + ')' : '') + + ')' + ) + default: + return 'typeof ' + data + EQUAL + '"' + dataType + '"' + } + } + + function checkDataTypes(dataTypes, data, strictNumbers) { + switch (dataTypes.length) { + case 1: + return checkDataType(dataTypes[0], data, strictNumbers, true) + default: + var code = '' + var types = toHash(dataTypes) + if (types.array && types.object) { + code = types.null ? '(' : '(!' + data + ' || ' + code += 'typeof ' + data + ' !== "object")' + delete types.null + delete types.array + delete types.object + } + if (types.number) delete types.integer + for (var t in types) + code += + (code ? ' && ' : '') + + checkDataType(t, data, strictNumbers, true) + + return code + } + } + + var COERCE_TO_TYPES = toHash([ + 'string', + 'number', + 'integer', + 'boolean', + 'null' + ]) + function coerceToTypes(optionCoerceTypes, dataTypes) { + if (Array.isArray(dataTypes)) { + var types = [] + for (var i = 0; i < dataTypes.length; i++) { + var t = dataTypes[i] + if (COERCE_TO_TYPES[t]) types[types.length] = t + else if (optionCoerceTypes === 'array' && t === 'array') + types[types.length] = t + } + if (types.length) return types + } else if (COERCE_TO_TYPES[dataTypes]) { + return [dataTypes] + } else if (optionCoerceTypes === 'array' && dataTypes === 'array') { + return ['array'] + } + } + + function toHash(arr) { + var hash = {} + for (var i = 0; i < arr.length; i++) hash[arr[i]] = true + return hash + } + + var IDENTIFIER = /^[a-z$_][a-z$_0-9]*$/i + var SINGLE_QUOTE = /'|\\/g + function getProperty(key) { + return typeof key == 'number' + ? '[' + key + ']' + : IDENTIFIER.test(key) + ? '.' + key + : "['" + escapeQuotes(key) + "']" + } + + function escapeQuotes(str) { + return str + .replace(SINGLE_QUOTE, '\\$&') + .replace(/\n/g, '\\n') + .replace(/\r/g, '\\r') + .replace(/\f/g, '\\f') + .replace(/\t/g, '\\t') + } + + function varOccurences(str, dataVar) { + dataVar += '[^0-9]' + var matches = str.match(new RegExp(dataVar, 'g')) + return matches ? matches.length : 0 + } + + function varReplace(str, dataVar, expr) { + dataVar += '([^0-9])' + expr = expr.replace(/\$/g, '$$$$') + return str.replace(new RegExp(dataVar, 'g'), expr + '$1') + } + + function schemaHasRules(schema, rules) { + if (typeof schema == 'boolean') return !schema + for (var key in schema) if (rules[key]) return true + } + + function schemaHasRulesExcept(schema, rules, exceptKeyword) { + if (typeof schema == 'boolean') return !schema && exceptKeyword != 'not' + for (var key in schema) + if (key != exceptKeyword && rules[key]) return true + } + + function schemaUnknownRules(schema, rules) { + if (typeof schema == 'boolean') return + for (var key in schema) if (!rules[key]) return key + } + + function toQuotedString(str) { + return "'" + escapeQuotes(str) + "'" + } + + function getPathExpr(currentPath, expr, jsonPointers, isNumber) { + var path = jsonPointers // false by default + ? "'/' + " + + expr + + (isNumber ? '' : ".replace(/~/g, '~0').replace(/\\//g, '~1')") + : isNumber + ? "'[' + " + expr + " + ']'" + : "'[\\'' + " + expr + " + '\\']'" + return joinPaths(currentPath, path) + } + + function getPath(currentPath, prop, jsonPointers) { + var path = jsonPointers // false by default + ? toQuotedString('/' + escapeJsonPointer(prop)) + : toQuotedString(getProperty(prop)) + return joinPaths(currentPath, path) + } + + var JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/ + var RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/ + function getData($data, lvl, paths) { + var up, jsonPointer, data, matches + if ($data === '') return 'rootData' + if ($data[0] == '/') { + if (!JSON_POINTER.test($data)) + throw new Error('Invalid JSON-pointer: ' + $data) + jsonPointer = $data + data = 'rootData' + } else { + matches = $data.match(RELATIVE_JSON_POINTER) + if (!matches) throw new Error('Invalid JSON-pointer: ' + $data) + up = +matches[1] + jsonPointer = matches[2] + if (jsonPointer == '#') { + if (up >= lvl) + throw new Error( + 'Cannot access property/index ' + + up + + ' levels up, current level is ' + + lvl + ) + return paths[lvl - up] + } + + if (up > lvl) + throw new Error( + 'Cannot access data ' + up + ' levels up, current level is ' + lvl + ) + data = 'data' + (lvl - up || '') + if (!jsonPointer) return data + } + + var expr = data + var segments = jsonPointer.split('/') + for (var i = 0; i < segments.length; i++) { + var segment = segments[i] + if (segment) { + data += getProperty(unescapeJsonPointer(segment)) + expr += ' && ' + data + } + } + return expr + } + + function joinPaths(a, b) { + if (a == '""') return b + return (a + ' + ' + b).replace(/([^\\])' \+ '/g, '$1') + } + + function unescapeFragment(str) { + return unescapeJsonPointer(decodeURIComponent(str)) + } + + function escapeFragment(str) { + return encodeURIComponent(escapeJsonPointer(str)) + } + + function escapeJsonPointer(str) { + return str.replace(/~/g, '~0').replace(/\//g, '~1') + } + + function unescapeJsonPointer(str) { + return str.replace(/~1/g, '/').replace(/~0/g, '~') + } + + /***/ + }, + + /***/ 21412: /***/ module => { + 'use strict' + + var KEYWORDS = [ + 'multipleOf', + 'maximum', + 'exclusiveMaximum', + 'minimum', + 'exclusiveMinimum', + 'maxLength', + 'minLength', + 'pattern', + 'additionalItems', + 'maxItems', + 'minItems', + 'uniqueItems', + 'maxProperties', + 'minProperties', + 'required', + 'additionalProperties', + 'enum', + 'format', + 'const' + ] + + module.exports = function (metaSchema, keywordsJsonPointers) { + for (var i = 0; i < keywordsJsonPointers.length; i++) { + metaSchema = JSON.parse(JSON.stringify(metaSchema)) + var segments = keywordsJsonPointers[i].split('/') + var keywords = metaSchema + var j + for (j = 1; j < segments.length; j++) keywords = keywords[segments[j]] + + for (j = 0; j < KEYWORDS.length; j++) { + var key = KEYWORDS[j] + var schema = keywords[key] + if (schema) { + keywords[key] = { + anyOf: [ + schema, + { + $ref: + 'https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#' + } + ] + } + } + } + } + + return metaSchema + } + + /***/ + }, + + /***/ 10458: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + 'use strict' + + var metaSchema = __webpack_require__(40038) + + module.exports = { + $id: + 'https://github.com/ajv-validator/ajv/blob/master/lib/definition_schema.js', + definitions: { + simpleTypes: metaSchema.definitions.simpleTypes + }, + type: 'object', + dependencies: { + schema: ['validate'], + $data: ['validate'], + statements: ['inline'], + valid: { not: { required: ['macro'] } } + }, + properties: { + type: metaSchema.properties.type, + schema: { type: 'boolean' }, + statements: { type: 'boolean' }, + dependencies: { + type: 'array', + items: { type: 'string' } + }, + metaSchema: { type: 'object' }, + modifying: { type: 'boolean' }, + valid: { type: 'boolean' }, + $data: { type: 'boolean' }, + async: { type: 'boolean' }, + errors: { + anyOf: [{ type: 'boolean' }, { const: 'full' }] + } + } + } + + /***/ + }, + + /***/ 7404: /***/ module => { + 'use strict' + + module.exports = function generate__limit(it, $keyword, $ruleType) { + var out = ' ' + var $lvl = it.level + var $dataLvl = it.dataLevel + var $schema = it.schema[$keyword] + var $schemaPath = it.schemaPath + it.util.getProperty($keyword) + var $errSchemaPath = it.errSchemaPath + '/' + $keyword + var $breakOnError = !it.opts.allErrors + var $errorKeyword + var $data = 'data' + ($dataLvl || '') + var $isData = it.opts.$data && $schema && $schema.$data, + $schemaValue + if ($isData) { + out += + ' var schema' + + $lvl + + ' = ' + + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + + '; ' + $schemaValue = 'schema' + $lvl + } else { + $schemaValue = $schema + } + var $isMax = $keyword == 'maximum', + $exclusiveKeyword = $isMax ? 'exclusiveMaximum' : 'exclusiveMinimum', + $schemaExcl = it.schema[$exclusiveKeyword], + $isDataExcl = it.opts.$data && $schemaExcl && $schemaExcl.$data, + $op = $isMax ? '<' : '>', + $notOp = $isMax ? '>' : '<', + $errorKeyword = undefined + if (!($isData || typeof $schema == 'number' || $schema === undefined)) { + throw new Error($keyword + ' must be number') + } + if ( + !( + $isDataExcl || + $schemaExcl === undefined || + typeof $schemaExcl == 'number' || + typeof $schemaExcl == 'boolean' + ) + ) { + throw new Error($exclusiveKeyword + ' must be number or boolean') + } + if ($isDataExcl) { + var $schemaValueExcl = it.util.getData( + $schemaExcl.$data, + $dataLvl, + it.dataPathArr + ), + $exclusive = 'exclusive' + $lvl, + $exclType = 'exclType' + $lvl, + $exclIsNumber = 'exclIsNumber' + $lvl, + $opExpr = 'op' + $lvl, + $opStr = "' + " + $opExpr + " + '" + out += ' var schemaExcl' + $lvl + ' = ' + $schemaValueExcl + '; ' + $schemaValueExcl = 'schemaExcl' + $lvl + out += + ' var ' + + $exclusive + + '; var ' + + $exclType + + ' = typeof ' + + $schemaValueExcl + + '; if (' + + $exclType + + " != 'boolean' && " + + $exclType + + " != 'undefined' && " + + $exclType + + " != 'number') { " + var $errorKeyword = $exclusiveKeyword + var $$outStack = $$outStack || [] + $$outStack.push(out) + out = '' /* istanbul ignore else */ + if (it.createErrors !== false) { + out += + " { keyword: '" + + ($errorKeyword || '_exclusiveLimit') + + "' , dataPath: (dataPath || '') + " + + it.errorPath + + ' , schemaPath: ' + + it.util.toQuotedString($errSchemaPath) + + ' , params: {} ' + if (it.opts.messages !== false) { + out += + " , message: '" + $exclusiveKeyword + " should be boolean' " + } + if (it.opts.verbose) { + out += + ' , schema: validate.schema' + + $schemaPath + + ' , parentSchema: validate.schema' + + it.schemaPath + + ' , data: ' + + $data + + ' ' + } + out += ' } ' + } else { + out += ' {} ' + } + var __err = out + out = $$outStack.pop() + if (!it.compositeRule && $breakOnError) { + /* istanbul ignore if */ + if (it.async) { + out += ' throw new ValidationError([' + __err + ']); ' + } else { + out += ' validate.errors = [' + __err + ']; return false; ' + } + } else { + out += + ' var err = ' + + __err + + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ' + } + out += ' } else if ( ' + if ($isData) { + out += + ' (' + + $schemaValue + + ' !== undefined && typeof ' + + $schemaValue + + " != 'number') || " + } + out += + ' ' + + $exclType + + " == 'number' ? ( (" + + $exclusive + + ' = ' + + $schemaValue + + ' === undefined || ' + + $schemaValueExcl + + ' ' + + $op + + '= ' + + $schemaValue + + ') ? ' + + $data + + ' ' + + $notOp + + '= ' + + $schemaValueExcl + + ' : ' + + $data + + ' ' + + $notOp + + ' ' + + $schemaValue + + ' ) : ( (' + + $exclusive + + ' = ' + + $schemaValueExcl + + ' === true) ? ' + + $data + + ' ' + + $notOp + + '= ' + + $schemaValue + + ' : ' + + $data + + ' ' + + $notOp + + ' ' + + $schemaValue + + ' ) || ' + + $data + + ' !== ' + + $data + + ') { var op' + + $lvl + + ' = ' + + $exclusive + + " ? '" + + $op + + "' : '" + + $op + + "='; " + if ($schema === undefined) { + $errorKeyword = $exclusiveKeyword + $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword + $schemaValue = $schemaValueExcl + $isData = $isDataExcl + } + } else { + var $exclIsNumber = typeof $schemaExcl == 'number', + $opStr = $op + if ($exclIsNumber && $isData) { + var $opExpr = "'" + $opStr + "'" + out += ' if ( ' + if ($isData) { + out += + ' (' + + $schemaValue + + ' !== undefined && typeof ' + + $schemaValue + + " != 'number') || " + } + out += + ' ( ' + + $schemaValue + + ' === undefined || ' + + $schemaExcl + + ' ' + + $op + + '= ' + + $schemaValue + + ' ? ' + + $data + + ' ' + + $notOp + + '= ' + + $schemaExcl + + ' : ' + + $data + + ' ' + + $notOp + + ' ' + + $schemaValue + + ' ) || ' + + $data + + ' !== ' + + $data + + ') { ' + } else { + if ($exclIsNumber && $schema === undefined) { + $exclusive = true + $errorKeyword = $exclusiveKeyword + $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword + $schemaValue = $schemaExcl + $notOp += '=' + } else { + if ($exclIsNumber) + $schemaValue = Math[$isMax ? 'min' : 'max']( + $schemaExcl, + $schema + ) + if ($schemaExcl === ($exclIsNumber ? $schemaValue : true)) { + $exclusive = true + $errorKeyword = $exclusiveKeyword + $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword + $notOp += '=' + } else { + $exclusive = false + $opStr += '=' + } + } + var $opExpr = "'" + $opStr + "'" + out += ' if ( ' + if ($isData) { + out += + ' (' + + $schemaValue + + ' !== undefined && typeof ' + + $schemaValue + + " != 'number') || " + } + out += + ' ' + + $data + + ' ' + + $notOp + + ' ' + + $schemaValue + + ' || ' + + $data + + ' !== ' + + $data + + ') { ' + } + } + $errorKeyword = $errorKeyword || $keyword + var $$outStack = $$outStack || [] + $$outStack.push(out) + out = '' /* istanbul ignore else */ + if (it.createErrors !== false) { + out += + " { keyword: '" + + ($errorKeyword || '_limit') + + "' , dataPath: (dataPath || '') + " + + it.errorPath + + ' , schemaPath: ' + + it.util.toQuotedString($errSchemaPath) + + ' , params: { comparison: ' + + $opExpr + + ', limit: ' + + $schemaValue + + ', exclusive: ' + + $exclusive + + ' } ' + if (it.opts.messages !== false) { + out += " , message: 'should be " + $opStr + ' ' + if ($isData) { + out += "' + " + $schemaValue + } else { + out += '' + $schemaValue + "'" + } + } + if (it.opts.verbose) { + out += ' , schema: ' + if ($isData) { + out += 'validate.schema' + $schemaPath + } else { + out += '' + $schema + } + out += + ' , parentSchema: validate.schema' + + it.schemaPath + + ' , data: ' + + $data + + ' ' + } + out += ' } ' + } else { + out += ' {} ' + } + var __err = out + out = $$outStack.pop() + if (!it.compositeRule && $breakOnError) { + /* istanbul ignore if */ + if (it.async) { + out += ' throw new ValidationError([' + __err + ']); ' + } else { + out += ' validate.errors = [' + __err + ']; return false; ' + } + } else { + out += + ' var err = ' + + __err + + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ' + } + out += ' } ' + if ($breakOnError) { + out += ' else { ' + } + return out + } + + /***/ + }, + + /***/ 64683: /***/ module => { + 'use strict' + + module.exports = function generate__limitItems(it, $keyword, $ruleType) { + var out = ' ' + var $lvl = it.level + var $dataLvl = it.dataLevel + var $schema = it.schema[$keyword] + var $schemaPath = it.schemaPath + it.util.getProperty($keyword) + var $errSchemaPath = it.errSchemaPath + '/' + $keyword + var $breakOnError = !it.opts.allErrors + var $errorKeyword + var $data = 'data' + ($dataLvl || '') + var $isData = it.opts.$data && $schema && $schema.$data, + $schemaValue + if ($isData) { + out += + ' var schema' + + $lvl + + ' = ' + + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + + '; ' + $schemaValue = 'schema' + $lvl + } else { + $schemaValue = $schema + } + if (!($isData || typeof $schema == 'number')) { + throw new Error($keyword + ' must be number') + } + var $op = $keyword == 'maxItems' ? '>' : '<' + out += 'if ( ' + if ($isData) { + out += + ' (' + + $schemaValue + + ' !== undefined && typeof ' + + $schemaValue + + " != 'number') || " + } + out += ' ' + $data + '.length ' + $op + ' ' + $schemaValue + ') { ' + var $errorKeyword = $keyword + var $$outStack = $$outStack || [] + $$outStack.push(out) + out = '' /* istanbul ignore else */ + if (it.createErrors !== false) { + out += + " { keyword: '" + + ($errorKeyword || '_limitItems') + + "' , dataPath: (dataPath || '') + " + + it.errorPath + + ' , schemaPath: ' + + it.util.toQuotedString($errSchemaPath) + + ' , params: { limit: ' + + $schemaValue + + ' } ' + if (it.opts.messages !== false) { + out += " , message: 'should NOT have " + if ($keyword == 'maxItems') { + out += 'more' + } else { + out += 'fewer' + } + out += ' than ' + if ($isData) { + out += "' + " + $schemaValue + " + '" + } else { + out += '' + $schema + } + out += " items' " + } + if (it.opts.verbose) { + out += ' , schema: ' + if ($isData) { + out += 'validate.schema' + $schemaPath + } else { + out += '' + $schema + } + out += + ' , parentSchema: validate.schema' + + it.schemaPath + + ' , data: ' + + $data + + ' ' + } + out += ' } ' + } else { + out += ' {} ' + } + var __err = out + out = $$outStack.pop() + if (!it.compositeRule && $breakOnError) { + /* istanbul ignore if */ + if (it.async) { + out += ' throw new ValidationError([' + __err + ']); ' + } else { + out += ' validate.errors = [' + __err + ']; return false; ' + } + } else { + out += + ' var err = ' + + __err + + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ' + } + out += '} ' + if ($breakOnError) { + out += ' else { ' + } + return out + } + + /***/ + }, + + /***/ 52114: /***/ module => { + 'use strict' + + module.exports = function generate__limitLength(it, $keyword, $ruleType) { + var out = ' ' + var $lvl = it.level + var $dataLvl = it.dataLevel + var $schema = it.schema[$keyword] + var $schemaPath = it.schemaPath + it.util.getProperty($keyword) + var $errSchemaPath = it.errSchemaPath + '/' + $keyword + var $breakOnError = !it.opts.allErrors + var $errorKeyword + var $data = 'data' + ($dataLvl || '') + var $isData = it.opts.$data && $schema && $schema.$data, + $schemaValue + if ($isData) { + out += + ' var schema' + + $lvl + + ' = ' + + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + + '; ' + $schemaValue = 'schema' + $lvl + } else { + $schemaValue = $schema + } + if (!($isData || typeof $schema == 'number')) { + throw new Error($keyword + ' must be number') + } + var $op = $keyword == 'maxLength' ? '>' : '<' + out += 'if ( ' + if ($isData) { + out += + ' (' + + $schemaValue + + ' !== undefined && typeof ' + + $schemaValue + + " != 'number') || " + } + if (it.opts.unicode === false) { + out += ' ' + $data + '.length ' + } else { + out += ' ucs2length(' + $data + ') ' + } + out += ' ' + $op + ' ' + $schemaValue + ') { ' + var $errorKeyword = $keyword + var $$outStack = $$outStack || [] + $$outStack.push(out) + out = '' /* istanbul ignore else */ + if (it.createErrors !== false) { + out += + " { keyword: '" + + ($errorKeyword || '_limitLength') + + "' , dataPath: (dataPath || '') + " + + it.errorPath + + ' , schemaPath: ' + + it.util.toQuotedString($errSchemaPath) + + ' , params: { limit: ' + + $schemaValue + + ' } ' + if (it.opts.messages !== false) { + out += " , message: 'should NOT be " + if ($keyword == 'maxLength') { + out += 'longer' + } else { + out += 'shorter' + } + out += ' than ' + if ($isData) { + out += "' + " + $schemaValue + " + '" + } else { + out += '' + $schema + } + out += " characters' " + } + if (it.opts.verbose) { + out += ' , schema: ' + if ($isData) { + out += 'validate.schema' + $schemaPath + } else { + out += '' + $schema + } + out += + ' , parentSchema: validate.schema' + + it.schemaPath + + ' , data: ' + + $data + + ' ' + } + out += ' } ' + } else { + out += ' {} ' + } + var __err = out + out = $$outStack.pop() + if (!it.compositeRule && $breakOnError) { + /* istanbul ignore if */ + if (it.async) { + out += ' throw new ValidationError([' + __err + ']); ' + } else { + out += ' validate.errors = [' + __err + ']; return false; ' + } + } else { + out += + ' var err = ' + + __err + + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ' + } + out += '} ' + if ($breakOnError) { + out += ' else { ' + } + return out + } + + /***/ + }, + + /***/ 71142: /***/ module => { + 'use strict' + + module.exports = function generate__limitProperties( + it, + $keyword, + $ruleType + ) { + var out = ' ' + var $lvl = it.level + var $dataLvl = it.dataLevel + var $schema = it.schema[$keyword] + var $schemaPath = it.schemaPath + it.util.getProperty($keyword) + var $errSchemaPath = it.errSchemaPath + '/' + $keyword + var $breakOnError = !it.opts.allErrors + var $errorKeyword + var $data = 'data' + ($dataLvl || '') + var $isData = it.opts.$data && $schema && $schema.$data, + $schemaValue + if ($isData) { + out += + ' var schema' + + $lvl + + ' = ' + + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + + '; ' + $schemaValue = 'schema' + $lvl + } else { + $schemaValue = $schema + } + if (!($isData || typeof $schema == 'number')) { + throw new Error($keyword + ' must be number') + } + var $op = $keyword == 'maxProperties' ? '>' : '<' + out += 'if ( ' + if ($isData) { + out += + ' (' + + $schemaValue + + ' !== undefined && typeof ' + + $schemaValue + + " != 'number') || " + } + out += + ' Object.keys(' + + $data + + ').length ' + + $op + + ' ' + + $schemaValue + + ') { ' + var $errorKeyword = $keyword + var $$outStack = $$outStack || [] + $$outStack.push(out) + out = '' /* istanbul ignore else */ + if (it.createErrors !== false) { + out += + " { keyword: '" + + ($errorKeyword || '_limitProperties') + + "' , dataPath: (dataPath || '') + " + + it.errorPath + + ' , schemaPath: ' + + it.util.toQuotedString($errSchemaPath) + + ' , params: { limit: ' + + $schemaValue + + ' } ' + if (it.opts.messages !== false) { + out += " , message: 'should NOT have " + if ($keyword == 'maxProperties') { + out += 'more' + } else { + out += 'fewer' + } + out += ' than ' + if ($isData) { + out += "' + " + $schemaValue + " + '" + } else { + out += '' + $schema + } + out += " properties' " + } + if (it.opts.verbose) { + out += ' , schema: ' + if ($isData) { + out += 'validate.schema' + $schemaPath + } else { + out += '' + $schema + } + out += + ' , parentSchema: validate.schema' + + it.schemaPath + + ' , data: ' + + $data + + ' ' + } + out += ' } ' + } else { + out += ' {} ' + } + var __err = out + out = $$outStack.pop() + if (!it.compositeRule && $breakOnError) { + /* istanbul ignore if */ + if (it.async) { + out += ' throw new ValidationError([' + __err + ']); ' + } else { + out += ' validate.errors = [' + __err + ']; return false; ' + } + } else { + out += + ' var err = ' + + __err + + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ' + } + out += '} ' + if ($breakOnError) { + out += ' else { ' + } + return out + } + + /***/ + }, + + /***/ 89443: /***/ module => { + 'use strict' + + module.exports = function generate_allOf(it, $keyword, $ruleType) { + var out = ' ' + var $schema = it.schema[$keyword] + var $schemaPath = it.schemaPath + it.util.getProperty($keyword) + var $errSchemaPath = it.errSchemaPath + '/' + $keyword + var $breakOnError = !it.opts.allErrors + var $it = it.util.copy(it) + var $closingBraces = '' + $it.level++ + var $nextValid = 'valid' + $it.level + var $currentBaseId = $it.baseId, + $allSchemasEmpty = true + var arr1 = $schema + if (arr1) { + var $sch, + $i = -1, + l1 = arr1.length - 1 + while ($i < l1) { + $sch = arr1[($i += 1)] + if ( + it.opts.strictKeywords + ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || + $sch === false + : it.util.schemaHasRules($sch, it.RULES.all) + ) { + $allSchemasEmpty = false + $it.schema = $sch + $it.schemaPath = $schemaPath + '[' + $i + ']' + $it.errSchemaPath = $errSchemaPath + '/' + $i + out += ' ' + it.validate($it) + ' ' + $it.baseId = $currentBaseId + if ($breakOnError) { + out += ' if (' + $nextValid + ') { ' + $closingBraces += '}' + } + } + } + } + if ($breakOnError) { + if ($allSchemasEmpty) { + out += ' if (true) { ' + } else { + out += ' ' + $closingBraces.slice(0, -1) + ' ' + } + } + return out + } + + /***/ + }, + + /***/ 63093: /***/ module => { + 'use strict' + + module.exports = function generate_anyOf(it, $keyword, $ruleType) { + var out = ' ' + var $lvl = it.level + var $dataLvl = it.dataLevel + var $schema = it.schema[$keyword] + var $schemaPath = it.schemaPath + it.util.getProperty($keyword) + var $errSchemaPath = it.errSchemaPath + '/' + $keyword + var $breakOnError = !it.opts.allErrors + var $data = 'data' + ($dataLvl || '') + var $valid = 'valid' + $lvl + var $errs = 'errs__' + $lvl + var $it = it.util.copy(it) + var $closingBraces = '' + $it.level++ + var $nextValid = 'valid' + $it.level + var $noEmptySchema = $schema.every(function ($sch) { + return it.opts.strictKeywords + ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || + $sch === false + : it.util.schemaHasRules($sch, it.RULES.all) + }) + if ($noEmptySchema) { + var $currentBaseId = $it.baseId + out += ' var ' + $errs + ' = errors; var ' + $valid + ' = false; ' + var $wasComposite = it.compositeRule + it.compositeRule = $it.compositeRule = true + var arr1 = $schema + if (arr1) { + var $sch, + $i = -1, + l1 = arr1.length - 1 + while ($i < l1) { + $sch = arr1[($i += 1)] + $it.schema = $sch + $it.schemaPath = $schemaPath + '[' + $i + ']' + $it.errSchemaPath = $errSchemaPath + '/' + $i + out += ' ' + it.validate($it) + ' ' + $it.baseId = $currentBaseId + out += + ' ' + + $valid + + ' = ' + + $valid + + ' || ' + + $nextValid + + '; if (!' + + $valid + + ') { ' + $closingBraces += '}' + } + } + it.compositeRule = $it.compositeRule = $wasComposite + out += + ' ' + + $closingBraces + + ' if (!' + + $valid + + ') { var err = ' /* istanbul ignore else */ + if (it.createErrors !== false) { + out += + " { keyword: '" + + 'anyOf' + + "' , dataPath: (dataPath || '') + " + + it.errorPath + + ' , schemaPath: ' + + it.util.toQuotedString($errSchemaPath) + + ' , params: {} ' + if (it.opts.messages !== false) { + out += " , message: 'should match some schema in anyOf' " + } + if (it.opts.verbose) { + out += + ' , schema: validate.schema' + + $schemaPath + + ' , parentSchema: validate.schema' + + it.schemaPath + + ' , data: ' + + $data + + ' ' + } + out += ' } ' + } else { + out += ' {} ' + } + out += + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ' + if (!it.compositeRule && $breakOnError) { + /* istanbul ignore if */ + if (it.async) { + out += ' throw new ValidationError(vErrors); ' + } else { + out += ' validate.errors = vErrors; return false; ' + } + } + out += + ' } else { errors = ' + + $errs + + '; if (vErrors !== null) { if (' + + $errs + + ') vErrors.length = ' + + $errs + + '; else vErrors = null; } ' + if (it.opts.allErrors) { + out += ' } ' + } + } else { + if ($breakOnError) { + out += ' if (true) { ' + } + } + return out + } + + /***/ + }, + + /***/ 30134: /***/ module => { + 'use strict' + + module.exports = function generate_comment(it, $keyword, $ruleType) { + var out = ' ' + var $schema = it.schema[$keyword] + var $errSchemaPath = it.errSchemaPath + '/' + $keyword + var $breakOnError = !it.opts.allErrors + var $comment = it.util.toQuotedString($schema) + if (it.opts.$comment === true) { + out += ' console.log(' + $comment + ');' + } else if (typeof it.opts.$comment == 'function') { + out += + ' self._opts.$comment(' + + $comment + + ', ' + + it.util.toQuotedString($errSchemaPath) + + ', validate.root.schema);' + } + return out + } + + /***/ + }, + + /***/ 1661: /***/ module => { + 'use strict' + + module.exports = function generate_const(it, $keyword, $ruleType) { + var out = ' ' + var $lvl = it.level + var $dataLvl = it.dataLevel + var $schema = it.schema[$keyword] + var $schemaPath = it.schemaPath + it.util.getProperty($keyword) + var $errSchemaPath = it.errSchemaPath + '/' + $keyword + var $breakOnError = !it.opts.allErrors + var $data = 'data' + ($dataLvl || '') + var $valid = 'valid' + $lvl + var $isData = it.opts.$data && $schema && $schema.$data, + $schemaValue + if ($isData) { + out += + ' var schema' + + $lvl + + ' = ' + + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + + '; ' + $schemaValue = 'schema' + $lvl + } else { + $schemaValue = $schema + } + if (!$isData) { + out += ' var schema' + $lvl + ' = validate.schema' + $schemaPath + ';' + } + out += + 'var ' + + $valid + + ' = equal(' + + $data + + ', schema' + + $lvl + + '); if (!' + + $valid + + ') { ' + var $$outStack = $$outStack || [] + $$outStack.push(out) + out = '' /* istanbul ignore else */ + if (it.createErrors !== false) { + out += + " { keyword: '" + + 'const' + + "' , dataPath: (dataPath || '') + " + + it.errorPath + + ' , schemaPath: ' + + it.util.toQuotedString($errSchemaPath) + + ' , params: { allowedValue: schema' + + $lvl + + ' } ' + if (it.opts.messages !== false) { + out += " , message: 'should be equal to constant' " + } + if (it.opts.verbose) { + out += + ' , schema: validate.schema' + + $schemaPath + + ' , parentSchema: validate.schema' + + it.schemaPath + + ' , data: ' + + $data + + ' ' + } + out += ' } ' + } else { + out += ' {} ' + } + var __err = out + out = $$outStack.pop() + if (!it.compositeRule && $breakOnError) { + /* istanbul ignore if */ + if (it.async) { + out += ' throw new ValidationError([' + __err + ']); ' + } else { + out += ' validate.errors = [' + __err + ']; return false; ' + } + } else { + out += + ' var err = ' + + __err + + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ' + } + out += ' }' + if ($breakOnError) { + out += ' else { ' + } + return out + } + + /***/ + }, + + /***/ 55964: /***/ module => { + 'use strict' + + module.exports = function generate_contains(it, $keyword, $ruleType) { + var out = ' ' + var $lvl = it.level + var $dataLvl = it.dataLevel + var $schema = it.schema[$keyword] + var $schemaPath = it.schemaPath + it.util.getProperty($keyword) + var $errSchemaPath = it.errSchemaPath + '/' + $keyword + var $breakOnError = !it.opts.allErrors + var $data = 'data' + ($dataLvl || '') + var $valid = 'valid' + $lvl + var $errs = 'errs__' + $lvl + var $it = it.util.copy(it) + var $closingBraces = '' + $it.level++ + var $nextValid = 'valid' + $it.level + var $idx = 'i' + $lvl, + $dataNxt = ($it.dataLevel = it.dataLevel + 1), + $nextData = 'data' + $dataNxt, + $currentBaseId = it.baseId, + $nonEmptySchema = it.opts.strictKeywords + ? (typeof $schema == 'object' && Object.keys($schema).length > 0) || + $schema === false + : it.util.schemaHasRules($schema, it.RULES.all) + out += 'var ' + $errs + ' = errors;var ' + $valid + ';' + if ($nonEmptySchema) { + var $wasComposite = it.compositeRule + it.compositeRule = $it.compositeRule = true + $it.schema = $schema + $it.schemaPath = $schemaPath + $it.errSchemaPath = $errSchemaPath + out += + ' var ' + + $nextValid + + ' = false; for (var ' + + $idx + + ' = 0; ' + + $idx + + ' < ' + + $data + + '.length; ' + + $idx + + '++) { ' + $it.errorPath = it.util.getPathExpr( + it.errorPath, + $idx, + it.opts.jsonPointers, + true + ) + var $passData = $data + '[' + $idx + ']' + $it.dataPathArr[$dataNxt] = $idx + var $code = it.validate($it) + $it.baseId = $currentBaseId + if (it.util.varOccurences($code, $nextData) < 2) { + out += ' ' + it.util.varReplace($code, $nextData, $passData) + ' ' + } else { + out += ' var ' + $nextData + ' = ' + $passData + '; ' + $code + ' ' + } + out += ' if (' + $nextValid + ') break; } ' + it.compositeRule = $it.compositeRule = $wasComposite + out += ' ' + $closingBraces + ' if (!' + $nextValid + ') {' + } else { + out += ' if (' + $data + '.length == 0) {' + } + var $$outStack = $$outStack || [] + $$outStack.push(out) + out = '' /* istanbul ignore else */ + if (it.createErrors !== false) { + out += + " { keyword: '" + + 'contains' + + "' , dataPath: (dataPath || '') + " + + it.errorPath + + ' , schemaPath: ' + + it.util.toQuotedString($errSchemaPath) + + ' , params: {} ' + if (it.opts.messages !== false) { + out += " , message: 'should contain a valid item' " + } + if (it.opts.verbose) { + out += + ' , schema: validate.schema' + + $schemaPath + + ' , parentSchema: validate.schema' + + it.schemaPath + + ' , data: ' + + $data + + ' ' + } + out += ' } ' + } else { + out += ' {} ' + } + var __err = out + out = $$outStack.pop() + if (!it.compositeRule && $breakOnError) { + /* istanbul ignore if */ + if (it.async) { + out += ' throw new ValidationError([' + __err + ']); ' + } else { + out += ' validate.errors = [' + __err + ']; return false; ' + } + } else { + out += + ' var err = ' + + __err + + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ' + } + out += ' } else { ' + if ($nonEmptySchema) { + out += + ' errors = ' + + $errs + + '; if (vErrors !== null) { if (' + + $errs + + ') vErrors.length = ' + + $errs + + '; else vErrors = null; } ' + } + if (it.opts.allErrors) { + out += ' } ' + } + return out + } + + /***/ + }, + + /***/ 5912: /***/ module => { + 'use strict' + + module.exports = function generate_custom(it, $keyword, $ruleType) { + var out = ' ' + var $lvl = it.level + var $dataLvl = it.dataLevel + var $schema = it.schema[$keyword] + var $schemaPath = it.schemaPath + it.util.getProperty($keyword) + var $errSchemaPath = it.errSchemaPath + '/' + $keyword + var $breakOnError = !it.opts.allErrors + var $errorKeyword + var $data = 'data' + ($dataLvl || '') + var $valid = 'valid' + $lvl + var $errs = 'errs__' + $lvl + var $isData = it.opts.$data && $schema && $schema.$data, + $schemaValue + if ($isData) { + out += + ' var schema' + + $lvl + + ' = ' + + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + + '; ' + $schemaValue = 'schema' + $lvl + } else { + $schemaValue = $schema + } + var $rule = this, + $definition = 'definition' + $lvl, + $rDef = $rule.definition, + $closingBraces = '' + var $compile, $inline, $macro, $ruleValidate, $validateCode + if ($isData && $rDef.$data) { + $validateCode = 'keywordValidate' + $lvl + var $validateSchema = $rDef.validateSchema + out += + ' var ' + + $definition + + " = RULES.custom['" + + $keyword + + "'].definition; var " + + $validateCode + + ' = ' + + $definition + + '.validate;' + } else { + $ruleValidate = it.useCustomRule($rule, $schema, it.schema, it) + if (!$ruleValidate) return + $schemaValue = 'validate.schema' + $schemaPath + $validateCode = $ruleValidate.code + $compile = $rDef.compile + $inline = $rDef.inline + $macro = $rDef.macro + } + var $ruleErrs = $validateCode + '.errors', + $i = 'i' + $lvl, + $ruleErr = 'ruleErr' + $lvl, + $asyncKeyword = $rDef.async + if ($asyncKeyword && !it.async) + throw new Error('async keyword in sync schema') + if (!($inline || $macro)) { + out += '' + $ruleErrs + ' = null;' + } + out += 'var ' + $errs + ' = errors;var ' + $valid + ';' + if ($isData && $rDef.$data) { + $closingBraces += '}' + out += + ' if (' + + $schemaValue + + ' === undefined) { ' + + $valid + + ' = true; } else { ' + if ($validateSchema) { + $closingBraces += '}' + out += + ' ' + + $valid + + ' = ' + + $definition + + '.validateSchema(' + + $schemaValue + + '); if (' + + $valid + + ') { ' + } + } + if ($inline) { + if ($rDef.statements) { + out += ' ' + $ruleValidate.validate + ' ' + } else { + out += ' ' + $valid + ' = ' + $ruleValidate.validate + '; ' + } + } else if ($macro) { + var $it = it.util.copy(it) + var $closingBraces = '' + $it.level++ + var $nextValid = 'valid' + $it.level + $it.schema = $ruleValidate.validate + $it.schemaPath = '' + var $wasComposite = it.compositeRule + it.compositeRule = $it.compositeRule = true + var $code = it + .validate($it) + .replace(/validate\.schema/g, $validateCode) + it.compositeRule = $it.compositeRule = $wasComposite + out += ' ' + $code + } else { + var $$outStack = $$outStack || [] + $$outStack.push(out) + out = '' + out += ' ' + $validateCode + '.call( ' + if (it.opts.passContext) { + out += 'this' + } else { + out += 'self' + } + if ($compile || $rDef.schema === false) { + out += ' , ' + $data + ' ' + } else { + out += + ' , ' + + $schemaValue + + ' , ' + + $data + + ' , validate.schema' + + it.schemaPath + + ' ' + } + out += " , (dataPath || '')" + if (it.errorPath != '""') { + out += ' + ' + it.errorPath + } + var $parentData = $dataLvl + ? 'data' + ($dataLvl - 1 || '') + : 'parentData', + $parentDataProperty = $dataLvl + ? it.dataPathArr[$dataLvl] + : 'parentDataProperty' + out += + ' , ' + + $parentData + + ' , ' + + $parentDataProperty + + ' , rootData ) ' + var def_callRuleValidate = out + out = $$outStack.pop() + if ($rDef.errors === false) { + out += ' ' + $valid + ' = ' + if ($asyncKeyword) { + out += 'await ' + } + out += '' + def_callRuleValidate + '; ' + } else { + if ($asyncKeyword) { + $ruleErrs = 'customErrors' + $lvl + out += + ' var ' + + $ruleErrs + + ' = null; try { ' + + $valid + + ' = await ' + + def_callRuleValidate + + '; } catch (e) { ' + + $valid + + ' = false; if (e instanceof ValidationError) ' + + $ruleErrs + + ' = e.errors; else throw e; } ' + } else { + out += + ' ' + + $ruleErrs + + ' = null; ' + + $valid + + ' = ' + + def_callRuleValidate + + '; ' + } + } + } + if ($rDef.modifying) { + out += + ' if (' + + $parentData + + ') ' + + $data + + ' = ' + + $parentData + + '[' + + $parentDataProperty + + '];' + } + out += '' + $closingBraces + if ($rDef.valid) { + if ($breakOnError) { + out += ' if (true) { ' + } + } else { + out += ' if ( ' + if ($rDef.valid === undefined) { + out += ' !' + if ($macro) { + out += '' + $nextValid + } else { + out += '' + $valid + } + } else { + out += ' ' + !$rDef.valid + ' ' + } + out += ') { ' + $errorKeyword = $rule.keyword + var $$outStack = $$outStack || [] + $$outStack.push(out) + out = '' + var $$outStack = $$outStack || [] + $$outStack.push(out) + out = '' /* istanbul ignore else */ + if (it.createErrors !== false) { + out += + " { keyword: '" + + ($errorKeyword || 'custom') + + "' , dataPath: (dataPath || '') + " + + it.errorPath + + ' , schemaPath: ' + + it.util.toQuotedString($errSchemaPath) + + " , params: { keyword: '" + + $rule.keyword + + "' } " + if (it.opts.messages !== false) { + out += + ' , message: \'should pass "' + + $rule.keyword + + '" keyword validation\' ' + } + if (it.opts.verbose) { + out += + ' , schema: validate.schema' + + $schemaPath + + ' , parentSchema: validate.schema' + + it.schemaPath + + ' , data: ' + + $data + + ' ' + } + out += ' } ' + } else { + out += ' {} ' + } + var __err = out + out = $$outStack.pop() + if (!it.compositeRule && $breakOnError) { + /* istanbul ignore if */ + if (it.async) { + out += ' throw new ValidationError([' + __err + ']); ' + } else { + out += ' validate.errors = [' + __err + ']; return false; ' + } + } else { + out += + ' var err = ' + + __err + + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ' + } + var def_customError = out + out = $$outStack.pop() + if ($inline) { + if ($rDef.errors) { + if ($rDef.errors != 'full') { + out += + ' for (var ' + + $i + + '=' + + $errs + + '; ' + + $i + + ' { + 'use strict' + + module.exports = function generate_dependencies(it, $keyword, $ruleType) { + var out = ' ' + var $lvl = it.level + var $dataLvl = it.dataLevel + var $schema = it.schema[$keyword] + var $schemaPath = it.schemaPath + it.util.getProperty($keyword) + var $errSchemaPath = it.errSchemaPath + '/' + $keyword + var $breakOnError = !it.opts.allErrors + var $data = 'data' + ($dataLvl || '') + var $errs = 'errs__' + $lvl + var $it = it.util.copy(it) + var $closingBraces = '' + $it.level++ + var $nextValid = 'valid' + $it.level + var $schemaDeps = {}, + $propertyDeps = {}, + $ownProperties = it.opts.ownProperties + for ($property in $schema) { + if ($property == '__proto__') continue + var $sch = $schema[$property] + var $deps = Array.isArray($sch) ? $propertyDeps : $schemaDeps + $deps[$property] = $sch + } + out += 'var ' + $errs + ' = errors;' + var $currentErrorPath = it.errorPath + out += 'var missing' + $lvl + ';' + for (var $property in $propertyDeps) { + $deps = $propertyDeps[$property] + if ($deps.length) { + out += + ' if ( ' + + $data + + it.util.getProperty($property) + + ' !== undefined ' + if ($ownProperties) { + out += + ' && Object.prototype.hasOwnProperty.call(' + + $data + + ", '" + + it.util.escapeQuotes($property) + + "') " + } + if ($breakOnError) { + out += ' && ( ' + var arr1 = $deps + if (arr1) { + var $propertyKey, + $i = -1, + l1 = arr1.length - 1 + while ($i < l1) { + $propertyKey = arr1[($i += 1)] + if ($i) { + out += ' || ' + } + var $prop = it.util.getProperty($propertyKey), + $useData = $data + $prop + out += ' ( ( ' + $useData + ' === undefined ' + if ($ownProperties) { + out += + ' || ! Object.prototype.hasOwnProperty.call(' + + $data + + ", '" + + it.util.escapeQuotes($propertyKey) + + "') " + } + out += + ') && (missing' + + $lvl + + ' = ' + + it.util.toQuotedString( + it.opts.jsonPointers ? $propertyKey : $prop + ) + + ') ) ' + } + } + out += ')) { ' + var $propertyPath = 'missing' + $lvl, + $missingProperty = "' + " + $propertyPath + " + '" + if (it.opts._errorDataPathProperty) { + it.errorPath = it.opts.jsonPointers + ? it.util.getPathExpr($currentErrorPath, $propertyPath, true) + : $currentErrorPath + ' + ' + $propertyPath + } + var $$outStack = $$outStack || [] + $$outStack.push(out) + out = '' /* istanbul ignore else */ + if (it.createErrors !== false) { + out += + " { keyword: '" + + 'dependencies' + + "' , dataPath: (dataPath || '') + " + + it.errorPath + + ' , schemaPath: ' + + it.util.toQuotedString($errSchemaPath) + + " , params: { property: '" + + it.util.escapeQuotes($property) + + "', missingProperty: '" + + $missingProperty + + "', depsCount: " + + $deps.length + + ", deps: '" + + it.util.escapeQuotes( + $deps.length == 1 ? $deps[0] : $deps.join(', ') + ) + + "' } " + if (it.opts.messages !== false) { + out += " , message: 'should have " + if ($deps.length == 1) { + out += 'property ' + it.util.escapeQuotes($deps[0]) + } else { + out += + 'properties ' + it.util.escapeQuotes($deps.join(', ')) + } + out += + ' when property ' + + it.util.escapeQuotes($property) + + " is present' " + } + if (it.opts.verbose) { + out += + ' , schema: validate.schema' + + $schemaPath + + ' , parentSchema: validate.schema' + + it.schemaPath + + ' , data: ' + + $data + + ' ' + } + out += ' } ' + } else { + out += ' {} ' + } + var __err = out + out = $$outStack.pop() + if (!it.compositeRule && $breakOnError) { + /* istanbul ignore if */ + if (it.async) { + out += ' throw new ValidationError([' + __err + ']); ' + } else { + out += ' validate.errors = [' + __err + ']; return false; ' + } + } else { + out += + ' var err = ' + + __err + + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ' + } + } else { + out += ' ) { ' + var arr2 = $deps + if (arr2) { + var $propertyKey, + i2 = -1, + l2 = arr2.length - 1 + while (i2 < l2) { + $propertyKey = arr2[(i2 += 1)] + var $prop = it.util.getProperty($propertyKey), + $missingProperty = it.util.escapeQuotes($propertyKey), + $useData = $data + $prop + if (it.opts._errorDataPathProperty) { + it.errorPath = it.util.getPath( + $currentErrorPath, + $propertyKey, + it.opts.jsonPointers + ) + } + out += ' if ( ' + $useData + ' === undefined ' + if ($ownProperties) { + out += + ' || ! Object.prototype.hasOwnProperty.call(' + + $data + + ", '" + + it.util.escapeQuotes($propertyKey) + + "') " + } + out += ') { var err = ' /* istanbul ignore else */ + if (it.createErrors !== false) { + out += + " { keyword: '" + + 'dependencies' + + "' , dataPath: (dataPath || '') + " + + it.errorPath + + ' , schemaPath: ' + + it.util.toQuotedString($errSchemaPath) + + " , params: { property: '" + + it.util.escapeQuotes($property) + + "', missingProperty: '" + + $missingProperty + + "', depsCount: " + + $deps.length + + ", deps: '" + + it.util.escapeQuotes( + $deps.length == 1 ? $deps[0] : $deps.join(', ') + ) + + "' } " + if (it.opts.messages !== false) { + out += " , message: 'should have " + if ($deps.length == 1) { + out += 'property ' + it.util.escapeQuotes($deps[0]) + } else { + out += + 'properties ' + it.util.escapeQuotes($deps.join(', ')) + } + out += + ' when property ' + + it.util.escapeQuotes($property) + + " is present' " + } + if (it.opts.verbose) { + out += + ' , schema: validate.schema' + + $schemaPath + + ' , parentSchema: validate.schema' + + it.schemaPath + + ' , data: ' + + $data + + ' ' + } + out += ' } ' + } else { + out += ' {} ' + } + out += + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } ' + } + } + } + out += ' } ' + if ($breakOnError) { + $closingBraces += '}' + out += ' else { ' + } + } + } + it.errorPath = $currentErrorPath + var $currentBaseId = $it.baseId + for (var $property in $schemaDeps) { + var $sch = $schemaDeps[$property] + if ( + it.opts.strictKeywords + ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || + $sch === false + : it.util.schemaHasRules($sch, it.RULES.all) + ) { + out += + ' ' + + $nextValid + + ' = true; if ( ' + + $data + + it.util.getProperty($property) + + ' !== undefined ' + if ($ownProperties) { + out += + ' && Object.prototype.hasOwnProperty.call(' + + $data + + ", '" + + it.util.escapeQuotes($property) + + "') " + } + out += ') { ' + $it.schema = $sch + $it.schemaPath = $schemaPath + it.util.getProperty($property) + $it.errSchemaPath = + $errSchemaPath + '/' + it.util.escapeFragment($property) + out += ' ' + it.validate($it) + ' ' + $it.baseId = $currentBaseId + out += ' } ' + if ($breakOnError) { + out += ' if (' + $nextValid + ') { ' + $closingBraces += '}' + } + } + } + if ($breakOnError) { + out += ' ' + $closingBraces + ' if (' + $errs + ' == errors) {' + } + return out + } + + /***/ + }, + + /***/ 10163: /***/ module => { + 'use strict' + + module.exports = function generate_enum(it, $keyword, $ruleType) { + var out = ' ' + var $lvl = it.level + var $dataLvl = it.dataLevel + var $schema = it.schema[$keyword] + var $schemaPath = it.schemaPath + it.util.getProperty($keyword) + var $errSchemaPath = it.errSchemaPath + '/' + $keyword + var $breakOnError = !it.opts.allErrors + var $data = 'data' + ($dataLvl || '') + var $valid = 'valid' + $lvl + var $isData = it.opts.$data && $schema && $schema.$data, + $schemaValue + if ($isData) { + out += + ' var schema' + + $lvl + + ' = ' + + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + + '; ' + $schemaValue = 'schema' + $lvl + } else { + $schemaValue = $schema + } + var $i = 'i' + $lvl, + $vSchema = 'schema' + $lvl + if (!$isData) { + out += ' var ' + $vSchema + ' = validate.schema' + $schemaPath + ';' + } + out += 'var ' + $valid + ';' + if ($isData) { + out += + ' if (schema' + + $lvl + + ' === undefined) ' + + $valid + + ' = true; else if (!Array.isArray(schema' + + $lvl + + ')) ' + + $valid + + ' = false; else {' + } + out += + '' + + $valid + + ' = false;for (var ' + + $i + + '=0; ' + + $i + + '<' + + $vSchema + + '.length; ' + + $i + + '++) if (equal(' + + $data + + ', ' + + $vSchema + + '[' + + $i + + '])) { ' + + $valid + + ' = true; break; }' + if ($isData) { + out += ' } ' + } + out += ' if (!' + $valid + ') { ' + var $$outStack = $$outStack || [] + $$outStack.push(out) + out = '' /* istanbul ignore else */ + if (it.createErrors !== false) { + out += + " { keyword: '" + + 'enum' + + "' , dataPath: (dataPath || '') + " + + it.errorPath + + ' , schemaPath: ' + + it.util.toQuotedString($errSchemaPath) + + ' , params: { allowedValues: schema' + + $lvl + + ' } ' + if (it.opts.messages !== false) { + out += " , message: 'should be equal to one of the allowed values' " + } + if (it.opts.verbose) { + out += + ' , schema: validate.schema' + + $schemaPath + + ' , parentSchema: validate.schema' + + it.schemaPath + + ' , data: ' + + $data + + ' ' + } + out += ' } ' + } else { + out += ' {} ' + } + var __err = out + out = $$outStack.pop() + if (!it.compositeRule && $breakOnError) { + /* istanbul ignore if */ + if (it.async) { + out += ' throw new ValidationError([' + __err + ']); ' + } else { + out += ' validate.errors = [' + __err + ']; return false; ' + } + } else { + out += + ' var err = ' + + __err + + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ' + } + out += ' }' + if ($breakOnError) { + out += ' else { ' + } + return out + } + + /***/ + }, + + /***/ 63847: /***/ module => { + 'use strict' + + module.exports = function generate_format(it, $keyword, $ruleType) { + var out = ' ' + var $lvl = it.level + var $dataLvl = it.dataLevel + var $schema = it.schema[$keyword] + var $schemaPath = it.schemaPath + it.util.getProperty($keyword) + var $errSchemaPath = it.errSchemaPath + '/' + $keyword + var $breakOnError = !it.opts.allErrors + var $data = 'data' + ($dataLvl || '') + if (it.opts.format === false) { + if ($breakOnError) { + out += ' if (true) { ' + } + return out + } + var $isData = it.opts.$data && $schema && $schema.$data, + $schemaValue + if ($isData) { + out += + ' var schema' + + $lvl + + ' = ' + + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + + '; ' + $schemaValue = 'schema' + $lvl + } else { + $schemaValue = $schema + } + var $unknownFormats = it.opts.unknownFormats, + $allowUnknown = Array.isArray($unknownFormats) + if ($isData) { + var $format = 'format' + $lvl, + $isObject = 'isObject' + $lvl, + $formatType = 'formatType' + $lvl + out += + ' var ' + + $format + + ' = formats[' + + $schemaValue + + ']; var ' + + $isObject + + ' = typeof ' + + $format + + " == 'object' && !(" + + $format + + ' instanceof RegExp) && ' + + $format + + '.validate; var ' + + $formatType + + ' = ' + + $isObject + + ' && ' + + $format + + ".type || 'string'; if (" + + $isObject + + ') { ' + if (it.async) { + out += ' var async' + $lvl + ' = ' + $format + '.async; ' + } + out += ' ' + $format + ' = ' + $format + '.validate; } if ( ' + if ($isData) { + out += + ' (' + + $schemaValue + + ' !== undefined && typeof ' + + $schemaValue + + " != 'string') || " + } + out += ' (' + if ($unknownFormats != 'ignore') { + out += ' (' + $schemaValue + ' && !' + $format + ' ' + if ($allowUnknown) { + out += + ' && self._opts.unknownFormats.indexOf(' + + $schemaValue + + ') == -1 ' + } + out += ') || ' + } + out += + ' (' + + $format + + ' && ' + + $formatType + + " == '" + + $ruleType + + "' && !(typeof " + + $format + + " == 'function' ? " + if (it.async) { + out += + ' (async' + + $lvl + + ' ? await ' + + $format + + '(' + + $data + + ') : ' + + $format + + '(' + + $data + + ')) ' + } else { + out += ' ' + $format + '(' + $data + ') ' + } + out += ' : ' + $format + '.test(' + $data + '))))) {' + } else { + var $format = it.formats[$schema] + if (!$format) { + if ($unknownFormats == 'ignore') { + it.logger.warn( + 'unknown format "' + + $schema + + '" ignored in schema at path "' + + it.errSchemaPath + + '"' + ) + if ($breakOnError) { + out += ' if (true) { ' + } + return out + } else if ($allowUnknown && $unknownFormats.indexOf($schema) >= 0) { + if ($breakOnError) { + out += ' if (true) { ' + } + return out + } else { + throw new Error( + 'unknown format "' + + $schema + + '" is used in schema at path "' + + it.errSchemaPath + + '"' + ) + } + } + var $isObject = + typeof $format == 'object' && + !($format instanceof RegExp) && + $format.validate + var $formatType = ($isObject && $format.type) || 'string' + if ($isObject) { + var $async = $format.async === true + $format = $format.validate + } + if ($formatType != $ruleType) { + if ($breakOnError) { + out += ' if (true) { ' + } + return out + } + if ($async) { + if (!it.async) throw new Error('async format in sync schema') + var $formatRef = + 'formats' + it.util.getProperty($schema) + '.validate' + out += ' if (!(await ' + $formatRef + '(' + $data + '))) { ' + } else { + out += ' if (! ' + var $formatRef = 'formats' + it.util.getProperty($schema) + if ($isObject) $formatRef += '.validate' + if (typeof $format == 'function') { + out += ' ' + $formatRef + '(' + $data + ') ' + } else { + out += ' ' + $formatRef + '.test(' + $data + ') ' + } + out += ') { ' + } + } + var $$outStack = $$outStack || [] + $$outStack.push(out) + out = '' /* istanbul ignore else */ + if (it.createErrors !== false) { + out += + " { keyword: '" + + 'format' + + "' , dataPath: (dataPath || '') + " + + it.errorPath + + ' , schemaPath: ' + + it.util.toQuotedString($errSchemaPath) + + ' , params: { format: ' + if ($isData) { + out += '' + $schemaValue + } else { + out += '' + it.util.toQuotedString($schema) + } + out += ' } ' + if (it.opts.messages !== false) { + out += ' , message: \'should match format "' + if ($isData) { + out += "' + " + $schemaValue + " + '" + } else { + out += '' + it.util.escapeQuotes($schema) + } + out += '"\' ' + } + if (it.opts.verbose) { + out += ' , schema: ' + if ($isData) { + out += 'validate.schema' + $schemaPath + } else { + out += '' + it.util.toQuotedString($schema) + } + out += + ' , parentSchema: validate.schema' + + it.schemaPath + + ' , data: ' + + $data + + ' ' + } + out += ' } ' + } else { + out += ' {} ' + } + var __err = out + out = $$outStack.pop() + if (!it.compositeRule && $breakOnError) { + /* istanbul ignore if */ + if (it.async) { + out += ' throw new ValidationError([' + __err + ']); ' + } else { + out += ' validate.errors = [' + __err + ']; return false; ' + } + } else { + out += + ' var err = ' + + __err + + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ' + } + out += ' } ' + if ($breakOnError) { + out += ' else { ' + } + return out + } + + /***/ + }, + + /***/ 80862: /***/ module => { + 'use strict' + + module.exports = function generate_if(it, $keyword, $ruleType) { + var out = ' ' + var $lvl = it.level + var $dataLvl = it.dataLevel + var $schema = it.schema[$keyword] + var $schemaPath = it.schemaPath + it.util.getProperty($keyword) + var $errSchemaPath = it.errSchemaPath + '/' + $keyword + var $breakOnError = !it.opts.allErrors + var $data = 'data' + ($dataLvl || '') + var $valid = 'valid' + $lvl + var $errs = 'errs__' + $lvl + var $it = it.util.copy(it) + $it.level++ + var $nextValid = 'valid' + $it.level + var $thenSch = it.schema['then'], + $elseSch = it.schema['else'], + $thenPresent = + $thenSch !== undefined && + (it.opts.strictKeywords + ? (typeof $thenSch == 'object' && + Object.keys($thenSch).length > 0) || + $thenSch === false + : it.util.schemaHasRules($thenSch, it.RULES.all)), + $elsePresent = + $elseSch !== undefined && + (it.opts.strictKeywords + ? (typeof $elseSch == 'object' && + Object.keys($elseSch).length > 0) || + $elseSch === false + : it.util.schemaHasRules($elseSch, it.RULES.all)), + $currentBaseId = $it.baseId + if ($thenPresent || $elsePresent) { + var $ifClause + $it.createErrors = false + $it.schema = $schema + $it.schemaPath = $schemaPath + $it.errSchemaPath = $errSchemaPath + out += ' var ' + $errs + ' = errors; var ' + $valid + ' = true; ' + var $wasComposite = it.compositeRule + it.compositeRule = $it.compositeRule = true + out += ' ' + it.validate($it) + ' ' + $it.baseId = $currentBaseId + $it.createErrors = true + out += + ' errors = ' + + $errs + + '; if (vErrors !== null) { if (' + + $errs + + ') vErrors.length = ' + + $errs + + '; else vErrors = null; } ' + it.compositeRule = $it.compositeRule = $wasComposite + if ($thenPresent) { + out += ' if (' + $nextValid + ') { ' + $it.schema = it.schema['then'] + $it.schemaPath = it.schemaPath + '.then' + $it.errSchemaPath = it.errSchemaPath + '/then' + out += ' ' + it.validate($it) + ' ' + $it.baseId = $currentBaseId + out += ' ' + $valid + ' = ' + $nextValid + '; ' + if ($thenPresent && $elsePresent) { + $ifClause = 'ifClause' + $lvl + out += ' var ' + $ifClause + " = 'then'; " + } else { + $ifClause = "'then'" + } + out += ' } ' + if ($elsePresent) { + out += ' else { ' + } + } else { + out += ' if (!' + $nextValid + ') { ' + } + if ($elsePresent) { + $it.schema = it.schema['else'] + $it.schemaPath = it.schemaPath + '.else' + $it.errSchemaPath = it.errSchemaPath + '/else' + out += ' ' + it.validate($it) + ' ' + $it.baseId = $currentBaseId + out += ' ' + $valid + ' = ' + $nextValid + '; ' + if ($thenPresent && $elsePresent) { + $ifClause = 'ifClause' + $lvl + out += ' var ' + $ifClause + " = 'else'; " + } else { + $ifClause = "'else'" + } + out += ' } ' + } + out += + ' if (!' + $valid + ') { var err = ' /* istanbul ignore else */ + if (it.createErrors !== false) { + out += + " { keyword: '" + + 'if' + + "' , dataPath: (dataPath || '') + " + + it.errorPath + + ' , schemaPath: ' + + it.util.toQuotedString($errSchemaPath) + + ' , params: { failingKeyword: ' + + $ifClause + + ' } ' + if (it.opts.messages !== false) { + out += + " , message: 'should match \"' + " + + $ifClause + + " + '\" schema' " + } + if (it.opts.verbose) { + out += + ' , schema: validate.schema' + + $schemaPath + + ' , parentSchema: validate.schema' + + it.schemaPath + + ' , data: ' + + $data + + ' ' + } + out += ' } ' + } else { + out += ' {} ' + } + out += + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ' + if (!it.compositeRule && $breakOnError) { + /* istanbul ignore if */ + if (it.async) { + out += ' throw new ValidationError(vErrors); ' + } else { + out += ' validate.errors = vErrors; return false; ' + } + } + out += ' } ' + if ($breakOnError) { + out += ' else { ' + } + } else { + if ($breakOnError) { + out += ' if (true) { ' + } + } + return out + } + + /***/ + }, + + /***/ 85810: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + 'use strict' + + //all requires must be explicit because browserify won't work with dynamic requires + module.exports = { + $ref: __webpack_require__(42393), + allOf: __webpack_require__(89443), + anyOf: __webpack_require__(63093), + $comment: __webpack_require__(30134), + const: __webpack_require__(1661), + contains: __webpack_require__(55964), + dependencies: __webpack_require__(2591), + enum: __webpack_require__(10163), + format: __webpack_require__(63847), + if: __webpack_require__(80862), + items: __webpack_require__(54408), + maximum: __webpack_require__(7404), + minimum: __webpack_require__(7404), + maxItems: __webpack_require__(64683), + minItems: __webpack_require__(64683), + maxLength: __webpack_require__(52114), + minLength: __webpack_require__(52114), + maxProperties: __webpack_require__(71142), + minProperties: __webpack_require__(71142), + multipleOf: __webpack_require__(39772), + not: __webpack_require__(60750), + oneOf: __webpack_require__(6106), + pattern: __webpack_require__(13912), + properties: __webpack_require__(52924), + propertyNames: __webpack_require__(19195), + required: __webpack_require__(8420), + uniqueItems: __webpack_require__(24995), + validate: __webpack_require__(49585) + } + + /***/ + }, + + /***/ 54408: /***/ module => { + 'use strict' + + module.exports = function generate_items(it, $keyword, $ruleType) { + var out = ' ' + var $lvl = it.level + var $dataLvl = it.dataLevel + var $schema = it.schema[$keyword] + var $schemaPath = it.schemaPath + it.util.getProperty($keyword) + var $errSchemaPath = it.errSchemaPath + '/' + $keyword + var $breakOnError = !it.opts.allErrors + var $data = 'data' + ($dataLvl || '') + var $valid = 'valid' + $lvl + var $errs = 'errs__' + $lvl + var $it = it.util.copy(it) + var $closingBraces = '' + $it.level++ + var $nextValid = 'valid' + $it.level + var $idx = 'i' + $lvl, + $dataNxt = ($it.dataLevel = it.dataLevel + 1), + $nextData = 'data' + $dataNxt, + $currentBaseId = it.baseId + out += 'var ' + $errs + ' = errors;var ' + $valid + ';' + if (Array.isArray($schema)) { + var $additionalItems = it.schema.additionalItems + if ($additionalItems === false) { + out += + ' ' + + $valid + + ' = ' + + $data + + '.length <= ' + + $schema.length + + '; ' + var $currErrSchemaPath = $errSchemaPath + $errSchemaPath = it.errSchemaPath + '/additionalItems' + out += ' if (!' + $valid + ') { ' + var $$outStack = $$outStack || [] + $$outStack.push(out) + out = '' /* istanbul ignore else */ + if (it.createErrors !== false) { + out += + " { keyword: '" + + 'additionalItems' + + "' , dataPath: (dataPath || '') + " + + it.errorPath + + ' , schemaPath: ' + + it.util.toQuotedString($errSchemaPath) + + ' , params: { limit: ' + + $schema.length + + ' } ' + if (it.opts.messages !== false) { + out += + " , message: 'should NOT have more than " + + $schema.length + + " items' " + } + if (it.opts.verbose) { + out += + ' , schema: false , parentSchema: validate.schema' + + it.schemaPath + + ' , data: ' + + $data + + ' ' + } + out += ' } ' + } else { + out += ' {} ' + } + var __err = out + out = $$outStack.pop() + if (!it.compositeRule && $breakOnError) { + /* istanbul ignore if */ + if (it.async) { + out += ' throw new ValidationError([' + __err + ']); ' + } else { + out += ' validate.errors = [' + __err + ']; return false; ' + } + } else { + out += + ' var err = ' + + __err + + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ' + } + out += ' } ' + $errSchemaPath = $currErrSchemaPath + if ($breakOnError) { + $closingBraces += '}' + out += ' else { ' + } + } + var arr1 = $schema + if (arr1) { + var $sch, + $i = -1, + l1 = arr1.length - 1 + while ($i < l1) { + $sch = arr1[($i += 1)] + if ( + it.opts.strictKeywords + ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || + $sch === false + : it.util.schemaHasRules($sch, it.RULES.all) + ) { + out += + ' ' + + $nextValid + + ' = true; if (' + + $data + + '.length > ' + + $i + + ') { ' + var $passData = $data + '[' + $i + ']' + $it.schema = $sch + $it.schemaPath = $schemaPath + '[' + $i + ']' + $it.errSchemaPath = $errSchemaPath + '/' + $i + $it.errorPath = it.util.getPathExpr( + it.errorPath, + $i, + it.opts.jsonPointers, + true + ) + $it.dataPathArr[$dataNxt] = $i + var $code = it.validate($it) + $it.baseId = $currentBaseId + if (it.util.varOccurences($code, $nextData) < 2) { + out += + ' ' + it.util.varReplace($code, $nextData, $passData) + ' ' + } else { + out += + ' var ' + $nextData + ' = ' + $passData + '; ' + $code + ' ' + } + out += ' } ' + if ($breakOnError) { + out += ' if (' + $nextValid + ') { ' + $closingBraces += '}' + } + } + } + } + if ( + typeof $additionalItems == 'object' && + (it.opts.strictKeywords + ? (typeof $additionalItems == 'object' && + Object.keys($additionalItems).length > 0) || + $additionalItems === false + : it.util.schemaHasRules($additionalItems, it.RULES.all)) + ) { + $it.schema = $additionalItems + $it.schemaPath = it.schemaPath + '.additionalItems' + $it.errSchemaPath = it.errSchemaPath + '/additionalItems' + out += + ' ' + + $nextValid + + ' = true; if (' + + $data + + '.length > ' + + $schema.length + + ') { for (var ' + + $idx + + ' = ' + + $schema.length + + '; ' + + $idx + + ' < ' + + $data + + '.length; ' + + $idx + + '++) { ' + $it.errorPath = it.util.getPathExpr( + it.errorPath, + $idx, + it.opts.jsonPointers, + true + ) + var $passData = $data + '[' + $idx + ']' + $it.dataPathArr[$dataNxt] = $idx + var $code = it.validate($it) + $it.baseId = $currentBaseId + if (it.util.varOccurences($code, $nextData) < 2) { + out += ' ' + it.util.varReplace($code, $nextData, $passData) + ' ' + } else { + out += + ' var ' + $nextData + ' = ' + $passData + '; ' + $code + ' ' + } + if ($breakOnError) { + out += ' if (!' + $nextValid + ') break; ' + } + out += ' } } ' + if ($breakOnError) { + out += ' if (' + $nextValid + ') { ' + $closingBraces += '}' + } + } + } else if ( + it.opts.strictKeywords + ? (typeof $schema == 'object' && Object.keys($schema).length > 0) || + $schema === false + : it.util.schemaHasRules($schema, it.RULES.all) + ) { + $it.schema = $schema + $it.schemaPath = $schemaPath + $it.errSchemaPath = $errSchemaPath + out += + ' for (var ' + + $idx + + ' = ' + + 0 + + '; ' + + $idx + + ' < ' + + $data + + '.length; ' + + $idx + + '++) { ' + $it.errorPath = it.util.getPathExpr( + it.errorPath, + $idx, + it.opts.jsonPointers, + true + ) + var $passData = $data + '[' + $idx + ']' + $it.dataPathArr[$dataNxt] = $idx + var $code = it.validate($it) + $it.baseId = $currentBaseId + if (it.util.varOccurences($code, $nextData) < 2) { + out += ' ' + it.util.varReplace($code, $nextData, $passData) + ' ' + } else { + out += ' var ' + $nextData + ' = ' + $passData + '; ' + $code + ' ' + } + if ($breakOnError) { + out += ' if (!' + $nextValid + ') break; ' + } + out += ' }' + } + if ($breakOnError) { + out += ' ' + $closingBraces + ' if (' + $errs + ' == errors) {' + } + return out + } + + /***/ + }, + + /***/ 39772: /***/ module => { + 'use strict' + + module.exports = function generate_multipleOf(it, $keyword, $ruleType) { + var out = ' ' + var $lvl = it.level + var $dataLvl = it.dataLevel + var $schema = it.schema[$keyword] + var $schemaPath = it.schemaPath + it.util.getProperty($keyword) + var $errSchemaPath = it.errSchemaPath + '/' + $keyword + var $breakOnError = !it.opts.allErrors + var $data = 'data' + ($dataLvl || '') + var $isData = it.opts.$data && $schema && $schema.$data, + $schemaValue + if ($isData) { + out += + ' var schema' + + $lvl + + ' = ' + + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + + '; ' + $schemaValue = 'schema' + $lvl + } else { + $schemaValue = $schema + } + if (!($isData || typeof $schema == 'number')) { + throw new Error($keyword + ' must be number') + } + out += 'var division' + $lvl + ';if (' + if ($isData) { + out += + ' ' + + $schemaValue + + ' !== undefined && ( typeof ' + + $schemaValue + + " != 'number' || " + } + out += ' (division' + $lvl + ' = ' + $data + ' / ' + $schemaValue + ', ' + if (it.opts.multipleOfPrecision) { + out += + ' Math.abs(Math.round(division' + + $lvl + + ') - division' + + $lvl + + ') > 1e-' + + it.opts.multipleOfPrecision + + ' ' + } else { + out += ' division' + $lvl + ' !== parseInt(division' + $lvl + ') ' + } + out += ' ) ' + if ($isData) { + out += ' ) ' + } + out += ' ) { ' + var $$outStack = $$outStack || [] + $$outStack.push(out) + out = '' /* istanbul ignore else */ + if (it.createErrors !== false) { + out += + " { keyword: '" + + 'multipleOf' + + "' , dataPath: (dataPath || '') + " + + it.errorPath + + ' , schemaPath: ' + + it.util.toQuotedString($errSchemaPath) + + ' , params: { multipleOf: ' + + $schemaValue + + ' } ' + if (it.opts.messages !== false) { + out += " , message: 'should be multiple of " + if ($isData) { + out += "' + " + $schemaValue + } else { + out += '' + $schemaValue + "'" + } + } + if (it.opts.verbose) { + out += ' , schema: ' + if ($isData) { + out += 'validate.schema' + $schemaPath + } else { + out += '' + $schema + } + out += + ' , parentSchema: validate.schema' + + it.schemaPath + + ' , data: ' + + $data + + ' ' + } + out += ' } ' + } else { + out += ' {} ' + } + var __err = out + out = $$outStack.pop() + if (!it.compositeRule && $breakOnError) { + /* istanbul ignore if */ + if (it.async) { + out += ' throw new ValidationError([' + __err + ']); ' + } else { + out += ' validate.errors = [' + __err + ']; return false; ' + } + } else { + out += + ' var err = ' + + __err + + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ' + } + out += '} ' + if ($breakOnError) { + out += ' else { ' + } + return out + } + + /***/ + }, + + /***/ 60750: /***/ module => { + 'use strict' + + module.exports = function generate_not(it, $keyword, $ruleType) { + var out = ' ' + var $lvl = it.level + var $dataLvl = it.dataLevel + var $schema = it.schema[$keyword] + var $schemaPath = it.schemaPath + it.util.getProperty($keyword) + var $errSchemaPath = it.errSchemaPath + '/' + $keyword + var $breakOnError = !it.opts.allErrors + var $data = 'data' + ($dataLvl || '') + var $errs = 'errs__' + $lvl + var $it = it.util.copy(it) + $it.level++ + var $nextValid = 'valid' + $it.level + if ( + it.opts.strictKeywords + ? (typeof $schema == 'object' && Object.keys($schema).length > 0) || + $schema === false + : it.util.schemaHasRules($schema, it.RULES.all) + ) { + $it.schema = $schema + $it.schemaPath = $schemaPath + $it.errSchemaPath = $errSchemaPath + out += ' var ' + $errs + ' = errors; ' + var $wasComposite = it.compositeRule + it.compositeRule = $it.compositeRule = true + $it.createErrors = false + var $allErrorsOption + if ($it.opts.allErrors) { + $allErrorsOption = $it.opts.allErrors + $it.opts.allErrors = false + } + out += ' ' + it.validate($it) + ' ' + $it.createErrors = true + if ($allErrorsOption) $it.opts.allErrors = $allErrorsOption + it.compositeRule = $it.compositeRule = $wasComposite + out += ' if (' + $nextValid + ') { ' + var $$outStack = $$outStack || [] + $$outStack.push(out) + out = '' /* istanbul ignore else */ + if (it.createErrors !== false) { + out += + " { keyword: '" + + 'not' + + "' , dataPath: (dataPath || '') + " + + it.errorPath + + ' , schemaPath: ' + + it.util.toQuotedString($errSchemaPath) + + ' , params: {} ' + if (it.opts.messages !== false) { + out += " , message: 'should NOT be valid' " + } + if (it.opts.verbose) { + out += + ' , schema: validate.schema' + + $schemaPath + + ' , parentSchema: validate.schema' + + it.schemaPath + + ' , data: ' + + $data + + ' ' + } + out += ' } ' + } else { + out += ' {} ' + } + var __err = out + out = $$outStack.pop() + if (!it.compositeRule && $breakOnError) { + /* istanbul ignore if */ + if (it.async) { + out += ' throw new ValidationError([' + __err + ']); ' + } else { + out += ' validate.errors = [' + __err + ']; return false; ' + } + } else { + out += + ' var err = ' + + __err + + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ' + } + out += + ' } else { errors = ' + + $errs + + '; if (vErrors !== null) { if (' + + $errs + + ') vErrors.length = ' + + $errs + + '; else vErrors = null; } ' + if (it.opts.allErrors) { + out += ' } ' + } + } else { + out += ' var err = ' /* istanbul ignore else */ + if (it.createErrors !== false) { + out += + " { keyword: '" + + 'not' + + "' , dataPath: (dataPath || '') + " + + it.errorPath + + ' , schemaPath: ' + + it.util.toQuotedString($errSchemaPath) + + ' , params: {} ' + if (it.opts.messages !== false) { + out += " , message: 'should NOT be valid' " + } + if (it.opts.verbose) { + out += + ' , schema: validate.schema' + + $schemaPath + + ' , parentSchema: validate.schema' + + it.schemaPath + + ' , data: ' + + $data + + ' ' + } + out += ' } ' + } else { + out += ' {} ' + } + out += + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ' + if ($breakOnError) { + out += ' if (false) { ' + } + } + return out + } + + /***/ + }, + + /***/ 6106: /***/ module => { + 'use strict' + + module.exports = function generate_oneOf(it, $keyword, $ruleType) { + var out = ' ' + var $lvl = it.level + var $dataLvl = it.dataLevel + var $schema = it.schema[$keyword] + var $schemaPath = it.schemaPath + it.util.getProperty($keyword) + var $errSchemaPath = it.errSchemaPath + '/' + $keyword + var $breakOnError = !it.opts.allErrors + var $data = 'data' + ($dataLvl || '') + var $valid = 'valid' + $lvl + var $errs = 'errs__' + $lvl + var $it = it.util.copy(it) + var $closingBraces = '' + $it.level++ + var $nextValid = 'valid' + $it.level + var $currentBaseId = $it.baseId, + $prevValid = 'prevValid' + $lvl, + $passingSchemas = 'passingSchemas' + $lvl + out += + 'var ' + + $errs + + ' = errors , ' + + $prevValid + + ' = false , ' + + $valid + + ' = false , ' + + $passingSchemas + + ' = null; ' + var $wasComposite = it.compositeRule + it.compositeRule = $it.compositeRule = true + var arr1 = $schema + if (arr1) { + var $sch, + $i = -1, + l1 = arr1.length - 1 + while ($i < l1) { + $sch = arr1[($i += 1)] + if ( + it.opts.strictKeywords + ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || + $sch === false + : it.util.schemaHasRules($sch, it.RULES.all) + ) { + $it.schema = $sch + $it.schemaPath = $schemaPath + '[' + $i + ']' + $it.errSchemaPath = $errSchemaPath + '/' + $i + out += ' ' + it.validate($it) + ' ' + $it.baseId = $currentBaseId + } else { + out += ' var ' + $nextValid + ' = true; ' + } + if ($i) { + out += + ' if (' + + $nextValid + + ' && ' + + $prevValid + + ') { ' + + $valid + + ' = false; ' + + $passingSchemas + + ' = [' + + $passingSchemas + + ', ' + + $i + + ']; } else { ' + $closingBraces += '}' + } + out += + ' if (' + + $nextValid + + ') { ' + + $valid + + ' = ' + + $prevValid + + ' = true; ' + + $passingSchemas + + ' = ' + + $i + + '; }' + } + } + it.compositeRule = $it.compositeRule = $wasComposite + out += + '' + + $closingBraces + + 'if (!' + + $valid + + ') { var err = ' /* istanbul ignore else */ + if (it.createErrors !== false) { + out += + " { keyword: '" + + 'oneOf' + + "' , dataPath: (dataPath || '') + " + + it.errorPath + + ' , schemaPath: ' + + it.util.toQuotedString($errSchemaPath) + + ' , params: { passingSchemas: ' + + $passingSchemas + + ' } ' + if (it.opts.messages !== false) { + out += " , message: 'should match exactly one schema in oneOf' " + } + if (it.opts.verbose) { + out += + ' , schema: validate.schema' + + $schemaPath + + ' , parentSchema: validate.schema' + + it.schemaPath + + ' , data: ' + + $data + + ' ' + } + out += ' } ' + } else { + out += ' {} ' + } + out += + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ' + if (!it.compositeRule && $breakOnError) { + /* istanbul ignore if */ + if (it.async) { + out += ' throw new ValidationError(vErrors); ' + } else { + out += ' validate.errors = vErrors; return false; ' + } + } + out += + '} else { errors = ' + + $errs + + '; if (vErrors !== null) { if (' + + $errs + + ') vErrors.length = ' + + $errs + + '; else vErrors = null; }' + if (it.opts.allErrors) { + out += ' } ' + } + return out + } + + /***/ + }, + + /***/ 13912: /***/ module => { + 'use strict' + + module.exports = function generate_pattern(it, $keyword, $ruleType) { + var out = ' ' + var $lvl = it.level + var $dataLvl = it.dataLevel + var $schema = it.schema[$keyword] + var $schemaPath = it.schemaPath + it.util.getProperty($keyword) + var $errSchemaPath = it.errSchemaPath + '/' + $keyword + var $breakOnError = !it.opts.allErrors + var $data = 'data' + ($dataLvl || '') + var $isData = it.opts.$data && $schema && $schema.$data, + $schemaValue + if ($isData) { + out += + ' var schema' + + $lvl + + ' = ' + + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + + '; ' + $schemaValue = 'schema' + $lvl + } else { + $schemaValue = $schema + } + var $regexp = $isData + ? '(new RegExp(' + $schemaValue + '))' + : it.usePattern($schema) + out += 'if ( ' + if ($isData) { + out += + ' (' + + $schemaValue + + ' !== undefined && typeof ' + + $schemaValue + + " != 'string') || " + } + out += ' !' + $regexp + '.test(' + $data + ') ) { ' + var $$outStack = $$outStack || [] + $$outStack.push(out) + out = '' /* istanbul ignore else */ + if (it.createErrors !== false) { + out += + " { keyword: '" + + 'pattern' + + "' , dataPath: (dataPath || '') + " + + it.errorPath + + ' , schemaPath: ' + + it.util.toQuotedString($errSchemaPath) + + ' , params: { pattern: ' + if ($isData) { + out += '' + $schemaValue + } else { + out += '' + it.util.toQuotedString($schema) + } + out += ' } ' + if (it.opts.messages !== false) { + out += ' , message: \'should match pattern "' + if ($isData) { + out += "' + " + $schemaValue + " + '" + } else { + out += '' + it.util.escapeQuotes($schema) + } + out += '"\' ' + } + if (it.opts.verbose) { + out += ' , schema: ' + if ($isData) { + out += 'validate.schema' + $schemaPath + } else { + out += '' + it.util.toQuotedString($schema) + } + out += + ' , parentSchema: validate.schema' + + it.schemaPath + + ' , data: ' + + $data + + ' ' + } + out += ' } ' + } else { + out += ' {} ' + } + var __err = out + out = $$outStack.pop() + if (!it.compositeRule && $breakOnError) { + /* istanbul ignore if */ + if (it.async) { + out += ' throw new ValidationError([' + __err + ']); ' + } else { + out += ' validate.errors = [' + __err + ']; return false; ' + } + } else { + out += + ' var err = ' + + __err + + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ' + } + out += '} ' + if ($breakOnError) { + out += ' else { ' + } + return out + } + + /***/ + }, + + /***/ 52924: /***/ module => { + 'use strict' + + module.exports = function generate_properties(it, $keyword, $ruleType) { + var out = ' ' + var $lvl = it.level + var $dataLvl = it.dataLevel + var $schema = it.schema[$keyword] + var $schemaPath = it.schemaPath + it.util.getProperty($keyword) + var $errSchemaPath = it.errSchemaPath + '/' + $keyword + var $breakOnError = !it.opts.allErrors + var $data = 'data' + ($dataLvl || '') + var $errs = 'errs__' + $lvl + var $it = it.util.copy(it) + var $closingBraces = '' + $it.level++ + var $nextValid = 'valid' + $it.level + var $key = 'key' + $lvl, + $idx = 'idx' + $lvl, + $dataNxt = ($it.dataLevel = it.dataLevel + 1), + $nextData = 'data' + $dataNxt, + $dataProperties = 'dataProperties' + $lvl + var $schemaKeys = Object.keys($schema || {}).filter(notProto), + $pProperties = it.schema.patternProperties || {}, + $pPropertyKeys = Object.keys($pProperties).filter(notProto), + $aProperties = it.schema.additionalProperties, + $someProperties = $schemaKeys.length || $pPropertyKeys.length, + $noAdditional = $aProperties === false, + $additionalIsSchema = + typeof $aProperties == 'object' && Object.keys($aProperties).length, + $removeAdditional = it.opts.removeAdditional, + $checkAdditional = + $noAdditional || $additionalIsSchema || $removeAdditional, + $ownProperties = it.opts.ownProperties, + $currentBaseId = it.baseId + var $required = it.schema.required + if ( + $required && + !(it.opts.$data && $required.$data) && + $required.length < it.opts.loopRequired + ) { + var $requiredHash = it.util.toHash($required) + } + + function notProto(p) { + return p !== '__proto__' + } + out += 'var ' + $errs + ' = errors;var ' + $nextValid + ' = true;' + if ($ownProperties) { + out += ' var ' + $dataProperties + ' = undefined;' + } + if ($checkAdditional) { + if ($ownProperties) { + out += + ' ' + + $dataProperties + + ' = ' + + $dataProperties + + ' || Object.keys(' + + $data + + '); for (var ' + + $idx + + '=0; ' + + $idx + + '<' + + $dataProperties + + '.length; ' + + $idx + + '++) { var ' + + $key + + ' = ' + + $dataProperties + + '[' + + $idx + + ']; ' + } else { + out += ' for (var ' + $key + ' in ' + $data + ') { ' + } + if ($someProperties) { + out += ' var isAdditional' + $lvl + ' = !(false ' + if ($schemaKeys.length) { + if ($schemaKeys.length > 8) { + out += + ' || validate.schema' + + $schemaPath + + '.hasOwnProperty(' + + $key + + ') ' + } else { + var arr1 = $schemaKeys + if (arr1) { + var $propertyKey, + i1 = -1, + l1 = arr1.length - 1 + while (i1 < l1) { + $propertyKey = arr1[(i1 += 1)] + out += + ' || ' + + $key + + ' == ' + + it.util.toQuotedString($propertyKey) + + ' ' + } + } + } + } + if ($pPropertyKeys.length) { + var arr2 = $pPropertyKeys + if (arr2) { + var $pProperty, + $i = -1, + l2 = arr2.length - 1 + while ($i < l2) { + $pProperty = arr2[($i += 1)] + out += + ' || ' + it.usePattern($pProperty) + '.test(' + $key + ') ' + } + } + } + out += ' ); if (isAdditional' + $lvl + ') { ' + } + if ($removeAdditional == 'all') { + out += ' delete ' + $data + '[' + $key + ']; ' + } else { + var $currentErrorPath = it.errorPath + var $additionalProperty = "' + " + $key + " + '" + if (it.opts._errorDataPathProperty) { + it.errorPath = it.util.getPathExpr( + it.errorPath, + $key, + it.opts.jsonPointers + ) + } + if ($noAdditional) { + if ($removeAdditional) { + out += ' delete ' + $data + '[' + $key + ']; ' + } else { + out += ' ' + $nextValid + ' = false; ' + var $currErrSchemaPath = $errSchemaPath + $errSchemaPath = it.errSchemaPath + '/additionalProperties' + var $$outStack = $$outStack || [] + $$outStack.push(out) + out = '' /* istanbul ignore else */ + if (it.createErrors !== false) { + out += + " { keyword: '" + + 'additionalProperties' + + "' , dataPath: (dataPath || '') + " + + it.errorPath + + ' , schemaPath: ' + + it.util.toQuotedString($errSchemaPath) + + " , params: { additionalProperty: '" + + $additionalProperty + + "' } " + if (it.opts.messages !== false) { + out += " , message: '" + if (it.opts._errorDataPathProperty) { + out += 'is an invalid additional property' + } else { + out += 'should NOT have additional properties' + } + out += "' " + } + if (it.opts.verbose) { + out += + ' , schema: false , parentSchema: validate.schema' + + it.schemaPath + + ' , data: ' + + $data + + ' ' + } + out += ' } ' + } else { + out += ' {} ' + } + var __err = out + out = $$outStack.pop() + if (!it.compositeRule && $breakOnError) { + /* istanbul ignore if */ + if (it.async) { + out += ' throw new ValidationError([' + __err + ']); ' + } else { + out += ' validate.errors = [' + __err + ']; return false; ' + } + } else { + out += + ' var err = ' + + __err + + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ' + } + $errSchemaPath = $currErrSchemaPath + if ($breakOnError) { + out += ' break; ' + } + } + } else if ($additionalIsSchema) { + if ($removeAdditional == 'failing') { + out += ' var ' + $errs + ' = errors; ' + var $wasComposite = it.compositeRule + it.compositeRule = $it.compositeRule = true + $it.schema = $aProperties + $it.schemaPath = it.schemaPath + '.additionalProperties' + $it.errSchemaPath = it.errSchemaPath + '/additionalProperties' + $it.errorPath = it.opts._errorDataPathProperty + ? it.errorPath + : it.util.getPathExpr( + it.errorPath, + $key, + it.opts.jsonPointers + ) + var $passData = $data + '[' + $key + ']' + $it.dataPathArr[$dataNxt] = $key + var $code = it.validate($it) + $it.baseId = $currentBaseId + if (it.util.varOccurences($code, $nextData) < 2) { + out += + ' ' + it.util.varReplace($code, $nextData, $passData) + ' ' + } else { + out += + ' var ' + $nextData + ' = ' + $passData + '; ' + $code + ' ' + } + out += + ' if (!' + + $nextValid + + ') { errors = ' + + $errs + + '; if (validate.errors !== null) { if (errors) validate.errors.length = errors; else validate.errors = null; } delete ' + + $data + + '[' + + $key + + ']; } ' + it.compositeRule = $it.compositeRule = $wasComposite + } else { + $it.schema = $aProperties + $it.schemaPath = it.schemaPath + '.additionalProperties' + $it.errSchemaPath = it.errSchemaPath + '/additionalProperties' + $it.errorPath = it.opts._errorDataPathProperty + ? it.errorPath + : it.util.getPathExpr( + it.errorPath, + $key, + it.opts.jsonPointers + ) + var $passData = $data + '[' + $key + ']' + $it.dataPathArr[$dataNxt] = $key + var $code = it.validate($it) + $it.baseId = $currentBaseId + if (it.util.varOccurences($code, $nextData) < 2) { + out += + ' ' + it.util.varReplace($code, $nextData, $passData) + ' ' + } else { + out += + ' var ' + $nextData + ' = ' + $passData + '; ' + $code + ' ' + } + if ($breakOnError) { + out += ' if (!' + $nextValid + ') break; ' + } + } + } + it.errorPath = $currentErrorPath + } + if ($someProperties) { + out += ' } ' + } + out += ' } ' + if ($breakOnError) { + out += ' if (' + $nextValid + ') { ' + $closingBraces += '}' + } + } + var $useDefaults = it.opts.useDefaults && !it.compositeRule + if ($schemaKeys.length) { + var arr3 = $schemaKeys + if (arr3) { + var $propertyKey, + i3 = -1, + l3 = arr3.length - 1 + while (i3 < l3) { + $propertyKey = arr3[(i3 += 1)] + var $sch = $schema[$propertyKey] + if ( + it.opts.strictKeywords + ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || + $sch === false + : it.util.schemaHasRules($sch, it.RULES.all) + ) { + var $prop = it.util.getProperty($propertyKey), + $passData = $data + $prop, + $hasDefault = $useDefaults && $sch.default !== undefined + $it.schema = $sch + $it.schemaPath = $schemaPath + $prop + $it.errSchemaPath = + $errSchemaPath + '/' + it.util.escapeFragment($propertyKey) + $it.errorPath = it.util.getPath( + it.errorPath, + $propertyKey, + it.opts.jsonPointers + ) + $it.dataPathArr[$dataNxt] = it.util.toQuotedString($propertyKey) + var $code = it.validate($it) + $it.baseId = $currentBaseId + if (it.util.varOccurences($code, $nextData) < 2) { + $code = it.util.varReplace($code, $nextData, $passData) + var $useData = $passData + } else { + var $useData = $nextData + out += ' var ' + $nextData + ' = ' + $passData + '; ' + } + if ($hasDefault) { + out += ' ' + $code + ' ' + } else { + if ($requiredHash && $requiredHash[$propertyKey]) { + out += ' if ( ' + $useData + ' === undefined ' + if ($ownProperties) { + out += + ' || ! Object.prototype.hasOwnProperty.call(' + + $data + + ", '" + + it.util.escapeQuotes($propertyKey) + + "') " + } + out += ') { ' + $nextValid + ' = false; ' + var $currentErrorPath = it.errorPath, + $currErrSchemaPath = $errSchemaPath, + $missingProperty = it.util.escapeQuotes($propertyKey) + if (it.opts._errorDataPathProperty) { + it.errorPath = it.util.getPath( + $currentErrorPath, + $propertyKey, + it.opts.jsonPointers + ) + } + $errSchemaPath = it.errSchemaPath + '/required' + var $$outStack = $$outStack || [] + $$outStack.push(out) + out = '' /* istanbul ignore else */ + if (it.createErrors !== false) { + out += + " { keyword: '" + + 'required' + + "' , dataPath: (dataPath || '') + " + + it.errorPath + + ' , schemaPath: ' + + it.util.toQuotedString($errSchemaPath) + + " , params: { missingProperty: '" + + $missingProperty + + "' } " + if (it.opts.messages !== false) { + out += " , message: '" + if (it.opts._errorDataPathProperty) { + out += 'is a required property' + } else { + out += + "should have required property \\'" + + $missingProperty + + "\\'" + } + out += "' " + } + if (it.opts.verbose) { + out += + ' , schema: validate.schema' + + $schemaPath + + ' , parentSchema: validate.schema' + + it.schemaPath + + ' , data: ' + + $data + + ' ' + } + out += ' } ' + } else { + out += ' {} ' + } + var __err = out + out = $$outStack.pop() + if (!it.compositeRule && $breakOnError) { + /* istanbul ignore if */ + if (it.async) { + out += ' throw new ValidationError([' + __err + ']); ' + } else { + out += + ' validate.errors = [' + __err + ']; return false; ' + } + } else { + out += + ' var err = ' + + __err + + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ' + } + $errSchemaPath = $currErrSchemaPath + it.errorPath = $currentErrorPath + out += ' } else { ' + } else { + if ($breakOnError) { + out += ' if ( ' + $useData + ' === undefined ' + if ($ownProperties) { + out += + ' || ! Object.prototype.hasOwnProperty.call(' + + $data + + ", '" + + it.util.escapeQuotes($propertyKey) + + "') " + } + out += ') { ' + $nextValid + ' = true; } else { ' + } else { + out += ' if (' + $useData + ' !== undefined ' + if ($ownProperties) { + out += + ' && Object.prototype.hasOwnProperty.call(' + + $data + + ", '" + + it.util.escapeQuotes($propertyKey) + + "') " + } + out += ' ) { ' + } + } + out += ' ' + $code + ' } ' + } + } + if ($breakOnError) { + out += ' if (' + $nextValid + ') { ' + $closingBraces += '}' + } + } + } + } + if ($pPropertyKeys.length) { + var arr4 = $pPropertyKeys + if (arr4) { + var $pProperty, + i4 = -1, + l4 = arr4.length - 1 + while (i4 < l4) { + $pProperty = arr4[(i4 += 1)] + var $sch = $pProperties[$pProperty] + if ( + it.opts.strictKeywords + ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || + $sch === false + : it.util.schemaHasRules($sch, it.RULES.all) + ) { + $it.schema = $sch + $it.schemaPath = + it.schemaPath + + '.patternProperties' + + it.util.getProperty($pProperty) + $it.errSchemaPath = + it.errSchemaPath + + '/patternProperties/' + + it.util.escapeFragment($pProperty) + if ($ownProperties) { + out += + ' ' + + $dataProperties + + ' = ' + + $dataProperties + + ' || Object.keys(' + + $data + + '); for (var ' + + $idx + + '=0; ' + + $idx + + '<' + + $dataProperties + + '.length; ' + + $idx + + '++) { var ' + + $key + + ' = ' + + $dataProperties + + '[' + + $idx + + ']; ' + } else { + out += ' for (var ' + $key + ' in ' + $data + ') { ' + } + out += + ' if (' + + it.usePattern($pProperty) + + '.test(' + + $key + + ')) { ' + $it.errorPath = it.util.getPathExpr( + it.errorPath, + $key, + it.opts.jsonPointers + ) + var $passData = $data + '[' + $key + ']' + $it.dataPathArr[$dataNxt] = $key + var $code = it.validate($it) + $it.baseId = $currentBaseId + if (it.util.varOccurences($code, $nextData) < 2) { + out += + ' ' + it.util.varReplace($code, $nextData, $passData) + ' ' + } else { + out += + ' var ' + $nextData + ' = ' + $passData + '; ' + $code + ' ' + } + if ($breakOnError) { + out += ' if (!' + $nextValid + ') break; ' + } + out += ' } ' + if ($breakOnError) { + out += ' else ' + $nextValid + ' = true; ' + } + out += ' } ' + if ($breakOnError) { + out += ' if (' + $nextValid + ') { ' + $closingBraces += '}' + } + } + } + } + } + if ($breakOnError) { + out += ' ' + $closingBraces + ' if (' + $errs + ' == errors) {' + } + return out + } + + /***/ + }, + + /***/ 19195: /***/ module => { + 'use strict' + + module.exports = function generate_propertyNames( + it, + $keyword, + $ruleType + ) { + var out = ' ' + var $lvl = it.level + var $dataLvl = it.dataLevel + var $schema = it.schema[$keyword] + var $schemaPath = it.schemaPath + it.util.getProperty($keyword) + var $errSchemaPath = it.errSchemaPath + '/' + $keyword + var $breakOnError = !it.opts.allErrors + var $data = 'data' + ($dataLvl || '') + var $errs = 'errs__' + $lvl + var $it = it.util.copy(it) + var $closingBraces = '' + $it.level++ + var $nextValid = 'valid' + $it.level + out += 'var ' + $errs + ' = errors;' + if ( + it.opts.strictKeywords + ? (typeof $schema == 'object' && Object.keys($schema).length > 0) || + $schema === false + : it.util.schemaHasRules($schema, it.RULES.all) + ) { + $it.schema = $schema + $it.schemaPath = $schemaPath + $it.errSchemaPath = $errSchemaPath + var $key = 'key' + $lvl, + $idx = 'idx' + $lvl, + $i = 'i' + $lvl, + $invalidName = "' + " + $key + " + '", + $dataNxt = ($it.dataLevel = it.dataLevel + 1), + $nextData = 'data' + $dataNxt, + $dataProperties = 'dataProperties' + $lvl, + $ownProperties = it.opts.ownProperties, + $currentBaseId = it.baseId + if ($ownProperties) { + out += ' var ' + $dataProperties + ' = undefined; ' + } + if ($ownProperties) { + out += + ' ' + + $dataProperties + + ' = ' + + $dataProperties + + ' || Object.keys(' + + $data + + '); for (var ' + + $idx + + '=0; ' + + $idx + + '<' + + $dataProperties + + '.length; ' + + $idx + + '++) { var ' + + $key + + ' = ' + + $dataProperties + + '[' + + $idx + + ']; ' + } else { + out += ' for (var ' + $key + ' in ' + $data + ') { ' + } + out += ' var startErrs' + $lvl + ' = errors; ' + var $passData = $key + var $wasComposite = it.compositeRule + it.compositeRule = $it.compositeRule = true + var $code = it.validate($it) + $it.baseId = $currentBaseId + if (it.util.varOccurences($code, $nextData) < 2) { + out += ' ' + it.util.varReplace($code, $nextData, $passData) + ' ' + } else { + out += ' var ' + $nextData + ' = ' + $passData + '; ' + $code + ' ' + } + it.compositeRule = $it.compositeRule = $wasComposite + out += + ' if (!' + + $nextValid + + ') { for (var ' + + $i + + '=startErrs' + + $lvl + + '; ' + + $i + + ' { + 'use strict' + + module.exports = function generate_ref(it, $keyword, $ruleType) { + var out = ' ' + var $lvl = it.level + var $dataLvl = it.dataLevel + var $schema = it.schema[$keyword] + var $errSchemaPath = it.errSchemaPath + '/' + $keyword + var $breakOnError = !it.opts.allErrors + var $data = 'data' + ($dataLvl || '') + var $valid = 'valid' + $lvl + var $async, $refCode + if ($schema == '#' || $schema == '#/') { + if (it.isRoot) { + $async = it.async + $refCode = 'validate' + } else { + $async = it.root.schema.$async === true + $refCode = 'root.refVal[0]' + } + } else { + var $refVal = it.resolveRef(it.baseId, $schema, it.isRoot) + if ($refVal === undefined) { + var $message = it.MissingRefError.message(it.baseId, $schema) + if (it.opts.missingRefs == 'fail') { + it.logger.error($message) + var $$outStack = $$outStack || [] + $$outStack.push(out) + out = '' /* istanbul ignore else */ + if (it.createErrors !== false) { + out += + " { keyword: '" + + '$ref' + + "' , dataPath: (dataPath || '') + " + + it.errorPath + + ' , schemaPath: ' + + it.util.toQuotedString($errSchemaPath) + + " , params: { ref: '" + + it.util.escapeQuotes($schema) + + "' } " + if (it.opts.messages !== false) { + out += + " , message: 'can\\'t resolve reference " + + it.util.escapeQuotes($schema) + + "' " + } + if (it.opts.verbose) { + out += + ' , schema: ' + + it.util.toQuotedString($schema) + + ' , parentSchema: validate.schema' + + it.schemaPath + + ' , data: ' + + $data + + ' ' + } + out += ' } ' + } else { + out += ' {} ' + } + var __err = out + out = $$outStack.pop() + if (!it.compositeRule && $breakOnError) { + /* istanbul ignore if */ + if (it.async) { + out += ' throw new ValidationError([' + __err + ']); ' + } else { + out += ' validate.errors = [' + __err + ']; return false; ' + } + } else { + out += + ' var err = ' + + __err + + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ' + } + if ($breakOnError) { + out += ' if (false) { ' + } + } else if (it.opts.missingRefs == 'ignore') { + it.logger.warn($message) + if ($breakOnError) { + out += ' if (true) { ' + } + } else { + throw new it.MissingRefError(it.baseId, $schema, $message) + } + } else if ($refVal.inline) { + var $it = it.util.copy(it) + $it.level++ + var $nextValid = 'valid' + $it.level + $it.schema = $refVal.schema + $it.schemaPath = '' + $it.errSchemaPath = $schema + var $code = it + .validate($it) + .replace(/validate\.schema/g, $refVal.code) + out += ' ' + $code + ' ' + if ($breakOnError) { + out += ' if (' + $nextValid + ') { ' + } + } else { + $async = + $refVal.$async === true || (it.async && $refVal.$async !== false) + $refCode = $refVal.code + } + } + if ($refCode) { + var $$outStack = $$outStack || [] + $$outStack.push(out) + out = '' + if (it.opts.passContext) { + out += ' ' + $refCode + '.call(this, ' + } else { + out += ' ' + $refCode + '( ' + } + out += ' ' + $data + ", (dataPath || '')" + if (it.errorPath != '""') { + out += ' + ' + it.errorPath + } + var $parentData = $dataLvl + ? 'data' + ($dataLvl - 1 || '') + : 'parentData', + $parentDataProperty = $dataLvl + ? it.dataPathArr[$dataLvl] + : 'parentDataProperty' + out += + ' , ' + $parentData + ' , ' + $parentDataProperty + ', rootData) ' + var __callValidate = out + out = $$outStack.pop() + if ($async) { + if (!it.async) + throw new Error('async schema referenced by sync schema') + if ($breakOnError) { + out += ' var ' + $valid + '; ' + } + out += ' try { await ' + __callValidate + '; ' + if ($breakOnError) { + out += ' ' + $valid + ' = true; ' + } + out += + ' } catch (e) { if (!(e instanceof ValidationError)) throw e; if (vErrors === null) vErrors = e.errors; else vErrors = vErrors.concat(e.errors); errors = vErrors.length; ' + if ($breakOnError) { + out += ' ' + $valid + ' = false; ' + } + out += ' } ' + if ($breakOnError) { + out += ' if (' + $valid + ') { ' + } + } else { + out += + ' if (!' + + __callValidate + + ') { if (vErrors === null) vErrors = ' + + $refCode + + '.errors; else vErrors = vErrors.concat(' + + $refCode + + '.errors); errors = vErrors.length; } ' + if ($breakOnError) { + out += ' else { ' + } + } + } + return out + } + + /***/ + }, + + /***/ 8420: /***/ module => { + 'use strict' + + module.exports = function generate_required(it, $keyword, $ruleType) { + var out = ' ' + var $lvl = it.level + var $dataLvl = it.dataLevel + var $schema = it.schema[$keyword] + var $schemaPath = it.schemaPath + it.util.getProperty($keyword) + var $errSchemaPath = it.errSchemaPath + '/' + $keyword + var $breakOnError = !it.opts.allErrors + var $data = 'data' + ($dataLvl || '') + var $valid = 'valid' + $lvl + var $isData = it.opts.$data && $schema && $schema.$data, + $schemaValue + if ($isData) { + out += + ' var schema' + + $lvl + + ' = ' + + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + + '; ' + $schemaValue = 'schema' + $lvl + } else { + $schemaValue = $schema + } + var $vSchema = 'schema' + $lvl + if (!$isData) { + if ( + $schema.length < it.opts.loopRequired && + it.schema.properties && + Object.keys(it.schema.properties).length + ) { + var $required = [] + var arr1 = $schema + if (arr1) { + var $property, + i1 = -1, + l1 = arr1.length - 1 + while (i1 < l1) { + $property = arr1[(i1 += 1)] + var $propertySch = it.schema.properties[$property] + if ( + !( + $propertySch && + (it.opts.strictKeywords + ? (typeof $propertySch == 'object' && + Object.keys($propertySch).length > 0) || + $propertySch === false + : it.util.schemaHasRules($propertySch, it.RULES.all)) + ) + ) { + $required[$required.length] = $property + } + } + } + } else { + var $required = $schema + } + } + if ($isData || $required.length) { + var $currentErrorPath = it.errorPath, + $loopRequired = $isData || $required.length >= it.opts.loopRequired, + $ownProperties = it.opts.ownProperties + if ($breakOnError) { + out += ' var missing' + $lvl + '; ' + if ($loopRequired) { + if (!$isData) { + out += + ' var ' + $vSchema + ' = validate.schema' + $schemaPath + '; ' + } + var $i = 'i' + $lvl, + $propertyPath = 'schema' + $lvl + '[' + $i + ']', + $missingProperty = "' + " + $propertyPath + " + '" + if (it.opts._errorDataPathProperty) { + it.errorPath = it.util.getPathExpr( + $currentErrorPath, + $propertyPath, + it.opts.jsonPointers + ) + } + out += ' var ' + $valid + ' = true; ' + if ($isData) { + out += + ' if (schema' + + $lvl + + ' === undefined) ' + + $valid + + ' = true; else if (!Array.isArray(schema' + + $lvl + + ')) ' + + $valid + + ' = false; else {' + } + out += + ' for (var ' + + $i + + ' = 0; ' + + $i + + ' < ' + + $vSchema + + '.length; ' + + $i + + '++) { ' + + $valid + + ' = ' + + $data + + '[' + + $vSchema + + '[' + + $i + + ']] !== undefined ' + if ($ownProperties) { + out += + ' && Object.prototype.hasOwnProperty.call(' + + $data + + ', ' + + $vSchema + + '[' + + $i + + ']) ' + } + out += '; if (!' + $valid + ') break; } ' + if ($isData) { + out += ' } ' + } + out += ' if (!' + $valid + ') { ' + var $$outStack = $$outStack || [] + $$outStack.push(out) + out = '' /* istanbul ignore else */ + if (it.createErrors !== false) { + out += + " { keyword: '" + + 'required' + + "' , dataPath: (dataPath || '') + " + + it.errorPath + + ' , schemaPath: ' + + it.util.toQuotedString($errSchemaPath) + + " , params: { missingProperty: '" + + $missingProperty + + "' } " + if (it.opts.messages !== false) { + out += " , message: '" + if (it.opts._errorDataPathProperty) { + out += 'is a required property' + } else { + out += + "should have required property \\'" + + $missingProperty + + "\\'" + } + out += "' " + } + if (it.opts.verbose) { + out += + ' , schema: validate.schema' + + $schemaPath + + ' , parentSchema: validate.schema' + + it.schemaPath + + ' , data: ' + + $data + + ' ' + } + out += ' } ' + } else { + out += ' {} ' + } + var __err = out + out = $$outStack.pop() + if (!it.compositeRule && $breakOnError) { + /* istanbul ignore if */ + if (it.async) { + out += ' throw new ValidationError([' + __err + ']); ' + } else { + out += ' validate.errors = [' + __err + ']; return false; ' + } + } else { + out += + ' var err = ' + + __err + + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ' + } + out += ' } else { ' + } else { + out += ' if ( ' + var arr2 = $required + if (arr2) { + var $propertyKey, + $i = -1, + l2 = arr2.length - 1 + while ($i < l2) { + $propertyKey = arr2[($i += 1)] + if ($i) { + out += ' || ' + } + var $prop = it.util.getProperty($propertyKey), + $useData = $data + $prop + out += ' ( ( ' + $useData + ' === undefined ' + if ($ownProperties) { + out += + ' || ! Object.prototype.hasOwnProperty.call(' + + $data + + ", '" + + it.util.escapeQuotes($propertyKey) + + "') " + } + out += + ') && (missing' + + $lvl + + ' = ' + + it.util.toQuotedString( + it.opts.jsonPointers ? $propertyKey : $prop + ) + + ') ) ' + } + } + out += ') { ' + var $propertyPath = 'missing' + $lvl, + $missingProperty = "' + " + $propertyPath + " + '" + if (it.opts._errorDataPathProperty) { + it.errorPath = it.opts.jsonPointers + ? it.util.getPathExpr($currentErrorPath, $propertyPath, true) + : $currentErrorPath + ' + ' + $propertyPath + } + var $$outStack = $$outStack || [] + $$outStack.push(out) + out = '' /* istanbul ignore else */ + if (it.createErrors !== false) { + out += + " { keyword: '" + + 'required' + + "' , dataPath: (dataPath || '') + " + + it.errorPath + + ' , schemaPath: ' + + it.util.toQuotedString($errSchemaPath) + + " , params: { missingProperty: '" + + $missingProperty + + "' } " + if (it.opts.messages !== false) { + out += " , message: '" + if (it.opts._errorDataPathProperty) { + out += 'is a required property' + } else { + out += + "should have required property \\'" + + $missingProperty + + "\\'" + } + out += "' " + } + if (it.opts.verbose) { + out += + ' , schema: validate.schema' + + $schemaPath + + ' , parentSchema: validate.schema' + + it.schemaPath + + ' , data: ' + + $data + + ' ' + } + out += ' } ' + } else { + out += ' {} ' + } + var __err = out + out = $$outStack.pop() + if (!it.compositeRule && $breakOnError) { + /* istanbul ignore if */ + if (it.async) { + out += ' throw new ValidationError([' + __err + ']); ' + } else { + out += ' validate.errors = [' + __err + ']; return false; ' + } + } else { + out += + ' var err = ' + + __err + + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ' + } + out += ' } else { ' + } + } else { + if ($loopRequired) { + if (!$isData) { + out += + ' var ' + $vSchema + ' = validate.schema' + $schemaPath + '; ' + } + var $i = 'i' + $lvl, + $propertyPath = 'schema' + $lvl + '[' + $i + ']', + $missingProperty = "' + " + $propertyPath + " + '" + if (it.opts._errorDataPathProperty) { + it.errorPath = it.util.getPathExpr( + $currentErrorPath, + $propertyPath, + it.opts.jsonPointers + ) + } + if ($isData) { + out += + ' if (' + + $vSchema + + ' && !Array.isArray(' + + $vSchema + + ')) { var err = ' /* istanbul ignore else */ + if (it.createErrors !== false) { + out += + " { keyword: '" + + 'required' + + "' , dataPath: (dataPath || '') + " + + it.errorPath + + ' , schemaPath: ' + + it.util.toQuotedString($errSchemaPath) + + " , params: { missingProperty: '" + + $missingProperty + + "' } " + if (it.opts.messages !== false) { + out += " , message: '" + if (it.opts._errorDataPathProperty) { + out += 'is a required property' + } else { + out += + "should have required property \\'" + + $missingProperty + + "\\'" + } + out += "' " + } + if (it.opts.verbose) { + out += + ' , schema: validate.schema' + + $schemaPath + + ' , parentSchema: validate.schema' + + it.schemaPath + + ' , data: ' + + $data + + ' ' + } + out += ' } ' + } else { + out += ' {} ' + } + out += + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } else if (' + + $vSchema + + ' !== undefined) { ' + } + out += + ' for (var ' + + $i + + ' = 0; ' + + $i + + ' < ' + + $vSchema + + '.length; ' + + $i + + '++) { if (' + + $data + + '[' + + $vSchema + + '[' + + $i + + ']] === undefined ' + if ($ownProperties) { + out += + ' || ! Object.prototype.hasOwnProperty.call(' + + $data + + ', ' + + $vSchema + + '[' + + $i + + ']) ' + } + out += ') { var err = ' /* istanbul ignore else */ + if (it.createErrors !== false) { + out += + " { keyword: '" + + 'required' + + "' , dataPath: (dataPath || '') + " + + it.errorPath + + ' , schemaPath: ' + + it.util.toQuotedString($errSchemaPath) + + " , params: { missingProperty: '" + + $missingProperty + + "' } " + if (it.opts.messages !== false) { + out += " , message: '" + if (it.opts._errorDataPathProperty) { + out += 'is a required property' + } else { + out += + "should have required property \\'" + + $missingProperty + + "\\'" + } + out += "' " + } + if (it.opts.verbose) { + out += + ' , schema: validate.schema' + + $schemaPath + + ' , parentSchema: validate.schema' + + it.schemaPath + + ' , data: ' + + $data + + ' ' + } + out += ' } ' + } else { + out += ' {} ' + } + out += + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } } ' + if ($isData) { + out += ' } ' + } + } else { + var arr3 = $required + if (arr3) { + var $propertyKey, + i3 = -1, + l3 = arr3.length - 1 + while (i3 < l3) { + $propertyKey = arr3[(i3 += 1)] + var $prop = it.util.getProperty($propertyKey), + $missingProperty = it.util.escapeQuotes($propertyKey), + $useData = $data + $prop + if (it.opts._errorDataPathProperty) { + it.errorPath = it.util.getPath( + $currentErrorPath, + $propertyKey, + it.opts.jsonPointers + ) + } + out += ' if ( ' + $useData + ' === undefined ' + if ($ownProperties) { + out += + ' || ! Object.prototype.hasOwnProperty.call(' + + $data + + ", '" + + it.util.escapeQuotes($propertyKey) + + "') " + } + out += ') { var err = ' /* istanbul ignore else */ + if (it.createErrors !== false) { + out += + " { keyword: '" + + 'required' + + "' , dataPath: (dataPath || '') + " + + it.errorPath + + ' , schemaPath: ' + + it.util.toQuotedString($errSchemaPath) + + " , params: { missingProperty: '" + + $missingProperty + + "' } " + if (it.opts.messages !== false) { + out += " , message: '" + if (it.opts._errorDataPathProperty) { + out += 'is a required property' + } else { + out += + "should have required property \\'" + + $missingProperty + + "\\'" + } + out += "' " + } + if (it.opts.verbose) { + out += + ' , schema: validate.schema' + + $schemaPath + + ' , parentSchema: validate.schema' + + it.schemaPath + + ' , data: ' + + $data + + ' ' + } + out += ' } ' + } else { + out += ' {} ' + } + out += + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } ' + } + } + } + } + it.errorPath = $currentErrorPath + } else if ($breakOnError) { + out += ' if (true) {' + } + return out + } + + /***/ + }, + + /***/ 24995: /***/ module => { + 'use strict' + + module.exports = function generate_uniqueItems(it, $keyword, $ruleType) { + var out = ' ' + var $lvl = it.level + var $dataLvl = it.dataLevel + var $schema = it.schema[$keyword] + var $schemaPath = it.schemaPath + it.util.getProperty($keyword) + var $errSchemaPath = it.errSchemaPath + '/' + $keyword + var $breakOnError = !it.opts.allErrors + var $data = 'data' + ($dataLvl || '') + var $valid = 'valid' + $lvl + var $isData = it.opts.$data && $schema && $schema.$data, + $schemaValue + if ($isData) { + out += + ' var schema' + + $lvl + + ' = ' + + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + + '; ' + $schemaValue = 'schema' + $lvl + } else { + $schemaValue = $schema + } + if (($schema || $isData) && it.opts.uniqueItems !== false) { + if ($isData) { + out += + ' var ' + + $valid + + '; if (' + + $schemaValue + + ' === false || ' + + $schemaValue + + ' === undefined) ' + + $valid + + ' = true; else if (typeof ' + + $schemaValue + + " != 'boolean') " + + $valid + + ' = false; else { ' + } + out += + ' var i = ' + + $data + + '.length , ' + + $valid + + ' = true , j; if (i > 1) { ' + var $itemType = it.schema.items && it.schema.items.type, + $typeIsArray = Array.isArray($itemType) + if ( + !$itemType || + $itemType == 'object' || + $itemType == 'array' || + ($typeIsArray && + ($itemType.indexOf('object') >= 0 || + $itemType.indexOf('array') >= 0)) + ) { + out += + ' outer: for (;i--;) { for (j = i; j--;) { if (equal(' + + $data + + '[i], ' + + $data + + '[j])) { ' + + $valid + + ' = false; break outer; } } } ' + } else { + out += + ' var itemIndices = {}, item; for (;i--;) { var item = ' + + $data + + '[i]; ' + var $method = 'checkDataType' + ($typeIsArray ? 's' : '') + out += + ' if (' + + it.util[$method]($itemType, 'item', it.opts.strictNumbers, true) + + ') continue; ' + if ($typeIsArray) { + out += " if (typeof item == 'string') item = '\"' + item; " + } + out += + " if (typeof itemIndices[item] == 'number') { " + + $valid + + ' = false; j = itemIndices[item]; break; } itemIndices[item] = i; } ' + } + out += ' } ' + if ($isData) { + out += ' } ' + } + out += ' if (!' + $valid + ') { ' + var $$outStack = $$outStack || [] + $$outStack.push(out) + out = '' /* istanbul ignore else */ + if (it.createErrors !== false) { + out += + " { keyword: '" + + 'uniqueItems' + + "' , dataPath: (dataPath || '') + " + + it.errorPath + + ' , schemaPath: ' + + it.util.toQuotedString($errSchemaPath) + + ' , params: { i: i, j: j } ' + if (it.opts.messages !== false) { + out += + " , message: 'should NOT have duplicate items (items ## ' + j + ' and ' + i + ' are identical)' " + } + if (it.opts.verbose) { + out += ' , schema: ' + if ($isData) { + out += 'validate.schema' + $schemaPath + } else { + out += '' + $schema + } + out += + ' , parentSchema: validate.schema' + + it.schemaPath + + ' , data: ' + + $data + + ' ' + } + out += ' } ' + } else { + out += ' {} ' + } + var __err = out + out = $$outStack.pop() + if (!it.compositeRule && $breakOnError) { + /* istanbul ignore if */ + if (it.async) { + out += ' throw new ValidationError([' + __err + ']); ' + } else { + out += ' validate.errors = [' + __err + ']; return false; ' + } + } else { + out += + ' var err = ' + + __err + + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ' + } + out += ' } ' + if ($breakOnError) { + out += ' else { ' + } + } else { + if ($breakOnError) { + out += ' if (true) { ' + } + } + return out + } + + /***/ + }, + + /***/ 49585: /***/ module => { + 'use strict' + + module.exports = function generate_validate(it, $keyword, $ruleType) { + var out = '' + var $async = it.schema.$async === true, + $refKeywords = it.util.schemaHasRulesExcept( + it.schema, + it.RULES.all, + '$ref' + ), + $id = it.self._getId(it.schema) + if (it.opts.strictKeywords) { + var $unknownKwd = it.util.schemaUnknownRules( + it.schema, + it.RULES.keywords + ) + if ($unknownKwd) { + var $keywordsMsg = 'unknown keyword: ' + $unknownKwd + if (it.opts.strictKeywords === 'log') it.logger.warn($keywordsMsg) + else throw new Error($keywordsMsg) + } + } + if (it.isTop) { + out += ' var validate = ' + if ($async) { + it.async = true + out += 'async ' + } + out += + "function(data, dataPath, parentData, parentDataProperty, rootData) { 'use strict'; " + if ($id && (it.opts.sourceCode || it.opts.processCode)) { + out += ' ' + ('/*# sourceURL=' + $id + ' */') + ' ' + } + } + if ( + typeof it.schema == 'boolean' || + !($refKeywords || it.schema.$ref) + ) { + var $keyword = 'false schema' + var $lvl = it.level + var $dataLvl = it.dataLevel + var $schema = it.schema[$keyword] + var $schemaPath = it.schemaPath + it.util.getProperty($keyword) + var $errSchemaPath = it.errSchemaPath + '/' + $keyword + var $breakOnError = !it.opts.allErrors + var $errorKeyword + var $data = 'data' + ($dataLvl || '') + var $valid = 'valid' + $lvl + if (it.schema === false) { + if (it.isTop) { + $breakOnError = true + } else { + out += ' var ' + $valid + ' = false; ' + } + var $$outStack = $$outStack || [] + $$outStack.push(out) + out = '' /* istanbul ignore else */ + if (it.createErrors !== false) { + out += + " { keyword: '" + + ($errorKeyword || 'false schema') + + "' , dataPath: (dataPath || '') + " + + it.errorPath + + ' , schemaPath: ' + + it.util.toQuotedString($errSchemaPath) + + ' , params: {} ' + if (it.opts.messages !== false) { + out += " , message: 'boolean schema is false' " + } + if (it.opts.verbose) { + out += + ' , schema: false , parentSchema: validate.schema' + + it.schemaPath + + ' , data: ' + + $data + + ' ' + } + out += ' } ' + } else { + out += ' {} ' + } + var __err = out + out = $$outStack.pop() + if (!it.compositeRule && $breakOnError) { + /* istanbul ignore if */ + if (it.async) { + out += ' throw new ValidationError([' + __err + ']); ' + } else { + out += ' validate.errors = [' + __err + ']; return false; ' + } + } else { + out += + ' var err = ' + + __err + + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ' + } + } else { + if (it.isTop) { + if ($async) { + out += ' return data; ' + } else { + out += ' validate.errors = null; return true; ' + } + } else { + out += ' var ' + $valid + ' = true; ' + } + } + if (it.isTop) { + out += ' }; return validate; ' + } + return out + } + if (it.isTop) { + var $top = it.isTop, + $lvl = (it.level = 0), + $dataLvl = (it.dataLevel = 0), + $data = 'data' + it.rootId = it.resolve.fullPath(it.self._getId(it.root.schema)) + it.baseId = it.baseId || it.rootId + delete it.isTop + it.dataPathArr = [''] + if ( + it.schema.default !== undefined && + it.opts.useDefaults && + it.opts.strictDefaults + ) { + var $defaultMsg = 'default is ignored in the schema root' + if (it.opts.strictDefaults === 'log') it.logger.warn($defaultMsg) + else throw new Error($defaultMsg) + } + out += ' var vErrors = null; ' + out += ' var errors = 0; ' + out += ' if (rootData === undefined) rootData = data; ' + } else { + var $lvl = it.level, + $dataLvl = it.dataLevel, + $data = 'data' + ($dataLvl || '') + if ($id) it.baseId = it.resolve.url(it.baseId, $id) + if ($async && !it.async) + throw new Error('async schema in sync schema') + out += ' var errs_' + $lvl + ' = errors;' + } + var $valid = 'valid' + $lvl, + $breakOnError = !it.opts.allErrors, + $closingBraces1 = '', + $closingBraces2 = '' + var $errorKeyword + var $typeSchema = it.schema.type, + $typeIsArray = Array.isArray($typeSchema) + if ($typeSchema && it.opts.nullable && it.schema.nullable === true) { + if ($typeIsArray) { + if ($typeSchema.indexOf('null') == -1) + $typeSchema = $typeSchema.concat('null') + } else if ($typeSchema != 'null') { + $typeSchema = [$typeSchema, 'null'] + $typeIsArray = true + } + } + if ($typeIsArray && $typeSchema.length == 1) { + $typeSchema = $typeSchema[0] + $typeIsArray = false + } + if (it.schema.$ref && $refKeywords) { + if (it.opts.extendRefs == 'fail') { + throw new Error( + '$ref: validation keywords used in schema at path "' + + it.errSchemaPath + + '" (see option extendRefs)' + ) + } else if (it.opts.extendRefs !== true) { + $refKeywords = false + it.logger.warn( + '$ref: keywords ignored in schema at path "' + + it.errSchemaPath + + '"' + ) + } + } + if (it.schema.$comment && it.opts.$comment) { + out += ' ' + it.RULES.all.$comment.code(it, '$comment') + } + if ($typeSchema) { + if (it.opts.coerceTypes) { + var $coerceToTypes = it.util.coerceToTypes( + it.opts.coerceTypes, + $typeSchema + ) + } + var $rulesGroup = it.RULES.types[$typeSchema] + if ( + $coerceToTypes || + $typeIsArray || + $rulesGroup === true || + ($rulesGroup && !$shouldUseGroup($rulesGroup)) + ) { + var $schemaPath = it.schemaPath + '.type', + $errSchemaPath = it.errSchemaPath + '/type' + var $schemaPath = it.schemaPath + '.type', + $errSchemaPath = it.errSchemaPath + '/type', + $method = $typeIsArray ? 'checkDataTypes' : 'checkDataType' + out += + ' if (' + + it.util[$method]( + $typeSchema, + $data, + it.opts.strictNumbers, + true + ) + + ') { ' + if ($coerceToTypes) { + var $dataType = 'dataType' + $lvl, + $coerced = 'coerced' + $lvl + out += + ' var ' + + $dataType + + ' = typeof ' + + $data + + '; var ' + + $coerced + + ' = undefined; ' + if (it.opts.coerceTypes == 'array') { + out += + ' if (' + + $dataType + + " == 'object' && Array.isArray(" + + $data + + ') && ' + + $data + + '.length == 1) { ' + + $data + + ' = ' + + $data + + '[0]; ' + + $dataType + + ' = typeof ' + + $data + + '; if (' + + it.util.checkDataType( + it.schema.type, + $data, + it.opts.strictNumbers + ) + + ') ' + + $coerced + + ' = ' + + $data + + '; } ' + } + out += ' if (' + $coerced + ' !== undefined) ; ' + var arr1 = $coerceToTypes + if (arr1) { + var $type, + $i = -1, + l1 = arr1.length - 1 + while ($i < l1) { + $type = arr1[($i += 1)] + if ($type == 'string') { + out += + ' else if (' + + $dataType + + " == 'number' || " + + $dataType + + " == 'boolean') " + + $coerced + + " = '' + " + + $data + + '; else if (' + + $data + + ' === null) ' + + $coerced + + " = ''; " + } else if ($type == 'number' || $type == 'integer') { + out += + ' else if (' + + $dataType + + " == 'boolean' || " + + $data + + ' === null || (' + + $dataType + + " == 'string' && " + + $data + + ' && ' + + $data + + ' == +' + + $data + + ' ' + if ($type == 'integer') { + out += ' && !(' + $data + ' % 1)' + } + out += ')) ' + $coerced + ' = +' + $data + '; ' + } else if ($type == 'boolean') { + out += + ' else if (' + + $data + + " === 'false' || " + + $data + + ' === 0 || ' + + $data + + ' === null) ' + + $coerced + + ' = false; else if (' + + $data + + " === 'true' || " + + $data + + ' === 1) ' + + $coerced + + ' = true; ' + } else if ($type == 'null') { + out += + ' else if (' + + $data + + " === '' || " + + $data + + ' === 0 || ' + + $data + + ' === false) ' + + $coerced + + ' = null; ' + } else if ( + it.opts.coerceTypes == 'array' && + $type == 'array' + ) { + out += + ' else if (' + + $dataType + + " == 'string' || " + + $dataType + + " == 'number' || " + + $dataType + + " == 'boolean' || " + + $data + + ' == null) ' + + $coerced + + ' = [' + + $data + + ']; ' + } + } + } + out += ' else { ' + var $$outStack = $$outStack || [] + $$outStack.push(out) + out = '' /* istanbul ignore else */ + if (it.createErrors !== false) { + out += + " { keyword: '" + + ($errorKeyword || 'type') + + "' , dataPath: (dataPath || '') + " + + it.errorPath + + ' , schemaPath: ' + + it.util.toQuotedString($errSchemaPath) + + " , params: { type: '" + if ($typeIsArray) { + out += '' + $typeSchema.join(',') + } else { + out += '' + $typeSchema + } + out += "' } " + if (it.opts.messages !== false) { + out += " , message: 'should be " + if ($typeIsArray) { + out += '' + $typeSchema.join(',') + } else { + out += '' + $typeSchema + } + out += "' " + } + if (it.opts.verbose) { + out += + ' , schema: validate.schema' + + $schemaPath + + ' , parentSchema: validate.schema' + + it.schemaPath + + ' , data: ' + + $data + + ' ' + } + out += ' } ' + } else { + out += ' {} ' + } + var __err = out + out = $$outStack.pop() + if (!it.compositeRule && $breakOnError) { + /* istanbul ignore if */ + if (it.async) { + out += ' throw new ValidationError([' + __err + ']); ' + } else { + out += ' validate.errors = [' + __err + ']; return false; ' + } + } else { + out += + ' var err = ' + + __err + + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ' + } + out += ' } if (' + $coerced + ' !== undefined) { ' + var $parentData = $dataLvl + ? 'data' + ($dataLvl - 1 || '') + : 'parentData', + $parentDataProperty = $dataLvl + ? it.dataPathArr[$dataLvl] + : 'parentDataProperty' + out += ' ' + $data + ' = ' + $coerced + '; ' + if (!$dataLvl) { + out += 'if (' + $parentData + ' !== undefined)' + } + out += + ' ' + + $parentData + + '[' + + $parentDataProperty + + '] = ' + + $coerced + + '; } ' + } else { + var $$outStack = $$outStack || [] + $$outStack.push(out) + out = '' /* istanbul ignore else */ + if (it.createErrors !== false) { + out += + " { keyword: '" + + ($errorKeyword || 'type') + + "' , dataPath: (dataPath || '') + " + + it.errorPath + + ' , schemaPath: ' + + it.util.toQuotedString($errSchemaPath) + + " , params: { type: '" + if ($typeIsArray) { + out += '' + $typeSchema.join(',') + } else { + out += '' + $typeSchema + } + out += "' } " + if (it.opts.messages !== false) { + out += " , message: 'should be " + if ($typeIsArray) { + out += '' + $typeSchema.join(',') + } else { + out += '' + $typeSchema + } + out += "' " + } + if (it.opts.verbose) { + out += + ' , schema: validate.schema' + + $schemaPath + + ' , parentSchema: validate.schema' + + it.schemaPath + + ' , data: ' + + $data + + ' ' + } + out += ' } ' + } else { + out += ' {} ' + } + var __err = out + out = $$outStack.pop() + if (!it.compositeRule && $breakOnError) { + /* istanbul ignore if */ + if (it.async) { + out += ' throw new ValidationError([' + __err + ']); ' + } else { + out += ' validate.errors = [' + __err + ']; return false; ' + } + } else { + out += + ' var err = ' + + __err + + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ' + } + } + out += ' } ' + } + } + if (it.schema.$ref && !$refKeywords) { + out += ' ' + it.RULES.all.$ref.code(it, '$ref') + ' ' + if ($breakOnError) { + out += ' } if (errors === ' + if ($top) { + out += '0' + } else { + out += 'errs_' + $lvl + } + out += ') { ' + $closingBraces2 += '}' + } + } else { + var arr2 = it.RULES + if (arr2) { + var $rulesGroup, + i2 = -1, + l2 = arr2.length - 1 + while (i2 < l2) { + $rulesGroup = arr2[(i2 += 1)] + if ($shouldUseGroup($rulesGroup)) { + if ($rulesGroup.type) { + out += + ' if (' + + it.util.checkDataType( + $rulesGroup.type, + $data, + it.opts.strictNumbers + ) + + ') { ' + } + if (it.opts.useDefaults) { + if ($rulesGroup.type == 'object' && it.schema.properties) { + var $schema = it.schema.properties, + $schemaKeys = Object.keys($schema) + var arr3 = $schemaKeys + if (arr3) { + var $propertyKey, + i3 = -1, + l3 = arr3.length - 1 + while (i3 < l3) { + $propertyKey = arr3[(i3 += 1)] + var $sch = $schema[$propertyKey] + if ($sch.default !== undefined) { + var $passData = + $data + it.util.getProperty($propertyKey) + if (it.compositeRule) { + if (it.opts.strictDefaults) { + var $defaultMsg = + 'default is ignored for: ' + $passData + if (it.opts.strictDefaults === 'log') + it.logger.warn($defaultMsg) + else throw new Error($defaultMsg) + } + } else { + out += ' if (' + $passData + ' === undefined ' + if (it.opts.useDefaults == 'empty') { + out += + ' || ' + + $passData + + ' === null || ' + + $passData + + " === '' " + } + out += ' ) ' + $passData + ' = ' + if (it.opts.useDefaults == 'shared') { + out += ' ' + it.useDefault($sch.default) + ' ' + } else { + out += ' ' + JSON.stringify($sch.default) + ' ' + } + out += '; ' + } + } + } + } + } else if ( + $rulesGroup.type == 'array' && + Array.isArray(it.schema.items) + ) { + var arr4 = it.schema.items + if (arr4) { + var $sch, + $i = -1, + l4 = arr4.length - 1 + while ($i < l4) { + $sch = arr4[($i += 1)] + if ($sch.default !== undefined) { + var $passData = $data + '[' + $i + ']' + if (it.compositeRule) { + if (it.opts.strictDefaults) { + var $defaultMsg = + 'default is ignored for: ' + $passData + if (it.opts.strictDefaults === 'log') + it.logger.warn($defaultMsg) + else throw new Error($defaultMsg) + } + } else { + out += ' if (' + $passData + ' === undefined ' + if (it.opts.useDefaults == 'empty') { + out += + ' || ' + + $passData + + ' === null || ' + + $passData + + " === '' " + } + out += ' ) ' + $passData + ' = ' + if (it.opts.useDefaults == 'shared') { + out += ' ' + it.useDefault($sch.default) + ' ' + } else { + out += ' ' + JSON.stringify($sch.default) + ' ' + } + out += '; ' + } + } + } + } + } + } + var arr5 = $rulesGroup.rules + if (arr5) { + var $rule, + i5 = -1, + l5 = arr5.length - 1 + while (i5 < l5) { + $rule = arr5[(i5 += 1)] + if ($shouldUseRule($rule)) { + var $code = $rule.code( + it, + $rule.keyword, + $rulesGroup.type + ) + if ($code) { + out += ' ' + $code + ' ' + if ($breakOnError) { + $closingBraces1 += '}' + } + } + } + } + } + if ($breakOnError) { + out += ' ' + $closingBraces1 + ' ' + $closingBraces1 = '' + } + if ($rulesGroup.type) { + out += ' } ' + if ( + $typeSchema && + $typeSchema === $rulesGroup.type && + !$coerceToTypes + ) { + out += ' else { ' + var $schemaPath = it.schemaPath + '.type', + $errSchemaPath = it.errSchemaPath + '/type' + var $$outStack = $$outStack || [] + $$outStack.push(out) + out = '' /* istanbul ignore else */ + if (it.createErrors !== false) { + out += + " { keyword: '" + + ($errorKeyword || 'type') + + "' , dataPath: (dataPath || '') + " + + it.errorPath + + ' , schemaPath: ' + + it.util.toQuotedString($errSchemaPath) + + " , params: { type: '" + if ($typeIsArray) { + out += '' + $typeSchema.join(',') + } else { + out += '' + $typeSchema + } + out += "' } " + if (it.opts.messages !== false) { + out += " , message: 'should be " + if ($typeIsArray) { + out += '' + $typeSchema.join(',') + } else { + out += '' + $typeSchema + } + out += "' " + } + if (it.opts.verbose) { + out += + ' , schema: validate.schema' + + $schemaPath + + ' , parentSchema: validate.schema' + + it.schemaPath + + ' , data: ' + + $data + + ' ' + } + out += ' } ' + } else { + out += ' {} ' + } + var __err = out + out = $$outStack.pop() + if (!it.compositeRule && $breakOnError) { + /* istanbul ignore if */ + if (it.async) { + out += ' throw new ValidationError([' + __err + ']); ' + } else { + out += + ' validate.errors = [' + __err + ']; return false; ' + } + } else { + out += + ' var err = ' + + __err + + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ' + } + out += ' } ' + } + } + if ($breakOnError) { + out += ' if (errors === ' + if ($top) { + out += '0' + } else { + out += 'errs_' + $lvl + } + out += ') { ' + $closingBraces2 += '}' + } + } + } + } + } + if ($breakOnError) { + out += ' ' + $closingBraces2 + ' ' + } + if ($top) { + if ($async) { + out += ' if (errors === 0) return data; ' + out += ' else throw new ValidationError(vErrors); ' + } else { + out += ' validate.errors = vErrors; ' + out += ' return errors === 0; ' + } + out += ' }; return validate;' + } else { + out += ' var ' + $valid + ' = errors === errs_' + $lvl + ';' + } + + function $shouldUseGroup($rulesGroup) { + var rules = $rulesGroup.rules + for (var i = 0; i < rules.length; i++) + if ($shouldUseRule(rules[i])) return true + } + + function $shouldUseRule($rule) { + return ( + it.schema[$rule.keyword] !== undefined || + ($rule.implements && $ruleImplementsSomeKeyword($rule)) + ) + } + + function $ruleImplementsSomeKeyword($rule) { + var impl = $rule.implements + for (var i = 0; i < impl.length; i++) + if (it.schema[impl[i]] !== undefined) return true + } + return out + } + + /***/ + }, + + /***/ 53297: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + 'use strict' + + var IDENTIFIER = /^[a-z_$][a-z0-9_$-]*$/i + var customRuleCode = __webpack_require__(5912) + var definitionSchema = __webpack_require__(10458) + + module.exports = { + add: addKeyword, + get: getKeyword, + remove: removeKeyword, + validate: validateKeyword + } + + /** + * Define custom keyword + * @this Ajv + * @param {String} keyword custom keyword, should be unique (including different from all standard, custom and macro keywords). + * @param {Object} definition keyword definition object with properties `type` (type(s) which the keyword applies to), `validate` or `compile`. + * @return {Ajv} this for method chaining + */ + function addKeyword(keyword, definition) { + /* jshint validthis: true */ + /* eslint no-shadow: 0 */ + var RULES = this.RULES + if (RULES.keywords[keyword]) + throw new Error('Keyword ' + keyword + ' is already defined') + + if (!IDENTIFIER.test(keyword)) + throw new Error('Keyword ' + keyword + ' is not a valid identifier') + + if (definition) { + this.validateKeyword(definition, true) + + var dataType = definition.type + if (Array.isArray(dataType)) { + for (var i = 0; i < dataType.length; i++) + _addRule(keyword, dataType[i], definition) + } else { + _addRule(keyword, dataType, definition) + } + + var metaSchema = definition.metaSchema + if (metaSchema) { + if (definition.$data && this._opts.$data) { + metaSchema = { + anyOf: [ + metaSchema, + { + $ref: + 'https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#' + } + ] + } + } + definition.validateSchema = this.compile(metaSchema, true) + } + } + + RULES.keywords[keyword] = RULES.all[keyword] = true + + function _addRule(keyword, dataType, definition) { + var ruleGroup + for (var i = 0; i < RULES.length; i++) { + var rg = RULES[i] + if (rg.type == dataType) { + ruleGroup = rg + break + } + } + + if (!ruleGroup) { + ruleGroup = { type: dataType, rules: [] } + RULES.push(ruleGroup) + } + + var rule = { + keyword: keyword, + definition: definition, + custom: true, + code: customRuleCode, + implements: definition.implements + } + ruleGroup.rules.push(rule) + RULES.custom[keyword] = rule + } + + return this + } + + /** + * Get keyword + * @this Ajv + * @param {String} keyword pre-defined or custom keyword. + * @return {Object|Boolean} custom keyword definition, `true` if it is a predefined keyword, `false` otherwise. + */ + function getKeyword(keyword) { + /* jshint validthis: true */ + var rule = this.RULES.custom[keyword] + return rule ? rule.definition : this.RULES.keywords[keyword] || false + } + + /** + * Remove keyword + * @this Ajv + * @param {String} keyword pre-defined or custom keyword. + * @return {Ajv} this for method chaining + */ + function removeKeyword(keyword) { + /* jshint validthis: true */ + var RULES = this.RULES + delete RULES.keywords[keyword] + delete RULES.all[keyword] + delete RULES.custom[keyword] + for (var i = 0; i < RULES.length; i++) { + var rules = RULES[i].rules + for (var j = 0; j < rules.length; j++) { + if (rules[j].keyword == keyword) { + rules.splice(j, 1) + break + } + } + } + return this + } + + /** + * Validate keyword definition + * @this Ajv + * @param {Object} definition keyword definition object. + * @param {Boolean} throwError true to throw exception if definition is invalid + * @return {boolean} validation result + */ + function validateKeyword(definition, throwError) { + validateKeyword.errors = null + var v = (this._validateKeyword = + this._validateKeyword || this.compile(definitionSchema, true)) + + if (v(definition)) return true + validateKeyword.errors = v.errors + if (throwError) + throw new Error( + 'custom keyword definition is invalid: ' + this.errorsText(v.errors) + ) + else return false + } + + /***/ + }, + + /***/ 52068: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + 'use strict' + /* module decorator */ module = __webpack_require__.nmd(module) + + const wrapAnsi16 = (fn, offset) => (...args) => { + const code = fn(...args) + return `\u001B[${code + offset}m` + } + + const wrapAnsi256 = (fn, offset) => (...args) => { + const code = fn(...args) + return `\u001B[${38 + offset};5;${code}m` + } + + const wrapAnsi16m = (fn, offset) => (...args) => { + const rgb = fn(...args) + return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m` + } + + const ansi2ansi = n => n + const rgb2rgb = (r, g, b) => [r, g, b] + + const setLazyProperty = (object, property, get) => { + Object.defineProperty(object, property, { + get: () => { + const value = get() + + Object.defineProperty(object, property, { + value, + enumerable: true, + configurable: true + }) + + return value + }, + enumerable: true, + configurable: true + }) + } + + /** @type {typeof import('color-convert')} */ + let colorConvert + const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => { + if (colorConvert === undefined) { + colorConvert = __webpack_require__(86931) + } + + const offset = isBackground ? 10 : 0 + const styles = {} + + for (const [sourceSpace, suite] of Object.entries(colorConvert)) { + const name = sourceSpace === 'ansi16' ? 'ansi' : sourceSpace + if (sourceSpace === targetSpace) { + styles[name] = wrap(identity, offset) + } else if (typeof suite === 'object') { + styles[name] = wrap(suite[targetSpace], offset) + } + } + + return styles + } + + function assembleStyles() { + const codes = new Map() + const styles = { + modifier: { + reset: [0, 0], + // 21 isn't widely supported and 22 does the same thing + bold: [1, 22], + dim: [2, 22], + italic: [3, 23], + underline: [4, 24], + inverse: [7, 27], + hidden: [8, 28], + strikethrough: [9, 29] + }, + color: { + black: [30, 39], + red: [31, 39], + green: [32, 39], + yellow: [33, 39], + blue: [34, 39], + magenta: [35, 39], + cyan: [36, 39], + white: [37, 39], + + // Bright color + blackBright: [90, 39], + redBright: [91, 39], + greenBright: [92, 39], + yellowBright: [93, 39], + blueBright: [94, 39], + magentaBright: [95, 39], + cyanBright: [96, 39], + whiteBright: [97, 39] + }, + bgColor: { + bgBlack: [40, 49], + bgRed: [41, 49], + bgGreen: [42, 49], + bgYellow: [43, 49], + bgBlue: [44, 49], + bgMagenta: [45, 49], + bgCyan: [46, 49], + bgWhite: [47, 49], + + // Bright color + bgBlackBright: [100, 49], + bgRedBright: [101, 49], + bgGreenBright: [102, 49], + bgYellowBright: [103, 49], + bgBlueBright: [104, 49], + bgMagentaBright: [105, 49], + bgCyanBright: [106, 49], + bgWhiteBright: [107, 49] + } + } + + // Alias bright black as gray (and grey) + styles.color.gray = styles.color.blackBright + styles.bgColor.bgGray = styles.bgColor.bgBlackBright + styles.color.grey = styles.color.blackBright + styles.bgColor.bgGrey = styles.bgColor.bgBlackBright + + for (const [groupName, group] of Object.entries(styles)) { + for (const [styleName, style] of Object.entries(group)) { + styles[styleName] = { + open: `\u001B[${style[0]}m`, + close: `\u001B[${style[1]}m` + } + + group[styleName] = styles[styleName] + + codes.set(style[0], style[1]) + } + + Object.defineProperty(styles, groupName, { + value: group, + enumerable: false + }) + } + + Object.defineProperty(styles, 'codes', { + value: codes, + enumerable: false + }) + + styles.color.close = '\u001B[39m' + styles.bgColor.close = '\u001B[49m' + + setLazyProperty(styles.color, 'ansi', () => + makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, false) + ) + setLazyProperty(styles.color, 'ansi256', () => + makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, false) + ) + setLazyProperty(styles.color, 'ansi16m', () => + makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, false) + ) + setLazyProperty(styles.bgColor, 'ansi', () => + makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, true) + ) + setLazyProperty(styles.bgColor, 'ansi256', () => + makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, true) + ) + setLazyProperty(styles.bgColor, 'ansi16m', () => + makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, true) + ) + + return styles + } + + // Make the export immutable + Object.defineProperty(module, 'exports', { + enumerable: true, + get: assembleStyles + }) + + /***/ + }, + + /***/ 61546: /***/ module => { + 'use strict' + + const arrify = value => { + if (value === null || value === undefined) { + return [] + } + + if (Array.isArray(value)) { + return value + } + + if (typeof value === 'string') { + return [value] + } + + if (typeof value[Symbol.iterator] === 'function') { + return [...value] + } + + return [value] + } + + module.exports = arrify + + /***/ + }, + + /***/ 99348: /***/ module => { + // Copyright 2011 Mark Cavage All rights reserved. + + module.exports = { + newInvalidAsn1Error: function (msg) { + var e = new Error() + e.name = 'InvalidAsn1Error' + e.message = msg || '' + return e + } + } + + /***/ + }, + + /***/ 194: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + // Copyright 2011 Mark Cavage All rights reserved. + + var errors = __webpack_require__(99348) + var types = __webpack_require__(42473) + + var Reader = __webpack_require__(20290) + var Writer = __webpack_require__(43200) + + // --- Exports + + module.exports = { + Reader: Reader, + + Writer: Writer + } + + for (var t in types) { + if (types.hasOwnProperty(t)) module.exports[t] = types[t] + } + for (var e in errors) { + if (errors.hasOwnProperty(e)) module.exports[e] = errors[e] + } + + /***/ + }, + + /***/ 20290: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + // Copyright 2011 Mark Cavage All rights reserved. + + var assert = __webpack_require__(42357) + var Buffer = __webpack_require__(15118).Buffer + + var ASN1 = __webpack_require__(42473) + var errors = __webpack_require__(99348) + + // --- Globals + + var newInvalidAsn1Error = errors.newInvalidAsn1Error + + // --- API + + function Reader(data) { + if (!data || !Buffer.isBuffer(data)) + throw new TypeError('data must be a node Buffer') + + this._buf = data + this._size = data.length + + // These hold the "current" state + this._len = 0 + this._offset = 0 + } + + Object.defineProperty(Reader.prototype, 'length', { + enumerable: true, + get: function () { + return this._len + } + }) + + Object.defineProperty(Reader.prototype, 'offset', { + enumerable: true, + get: function () { + return this._offset + } + }) + + Object.defineProperty(Reader.prototype, 'remain', { + get: function () { + return this._size - this._offset + } + }) + + Object.defineProperty(Reader.prototype, 'buffer', { + get: function () { + return this._buf.slice(this._offset) + } + }) + + /** + * Reads a single byte and advances offset; you can pass in `true` to make this + * a "peek" operation (i.e., get the byte, but don't advance the offset). + * + * @param {Boolean} peek true means don't move offset. + * @return {Number} the next byte, null if not enough data. + */ + Reader.prototype.readByte = function (peek) { + if (this._size - this._offset < 1) return null + + var b = this._buf[this._offset] & 0xff + + if (!peek) this._offset += 1 + + return b + } + + Reader.prototype.peek = function () { + return this.readByte(true) + } + + /** + * Reads a (potentially) variable length off the BER buffer. This call is + * not really meant to be called directly, as callers have to manipulate + * the internal buffer afterwards. + * + * As a result of this call, you can call `Reader.length`, until the + * next thing called that does a readLength. + * + * @return {Number} the amount of offset to advance the buffer. + * @throws {InvalidAsn1Error} on bad ASN.1 + */ + Reader.prototype.readLength = function (offset) { + if (offset === undefined) offset = this._offset + + if (offset >= this._size) return null + + var lenB = this._buf[offset++] & 0xff + if (lenB === null) return null + + if ((lenB & 0x80) === 0x80) { + lenB &= 0x7f + + if (lenB === 0) + throw newInvalidAsn1Error('Indefinite length not supported') + + if (lenB > 4) throw newInvalidAsn1Error('encoding too long') + + if (this._size - offset < lenB) return null + + this._len = 0 + for (var i = 0; i < lenB; i++) + this._len = (this._len << 8) + (this._buf[offset++] & 0xff) + } else { + // Wasn't a variable length + this._len = lenB + } + + return offset + } + + /** + * Parses the next sequence in this BER buffer. + * + * To get the length of the sequence, call `Reader.length`. + * + * @return {Number} the sequence's tag. + */ + Reader.prototype.readSequence = function (tag) { + var seq = this.peek() + if (seq === null) return null + if (tag !== undefined && tag !== seq) + throw newInvalidAsn1Error( + 'Expected 0x' + tag.toString(16) + ': got 0x' + seq.toString(16) + ) + + var o = this.readLength(this._offset + 1) // stored in `length` + if (o === null) return null + + this._offset = o + return seq + } + + Reader.prototype.readInt = function () { + return this._readTag(ASN1.Integer) + } + + Reader.prototype.readBoolean = function () { + return this._readTag(ASN1.Boolean) === 0 ? false : true + } + + Reader.prototype.readEnumeration = function () { + return this._readTag(ASN1.Enumeration) + } + + Reader.prototype.readString = function (tag, retbuf) { + if (!tag) tag = ASN1.OctetString + + var b = this.peek() + if (b === null) return null + + if (b !== tag) + throw newInvalidAsn1Error( + 'Expected 0x' + tag.toString(16) + ': got 0x' + b.toString(16) + ) + + var o = this.readLength(this._offset + 1) // stored in `length` + + if (o === null) return null + + if (this.length > this._size - o) return null + + this._offset = o + + if (this.length === 0) return retbuf ? Buffer.alloc(0) : '' + + var str = this._buf.slice(this._offset, this._offset + this.length) + this._offset += this.length + + return retbuf ? str : str.toString('utf8') + } + + Reader.prototype.readOID = function (tag) { + if (!tag) tag = ASN1.OID + + var b = this.readString(tag, true) + if (b === null) return null + + var values = [] + var value = 0 + + for (var i = 0; i < b.length; i++) { + var byte = b[i] & 0xff + + value <<= 7 + value += byte & 0x7f + if ((byte & 0x80) === 0) { + values.push(value) + value = 0 + } + } + + value = values.shift() + values.unshift(value % 40) + values.unshift((value / 40) >> 0) + + return values.join('.') + } + + Reader.prototype._readTag = function (tag) { + assert.ok(tag !== undefined) + + var b = this.peek() + + if (b === null) return null + + if (b !== tag) + throw newInvalidAsn1Error( + 'Expected 0x' + tag.toString(16) + ': got 0x' + b.toString(16) + ) + + var o = this.readLength(this._offset + 1) // stored in `length` + if (o === null) return null + + if (this.length > 4) + throw newInvalidAsn1Error('Integer too long: ' + this.length) + + if (this.length > this._size - o) return null + this._offset = o + + var fb = this._buf[this._offset] + var value = 0 + + for (var i = 0; i < this.length; i++) { + value <<= 8 + value |= this._buf[this._offset++] & 0xff + } + + if ((fb & 0x80) === 0x80 && i !== 4) value -= 1 << (i * 8) + + return value >> 0 + } + + // --- Exported API + + module.exports = Reader + + /***/ + }, + + /***/ 42473: /***/ module => { + // Copyright 2011 Mark Cavage All rights reserved. + + module.exports = { + EOC: 0, + Boolean: 1, + Integer: 2, + BitString: 3, + OctetString: 4, + Null: 5, + OID: 6, + ObjectDescriptor: 7, + External: 8, + Real: 9, // float + Enumeration: 10, + PDV: 11, + Utf8String: 12, + RelativeOID: 13, + Sequence: 16, + Set: 17, + NumericString: 18, + PrintableString: 19, + T61String: 20, + VideotexString: 21, + IA5String: 22, + UTCTime: 23, + GeneralizedTime: 24, + GraphicString: 25, + VisibleString: 26, + GeneralString: 28, + UniversalString: 29, + CharacterString: 30, + BMPString: 31, + Constructor: 32, + Context: 128 + } + + /***/ + }, + + /***/ 43200: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + // Copyright 2011 Mark Cavage All rights reserved. + + var assert = __webpack_require__(42357) + var Buffer = __webpack_require__(15118).Buffer + var ASN1 = __webpack_require__(42473) + var errors = __webpack_require__(99348) + + // --- Globals + + var newInvalidAsn1Error = errors.newInvalidAsn1Error + + var DEFAULT_OPTS = { + size: 1024, + growthFactor: 8 + } + + // --- Helpers + + function merge(from, to) { + assert.ok(from) + assert.equal(typeof from, 'object') + assert.ok(to) + assert.equal(typeof to, 'object') + + var keys = Object.getOwnPropertyNames(from) + keys.forEach(function (key) { + if (to[key]) return + + var value = Object.getOwnPropertyDescriptor(from, key) + Object.defineProperty(to, key, value) + }) + + return to + } + + // --- API + + function Writer(options) { + options = merge(DEFAULT_OPTS, options || {}) + + this._buf = Buffer.alloc(options.size || 1024) + this._size = this._buf.length + this._offset = 0 + this._options = options + + // A list of offsets in the buffer where we need to insert + // sequence tag/len pairs. + this._seq = [] + } + + Object.defineProperty(Writer.prototype, 'buffer', { + get: function () { + if (this._seq.length) + throw newInvalidAsn1Error(this._seq.length + ' unended sequence(s)') + + return this._buf.slice(0, this._offset) + } + }) + + Writer.prototype.writeByte = function (b) { + if (typeof b !== 'number') + throw new TypeError('argument must be a Number') + + this._ensure(1) + this._buf[this._offset++] = b + } + + Writer.prototype.writeInt = function (i, tag) { + if (typeof i !== 'number') + throw new TypeError('argument must be a Number') + if (typeof tag !== 'number') tag = ASN1.Integer + + var sz = 4 + + while ( + ((i & 0xff800000) === 0 || (i & 0xff800000) === 0xff800000 >> 0) && + sz > 1 + ) { + sz-- + i <<= 8 + } + + if (sz > 4) throw newInvalidAsn1Error('BER ints cannot be > 0xffffffff') + + this._ensure(2 + sz) + this._buf[this._offset++] = tag + this._buf[this._offset++] = sz + + while (sz-- > 0) { + this._buf[this._offset++] = (i & 0xff000000) >>> 24 + i <<= 8 + } + } + + Writer.prototype.writeNull = function () { + this.writeByte(ASN1.Null) + this.writeByte(0x00) + } + + Writer.prototype.writeEnumeration = function (i, tag) { + if (typeof i !== 'number') + throw new TypeError('argument must be a Number') + if (typeof tag !== 'number') tag = ASN1.Enumeration + + return this.writeInt(i, tag) + } + + Writer.prototype.writeBoolean = function (b, tag) { + if (typeof b !== 'boolean') + throw new TypeError('argument must be a Boolean') + if (typeof tag !== 'number') tag = ASN1.Boolean + + this._ensure(3) + this._buf[this._offset++] = tag + this._buf[this._offset++] = 0x01 + this._buf[this._offset++] = b ? 0xff : 0x00 + } + + Writer.prototype.writeString = function (s, tag) { + if (typeof s !== 'string') + throw new TypeError( + 'argument must be a string (was: ' + typeof s + ')' + ) + if (typeof tag !== 'number') tag = ASN1.OctetString + + var len = Buffer.byteLength(s) + this.writeByte(tag) + this.writeLength(len) + if (len) { + this._ensure(len) + this._buf.write(s, this._offset) + this._offset += len + } + } + + Writer.prototype.writeBuffer = function (buf, tag) { + if (typeof tag !== 'number') throw new TypeError('tag must be a number') + if (!Buffer.isBuffer(buf)) + throw new TypeError('argument must be a buffer') + + this.writeByte(tag) + this.writeLength(buf.length) + this._ensure(buf.length) + buf.copy(this._buf, this._offset, 0, buf.length) + this._offset += buf.length + } + + Writer.prototype.writeStringArray = function (strings) { + if (!strings instanceof Array) + throw new TypeError('argument must be an Array[String]') + + var self = this + strings.forEach(function (s) { + self.writeString(s) + }) + } + + // This is really to solve DER cases, but whatever for now + Writer.prototype.writeOID = function (s, tag) { + if (typeof s !== 'string') + throw new TypeError('argument must be a string') + if (typeof tag !== 'number') tag = ASN1.OID + + if (!/^([0-9]+\.){3,}[0-9]+$/.test(s)) + throw new Error('argument is not a valid OID string') + + function encodeOctet(bytes, octet) { + if (octet < 128) { + bytes.push(octet) + } else if (octet < 16384) { + bytes.push((octet >>> 7) | 0x80) + bytes.push(octet & 0x7f) + } else if (octet < 2097152) { + bytes.push((octet >>> 14) | 0x80) + bytes.push(((octet >>> 7) | 0x80) & 0xff) + bytes.push(octet & 0x7f) + } else if (octet < 268435456) { + bytes.push((octet >>> 21) | 0x80) + bytes.push(((octet >>> 14) | 0x80) & 0xff) + bytes.push(((octet >>> 7) | 0x80) & 0xff) + bytes.push(octet & 0x7f) + } else { + bytes.push(((octet >>> 28) | 0x80) & 0xff) + bytes.push(((octet >>> 21) | 0x80) & 0xff) + bytes.push(((octet >>> 14) | 0x80) & 0xff) + bytes.push(((octet >>> 7) | 0x80) & 0xff) + bytes.push(octet & 0x7f) + } + } + + var tmp = s.split('.') + var bytes = [] + bytes.push(parseInt(tmp[0], 10) * 40 + parseInt(tmp[1], 10)) + tmp.slice(2).forEach(function (b) { + encodeOctet(bytes, parseInt(b, 10)) + }) + + var self = this + this._ensure(2 + bytes.length) + this.writeByte(tag) + this.writeLength(bytes.length) + bytes.forEach(function (b) { + self.writeByte(b) + }) + } + + Writer.prototype.writeLength = function (len) { + if (typeof len !== 'number') + throw new TypeError('argument must be a Number') + + this._ensure(4) + + if (len <= 0x7f) { + this._buf[this._offset++] = len + } else if (len <= 0xff) { + this._buf[this._offset++] = 0x81 + this._buf[this._offset++] = len + } else if (len <= 0xffff) { + this._buf[this._offset++] = 0x82 + this._buf[this._offset++] = len >> 8 + this._buf[this._offset++] = len + } else if (len <= 0xffffff) { + this._buf[this._offset++] = 0x83 + this._buf[this._offset++] = len >> 16 + this._buf[this._offset++] = len >> 8 + this._buf[this._offset++] = len + } else { + throw newInvalidAsn1Error('Length too long (> 4 bytes)') + } + } + + Writer.prototype.startSequence = function (tag) { + if (typeof tag !== 'number') tag = ASN1.Sequence | ASN1.Constructor + + this.writeByte(tag) + this._seq.push(this._offset) + this._ensure(3) + this._offset += 3 + } + + Writer.prototype.endSequence = function () { + var seq = this._seq.pop() + var start = seq + 3 + var len = this._offset - start + + if (len <= 0x7f) { + this._shift(start, len, -2) + this._buf[seq] = len + } else if (len <= 0xff) { + this._shift(start, len, -1) + this._buf[seq] = 0x81 + this._buf[seq + 1] = len + } else if (len <= 0xffff) { + this._buf[seq] = 0x82 + this._buf[seq + 1] = len >> 8 + this._buf[seq + 2] = len + } else if (len <= 0xffffff) { + this._shift(start, len, 1) + this._buf[seq] = 0x83 + this._buf[seq + 1] = len >> 16 + this._buf[seq + 2] = len >> 8 + this._buf[seq + 3] = len + } else { + throw newInvalidAsn1Error('Sequence too long') + } + } + + Writer.prototype._shift = function (start, len, shift) { + assert.ok(start !== undefined) + assert.ok(len !== undefined) + assert.ok(shift) + + this._buf.copy(this._buf, start + shift, start, start + len) + this._offset += shift + } + + Writer.prototype._ensure = function (len) { + assert.ok(len) + + if (this._size - this._offset < len) { + var sz = this._size * this._options.growthFactor + if (sz - this._offset < len) sz += len + + var buf = Buffer.alloc(sz) + + this._buf.copy(buf, 0, 0, this._offset) + this._buf = buf + this._size = sz + } + } + + // --- Exported API + + module.exports = Writer + + /***/ + }, + + /***/ 80970: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + // Copyright 2011 Mark Cavage All rights reserved. + + // If you have no idea what ASN.1 or BER is, see this: + // ftp://ftp.rsa.com/pub/pkcs/ascii/layman.asc + + var Ber = __webpack_require__(194) + + // --- Exported API + + module.exports = { + Ber: Ber, + + BerReader: Ber.Reader, + + BerWriter: Ber.Writer + } + + /***/ + }, + + /***/ 66631: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + // Copyright (c) 2012, Mark Cavage. All rights reserved. + // Copyright 2015 Joyent, Inc. + + var assert = __webpack_require__(42357) + var Stream = __webpack_require__(92413).Stream + var util = __webpack_require__(31669) + + ///--- Globals + + /* JSSTYLED */ + var UUID_REGEXP = /^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/ + + ///--- Internal + + function _capitalize(str) { + return str.charAt(0).toUpperCase() + str.slice(1) + } + + function _toss(name, expected, oper, arg, actual) { + throw new assert.AssertionError({ + message: util.format('%s (%s) is required', name, expected), + actual: actual === undefined ? typeof arg : actual(arg), + expected: expected, + operator: oper || '===', + stackStartFunction: _toss.caller + }) + } + + function _getClass(arg) { + return Object.prototype.toString.call(arg).slice(8, -1) + } + + function noop() { + // Why even bother with asserts? + } + + ///--- Exports + + var types = { + bool: { + check: function (arg) { + return typeof arg === 'boolean' + } + }, + func: { + check: function (arg) { + return typeof arg === 'function' + } + }, + string: { + check: function (arg) { + return typeof arg === 'string' + } + }, + object: { + check: function (arg) { + return typeof arg === 'object' && arg !== null + } + }, + number: { + check: function (arg) { + return typeof arg === 'number' && !isNaN(arg) + } + }, + finite: { + check: function (arg) { + return typeof arg === 'number' && !isNaN(arg) && isFinite(arg) + } + }, + buffer: { + check: function (arg) { + return Buffer.isBuffer(arg) + }, + operator: 'Buffer.isBuffer' + }, + array: { + check: function (arg) { + return Array.isArray(arg) + }, + operator: 'Array.isArray' + }, + stream: { + check: function (arg) { + return arg instanceof Stream + }, + operator: 'instanceof', + actual: _getClass + }, + date: { + check: function (arg) { + return arg instanceof Date + }, + operator: 'instanceof', + actual: _getClass + }, + regexp: { + check: function (arg) { + return arg instanceof RegExp + }, + operator: 'instanceof', + actual: _getClass + }, + uuid: { + check: function (arg) { + return typeof arg === 'string' && UUID_REGEXP.test(arg) + }, + operator: 'isUUID' + } + } + + function _setExports(ndebug) { + var keys = Object.keys(types) + var out + + /* re-export standard assert */ + if (process.env.NODE_NDEBUG) { + out = noop + } else { + out = function (arg, msg) { + if (!arg) { + _toss(msg, 'true', arg) + } + } + } + + /* standard checks */ + keys.forEach(function (k) { + if (ndebug) { + out[k] = noop + return + } + var type = types[k] + out[k] = function (arg, msg) { + if (!type.check(arg)) { + _toss(msg, k, type.operator, arg, type.actual) + } + } + }) + + /* optional checks */ + keys.forEach(function (k) { + var name = 'optional' + _capitalize(k) + if (ndebug) { + out[name] = noop + return + } + var type = types[k] + out[name] = function (arg, msg) { + if (arg === undefined || arg === null) { + return + } + if (!type.check(arg)) { + _toss(msg, k, type.operator, arg, type.actual) + } + } + }) + + /* arrayOf checks */ + keys.forEach(function (k) { + var name = 'arrayOf' + _capitalize(k) + if (ndebug) { + out[name] = noop + return + } + var type = types[k] + var expected = '[' + k + ']' + out[name] = function (arg, msg) { + if (!Array.isArray(arg)) { + _toss(msg, expected, type.operator, arg, type.actual) + } + var i + for (i = 0; i < arg.length; i++) { + if (!type.check(arg[i])) { + _toss(msg, expected, type.operator, arg, type.actual) + } + } + } + }) + + /* optionalArrayOf checks */ + keys.forEach(function (k) { + var name = 'optionalArrayOf' + _capitalize(k) + if (ndebug) { + out[name] = noop + return + } + var type = types[k] + var expected = '[' + k + ']' + out[name] = function (arg, msg) { + if (arg === undefined || arg === null) { + return + } + if (!Array.isArray(arg)) { + _toss(msg, expected, type.operator, arg, type.actual) + } + var i + for (i = 0; i < arg.length; i++) { + if (!type.check(arg[i])) { + _toss(msg, expected, type.operator, arg, type.actual) + } + } + } + }) + + /* re-export built-in assertions */ + Object.keys(assert).forEach(function (k) { + if (k === 'AssertionError') { + out[k] = assert[k] + return + } + if (ndebug) { + out[k] = noop + return + } + out[k] = assert[k] + }) + + /* export ourselves (for unit tests _only_) */ + out._setExports = _setExports + + return out + } + + module.exports = _setExports(process.env.NODE_NDEBUG) + + /***/ + }, + + /***/ 14812: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + module.exports = { + parallel: __webpack_require__(8210), + serial: __webpack_require__(50445), + serialOrdered: __webpack_require__(3578) + } + + /***/ + }, + + /***/ 1700: /***/ module => { + // API + module.exports = abort + + /** + * Aborts leftover active jobs + * + * @param {object} state - current state object + */ + function abort(state) { + Object.keys(state.jobs).forEach(clean.bind(state)) + + // reset leftover jobs + state.jobs = {} + } + + /** + * Cleans up leftover job by invoking abort function for the provided job id + * + * @this state + * @param {string|number} key - job id to abort + */ + function clean(key) { + if (typeof this.jobs[key] == 'function') { + this.jobs[key]() + } + } + + /***/ + }, + + /***/ 72794: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + var defer = __webpack_require__(15295) + + // API + module.exports = async + + /** + * Runs provided callback asynchronously + * even if callback itself is not + * + * @param {function} callback - callback to invoke + * @returns {function} - augmented callback + */ + function async(callback) { + var isAsync = false + + // check if async happened + defer(function () { + isAsync = true + }) + + return function async_callback(err, result) { + if (isAsync) { + callback(err, result) + } else { + defer(function nextTick_callback() { + callback(err, result) + }) + } + } + } + + /***/ + }, + + /***/ 15295: /***/ module => { + module.exports = defer + + /** + * Runs provided function on next iteration of the event loop + * + * @param {function} fn - function to run + */ + function defer(fn) { + var nextTick = + typeof setImmediate == 'function' + ? setImmediate + : typeof process == 'object' && + typeof process.nextTick == 'function' + ? process.nextTick + : null + + if (nextTick) { + nextTick(fn) + } else { + setTimeout(fn, 0) + } + } + + /***/ + }, + + /***/ 9023: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + var async = __webpack_require__(72794), + abort = __webpack_require__(1700) + // API + module.exports = iterate + + /** + * Iterates over each job object + * + * @param {array|object} list - array or object (named list) to iterate over + * @param {function} iterator - iterator to run + * @param {object} state - current job status + * @param {function} callback - invoked when all elements processed + */ + function iterate(list, iterator, state, callback) { + // store current index + var key = state['keyedList'] + ? state['keyedList'][state.index] + : state.index + + state.jobs[key] = runJob(iterator, key, list[key], function ( + error, + output + ) { + // don't repeat yourself + // skip secondary callbacks + if (!(key in state.jobs)) { + return + } + + // clean up jobs + delete state.jobs[key] + + if (error) { + // don't process rest of the results + // stop still active jobs + // and reset the list + abort(state) + } else { + state.results[key] = output + } + + // return salvaged results + callback(error, state.results) + }) + } + + /** + * Runs iterator over provided job element + * + * @param {function} iterator - iterator to invoke + * @param {string|number} key - key/index of the element in the list of jobs + * @param {mixed} item - job description + * @param {function} callback - invoked after iterator is done with the job + * @returns {function|mixed} - job abort function or something else + */ + function runJob(iterator, key, item, callback) { + var aborter + + // allow shortcut if iterator expects only two arguments + if (iterator.length == 2) { + aborter = iterator(item, async(callback)) + } + // otherwise go with full three arguments + else { + aborter = iterator(item, key, async(callback)) + } + + return aborter + } + + /***/ + }, + + /***/ 42474: /***/ module => { + // API + module.exports = state + + /** + * Creates initial state object + * for iteration over list + * + * @param {array|object} list - list to iterate over + * @param {function|null} sortMethod - function to use for keys sort, + * or `null` to keep them as is + * @returns {object} - initial state object + */ + function state(list, sortMethod) { + var isNamedList = !Array.isArray(list), + initState = { + index: 0, + keyedList: isNamedList || sortMethod ? Object.keys(list) : null, + jobs: {}, + results: isNamedList ? {} : [], + size: isNamedList ? Object.keys(list).length : list.length + } + if (sortMethod) { + // sort array keys based on it's values + // sort object's keys just on own merit + initState.keyedList.sort( + isNamedList + ? sortMethod + : function (a, b) { + return sortMethod(list[a], list[b]) + } + ) + } + + return initState + } + + /***/ + }, + + /***/ 37942: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + var abort = __webpack_require__(1700), + async = __webpack_require__(72794) + // API + module.exports = terminator + + /** + * Terminates jobs in the attached state context + * + * @this AsyncKitState# + * @param {function} callback - final callback to invoke after termination + */ + function terminator(callback) { + if (!Object.keys(this.jobs).length) { + return + } + + // fast forward iteration index + this.index = this.size + + // abort jobs + abort(this) + + // send back results we have so far + async(callback)(null, this.results) + } + + /***/ + }, + + /***/ 8210: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + var iterate = __webpack_require__(9023), + initState = __webpack_require__(42474), + terminator = __webpack_require__(37942) + // Public API + module.exports = parallel + + /** + * Runs iterator over provided array elements in parallel + * + * @param {array|object} list - array or object (named list) to iterate over + * @param {function} iterator - iterator to run + * @param {function} callback - invoked when all elements processed + * @returns {function} - jobs terminator + */ + function parallel(list, iterator, callback) { + var state = initState(list) + + while (state.index < (state['keyedList'] || list).length) { + iterate(list, iterator, state, function (error, result) { + if (error) { + callback(error, result) + return + } + + // looks like it's the last one + if (Object.keys(state.jobs).length === 0) { + callback(null, state.results) + return + } + }) + + state.index++ + } + + return terminator.bind(state, callback) + } + + /***/ + }, + + /***/ 50445: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + var serialOrdered = __webpack_require__(3578) + + // Public API + module.exports = serial + + /** + * Runs iterator over provided array elements in series + * + * @param {array|object} list - array or object (named list) to iterate over + * @param {function} iterator - iterator to run + * @param {function} callback - invoked when all elements processed + * @returns {function} - jobs terminator + */ + function serial(list, iterator, callback) { + return serialOrdered(list, iterator, null, callback) + } + + /***/ + }, + + /***/ 3578: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + var iterate = __webpack_require__(9023), + initState = __webpack_require__(42474), + terminator = __webpack_require__(37942) + // Public API + module.exports = serialOrdered + // sorting helpers + module.exports.ascending = ascending + module.exports.descending = descending + + /** + * Runs iterator over provided sorted array elements in series + * + * @param {array|object} list - array or object (named list) to iterate over + * @param {function} iterator - iterator to run + * @param {function} sortMethod - custom sort function + * @param {function} callback - invoked when all elements processed + * @returns {function} - jobs terminator + */ + function serialOrdered(list, iterator, sortMethod, callback) { + var state = initState(list, sortMethod) + + iterate(list, iterator, state, function iteratorHandler(error, result) { + if (error) { + callback(error, result) + return + } + + state.index++ + + // are we there yet? + if (state.index < (state['keyedList'] || list).length) { + iterate(list, iterator, state, iteratorHandler) + return + } + + // done here + callback(null, state.results) + }) + + return terminator.bind(state, callback) + } + + /* + * -- Sort methods + */ + + /** + * sort helper to sort array elements in ascending order + * + * @param {mixed} a - an item to compare + * @param {mixed} b - an item to compare + * @returns {number} - comparison result + */ + function ascending(a, b) { + return a < b ? -1 : a > b ? 1 : 0 + } + + /** + * sort helper to sort array elements in descending order + * + * @param {mixed} a - an item to compare + * @param {mixed} b - an item to compare + * @returns {number} - comparison result + */ + function descending(a, b) { + return -1 * ascending(a, b) + } + + /***/ + }, + + /***/ 55224: /***/ module => { + module.exports = function atob(str) { + return Buffer.from(str, 'base64').toString('binary') + } + + /***/ + }, + + /***/ 96342: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + /*! + * Copyright 2010 LearnBoost + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + /** + * Module dependencies. + */ + + var crypto = __webpack_require__(76417), + parse = __webpack_require__(78835).parse + /** + * Valid keys. + */ + + var keys = [ + 'acl', + 'location', + 'logging', + 'notification', + 'partNumber', + 'policy', + 'requestPayment', + 'torrent', + 'uploadId', + 'uploads', + 'versionId', + 'versioning', + 'versions', + 'website' + ] + + /** + * Return an "Authorization" header value with the given `options` + * in the form of "AWS :" + * + * @param {Object} options + * @return {String} + * @api private + */ + + function authorization(options) { + return 'AWS ' + options.key + ':' + sign(options) + } + + module.exports = authorization + module.exports.authorization = authorization + + /** + * Simple HMAC-SHA1 Wrapper + * + * @param {Object} options + * @return {String} + * @api private + */ + + function hmacSha1(options) { + return crypto + .createHmac('sha1', options.secret) + .update(options.message) + .digest('base64') + } + + module.exports.hmacSha1 = hmacSha1 + + /** + * Create a base64 sha1 HMAC for `options`. + * + * @param {Object} options + * @return {String} + * @api private + */ + + function sign(options) { + options.message = stringToSign(options) + return hmacSha1(options) + } + module.exports.sign = sign + + /** + * Create a base64 sha1 HMAC for `options`. + * + * Specifically to be used with S3 presigned URLs + * + * @param {Object} options + * @return {String} + * @api private + */ + + function signQuery(options) { + options.message = queryStringToSign(options) + return hmacSha1(options) + } + module.exports.signQuery = signQuery + + /** + * Return a string for sign() with the given `options`. + * + * Spec: + * + * \n + * \n + * \n + * \n + * [headers\n] + * + * + * @param {Object} options + * @return {String} + * @api private + */ + + function stringToSign(options) { + var headers = options.amazonHeaders || '' + if (headers) headers += '\n' + var r = [ + options.verb, + options.md5, + options.contentType, + options.date ? options.date.toUTCString() : '', + headers + options.resource + ] + return r.join('\n') + } + module.exports.stringToSign = stringToSign + + /** + * Return a string for sign() with the given `options`, but is meant exclusively + * for S3 presigned URLs + * + * Spec: + * + * \n + * + * + * @param {Object} options + * @return {String} + * @api private + */ + + function queryStringToSign(options) { + return 'GET\n\n\n' + options.date + '\n' + options.resource + } + module.exports.queryStringToSign = queryStringToSign + + /** + * Perform the following: + * + * - ignore non-amazon headers + * - lowercase fields + * - sort lexicographically + * - trim whitespace between ":" + * - join with newline + * + * @param {Object} headers + * @return {String} + * @api private + */ + + function canonicalizeHeaders(headers) { + var buf = [], + fields = Object.keys(headers) + for (var i = 0, len = fields.length; i < len; ++i) { + var field = fields[i], + val = headers[field], + field = field.toLowerCase() + if (0 !== field.indexOf('x-amz')) continue + buf.push(field + ':' + val) + } + return buf.sort().join('\n') + } + module.exports.canonicalizeHeaders = canonicalizeHeaders + + /** + * Perform the following: + * + * - ignore non sub-resources + * - sort lexicographically + * + * @param {String} resource + * @return {String} + * @api private + */ + + function canonicalizeResource(resource) { + var url = parse(resource, true), + path = url.pathname, + buf = [] + Object.keys(url.query).forEach(function (key) { + if (!~keys.indexOf(key)) return + var val = + '' == url.query[key] ? '' : '=' + encodeURIComponent(url.query[key]) + buf.push(key + val) + }) + + return path + (buf.length ? '?' + buf.sort().join('&') : '') + } + module.exports.canonicalizeResource = canonicalizeResource + + /***/ + }, + + /***/ 16071: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + var aws4 = exports, + url = __webpack_require__(78835), + querystring = __webpack_require__(71191), + crypto = __webpack_require__(76417), + lru = __webpack_require__(74225), + credentialsCache = lru(1000) + + // http://docs.amazonwebservices.com/general/latest/gr/signature-version-4.html + + function hmac(key, string, encoding) { + return crypto + .createHmac('sha256', key) + .update(string, 'utf8') + .digest(encoding) + } + + function hash(string, encoding) { + return crypto + .createHash('sha256') + .update(string, 'utf8') + .digest(encoding) + } + + // This function assumes the string has already been percent encoded + function encodeRfc3986(urlEncodedString) { + return urlEncodedString.replace(/[!'()*]/g, function (c) { + return '%' + c.charCodeAt(0).toString(16).toUpperCase() + }) + } + + function encodeRfc3986Full(str) { + return encodeRfc3986(encodeURIComponent(str)) + } + + // A bit of a combination of: + // https://github.com/aws/aws-sdk-java-v2/blob/dc695de6ab49ad03934e1b02e7263abbd2354be0/core/auth/src/main/java/software/amazon/awssdk/auth/signer/internal/AbstractAws4Signer.java#L59 + // https://github.com/aws/aws-sdk-js/blob/18cb7e5b463b46239f9fdd4a65e2ff8c81831e8f/lib/signers/v4.js#L191-L199 + // https://github.com/mhart/aws4fetch/blob/b3aed16b6f17384cf36ea33bcba3c1e9f3bdfefd/src/main.js#L25-L34 + var HEADERS_TO_IGNORE = { + authorization: true, + connection: true, + 'x-amzn-trace-id': true, + 'user-agent': true, + expect: true, + 'presigned-expires': true, + range: true + } + + // request: { path | body, [host], [method], [headers], [service], [region] } + // credentials: { accessKeyId, secretAccessKey, [sessionToken] } + function RequestSigner(request, credentials) { + if (typeof request === 'string') request = url.parse(request) + + var headers = (request.headers = request.headers || {}), + hostParts = + (!this.service || !this.region) && + this.matchHost( + request.hostname || request.host || headers.Host || headers.host + ) + + this.request = request + this.credentials = credentials || this.defaultCredentials() + + this.service = request.service || hostParts[0] || '' + this.region = request.region || hostParts[1] || 'us-east-1' + + // SES uses a different domain from the service name + if (this.service === 'email') this.service = 'ses' + + if (!request.method && request.body) request.method = 'POST' + + if (!headers.Host && !headers.host) { + headers.Host = request.hostname || request.host || this.createHost() + + // If a port is specified explicitly, use it as is + if (request.port) headers.Host += ':' + request.port + } + if (!request.hostname && !request.host) + request.hostname = headers.Host || headers.host + + this.isCodeCommitGit = + this.service === 'codecommit' && request.method === 'GIT' + } + + RequestSigner.prototype.matchHost = function (host) { + var match = (host || '').match( + /([^\.]+)\.(?:([^\.]*)\.)?amazonaws\.com(\.cn)?$/ + ) + var hostParts = (match || []).slice(1, 3) + + // ES's hostParts are sometimes the other way round, if the value that is expected + // to be region equals ‘es’ switch them back + // e.g. search-cluster-name-aaaa00aaaa0aaa0aaaaaaa0aaa.us-east-1.es.amazonaws.com + if (hostParts[1] === 'es') hostParts = hostParts.reverse() + + if (hostParts[1] == 's3') { + hostParts[0] = 's3' + hostParts[1] = 'us-east-1' + } else { + for (var i = 0; i < 2; i++) { + if (/^s3-/.test(hostParts[i])) { + hostParts[1] = hostParts[i].slice(3) + hostParts[0] = 's3' + break + } + } + } + + return hostParts + } + + // http://docs.aws.amazon.com/general/latest/gr/rande.html + RequestSigner.prototype.isSingleRegion = function () { + // Special case for S3 and SimpleDB in us-east-1 + if ( + ['s3', 'sdb'].indexOf(this.service) >= 0 && + this.region === 'us-east-1' + ) + return true + + return ( + ['cloudfront', 'ls', 'route53', 'iam', 'importexport', 'sts'].indexOf( + this.service + ) >= 0 + ) + } + + RequestSigner.prototype.createHost = function () { + var region = this.isSingleRegion() ? '' : '.' + this.region, + subdomain = this.service === 'ses' ? 'email' : this.service + return subdomain + region + '.amazonaws.com' + } + + RequestSigner.prototype.prepareRequest = function () { + this.parsePath() + + var request = this.request, + headers = request.headers, + query + + if (request.signQuery) { + this.parsedPath.query = query = this.parsedPath.query || {} + + if (this.credentials.sessionToken) + query['X-Amz-Security-Token'] = this.credentials.sessionToken + + if (this.service === 's3' && !query['X-Amz-Expires']) + query['X-Amz-Expires'] = 86400 + + if (query['X-Amz-Date']) this.datetime = query['X-Amz-Date'] + else query['X-Amz-Date'] = this.getDateTime() + + query['X-Amz-Algorithm'] = 'AWS4-HMAC-SHA256' + query['X-Amz-Credential'] = + this.credentials.accessKeyId + '/' + this.credentialString() + query['X-Amz-SignedHeaders'] = this.signedHeaders() + } else { + if (!request.doNotModifyHeaders && !this.isCodeCommitGit) { + if ( + request.body && + !headers['Content-Type'] && + !headers['content-type'] + ) + headers['Content-Type'] = + 'application/x-www-form-urlencoded; charset=utf-8' + + if ( + request.body && + !headers['Content-Length'] && + !headers['content-length'] + ) + headers['Content-Length'] = Buffer.byteLength(request.body) + + if ( + this.credentials.sessionToken && + !headers['X-Amz-Security-Token'] && + !headers['x-amz-security-token'] + ) + headers['X-Amz-Security-Token'] = this.credentials.sessionToken + + if ( + this.service === 's3' && + !headers['X-Amz-Content-Sha256'] && + !headers['x-amz-content-sha256'] + ) + headers['X-Amz-Content-Sha256'] = hash( + this.request.body || '', + 'hex' + ) + + if (headers['X-Amz-Date'] || headers['x-amz-date']) + this.datetime = headers['X-Amz-Date'] || headers['x-amz-date'] + else headers['X-Amz-Date'] = this.getDateTime() + } + + delete headers.Authorization + delete headers.authorization + } + } + + RequestSigner.prototype.sign = function () { + if (!this.parsedPath) this.prepareRequest() + + if (this.request.signQuery) { + this.parsedPath.query['X-Amz-Signature'] = this.signature() + } else { + this.request.headers.Authorization = this.authHeader() + } + + this.request.path = this.formatPath() + + return this.request + } + + RequestSigner.prototype.getDateTime = function () { + if (!this.datetime) { + var headers = this.request.headers, + date = new Date(headers.Date || headers.date || new Date()) + + this.datetime = date.toISOString().replace(/[:\-]|\.\d{3}/g, '') + + // Remove the trailing 'Z' on the timestamp string for CodeCommit git access + if (this.isCodeCommitGit) this.datetime = this.datetime.slice(0, -1) + } + return this.datetime + } + + RequestSigner.prototype.getDate = function () { + return this.getDateTime().substr(0, 8) + } + + RequestSigner.prototype.authHeader = function () { + return [ + 'AWS4-HMAC-SHA256 Credential=' + + this.credentials.accessKeyId + + '/' + + this.credentialString(), + 'SignedHeaders=' + this.signedHeaders(), + 'Signature=' + this.signature() + ].join(', ') + } + + RequestSigner.prototype.signature = function () { + var date = this.getDate(), + cacheKey = [ + this.credentials.secretAccessKey, + date, + this.region, + this.service + ].join(), + kDate, + kRegion, + kService, + kCredentials = credentialsCache.get(cacheKey) + if (!kCredentials) { + kDate = hmac('AWS4' + this.credentials.secretAccessKey, date) + kRegion = hmac(kDate, this.region) + kService = hmac(kRegion, this.service) + kCredentials = hmac(kService, 'aws4_request') + credentialsCache.set(cacheKey, kCredentials) + } + return hmac(kCredentials, this.stringToSign(), 'hex') + } + + RequestSigner.prototype.stringToSign = function () { + return [ + 'AWS4-HMAC-SHA256', + this.getDateTime(), + this.credentialString(), + hash(this.canonicalString(), 'hex') + ].join('\n') + } + + RequestSigner.prototype.canonicalString = function () { + if (!this.parsedPath) this.prepareRequest() + + var pathStr = this.parsedPath.path, + query = this.parsedPath.query, + headers = this.request.headers, + queryStr = '', + normalizePath = this.service !== 's3', + decodePath = this.service === 's3' || this.request.doNotEncodePath, + decodeSlashesInPath = this.service === 's3', + firstValOnly = this.service === 's3', + bodyHash + + if (this.service === 's3' && this.request.signQuery) { + bodyHash = 'UNSIGNED-PAYLOAD' + } else if (this.isCodeCommitGit) { + bodyHash = '' + } else { + bodyHash = + headers['X-Amz-Content-Sha256'] || + headers['x-amz-content-sha256'] || + hash(this.request.body || '', 'hex') + } + + if (query) { + var reducedQuery = Object.keys(query).reduce(function (obj, key) { + if (!key) return obj + obj[encodeRfc3986Full(key)] = !Array.isArray(query[key]) + ? query[key] + : firstValOnly + ? query[key][0] + : query[key] + return obj + }, {}) + var encodedQueryPieces = [] + Object.keys(reducedQuery) + .sort() + .forEach(function (key) { + if (!Array.isArray(reducedQuery[key])) { + encodedQueryPieces.push( + key + '=' + encodeRfc3986Full(reducedQuery[key]) + ) + } else { + reducedQuery[key] + .map(encodeRfc3986Full) + .sort() + .forEach(function (val) { + encodedQueryPieces.push(key + '=' + val) + }) + } + }) + queryStr = encodedQueryPieces.join('&') + } + if (pathStr !== '/') { + if (normalizePath) pathStr = pathStr.replace(/\/{2,}/g, '/') + pathStr = pathStr + .split('/') + .reduce(function (path, piece) { + if (normalizePath && piece === '..') { + path.pop() + } else if (!normalizePath || piece !== '.') { + if (decodePath) + piece = decodeURIComponent(piece.replace(/\+/g, ' ')) + path.push(encodeRfc3986Full(piece)) + } + return path + }, []) + .join('/') + if (pathStr[0] !== '/') pathStr = '/' + pathStr + if (decodeSlashesInPath) pathStr = pathStr.replace(/%2F/g, '/') + } + + return [ + this.request.method || 'GET', + pathStr, + queryStr, + this.canonicalHeaders() + '\n', + this.signedHeaders(), + bodyHash + ].join('\n') + } + + RequestSigner.prototype.canonicalHeaders = function () { + var headers = this.request.headers + function trimAll(header) { + return header.toString().trim().replace(/\s+/g, ' ') + } + return Object.keys(headers) + .filter(function (key) { + return HEADERS_TO_IGNORE[key.toLowerCase()] == null + }) + .sort(function (a, b) { + return a.toLowerCase() < b.toLowerCase() ? -1 : 1 + }) + .map(function (key) { + return key.toLowerCase() + ':' + trimAll(headers[key]) + }) + .join('\n') + } + + RequestSigner.prototype.signedHeaders = function () { + return Object.keys(this.request.headers) + .map(function (key) { + return key.toLowerCase() + }) + .filter(function (key) { + return HEADERS_TO_IGNORE[key] == null + }) + .sort() + .join(';') + } + + RequestSigner.prototype.credentialString = function () { + return [this.getDate(), this.region, this.service, 'aws4_request'].join( + '/' + ) + } + + RequestSigner.prototype.defaultCredentials = function () { + var env = process.env + return { + accessKeyId: env.AWS_ACCESS_KEY_ID || env.AWS_ACCESS_KEY, + secretAccessKey: env.AWS_SECRET_ACCESS_KEY || env.AWS_SECRET_KEY, + sessionToken: env.AWS_SESSION_TOKEN + } + } + + RequestSigner.prototype.parsePath = function () { + var path = this.request.path || '/' + + // S3 doesn't always encode characters > 127 correctly and + // all services don't encode characters > 255 correctly + // So if there are non-reserved chars (and it's not already all % encoded), just encode them all + if (/[^0-9A-Za-z;,/?:@&=+$\-_.!~*'()#%]/.test(path)) { + path = encodeURI(decodeURI(path)) + } + + var queryIx = path.indexOf('?'), + query = null + + if (queryIx >= 0) { + query = querystring.parse(path.slice(queryIx + 1)) + path = path.slice(0, queryIx) + } + + this.parsedPath = { + path: path, + query: query + } + } + + RequestSigner.prototype.formatPath = function () { + var path = this.parsedPath.path, + query = this.parsedPath.query + + if (!query) return path + + // Services don't support empty query string keys + if (query[''] != null) delete query[''] + + return path + '?' + encodeRfc3986(querystring.stringify(query)) + } + + aws4.RequestSigner = RequestSigner + + aws4.sign = function (request, credentials) { + return new RequestSigner(request, credentials).sign() + } + + /***/ + }, + + /***/ 74225: /***/ module => { + module.exports = function (size) { + return new LruCache(size) + } + + function LruCache(size) { + this.capacity = size | 0 + this.map = Object.create(null) + this.list = new DoublyLinkedList() + } + + LruCache.prototype.get = function (key) { + var node = this.map[key] + if (node == null) return undefined + this.used(node) + return node.val + } + + LruCache.prototype.set = function (key, val) { + var node = this.map[key] + if (node != null) { + node.val = val + } else { + if (!this.capacity) this.prune() + if (!this.capacity) return false + node = new DoublyLinkedNode(key, val) + this.map[key] = node + this.capacity-- + } + this.used(node) + return true + } + + LruCache.prototype.used = function (node) { + this.list.moveToFront(node) + } + + LruCache.prototype.prune = function () { + var node = this.list.pop() + if (node != null) { + delete this.map[node.key] + this.capacity++ + } + } + + function DoublyLinkedList() { + this.firstNode = null + this.lastNode = null + } + + DoublyLinkedList.prototype.moveToFront = function (node) { + if (this.firstNode == node) return + + this.remove(node) + + if (this.firstNode == null) { + this.firstNode = node + this.lastNode = node + node.prev = null + node.next = null + } else { + node.prev = null + node.next = this.firstNode + node.next.prev = node + this.firstNode = node + } + } + + DoublyLinkedList.prototype.pop = function () { + var lastNode = this.lastNode + if (lastNode != null) { + this.remove(lastNode) + } + return lastNode + } + + DoublyLinkedList.prototype.remove = function (node) { + if (this.firstNode == node) { + this.firstNode = node.next + } else if (node.prev != null) { + node.prev.next = node.next + } + if (this.lastNode == node) { + this.lastNode = node.prev + } else if (node.next != null) { + node.next.prev = node.prev + } + } + + function DoublyLinkedNode(key, val) { + this.key = key + this.val = val + this.prev = null + this.next = null + } + + /***/ + }, + + /***/ 9417: /***/ module => { + 'use strict' + + module.exports = balanced + function balanced(a, b, str) { + if (a instanceof RegExp) a = maybeMatch(a, str) + if (b instanceof RegExp) b = maybeMatch(b, str) + + var r = range(a, b, str) + + return ( + r && { + start: r[0], + end: r[1], + pre: str.slice(0, r[0]), + body: str.slice(r[0] + a.length, r[1]), + post: str.slice(r[1] + b.length) + } + ) + } + + function maybeMatch(reg, str) { + var m = str.match(reg) + return m ? m[0] : null + } + + balanced.range = range + function range(a, b, str) { + var begs, beg, left, right, result + var ai = str.indexOf(a) + var bi = str.indexOf(b, ai + 1) + var i = ai + + if (ai >= 0 && bi > 0) { + begs = [] + left = str.length + + while (i >= 0 && !result) { + if (i == ai) { + begs.push(i) + ai = str.indexOf(a, i + 1) + } else if (begs.length == 1) { + result = [begs.pop(), bi] + } else { + beg = begs.pop() + if (beg < left) { + left = beg + right = bi + } + + bi = str.indexOf(b, i + 1) + } + + i = ai < bi && ai >= 0 ? ai : bi + } + + if (begs.length) { + result = [left, right] + } + } + + return result + } + + /***/ + }, + + /***/ 26463: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + exports.byteLength = byteLength + exports.toByteArray = toByteArray + exports.fromByteArray = fromByteArray + + var lookup = [] + var revLookup = [] + var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array + + var code = + 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' + for (var i = 0, len = code.length; i < len; ++i) { + lookup[i] = code[i] + revLookup[code.charCodeAt(i)] = i + } + + // Support decoding URL-safe base64 strings, as Node.js does. + // See: https://en.wikipedia.org/wiki/Base64#URL_applications + revLookup['-'.charCodeAt(0)] = 62 + revLookup['_'.charCodeAt(0)] = 63 + + function getLens(b64) { + var len = b64.length + + if (len % 4 > 0) { + throw new Error('Invalid string. Length must be a multiple of 4') + } + + // Trim off extra bytes after placeholder bytes are found + // See: https://github.com/beatgammit/base64-js/issues/42 + var validLen = b64.indexOf('=') + if (validLen === -1) validLen = len + + var placeHoldersLen = validLen === len ? 0 : 4 - (validLen % 4) + + return [validLen, placeHoldersLen] + } + + // base64 is 4/3 + up to two characters of the original data + function byteLength(b64) { + var lens = getLens(b64) + var validLen = lens[0] + var placeHoldersLen = lens[1] + return ((validLen + placeHoldersLen) * 3) / 4 - placeHoldersLen + } + + function _byteLength(b64, validLen, placeHoldersLen) { + return ((validLen + placeHoldersLen) * 3) / 4 - placeHoldersLen + } + + function toByteArray(b64) { + var tmp + var lens = getLens(b64) + var validLen = lens[0] + var placeHoldersLen = lens[1] + + var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)) + + var curByte = 0 + + // if there are placeholders, only get up to the last complete 4 chars + var len = placeHoldersLen > 0 ? validLen - 4 : validLen + + var i + for (i = 0; i < len; i += 4) { + tmp = + (revLookup[b64.charCodeAt(i)] << 18) | + (revLookup[b64.charCodeAt(i + 1)] << 12) | + (revLookup[b64.charCodeAt(i + 2)] << 6) | + revLookup[b64.charCodeAt(i + 3)] + arr[curByte++] = (tmp >> 16) & 0xff + arr[curByte++] = (tmp >> 8) & 0xff + arr[curByte++] = tmp & 0xff + } + + if (placeHoldersLen === 2) { + tmp = + (revLookup[b64.charCodeAt(i)] << 2) | + (revLookup[b64.charCodeAt(i + 1)] >> 4) + arr[curByte++] = tmp & 0xff + } + + if (placeHoldersLen === 1) { + tmp = + (revLookup[b64.charCodeAt(i)] << 10) | + (revLookup[b64.charCodeAt(i + 1)] << 4) | + (revLookup[b64.charCodeAt(i + 2)] >> 2) + arr[curByte++] = (tmp >> 8) & 0xff + arr[curByte++] = tmp & 0xff + } + + return arr + } + + function tripletToBase64(num) { + return ( + lookup[(num >> 18) & 0x3f] + + lookup[(num >> 12) & 0x3f] + + lookup[(num >> 6) & 0x3f] + + lookup[num & 0x3f] + ) + } + + function encodeChunk(uint8, start, end) { + var tmp + var output = [] + for (var i = start; i < end; i += 3) { + tmp = + ((uint8[i] << 16) & 0xff0000) + + ((uint8[i + 1] << 8) & 0xff00) + + (uint8[i + 2] & 0xff) + output.push(tripletToBase64(tmp)) + } + return output.join('') + } + + function fromByteArray(uint8) { + var tmp + var len = uint8.length + var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes + var parts = [] + var maxChunkLength = 16383 // must be multiple of 3 + + // go through the array every three bytes, we'll deal with trailing stuff later + for ( + var i = 0, len2 = len - extraBytes; + i < len2; + i += maxChunkLength + ) { + parts.push( + encodeChunk( + uint8, + i, + i + maxChunkLength > len2 ? len2 : i + maxChunkLength + ) + ) + } + + // pad the end with zeros, but make sure to not forget the extra bytes + if (extraBytes === 1) { + tmp = uint8[len - 1] + parts.push(lookup[tmp >> 2] + lookup[(tmp << 4) & 0x3f] + '==') + } else if (extraBytes === 2) { + tmp = (uint8[len - 2] << 8) + uint8[len - 1] + parts.push( + lookup[tmp >> 10] + + lookup[(tmp >> 4) & 0x3f] + + lookup[(tmp << 2) & 0x3f] + + '=' + ) + } + + return parts.join('') + } + + /***/ + }, + + /***/ 45447: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + 'use strict' + + var crypto_hash_sha512 = __webpack_require__(68729).lowlevel.crypto_hash + + /* + * This file is a 1:1 port from the OpenBSD blowfish.c and bcrypt_pbkdf.c. As a + * result, it retains the original copyright and license. The two files are + * under slightly different (but compatible) licenses, and are here combined in + * one file. + * + * Credit for the actual porting work goes to: + * Devi Mandiri + */ + + /* + * The Blowfish portions are under the following license: + * + * Blowfish block cipher for OpenBSD + * Copyright 1997 Niels Provos + * All rights reserved. + * + * Implementation advice by David Mazieres . + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + /* + * The bcrypt_pbkdf portions are under the following license: + * + * Copyright (c) 2013 Ted Unangst + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + /* + * Performance improvements (Javascript-specific): + * + * Copyright 2016, Joyent Inc + * Author: Alex Wilson + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + // Ported from OpenBSD bcrypt_pbkdf.c v1.9 + + var BLF_J = 0 + + var Blowfish = function () { + this.S = [ + new Uint32Array([ + 0xd1310ba6, + 0x98dfb5ac, + 0x2ffd72db, + 0xd01adfb7, + 0xb8e1afed, + 0x6a267e96, + 0xba7c9045, + 0xf12c7f99, + 0x24a19947, + 0xb3916cf7, + 0x0801f2e2, + 0x858efc16, + 0x636920d8, + 0x71574e69, + 0xa458fea3, + 0xf4933d7e, + 0x0d95748f, + 0x728eb658, + 0x718bcd58, + 0x82154aee, + 0x7b54a41d, + 0xc25a59b5, + 0x9c30d539, + 0x2af26013, + 0xc5d1b023, + 0x286085f0, + 0xca417918, + 0xb8db38ef, + 0x8e79dcb0, + 0x603a180e, + 0x6c9e0e8b, + 0xb01e8a3e, + 0xd71577c1, + 0xbd314b27, + 0x78af2fda, + 0x55605c60, + 0xe65525f3, + 0xaa55ab94, + 0x57489862, + 0x63e81440, + 0x55ca396a, + 0x2aab10b6, + 0xb4cc5c34, + 0x1141e8ce, + 0xa15486af, + 0x7c72e993, + 0xb3ee1411, + 0x636fbc2a, + 0x2ba9c55d, + 0x741831f6, + 0xce5c3e16, + 0x9b87931e, + 0xafd6ba33, + 0x6c24cf5c, + 0x7a325381, + 0x28958677, + 0x3b8f4898, + 0x6b4bb9af, + 0xc4bfe81b, + 0x66282193, + 0x61d809cc, + 0xfb21a991, + 0x487cac60, + 0x5dec8032, + 0xef845d5d, + 0xe98575b1, + 0xdc262302, + 0xeb651b88, + 0x23893e81, + 0xd396acc5, + 0x0f6d6ff3, + 0x83f44239, + 0x2e0b4482, + 0xa4842004, + 0x69c8f04a, + 0x9e1f9b5e, + 0x21c66842, + 0xf6e96c9a, + 0x670c9c61, + 0xabd388f0, + 0x6a51a0d2, + 0xd8542f68, + 0x960fa728, + 0xab5133a3, + 0x6eef0b6c, + 0x137a3be4, + 0xba3bf050, + 0x7efb2a98, + 0xa1f1651d, + 0x39af0176, + 0x66ca593e, + 0x82430e88, + 0x8cee8619, + 0x456f9fb4, + 0x7d84a5c3, + 0x3b8b5ebe, + 0xe06f75d8, + 0x85c12073, + 0x401a449f, + 0x56c16aa6, + 0x4ed3aa62, + 0x363f7706, + 0x1bfedf72, + 0x429b023d, + 0x37d0d724, + 0xd00a1248, + 0xdb0fead3, + 0x49f1c09b, + 0x075372c9, + 0x80991b7b, + 0x25d479d8, + 0xf6e8def7, + 0xe3fe501a, + 0xb6794c3b, + 0x976ce0bd, + 0x04c006ba, + 0xc1a94fb6, + 0x409f60c4, + 0x5e5c9ec2, + 0x196a2463, + 0x68fb6faf, + 0x3e6c53b5, + 0x1339b2eb, + 0x3b52ec6f, + 0x6dfc511f, + 0x9b30952c, + 0xcc814544, + 0xaf5ebd09, + 0xbee3d004, + 0xde334afd, + 0x660f2807, + 0x192e4bb3, + 0xc0cba857, + 0x45c8740f, + 0xd20b5f39, + 0xb9d3fbdb, + 0x5579c0bd, + 0x1a60320a, + 0xd6a100c6, + 0x402c7279, + 0x679f25fe, + 0xfb1fa3cc, + 0x8ea5e9f8, + 0xdb3222f8, + 0x3c7516df, + 0xfd616b15, + 0x2f501ec8, + 0xad0552ab, + 0x323db5fa, + 0xfd238760, + 0x53317b48, + 0x3e00df82, + 0x9e5c57bb, + 0xca6f8ca0, + 0x1a87562e, + 0xdf1769db, + 0xd542a8f6, + 0x287effc3, + 0xac6732c6, + 0x8c4f5573, + 0x695b27b0, + 0xbbca58c8, + 0xe1ffa35d, + 0xb8f011a0, + 0x10fa3d98, + 0xfd2183b8, + 0x4afcb56c, + 0x2dd1d35b, + 0x9a53e479, + 0xb6f84565, + 0xd28e49bc, + 0x4bfb9790, + 0xe1ddf2da, + 0xa4cb7e33, + 0x62fb1341, + 0xcee4c6e8, + 0xef20cada, + 0x36774c01, + 0xd07e9efe, + 0x2bf11fb4, + 0x95dbda4d, + 0xae909198, + 0xeaad8e71, + 0x6b93d5a0, + 0xd08ed1d0, + 0xafc725e0, + 0x8e3c5b2f, + 0x8e7594b7, + 0x8ff6e2fb, + 0xf2122b64, + 0x8888b812, + 0x900df01c, + 0x4fad5ea0, + 0x688fc31c, + 0xd1cff191, + 0xb3a8c1ad, + 0x2f2f2218, + 0xbe0e1777, + 0xea752dfe, + 0x8b021fa1, + 0xe5a0cc0f, + 0xb56f74e8, + 0x18acf3d6, + 0xce89e299, + 0xb4a84fe0, + 0xfd13e0b7, + 0x7cc43b81, + 0xd2ada8d9, + 0x165fa266, + 0x80957705, + 0x93cc7314, + 0x211a1477, + 0xe6ad2065, + 0x77b5fa86, + 0xc75442f5, + 0xfb9d35cf, + 0xebcdaf0c, + 0x7b3e89a0, + 0xd6411bd3, + 0xae1e7e49, + 0x00250e2d, + 0x2071b35e, + 0x226800bb, + 0x57b8e0af, + 0x2464369b, + 0xf009b91e, + 0x5563911d, + 0x59dfa6aa, + 0x78c14389, + 0xd95a537f, + 0x207d5ba2, + 0x02e5b9c5, + 0x83260376, + 0x6295cfa9, + 0x11c81968, + 0x4e734a41, + 0xb3472dca, + 0x7b14a94a, + 0x1b510052, + 0x9a532915, + 0xd60f573f, + 0xbc9bc6e4, + 0x2b60a476, + 0x81e67400, + 0x08ba6fb5, + 0x571be91f, + 0xf296ec6b, + 0x2a0dd915, + 0xb6636521, + 0xe7b9f9b6, + 0xff34052e, + 0xc5855664, + 0x53b02d5d, + 0xa99f8fa1, + 0x08ba4799, + 0x6e85076a + ]), + new Uint32Array([ + 0x4b7a70e9, + 0xb5b32944, + 0xdb75092e, + 0xc4192623, + 0xad6ea6b0, + 0x49a7df7d, + 0x9cee60b8, + 0x8fedb266, + 0xecaa8c71, + 0x699a17ff, + 0x5664526c, + 0xc2b19ee1, + 0x193602a5, + 0x75094c29, + 0xa0591340, + 0xe4183a3e, + 0x3f54989a, + 0x5b429d65, + 0x6b8fe4d6, + 0x99f73fd6, + 0xa1d29c07, + 0xefe830f5, + 0x4d2d38e6, + 0xf0255dc1, + 0x4cdd2086, + 0x8470eb26, + 0x6382e9c6, + 0x021ecc5e, + 0x09686b3f, + 0x3ebaefc9, + 0x3c971814, + 0x6b6a70a1, + 0x687f3584, + 0x52a0e286, + 0xb79c5305, + 0xaa500737, + 0x3e07841c, + 0x7fdeae5c, + 0x8e7d44ec, + 0x5716f2b8, + 0xb03ada37, + 0xf0500c0d, + 0xf01c1f04, + 0x0200b3ff, + 0xae0cf51a, + 0x3cb574b2, + 0x25837a58, + 0xdc0921bd, + 0xd19113f9, + 0x7ca92ff6, + 0x94324773, + 0x22f54701, + 0x3ae5e581, + 0x37c2dadc, + 0xc8b57634, + 0x9af3dda7, + 0xa9446146, + 0x0fd0030e, + 0xecc8c73e, + 0xa4751e41, + 0xe238cd99, + 0x3bea0e2f, + 0x3280bba1, + 0x183eb331, + 0x4e548b38, + 0x4f6db908, + 0x6f420d03, + 0xf60a04bf, + 0x2cb81290, + 0x24977c79, + 0x5679b072, + 0xbcaf89af, + 0xde9a771f, + 0xd9930810, + 0xb38bae12, + 0xdccf3f2e, + 0x5512721f, + 0x2e6b7124, + 0x501adde6, + 0x9f84cd87, + 0x7a584718, + 0x7408da17, + 0xbc9f9abc, + 0xe94b7d8c, + 0xec7aec3a, + 0xdb851dfa, + 0x63094366, + 0xc464c3d2, + 0xef1c1847, + 0x3215d908, + 0xdd433b37, + 0x24c2ba16, + 0x12a14d43, + 0x2a65c451, + 0x50940002, + 0x133ae4dd, + 0x71dff89e, + 0x10314e55, + 0x81ac77d6, + 0x5f11199b, + 0x043556f1, + 0xd7a3c76b, + 0x3c11183b, + 0x5924a509, + 0xf28fe6ed, + 0x97f1fbfa, + 0x9ebabf2c, + 0x1e153c6e, + 0x86e34570, + 0xeae96fb1, + 0x860e5e0a, + 0x5a3e2ab3, + 0x771fe71c, + 0x4e3d06fa, + 0x2965dcb9, + 0x99e71d0f, + 0x803e89d6, + 0x5266c825, + 0x2e4cc978, + 0x9c10b36a, + 0xc6150eba, + 0x94e2ea78, + 0xa5fc3c53, + 0x1e0a2df4, + 0xf2f74ea7, + 0x361d2b3d, + 0x1939260f, + 0x19c27960, + 0x5223a708, + 0xf71312b6, + 0xebadfe6e, + 0xeac31f66, + 0xe3bc4595, + 0xa67bc883, + 0xb17f37d1, + 0x018cff28, + 0xc332ddef, + 0xbe6c5aa5, + 0x65582185, + 0x68ab9802, + 0xeecea50f, + 0xdb2f953b, + 0x2aef7dad, + 0x5b6e2f84, + 0x1521b628, + 0x29076170, + 0xecdd4775, + 0x619f1510, + 0x13cca830, + 0xeb61bd96, + 0x0334fe1e, + 0xaa0363cf, + 0xb5735c90, + 0x4c70a239, + 0xd59e9e0b, + 0xcbaade14, + 0xeecc86bc, + 0x60622ca7, + 0x9cab5cab, + 0xb2f3846e, + 0x648b1eaf, + 0x19bdf0ca, + 0xa02369b9, + 0x655abb50, + 0x40685a32, + 0x3c2ab4b3, + 0x319ee9d5, + 0xc021b8f7, + 0x9b540b19, + 0x875fa099, + 0x95f7997e, + 0x623d7da8, + 0xf837889a, + 0x97e32d77, + 0x11ed935f, + 0x16681281, + 0x0e358829, + 0xc7e61fd6, + 0x96dedfa1, + 0x7858ba99, + 0x57f584a5, + 0x1b227263, + 0x9b83c3ff, + 0x1ac24696, + 0xcdb30aeb, + 0x532e3054, + 0x8fd948e4, + 0x6dbc3128, + 0x58ebf2ef, + 0x34c6ffea, + 0xfe28ed61, + 0xee7c3c73, + 0x5d4a14d9, + 0xe864b7e3, + 0x42105d14, + 0x203e13e0, + 0x45eee2b6, + 0xa3aaabea, + 0xdb6c4f15, + 0xfacb4fd0, + 0xc742f442, + 0xef6abbb5, + 0x654f3b1d, + 0x41cd2105, + 0xd81e799e, + 0x86854dc7, + 0xe44b476a, + 0x3d816250, + 0xcf62a1f2, + 0x5b8d2646, + 0xfc8883a0, + 0xc1c7b6a3, + 0x7f1524c3, + 0x69cb7492, + 0x47848a0b, + 0x5692b285, + 0x095bbf00, + 0xad19489d, + 0x1462b174, + 0x23820e00, + 0x58428d2a, + 0x0c55f5ea, + 0x1dadf43e, + 0x233f7061, + 0x3372f092, + 0x8d937e41, + 0xd65fecf1, + 0x6c223bdb, + 0x7cde3759, + 0xcbee7460, + 0x4085f2a7, + 0xce77326e, + 0xa6078084, + 0x19f8509e, + 0xe8efd855, + 0x61d99735, + 0xa969a7aa, + 0xc50c06c2, + 0x5a04abfc, + 0x800bcadc, + 0x9e447a2e, + 0xc3453484, + 0xfdd56705, + 0x0e1e9ec9, + 0xdb73dbd3, + 0x105588cd, + 0x675fda79, + 0xe3674340, + 0xc5c43465, + 0x713e38d8, + 0x3d28f89e, + 0xf16dff20, + 0x153e21e7, + 0x8fb03d4a, + 0xe6e39f2b, + 0xdb83adf7 + ]), + new Uint32Array([ + 0xe93d5a68, + 0x948140f7, + 0xf64c261c, + 0x94692934, + 0x411520f7, + 0x7602d4f7, + 0xbcf46b2e, + 0xd4a20068, + 0xd4082471, + 0x3320f46a, + 0x43b7d4b7, + 0x500061af, + 0x1e39f62e, + 0x97244546, + 0x14214f74, + 0xbf8b8840, + 0x4d95fc1d, + 0x96b591af, + 0x70f4ddd3, + 0x66a02f45, + 0xbfbc09ec, + 0x03bd9785, + 0x7fac6dd0, + 0x31cb8504, + 0x96eb27b3, + 0x55fd3941, + 0xda2547e6, + 0xabca0a9a, + 0x28507825, + 0x530429f4, + 0x0a2c86da, + 0xe9b66dfb, + 0x68dc1462, + 0xd7486900, + 0x680ec0a4, + 0x27a18dee, + 0x4f3ffea2, + 0xe887ad8c, + 0xb58ce006, + 0x7af4d6b6, + 0xaace1e7c, + 0xd3375fec, + 0xce78a399, + 0x406b2a42, + 0x20fe9e35, + 0xd9f385b9, + 0xee39d7ab, + 0x3b124e8b, + 0x1dc9faf7, + 0x4b6d1856, + 0x26a36631, + 0xeae397b2, + 0x3a6efa74, + 0xdd5b4332, + 0x6841e7f7, + 0xca7820fb, + 0xfb0af54e, + 0xd8feb397, + 0x454056ac, + 0xba489527, + 0x55533a3a, + 0x20838d87, + 0xfe6ba9b7, + 0xd096954b, + 0x55a867bc, + 0xa1159a58, + 0xcca92963, + 0x99e1db33, + 0xa62a4a56, + 0x3f3125f9, + 0x5ef47e1c, + 0x9029317c, + 0xfdf8e802, + 0x04272f70, + 0x80bb155c, + 0x05282ce3, + 0x95c11548, + 0xe4c66d22, + 0x48c1133f, + 0xc70f86dc, + 0x07f9c9ee, + 0x41041f0f, + 0x404779a4, + 0x5d886e17, + 0x325f51eb, + 0xd59bc0d1, + 0xf2bcc18f, + 0x41113564, + 0x257b7834, + 0x602a9c60, + 0xdff8e8a3, + 0x1f636c1b, + 0x0e12b4c2, + 0x02e1329e, + 0xaf664fd1, + 0xcad18115, + 0x6b2395e0, + 0x333e92e1, + 0x3b240b62, + 0xeebeb922, + 0x85b2a20e, + 0xe6ba0d99, + 0xde720c8c, + 0x2da2f728, + 0xd0127845, + 0x95b794fd, + 0x647d0862, + 0xe7ccf5f0, + 0x5449a36f, + 0x877d48fa, + 0xc39dfd27, + 0xf33e8d1e, + 0x0a476341, + 0x992eff74, + 0x3a6f6eab, + 0xf4f8fd37, + 0xa812dc60, + 0xa1ebddf8, + 0x991be14c, + 0xdb6e6b0d, + 0xc67b5510, + 0x6d672c37, + 0x2765d43b, + 0xdcd0e804, + 0xf1290dc7, + 0xcc00ffa3, + 0xb5390f92, + 0x690fed0b, + 0x667b9ffb, + 0xcedb7d9c, + 0xa091cf0b, + 0xd9155ea3, + 0xbb132f88, + 0x515bad24, + 0x7b9479bf, + 0x763bd6eb, + 0x37392eb3, + 0xcc115979, + 0x8026e297, + 0xf42e312d, + 0x6842ada7, + 0xc66a2b3b, + 0x12754ccc, + 0x782ef11c, + 0x6a124237, + 0xb79251e7, + 0x06a1bbe6, + 0x4bfb6350, + 0x1a6b1018, + 0x11caedfa, + 0x3d25bdd8, + 0xe2e1c3c9, + 0x44421659, + 0x0a121386, + 0xd90cec6e, + 0xd5abea2a, + 0x64af674e, + 0xda86a85f, + 0xbebfe988, + 0x64e4c3fe, + 0x9dbc8057, + 0xf0f7c086, + 0x60787bf8, + 0x6003604d, + 0xd1fd8346, + 0xf6381fb0, + 0x7745ae04, + 0xd736fccc, + 0x83426b33, + 0xf01eab71, + 0xb0804187, + 0x3c005e5f, + 0x77a057be, + 0xbde8ae24, + 0x55464299, + 0xbf582e61, + 0x4e58f48f, + 0xf2ddfda2, + 0xf474ef38, + 0x8789bdc2, + 0x5366f9c3, + 0xc8b38e74, + 0xb475f255, + 0x46fcd9b9, + 0x7aeb2661, + 0x8b1ddf84, + 0x846a0e79, + 0x915f95e2, + 0x466e598e, + 0x20b45770, + 0x8cd55591, + 0xc902de4c, + 0xb90bace1, + 0xbb8205d0, + 0x11a86248, + 0x7574a99e, + 0xb77f19b6, + 0xe0a9dc09, + 0x662d09a1, + 0xc4324633, + 0xe85a1f02, + 0x09f0be8c, + 0x4a99a025, + 0x1d6efe10, + 0x1ab93d1d, + 0x0ba5a4df, + 0xa186f20f, + 0x2868f169, + 0xdcb7da83, + 0x573906fe, + 0xa1e2ce9b, + 0x4fcd7f52, + 0x50115e01, + 0xa70683fa, + 0xa002b5c4, + 0x0de6d027, + 0x9af88c27, + 0x773f8641, + 0xc3604c06, + 0x61a806b5, + 0xf0177a28, + 0xc0f586e0, + 0x006058aa, + 0x30dc7d62, + 0x11e69ed7, + 0x2338ea63, + 0x53c2dd94, + 0xc2c21634, + 0xbbcbee56, + 0x90bcb6de, + 0xebfc7da1, + 0xce591d76, + 0x6f05e409, + 0x4b7c0188, + 0x39720a3d, + 0x7c927c24, + 0x86e3725f, + 0x724d9db9, + 0x1ac15bb4, + 0xd39eb8fc, + 0xed545578, + 0x08fca5b5, + 0xd83d7cd3, + 0x4dad0fc4, + 0x1e50ef5e, + 0xb161e6f8, + 0xa28514d9, + 0x6c51133c, + 0x6fd5c7e7, + 0x56e14ec4, + 0x362abfce, + 0xddc6c837, + 0xd79a3234, + 0x92638212, + 0x670efa8e, + 0x406000e0 + ]), + new Uint32Array([ + 0x3a39ce37, + 0xd3faf5cf, + 0xabc27737, + 0x5ac52d1b, + 0x5cb0679e, + 0x4fa33742, + 0xd3822740, + 0x99bc9bbe, + 0xd5118e9d, + 0xbf0f7315, + 0xd62d1c7e, + 0xc700c47b, + 0xb78c1b6b, + 0x21a19045, + 0xb26eb1be, + 0x6a366eb4, + 0x5748ab2f, + 0xbc946e79, + 0xc6a376d2, + 0x6549c2c8, + 0x530ff8ee, + 0x468dde7d, + 0xd5730a1d, + 0x4cd04dc6, + 0x2939bbdb, + 0xa9ba4650, + 0xac9526e8, + 0xbe5ee304, + 0xa1fad5f0, + 0x6a2d519a, + 0x63ef8ce2, + 0x9a86ee22, + 0xc089c2b8, + 0x43242ef6, + 0xa51e03aa, + 0x9cf2d0a4, + 0x83c061ba, + 0x9be96a4d, + 0x8fe51550, + 0xba645bd6, + 0x2826a2f9, + 0xa73a3ae1, + 0x4ba99586, + 0xef5562e9, + 0xc72fefd3, + 0xf752f7da, + 0x3f046f69, + 0x77fa0a59, + 0x80e4a915, + 0x87b08601, + 0x9b09e6ad, + 0x3b3ee593, + 0xe990fd5a, + 0x9e34d797, + 0x2cf0b7d9, + 0x022b8b51, + 0x96d5ac3a, + 0x017da67d, + 0xd1cf3ed6, + 0x7c7d2d28, + 0x1f9f25cf, + 0xadf2b89b, + 0x5ad6b472, + 0x5a88f54c, + 0xe029ac71, + 0xe019a5e6, + 0x47b0acfd, + 0xed93fa9b, + 0xe8d3c48d, + 0x283b57cc, + 0xf8d56629, + 0x79132e28, + 0x785f0191, + 0xed756055, + 0xf7960e44, + 0xe3d35e8c, + 0x15056dd4, + 0x88f46dba, + 0x03a16125, + 0x0564f0bd, + 0xc3eb9e15, + 0x3c9057a2, + 0x97271aec, + 0xa93a072a, + 0x1b3f6d9b, + 0x1e6321f5, + 0xf59c66fb, + 0x26dcf319, + 0x7533d928, + 0xb155fdf5, + 0x03563482, + 0x8aba3cbb, + 0x28517711, + 0xc20ad9f8, + 0xabcc5167, + 0xccad925f, + 0x4de81751, + 0x3830dc8e, + 0x379d5862, + 0x9320f991, + 0xea7a90c2, + 0xfb3e7bce, + 0x5121ce64, + 0x774fbe32, + 0xa8b6e37e, + 0xc3293d46, + 0x48de5369, + 0x6413e680, + 0xa2ae0810, + 0xdd6db224, + 0x69852dfd, + 0x09072166, + 0xb39a460a, + 0x6445c0dd, + 0x586cdecf, + 0x1c20c8ae, + 0x5bbef7dd, + 0x1b588d40, + 0xccd2017f, + 0x6bb4e3bb, + 0xdda26a7e, + 0x3a59ff45, + 0x3e350a44, + 0xbcb4cdd5, + 0x72eacea8, + 0xfa6484bb, + 0x8d6612ae, + 0xbf3c6f47, + 0xd29be463, + 0x542f5d9e, + 0xaec2771b, + 0xf64e6370, + 0x740e0d8d, + 0xe75b1357, + 0xf8721671, + 0xaf537d5d, + 0x4040cb08, + 0x4eb4e2cc, + 0x34d2466a, + 0x0115af84, + 0xe1b00428, + 0x95983a1d, + 0x06b89fb4, + 0xce6ea048, + 0x6f3f3b82, + 0x3520ab82, + 0x011a1d4b, + 0x277227f8, + 0x611560b1, + 0xe7933fdc, + 0xbb3a792b, + 0x344525bd, + 0xa08839e1, + 0x51ce794b, + 0x2f32c9b7, + 0xa01fbac9, + 0xe01cc87e, + 0xbcc7d1f6, + 0xcf0111c3, + 0xa1e8aac7, + 0x1a908749, + 0xd44fbd9a, + 0xd0dadecb, + 0xd50ada38, + 0x0339c32a, + 0xc6913667, + 0x8df9317c, + 0xe0b12b4f, + 0xf79e59b7, + 0x43f5bb3a, + 0xf2d519ff, + 0x27d9459c, + 0xbf97222c, + 0x15e6fc2a, + 0x0f91fc71, + 0x9b941525, + 0xfae59361, + 0xceb69ceb, + 0xc2a86459, + 0x12baa8d1, + 0xb6c1075e, + 0xe3056a0c, + 0x10d25065, + 0xcb03a442, + 0xe0ec6e0e, + 0x1698db3b, + 0x4c98a0be, + 0x3278e964, + 0x9f1f9532, + 0xe0d392df, + 0xd3a0342b, + 0x8971f21e, + 0x1b0a7441, + 0x4ba3348c, + 0xc5be7120, + 0xc37632d8, + 0xdf359f8d, + 0x9b992f2e, + 0xe60b6f47, + 0x0fe3f11d, + 0xe54cda54, + 0x1edad891, + 0xce6279cf, + 0xcd3e7e6f, + 0x1618b166, + 0xfd2c1d05, + 0x848fd2c5, + 0xf6fb2299, + 0xf523f357, + 0xa6327623, + 0x93a83531, + 0x56cccd02, + 0xacf08162, + 0x5a75ebb5, + 0x6e163697, + 0x88d273cc, + 0xde966292, + 0x81b949d0, + 0x4c50901b, + 0x71c65614, + 0xe6c6c7bd, + 0x327a140a, + 0x45e1d006, + 0xc3f27b9a, + 0xc9aa53fd, + 0x62a80f00, + 0xbb25bfe2, + 0x35bdd2f6, + 0x71126905, + 0xb2040222, + 0xb6cbcf7c, + 0xcd769c2b, + 0x53113ec0, + 0x1640e3d3, + 0x38abbd60, + 0x2547adf0, + 0xba38209c, + 0xf746ce76, + 0x77afa1c5, + 0x20756060, + 0x85cbfe4e, + 0x8ae88dd8, + 0x7aaaf9b0, + 0x4cf9aa7e, + 0x1948c25c, + 0x02fb8a8c, + 0x01c36ae4, + 0xd6ebe1f9, + 0x90d4f869, + 0xa65cdea0, + 0x3f09252d, + 0xc208e69f, + 0xb74e6132, + 0xce77e25b, + 0x578fdfe3, + 0x3ac372e6 + ]) + ] + this.P = new Uint32Array([ + 0x243f6a88, + 0x85a308d3, + 0x13198a2e, + 0x03707344, + 0xa4093822, + 0x299f31d0, + 0x082efa98, + 0xec4e6c89, + 0x452821e6, + 0x38d01377, + 0xbe5466cf, + 0x34e90c6c, + 0xc0ac29b7, + 0xc97c50dd, + 0x3f84d5b5, + 0xb5470917, + 0x9216d5d9, + 0x8979fb1b + ]) + } + + function F(S, x8, i) { + return ( + ((S[0][x8[i + 3]] + S[1][x8[i + 2]]) ^ S[2][x8[i + 1]]) + S[3][x8[i]] + ) + } + + Blowfish.prototype.encipher = function (x, x8) { + if (x8 === undefined) { + x8 = new Uint8Array(x.buffer) + if (x.byteOffset !== 0) x8 = x8.subarray(x.byteOffset) + } + x[0] ^= this.P[0] + for (var i = 1; i < 16; i += 2) { + x[1] ^= F(this.S, x8, 0) ^ this.P[i] + x[0] ^= F(this.S, x8, 4) ^ this.P[i + 1] + } + var t = x[0] + x[0] = x[1] ^ this.P[17] + x[1] = t + } + + Blowfish.prototype.decipher = function (x) { + var x8 = new Uint8Array(x.buffer) + if (x.byteOffset !== 0) x8 = x8.subarray(x.byteOffset) + x[0] ^= this.P[17] + for (var i = 16; i > 0; i -= 2) { + x[1] ^= F(this.S, x8, 0) ^ this.P[i] + x[0] ^= F(this.S, x8, 4) ^ this.P[i - 1] + } + var t = x[0] + x[0] = x[1] ^ this.P[0] + x[1] = t + } + + function stream2word(data, databytes) { + var i, + temp = 0 + for (i = 0; i < 4; i++, BLF_J++) { + if (BLF_J >= databytes) BLF_J = 0 + temp = (temp << 8) | data[BLF_J] + } + return temp + } + + Blowfish.prototype.expand0state = function (key, keybytes) { + var d = new Uint32Array(2), + i, + k + var d8 = new Uint8Array(d.buffer) + + for (i = 0, BLF_J = 0; i < 18; i++) { + this.P[i] ^= stream2word(key, keybytes) + } + BLF_J = 0 + + for (i = 0; i < 18; i += 2) { + this.encipher(d, d8) + this.P[i] = d[0] + this.P[i + 1] = d[1] + } + + for (i = 0; i < 4; i++) { + for (k = 0; k < 256; k += 2) { + this.encipher(d, d8) + this.S[i][k] = d[0] + this.S[i][k + 1] = d[1] + } + } + } + + Blowfish.prototype.expandstate = function ( + data, + databytes, + key, + keybytes + ) { + var d = new Uint32Array(2), + i, + k + + for (i = 0, BLF_J = 0; i < 18; i++) { + this.P[i] ^= stream2word(key, keybytes) + } + + for (i = 0, BLF_J = 0; i < 18; i += 2) { + d[0] ^= stream2word(data, databytes) + d[1] ^= stream2word(data, databytes) + this.encipher(d) + this.P[i] = d[0] + this.P[i + 1] = d[1] + } + + for (i = 0; i < 4; i++) { + for (k = 0; k < 256; k += 2) { + d[0] ^= stream2word(data, databytes) + d[1] ^= stream2word(data, databytes) + this.encipher(d) + this.S[i][k] = d[0] + this.S[i][k + 1] = d[1] + } + } + BLF_J = 0 + } + + Blowfish.prototype.enc = function (data, blocks) { + for (var i = 0; i < blocks; i++) { + this.encipher(data.subarray(i * 2)) + } + } + + Blowfish.prototype.dec = function (data, blocks) { + for (var i = 0; i < blocks; i++) { + this.decipher(data.subarray(i * 2)) + } + } + + var BCRYPT_BLOCKS = 8, + BCRYPT_HASHSIZE = 32 + + function bcrypt_hash(sha2pass, sha2salt, out) { + var state = new Blowfish(), + cdata = new Uint32Array(BCRYPT_BLOCKS), + i, + ciphertext = new Uint8Array([ + 79, + 120, + 121, + 99, + 104, + 114, + 111, + 109, + 97, + 116, + 105, + 99, + 66, + 108, + 111, + 119, + 102, + 105, + 115, + 104, + 83, + 119, + 97, + 116, + 68, + 121, + 110, + 97, + 109, + 105, + 116, + 101 + ]) //"OxychromaticBlowfishSwatDynamite" + + state.expandstate(sha2salt, 64, sha2pass, 64) + for (i = 0; i < 64; i++) { + state.expand0state(sha2salt, 64) + state.expand0state(sha2pass, 64) + } + + for (i = 0; i < BCRYPT_BLOCKS; i++) + cdata[i] = stream2word(ciphertext, ciphertext.byteLength) + for (i = 0; i < 64; i++) state.enc(cdata, cdata.byteLength / 8) + + for (i = 0; i < BCRYPT_BLOCKS; i++) { + out[4 * i + 3] = cdata[i] >>> 24 + out[4 * i + 2] = cdata[i] >>> 16 + out[4 * i + 1] = cdata[i] >>> 8 + out[4 * i + 0] = cdata[i] + } + } + + function bcrypt_pbkdf(pass, passlen, salt, saltlen, key, keylen, rounds) { + var sha2pass = new Uint8Array(64), + sha2salt = new Uint8Array(64), + out = new Uint8Array(BCRYPT_HASHSIZE), + tmpout = new Uint8Array(BCRYPT_HASHSIZE), + countsalt = new Uint8Array(saltlen + 4), + i, + j, + amt, + stride, + dest, + count, + origkeylen = keylen + + if (rounds < 1) return -1 + if ( + passlen === 0 || + saltlen === 0 || + keylen === 0 || + keylen > out.byteLength * out.byteLength || + saltlen > 1 << 20 + ) + return -1 + + stride = Math.floor((keylen + out.byteLength - 1) / out.byteLength) + amt = Math.floor((keylen + stride - 1) / stride) + + for (i = 0; i < saltlen; i++) countsalt[i] = salt[i] + + crypto_hash_sha512(sha2pass, pass, passlen) + + for (count = 1; keylen > 0; count++) { + countsalt[saltlen + 0] = count >>> 24 + countsalt[saltlen + 1] = count >>> 16 + countsalt[saltlen + 2] = count >>> 8 + countsalt[saltlen + 3] = count + + crypto_hash_sha512(sha2salt, countsalt, saltlen + 4) + bcrypt_hash(sha2pass, sha2salt, tmpout) + for (i = out.byteLength; i--; ) out[i] = tmpout[i] + + for (i = 1; i < rounds; i++) { + crypto_hash_sha512(sha2salt, tmpout, tmpout.byteLength) + bcrypt_hash(sha2pass, sha2salt, tmpout) + for (j = 0; j < out.byteLength; j++) out[j] ^= tmpout[j] + } + + amt = Math.min(amt, keylen) + for (i = 0; i < amt; i++) { + dest = i * stride + (count - 1) + if (dest >= origkeylen) break + key[dest] = out[i] + } + keylen -= i + } + + return 0 + } + + module.exports = { + BLOCKS: BCRYPT_BLOCKS, + HASHSIZE: BCRYPT_HASHSIZE, + hash: bcrypt_hash, + pbkdf: bcrypt_pbkdf + } + + /***/ + }, + + /***/ 83682: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + var register = __webpack_require__(44670) + var addHook = __webpack_require__(5549) + var removeHook = __webpack_require__(6819) + + // bind with array of arguments: https://stackoverflow.com/a/21792913 + var bind = Function.bind + var bindable = bind.bind(bind) + + function bindApi(hook, state, name) { + var removeHookRef = bindable(removeHook, null).apply( + null, + name ? [state, name] : [state] + ) + hook.api = { remove: removeHookRef } + hook.remove = removeHookRef + ;['before', 'error', 'after', 'wrap'].forEach(function (kind) { + var args = name ? [state, kind, name] : [state, kind] + hook[kind] = hook.api[kind] = bindable(addHook, null).apply( + null, + args + ) + }) + } + + function HookSingular() { + var singularHookName = 'h' + var singularHookState = { + registry: {} + } + var singularHook = register.bind( + null, + singularHookState, + singularHookName + ) + bindApi(singularHook, singularHookState, singularHookName) + return singularHook + } + + function HookCollection() { + var state = { + registry: {} + } + + var hook = register.bind(null, state) + bindApi(hook, state) + + return hook + } + + var collectionHookDeprecationMessageDisplayed = false + function Hook() { + if (!collectionHookDeprecationMessageDisplayed) { + console.warn( + '[before-after-hook]: "Hook()" repurposing warning, use "Hook.Collection()". Read more: https://git.io/upgrade-before-after-hook-to-1.4' + ) + collectionHookDeprecationMessageDisplayed = true + } + return HookCollection() + } + + Hook.Singular = HookSingular.bind() + Hook.Collection = HookCollection.bind() + + module.exports = Hook + // expose constructors as a named property for TypeScript + module.exports.Hook = Hook + module.exports.Singular = Hook.Singular + module.exports.Collection = Hook.Collection + + /***/ + }, + + /***/ 5549: /***/ module => { + module.exports = addHook + + function addHook(state, kind, name, hook) { + var orig = hook + if (!state.registry[name]) { + state.registry[name] = [] + } + + if (kind === 'before') { + hook = function (method, options) { + return Promise.resolve() + .then(orig.bind(null, options)) + .then(method.bind(null, options)) + } + } + + if (kind === 'after') { + hook = function (method, options) { + var result + return Promise.resolve() + .then(method.bind(null, options)) + .then(function (result_) { + result = result_ + return orig(result, options) + }) + .then(function () { + return result + }) + } + } + + if (kind === 'error') { + hook = function (method, options) { + return Promise.resolve() + .then(method.bind(null, options)) + .catch(function (error) { + return orig(error, options) + }) + } + } + + state.registry[name].push({ + hook: hook, + orig: orig + }) + } + + /***/ + }, + + /***/ 44670: /***/ module => { + module.exports = register + + function register(state, name, method, options) { + if (typeof method !== 'function') { + throw new Error('method for before hook must be a function') + } + + if (!options) { + options = {} + } + + if (Array.isArray(name)) { + return name.reverse().reduce(function (callback, name) { + return register.bind(null, state, name, callback, options) + }, method)() + } + + return Promise.resolve().then(function () { + if (!state.registry[name]) { + return method(options) + } + + return state.registry[name].reduce(function (method, registered) { + return registered.hook.bind(null, method, options) + }, method)() + }) + } + + /***/ + }, + + /***/ 6819: /***/ module => { + module.exports = removeHook + + function removeHook(state, name, method) { + if (!state.registry[name]) { + return + } + + var index = state.registry[name] + .map(function (registered) { + return registered.orig + }) + .indexOf(method) + + if (index === -1) { + return + } + + state.registry[name].splice(index, 1) + } + + /***/ + }, + + /***/ 87558: /***/ function (module) { + ;(function (globalObject) { + 'use strict' + + /* + * bignumber.js v9.0.1 + * A JavaScript library for arbitrary-precision arithmetic. + * https://github.com/MikeMcl/bignumber.js + * Copyright (c) 2020 Michael Mclaughlin + * MIT Licensed. + * + * BigNumber.prototype methods | BigNumber methods + * | + * absoluteValue abs | clone + * comparedTo | config set + * decimalPlaces dp | DECIMAL_PLACES + * dividedBy div | ROUNDING_MODE + * dividedToIntegerBy idiv | EXPONENTIAL_AT + * exponentiatedBy pow | RANGE + * integerValue | CRYPTO + * isEqualTo eq | MODULO_MODE + * isFinite | POW_PRECISION + * isGreaterThan gt | FORMAT + * isGreaterThanOrEqualTo gte | ALPHABET + * isInteger | isBigNumber + * isLessThan lt | maximum max + * isLessThanOrEqualTo lte | minimum min + * isNaN | random + * isNegative | sum + * isPositive | + * isZero | + * minus | + * modulo mod | + * multipliedBy times | + * negated | + * plus | + * precision sd | + * shiftedBy | + * squareRoot sqrt | + * toExponential | + * toFixed | + * toFormat | + * toFraction | + * toJSON | + * toNumber | + * toPrecision | + * toString | + * valueOf | + * + */ + + var BigNumber, + isNumeric = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i, + mathceil = Math.ceil, + mathfloor = Math.floor, + bignumberError = '[BigNumber Error] ', + tooManyDigits = + bignumberError + + 'Number primitive has more than 15 significant digits: ', + BASE = 1e14, + LOG_BASE = 14, + MAX_SAFE_INTEGER = 0x1fffffffffffff, // 2^53 - 1 + // MAX_INT32 = 0x7fffffff, // 2^31 - 1 + POWS_TEN = [ + 1, + 10, + 100, + 1e3, + 1e4, + 1e5, + 1e6, + 1e7, + 1e8, + 1e9, + 1e10, + 1e11, + 1e12, + 1e13 + ], + SQRT_BASE = 1e7, + // EDITABLE + // The limit on the value of DECIMAL_PLACES, TO_EXP_NEG, TO_EXP_POS, MIN_EXP, MAX_EXP, and + // the arguments to toExponential, toFixed, toFormat, and toPrecision. + MAX = 1e9 // 0 to MAX_INT32 + + /* + * Create and return a BigNumber constructor. + */ + function clone(configObject) { + var div, + convertBase, + parseNumeric, + P = (BigNumber.prototype = { + constructor: BigNumber, + toString: null, + valueOf: null + }), + ONE = new BigNumber(1), + //----------------------------- EDITABLE CONFIG DEFAULTS ------------------------------- + + // The default values below must be integers within the inclusive ranges stated. + // The values can also be changed at run-time using BigNumber.set. + + // The maximum number of decimal places for operations involving division. + DECIMAL_PLACES = 20, // 0 to MAX + // The rounding mode used when rounding to the above decimal places, and when using + // toExponential, toFixed, toFormat and toPrecision, and round (default value). + // UP 0 Away from zero. + // DOWN 1 Towards zero. + // CEIL 2 Towards +Infinity. + // FLOOR 3 Towards -Infinity. + // HALF_UP 4 Towards nearest neighbour. If equidistant, up. + // HALF_DOWN 5 Towards nearest neighbour. If equidistant, down. + // HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour. + // HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity. + // HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity. + ROUNDING_MODE = 4, // 0 to 8 + // EXPONENTIAL_AT : [TO_EXP_NEG , TO_EXP_POS] + + // The exponent value at and beneath which toString returns exponential notation. + // Number type: -7 + TO_EXP_NEG = -7, // 0 to -MAX + // The exponent value at and above which toString returns exponential notation. + // Number type: 21 + TO_EXP_POS = 21, // 0 to MAX + // RANGE : [MIN_EXP, MAX_EXP] + + // The minimum exponent value, beneath which underflow to zero occurs. + // Number type: -324 (5e-324) + MIN_EXP = -1e7, // -1 to -MAX + // The maximum exponent value, above which overflow to Infinity occurs. + // Number type: 308 (1.7976931348623157e+308) + // For MAX_EXP > 1e7, e.g. new BigNumber('1e100000000').plus(1) may be slow. + MAX_EXP = 1e7, // 1 to MAX + // Whether to use cryptographically-secure random number generation, if available. + CRYPTO = false, // true or false + // The modulo mode used when calculating the modulus: a mod n. + // The quotient (q = a / n) is calculated according to the corresponding rounding mode. + // The remainder (r) is calculated as: r = a - n * q. + // + // UP 0 The remainder is positive if the dividend is negative, else is negative. + // DOWN 1 The remainder has the same sign as the dividend. + // This modulo mode is commonly known as 'truncated division' and is + // equivalent to (a % n) in JavaScript. + // FLOOR 3 The remainder has the same sign as the divisor (Python %). + // HALF_EVEN 6 This modulo mode implements the IEEE 754 remainder function. + // EUCLID 9 Euclidian division. q = sign(n) * floor(a / abs(n)). + // The remainder is always positive. + // + // The truncated division, floored division, Euclidian division and IEEE 754 remainder + // modes are commonly used for the modulus operation. + // Although the other rounding modes can also be used, they may not give useful results. + MODULO_MODE = 1, // 0 to 9 + // The maximum number of significant digits of the result of the exponentiatedBy operation. + // If POW_PRECISION is 0, there will be unlimited significant digits. + POW_PRECISION = 0, // 0 to MAX + // The format specification used by the BigNumber.prototype.toFormat method. + FORMAT = { + prefix: '', + groupSize: 3, + secondaryGroupSize: 0, + groupSeparator: ',', + decimalSeparator: '.', + fractionGroupSize: 0, + fractionGroupSeparator: '\xA0', // non-breaking space + suffix: '' + }, + // The alphabet used for base conversion. It must be at least 2 characters long, with no '+', + // '-', '.', whitespace, or repeated character. + // '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_' + ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyz' + + //------------------------------------------------------------------------------------------ + + // CONSTRUCTOR + + /* + * The BigNumber constructor and exported function. + * Create and return a new instance of a BigNumber object. + * + * v {number|string|BigNumber} A numeric value. + * [b] {number} The base of v. Integer, 2 to ALPHABET.length inclusive. + */ + function BigNumber(v, b) { + var alphabet, + c, + caseChanged, + e, + i, + isNum, + len, + str, + x = this + + // Enable constructor call without `new`. + if (!(x instanceof BigNumber)) return new BigNumber(v, b) + + if (b == null) { + if (v && v._isBigNumber === true) { + x.s = v.s + + if (!v.c || v.e > MAX_EXP) { + x.c = x.e = null + } else if (v.e < MIN_EXP) { + x.c = [(x.e = 0)] + } else { + x.e = v.e + x.c = v.c.slice() + } + + return + } + + if ((isNum = typeof v == 'number') && v * 0 == 0) { + // Use `1 / n` to handle minus zero also. + x.s = 1 / v < 0 ? ((v = -v), -1) : 1 + + // Fast path for integers, where n < 2147483648 (2**31). + if (v === ~~v) { + for (e = 0, i = v; i >= 10; i /= 10, e++); + + if (e > MAX_EXP) { + x.c = x.e = null + } else { + x.e = e + x.c = [v] + } + + return + } + + str = String(v) + } else { + if (!isNumeric.test((str = String(v)))) + return parseNumeric(x, str, isNum) + + x.s = str.charCodeAt(0) == 45 ? ((str = str.slice(1)), -1) : 1 + } + + // Decimal point? + if ((e = str.indexOf('.')) > -1) str = str.replace('.', '') + + // Exponential form? + if ((i = str.search(/e/i)) > 0) { + // Determine exponent. + if (e < 0) e = i + e += +str.slice(i + 1) + str = str.substring(0, i) + } else if (e < 0) { + // Integer. + e = str.length + } + } else { + // '[BigNumber Error] Base {not a primitive number|not an integer|out of range}: {b}' + intCheck(b, 2, ALPHABET.length, 'Base') + + // Allow exponential notation to be used with base 10 argument, while + // also rounding to DECIMAL_PLACES as with other bases. + if (b == 10) { + x = new BigNumber(v) + return round(x, DECIMAL_PLACES + x.e + 1, ROUNDING_MODE) + } + + str = String(v) + + if ((isNum = typeof v == 'number')) { + // Avoid potential interpretation of Infinity and NaN as base 44+ values. + if (v * 0 != 0) return parseNumeric(x, str, isNum, b) + + x.s = 1 / v < 0 ? ((str = str.slice(1)), -1) : 1 + + // '[BigNumber Error] Number primitive has more than 15 significant digits: {n}' + if ( + BigNumber.DEBUG && + str.replace(/^0\.0*|\./, '').length > 15 + ) { + throw Error(tooManyDigits + v) + } + } else { + x.s = str.charCodeAt(0) === 45 ? ((str = str.slice(1)), -1) : 1 + } + + alphabet = ALPHABET.slice(0, b) + e = i = 0 + + // Check that str is a valid base b number. + // Don't use RegExp, so alphabet can contain special characters. + for (len = str.length; i < len; i++) { + if (alphabet.indexOf((c = str.charAt(i))) < 0) { + if (c == '.') { + // If '.' is not the first character and it has not be found before. + if (i > e) { + e = len + continue + } + } else if (!caseChanged) { + // Allow e.g. hexadecimal 'FF' as well as 'ff'. + if ( + (str == str.toUpperCase() && (str = str.toLowerCase())) || + (str == str.toLowerCase() && (str = str.toUpperCase())) + ) { + caseChanged = true + i = -1 + e = 0 + continue + } + } + + return parseNumeric(x, String(v), isNum, b) + } + } + + // Prevent later check for length on converted number. + isNum = false + str = convertBase(str, b, 10, x.s) + + // Decimal point? + if ((e = str.indexOf('.')) > -1) str = str.replace('.', '') + else e = str.length + } + + // Determine leading zeros. + for (i = 0; str.charCodeAt(i) === 48; i++); + + // Determine trailing zeros. + for (len = str.length; str.charCodeAt(--len) === 48; ); + + if ((str = str.slice(i, ++len))) { + len -= i + + // '[BigNumber Error] Number primitive has more than 15 significant digits: {n}' + if ( + isNum && + BigNumber.DEBUG && + len > 15 && + (v > MAX_SAFE_INTEGER || v !== mathfloor(v)) + ) { + throw Error(tooManyDigits + x.s * v) + } + + // Overflow? + if ((e = e - i - 1) > MAX_EXP) { + // Infinity. + x.c = x.e = null + + // Underflow? + } else if (e < MIN_EXP) { + // Zero. + x.c = [(x.e = 0)] + } else { + x.e = e + x.c = [] + + // Transform base + + // e is the base 10 exponent. + // i is where to slice str to get the first element of the coefficient array. + i = (e + 1) % LOG_BASE + if (e < 0) i += LOG_BASE // i < 1 + + if (i < len) { + if (i) x.c.push(+str.slice(0, i)) + + for (len -= LOG_BASE; i < len; ) { + x.c.push(+str.slice(i, (i += LOG_BASE))) + } + + i = LOG_BASE - (str = str.slice(i)).length + } else { + i -= len + } + + for (; i--; str += '0'); + x.c.push(+str) + } + } else { + // Zero. + x.c = [(x.e = 0)] + } + } + + // CONSTRUCTOR PROPERTIES + + BigNumber.clone = clone + + BigNumber.ROUND_UP = 0 + BigNumber.ROUND_DOWN = 1 + BigNumber.ROUND_CEIL = 2 + BigNumber.ROUND_FLOOR = 3 + BigNumber.ROUND_HALF_UP = 4 + BigNumber.ROUND_HALF_DOWN = 5 + BigNumber.ROUND_HALF_EVEN = 6 + BigNumber.ROUND_HALF_CEIL = 7 + BigNumber.ROUND_HALF_FLOOR = 8 + BigNumber.EUCLID = 9 + + /* + * Configure infrequently-changing library-wide settings. + * + * Accept an object with the following optional properties (if the value of a property is + * a number, it must be an integer within the inclusive range stated): + * + * DECIMAL_PLACES {number} 0 to MAX + * ROUNDING_MODE {number} 0 to 8 + * EXPONENTIAL_AT {number|number[]} -MAX to MAX or [-MAX to 0, 0 to MAX] + * RANGE {number|number[]} -MAX to MAX (not zero) or [-MAX to -1, 1 to MAX] + * CRYPTO {boolean} true or false + * MODULO_MODE {number} 0 to 9 + * POW_PRECISION {number} 0 to MAX + * ALPHABET {string} A string of two or more unique characters which does + * not contain '.'. + * FORMAT {object} An object with some of the following properties: + * prefix {string} + * groupSize {number} + * secondaryGroupSize {number} + * groupSeparator {string} + * decimalSeparator {string} + * fractionGroupSize {number} + * fractionGroupSeparator {string} + * suffix {string} + * + * (The values assigned to the above FORMAT object properties are not checked for validity.) + * + * E.g. + * BigNumber.config({ DECIMAL_PLACES : 20, ROUNDING_MODE : 4 }) + * + * Ignore properties/parameters set to null or undefined, except for ALPHABET. + * + * Return an object with the properties current values. + */ + BigNumber.config = BigNumber.set = function (obj) { + var p, v + + if (obj != null) { + if (typeof obj == 'object') { + // DECIMAL_PLACES {number} Integer, 0 to MAX inclusive. + // '[BigNumber Error] DECIMAL_PLACES {not a primitive number|not an integer|out of range}: {v}' + if (obj.hasOwnProperty((p = 'DECIMAL_PLACES'))) { + v = obj[p] + intCheck(v, 0, MAX, p) + DECIMAL_PLACES = v + } + + // ROUNDING_MODE {number} Integer, 0 to 8 inclusive. + // '[BigNumber Error] ROUNDING_MODE {not a primitive number|not an integer|out of range}: {v}' + if (obj.hasOwnProperty((p = 'ROUNDING_MODE'))) { + v = obj[p] + intCheck(v, 0, 8, p) + ROUNDING_MODE = v + } + + // EXPONENTIAL_AT {number|number[]} + // Integer, -MAX to MAX inclusive or + // [integer -MAX to 0 inclusive, 0 to MAX inclusive]. + // '[BigNumber Error] EXPONENTIAL_AT {not a primitive number|not an integer|out of range}: {v}' + if (obj.hasOwnProperty((p = 'EXPONENTIAL_AT'))) { + v = obj[p] + if (v && v.pop) { + intCheck(v[0], -MAX, 0, p) + intCheck(v[1], 0, MAX, p) + TO_EXP_NEG = v[0] + TO_EXP_POS = v[1] + } else { + intCheck(v, -MAX, MAX, p) + TO_EXP_NEG = -(TO_EXP_POS = v < 0 ? -v : v) + } + } + + // RANGE {number|number[]} Non-zero integer, -MAX to MAX inclusive or + // [integer -MAX to -1 inclusive, integer 1 to MAX inclusive]. + // '[BigNumber Error] RANGE {not a primitive number|not an integer|out of range|cannot be zero}: {v}' + if (obj.hasOwnProperty((p = 'RANGE'))) { + v = obj[p] + if (v && v.pop) { + intCheck(v[0], -MAX, -1, p) + intCheck(v[1], 1, MAX, p) + MIN_EXP = v[0] + MAX_EXP = v[1] + } else { + intCheck(v, -MAX, MAX, p) + if (v) { + MIN_EXP = -(MAX_EXP = v < 0 ? -v : v) + } else { + throw Error(bignumberError + p + ' cannot be zero: ' + v) + } + } + } + + // CRYPTO {boolean} true or false. + // '[BigNumber Error] CRYPTO not true or false: {v}' + // '[BigNumber Error] crypto unavailable' + if (obj.hasOwnProperty((p = 'CRYPTO'))) { + v = obj[p] + if (v === !!v) { + if (v) { + if ( + typeof crypto != 'undefined' && + crypto && + (crypto.getRandomValues || crypto.randomBytes) + ) { + CRYPTO = v + } else { + CRYPTO = !v + throw Error(bignumberError + 'crypto unavailable') + } + } else { + CRYPTO = v + } + } else { + throw Error(bignumberError + p + ' not true or false: ' + v) + } + } + + // MODULO_MODE {number} Integer, 0 to 9 inclusive. + // '[BigNumber Error] MODULO_MODE {not a primitive number|not an integer|out of range}: {v}' + if (obj.hasOwnProperty((p = 'MODULO_MODE'))) { + v = obj[p] + intCheck(v, 0, 9, p) + MODULO_MODE = v + } + + // POW_PRECISION {number} Integer, 0 to MAX inclusive. + // '[BigNumber Error] POW_PRECISION {not a primitive number|not an integer|out of range}: {v}' + if (obj.hasOwnProperty((p = 'POW_PRECISION'))) { + v = obj[p] + intCheck(v, 0, MAX, p) + POW_PRECISION = v + } + + // FORMAT {object} + // '[BigNumber Error] FORMAT not an object: {v}' + if (obj.hasOwnProperty((p = 'FORMAT'))) { + v = obj[p] + if (typeof v == 'object') FORMAT = v + else throw Error(bignumberError + p + ' not an object: ' + v) + } + + // ALPHABET {string} + // '[BigNumber Error] ALPHABET invalid: {v}' + if (obj.hasOwnProperty((p = 'ALPHABET'))) { + v = obj[p] + + // Disallow if less than two characters, + // or if it contains '+', '-', '.', whitespace, or a repeated character. + if ( + typeof v == 'string' && + !/^.?$|[+\-.\s]|(.).*\1/.test(v) + ) { + ALPHABET = v + } else { + throw Error(bignumberError + p + ' invalid: ' + v) + } + } + } else { + // '[BigNumber Error] Object expected: {v}' + throw Error(bignumberError + 'Object expected: ' + obj) + } + } + + return { + DECIMAL_PLACES: DECIMAL_PLACES, + ROUNDING_MODE: ROUNDING_MODE, + EXPONENTIAL_AT: [TO_EXP_NEG, TO_EXP_POS], + RANGE: [MIN_EXP, MAX_EXP], + CRYPTO: CRYPTO, + MODULO_MODE: MODULO_MODE, + POW_PRECISION: POW_PRECISION, + FORMAT: FORMAT, + ALPHABET: ALPHABET + } + } + + /* + * Return true if v is a BigNumber instance, otherwise return false. + * + * If BigNumber.DEBUG is true, throw if a BigNumber instance is not well-formed. + * + * v {any} + * + * '[BigNumber Error] Invalid BigNumber: {v}' + */ + BigNumber.isBigNumber = function (v) { + if (!v || v._isBigNumber !== true) return false + if (!BigNumber.DEBUG) return true + + var i, + n, + c = v.c, + e = v.e, + s = v.s + + out: if ({}.toString.call(c) == '[object Array]') { + if ( + (s === 1 || s === -1) && + e >= -MAX && + e <= MAX && + e === mathfloor(e) + ) { + // If the first element is zero, the BigNumber value must be zero. + if (c[0] === 0) { + if (e === 0 && c.length === 1) return true + break out + } + + // Calculate number of digits that c[0] should have, based on the exponent. + i = (e + 1) % LOG_BASE + if (i < 1) i += LOG_BASE + + // Calculate number of digits of c[0]. + //if (Math.ceil(Math.log(c[0] + 1) / Math.LN10) == i) { + if (String(c[0]).length == i) { + for (i = 0; i < c.length; i++) { + n = c[i] + if (n < 0 || n >= BASE || n !== mathfloor(n)) break out + } + + // Last element cannot be zero, unless it is the only element. + if (n !== 0) return true + } + } + + // Infinity/NaN + } else if ( + c === null && + e === null && + (s === null || s === 1 || s === -1) + ) { + return true + } + + throw Error(bignumberError + 'Invalid BigNumber: ' + v) + } + + /* + * Return a new BigNumber whose value is the maximum of the arguments. + * + * arguments {number|string|BigNumber} + */ + BigNumber.maximum = BigNumber.max = function () { + return maxOrMin(arguments, P.lt) + } + + /* + * Return a new BigNumber whose value is the minimum of the arguments. + * + * arguments {number|string|BigNumber} + */ + BigNumber.minimum = BigNumber.min = function () { + return maxOrMin(arguments, P.gt) + } + + /* + * Return a new BigNumber with a random value equal to or greater than 0 and less than 1, + * and with dp, or DECIMAL_PLACES if dp is omitted, decimal places (or less if trailing + * zeros are produced). + * + * [dp] {number} Decimal places. Integer, 0 to MAX inclusive. + * + * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp}' + * '[BigNumber Error] crypto unavailable' + */ + BigNumber.random = (function () { + var pow2_53 = 0x20000000000000 + + // Return a 53 bit integer n, where 0 <= n < 9007199254740992. + // Check if Math.random() produces more than 32 bits of randomness. + // If it does, assume at least 53 bits are produced, otherwise assume at least 30 bits. + // 0x40000000 is 2^30, 0x800000 is 2^23, 0x1fffff is 2^21 - 1. + var random53bitInt = + (Math.random() * pow2_53) & 0x1fffff + ? function () { + return mathfloor(Math.random() * pow2_53) + } + : function () { + return ( + ((Math.random() * 0x40000000) | 0) * 0x800000 + + ((Math.random() * 0x800000) | 0) + ) + } + + return function (dp) { + var a, + b, + e, + k, + v, + i = 0, + c = [], + rand = new BigNumber(ONE) + + if (dp == null) dp = DECIMAL_PLACES + else intCheck(dp, 0, MAX) + + k = mathceil(dp / LOG_BASE) + + if (CRYPTO) { + // Browsers supporting crypto.getRandomValues. + if (crypto.getRandomValues) { + a = crypto.getRandomValues(new Uint32Array((k *= 2))) + + for (; i < k; ) { + // 53 bits: + // ((Math.pow(2, 32) - 1) * Math.pow(2, 21)).toString(2) + // 11111 11111111 11111111 11111111 11100000 00000000 00000000 + // ((Math.pow(2, 32) - 1) >>> 11).toString(2) + // 11111 11111111 11111111 + // 0x20000 is 2^21. + v = a[i] * 0x20000 + (a[i + 1] >>> 11) + + // Rejection sampling: + // 0 <= v < 9007199254740992 + // Probability that v >= 9e15, is + // 7199254740992 / 9007199254740992 ~= 0.0008, i.e. 1 in 1251 + if (v >= 9e15) { + b = crypto.getRandomValues(new Uint32Array(2)) + a[i] = b[0] + a[i + 1] = b[1] + } else { + // 0 <= v <= 8999999999999999 + // 0 <= (v % 1e14) <= 99999999999999 + c.push(v % 1e14) + i += 2 + } + } + i = k / 2 + + // Node.js supporting crypto.randomBytes. + } else if (crypto.randomBytes) { + // buffer + a = crypto.randomBytes((k *= 7)) + + for (; i < k; ) { + // 0x1000000000000 is 2^48, 0x10000000000 is 2^40 + // 0x100000000 is 2^32, 0x1000000 is 2^24 + // 11111 11111111 11111111 11111111 11111111 11111111 11111111 + // 0 <= v < 9007199254740992 + v = + (a[i] & 31) * 0x1000000000000 + + a[i + 1] * 0x10000000000 + + a[i + 2] * 0x100000000 + + a[i + 3] * 0x1000000 + + (a[i + 4] << 16) + + (a[i + 5] << 8) + + a[i + 6] + + if (v >= 9e15) { + crypto.randomBytes(7).copy(a, i) + } else { + // 0 <= (v % 1e14) <= 99999999999999 + c.push(v % 1e14) + i += 7 + } + } + i = k / 7 + } else { + CRYPTO = false + throw Error(bignumberError + 'crypto unavailable') + } + } + + // Use Math.random. + if (!CRYPTO) { + for (; i < k; ) { + v = random53bitInt() + if (v < 9e15) c[i++] = v % 1e14 + } + } + + k = c[--i] + dp %= LOG_BASE + + // Convert trailing digits to zeros according to dp. + if (k && dp) { + v = POWS_TEN[LOG_BASE - dp] + c[i] = mathfloor(k / v) * v + } + + // Remove trailing elements which are zero. + for (; c[i] === 0; c.pop(), i--); + + // Zero? + if (i < 0) { + c = [(e = 0)] + } else { + // Remove leading elements which are zero and adjust exponent accordingly. + for (e = -1; c[0] === 0; c.splice(0, 1), e -= LOG_BASE); + + // Count the digits of the first element of c to determine leading zeros, and... + for (i = 1, v = c[0]; v >= 10; v /= 10, i++); + + // adjust the exponent accordingly. + if (i < LOG_BASE) e -= LOG_BASE - i + } + + rand.e = e + rand.c = c + return rand + } + })() + + /* + * Return a BigNumber whose value is the sum of the arguments. + * + * arguments {number|string|BigNumber} + */ + BigNumber.sum = function () { + var i = 1, + args = arguments, + sum = new BigNumber(args[0]) + for (; i < args.length; ) sum = sum.plus(args[i++]) + return sum + } + + // PRIVATE FUNCTIONS + + // Called by BigNumber and BigNumber.prototype.toString. + convertBase = (function () { + var decimal = '0123456789' + + /* + * Convert string of baseIn to an array of numbers of baseOut. + * Eg. toBaseOut('255', 10, 16) returns [15, 15]. + * Eg. toBaseOut('ff', 16, 10) returns [2, 5, 5]. + */ + function toBaseOut(str, baseIn, baseOut, alphabet) { + var j, + arr = [0], + arrL, + i = 0, + len = str.length + + for (; i < len; ) { + for (arrL = arr.length; arrL--; arr[arrL] *= baseIn); + + arr[0] += alphabet.indexOf(str.charAt(i++)) + + for (j = 0; j < arr.length; j++) { + if (arr[j] > baseOut - 1) { + if (arr[j + 1] == null) arr[j + 1] = 0 + arr[j + 1] += (arr[j] / baseOut) | 0 + arr[j] %= baseOut + } + } + } + + return arr.reverse() + } + + // Convert a numeric string of baseIn to a numeric string of baseOut. + // If the caller is toString, we are converting from base 10 to baseOut. + // If the caller is BigNumber, we are converting from baseIn to base 10. + return function (str, baseIn, baseOut, sign, callerIsToString) { + var alphabet, + d, + e, + k, + r, + x, + xc, + y, + i = str.indexOf('.'), + dp = DECIMAL_PLACES, + rm = ROUNDING_MODE + + // Non-integer. + if (i >= 0) { + k = POW_PRECISION + + // Unlimited precision. + POW_PRECISION = 0 + str = str.replace('.', '') + y = new BigNumber(baseIn) + x = y.pow(str.length - i) + POW_PRECISION = k + + // Convert str as if an integer, then restore the fraction part by dividing the + // result by its base raised to a power. + + y.c = toBaseOut( + toFixedPoint(coeffToString(x.c), x.e, '0'), + 10, + baseOut, + decimal + ) + y.e = y.c.length + } + + // Convert the number as integer. + + xc = toBaseOut( + str, + baseIn, + baseOut, + callerIsToString + ? ((alphabet = ALPHABET), decimal) + : ((alphabet = decimal), ALPHABET) + ) + + // xc now represents str as an integer and converted to baseOut. e is the exponent. + e = k = xc.length + + // Remove trailing zeros. + for (; xc[--k] == 0; xc.pop()); + + // Zero? + if (!xc[0]) return alphabet.charAt(0) + + // Does str represent an integer? If so, no need for the division. + if (i < 0) { + --e + } else { + x.c = xc + x.e = e + + // The sign is needed for correct rounding. + x.s = sign + x = div(x, y, dp, rm, baseOut) + xc = x.c + r = x.r + e = x.e + } + + // xc now represents str converted to baseOut. + + // THe index of the rounding digit. + d = e + dp + 1 + + // The rounding digit: the digit to the right of the digit that may be rounded up. + i = xc[d] + + // Look at the rounding digits and mode to determine whether to round up. + + k = baseOut / 2 + r = r || d < 0 || xc[d + 1] != null + + r = + rm < 4 + ? (i != null || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) + : i > k || + (i == k && + (rm == 4 || + r || + (rm == 6 && xc[d - 1] & 1) || + rm == (x.s < 0 ? 8 : 7))) + + // If the index of the rounding digit is not greater than zero, or xc represents + // zero, then the result of the base conversion is zero or, if rounding up, a value + // such as 0.00001. + if (d < 1 || !xc[0]) { + // 1^-dp or 0 + str = r + ? toFixedPoint(alphabet.charAt(1), -dp, alphabet.charAt(0)) + : alphabet.charAt(0) + } else { + // Truncate xc to the required number of decimal places. + xc.length = d + + // Round up? + if (r) { + // Rounding up may mean the previous digit has to be rounded up and so on. + for (--baseOut; ++xc[--d] > baseOut; ) { + xc[d] = 0 + + if (!d) { + ++e + xc = [1].concat(xc) + } + } + } + + // Determine trailing zeros. + for (k = xc.length; !xc[--k]; ); + + // E.g. [4, 11, 15] becomes 4bf. + for (i = 0, str = ''; i <= k; str += alphabet.charAt(xc[i++])); + + // Add leading zeros, decimal point and trailing zeros as required. + str = toFixedPoint(str, e, alphabet.charAt(0)) + } + + // The caller will add the sign. + return str + } + })() + + // Perform division in the specified base. Called by div and convertBase. + div = (function () { + // Assume non-zero x and k. + function multiply(x, k, base) { + var m, + temp, + xlo, + xhi, + carry = 0, + i = x.length, + klo = k % SQRT_BASE, + khi = (k / SQRT_BASE) | 0 + + for (x = x.slice(); i--; ) { + xlo = x[i] % SQRT_BASE + xhi = (x[i] / SQRT_BASE) | 0 + m = khi * xlo + xhi * klo + temp = klo * xlo + (m % SQRT_BASE) * SQRT_BASE + carry + carry = ((temp / base) | 0) + ((m / SQRT_BASE) | 0) + khi * xhi + x[i] = temp % base + } + + if (carry) x = [carry].concat(x) + + return x + } + + function compare(a, b, aL, bL) { + var i, cmp + + if (aL != bL) { + cmp = aL > bL ? 1 : -1 + } else { + for (i = cmp = 0; i < aL; i++) { + if (a[i] != b[i]) { + cmp = a[i] > b[i] ? 1 : -1 + break + } + } + } + + return cmp + } + + function subtract(a, b, aL, base) { + var i = 0 + + // Subtract b from a. + for (; aL--; ) { + a[aL] -= i + i = a[aL] < b[aL] ? 1 : 0 + a[aL] = i * base + a[aL] - b[aL] + } + + // Remove leading zeros. + for (; !a[0] && a.length > 1; a.splice(0, 1)); + } + + // x: dividend, y: divisor. + return function (x, y, dp, rm, base) { + var cmp, + e, + i, + more, + n, + prod, + prodL, + q, + qc, + rem, + remL, + rem0, + xi, + xL, + yc0, + yL, + yz, + s = x.s == y.s ? 1 : -1, + xc = x.c, + yc = y.c + + // Either NaN, Infinity or 0? + if (!xc || !xc[0] || !yc || !yc[0]) { + return new BigNumber( + // Return NaN if either NaN, or both Infinity or 0. + !x.s || !y.s || (xc ? yc && xc[0] == yc[0] : !yc) + ? NaN + : // Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0. + (xc && xc[0] == 0) || !yc + ? s * 0 + : s / 0 + ) + } + + q = new BigNumber(s) + qc = q.c = [] + e = x.e - y.e + s = dp + e + 1 + + if (!base) { + base = BASE + e = bitFloor(x.e / LOG_BASE) - bitFloor(y.e / LOG_BASE) + s = (s / LOG_BASE) | 0 + } + + // Result exponent may be one less then the current value of e. + // The coefficients of the BigNumbers from convertBase may have trailing zeros. + for (i = 0; yc[i] == (xc[i] || 0); i++); + + if (yc[i] > (xc[i] || 0)) e-- + + if (s < 0) { + qc.push(1) + more = true + } else { + xL = xc.length + yL = yc.length + i = 0 + s += 2 + + // Normalise xc and yc so highest order digit of yc is >= base / 2. + + n = mathfloor(base / (yc[0] + 1)) + + // Not necessary, but to handle odd bases where yc[0] == (base / 2) - 1. + // if (n > 1 || n++ == 1 && yc[0] < base / 2) { + if (n > 1) { + yc = multiply(yc, n, base) + xc = multiply(xc, n, base) + yL = yc.length + xL = xc.length + } + + xi = yL + rem = xc.slice(0, yL) + remL = rem.length + + // Add zeros to make remainder as long as divisor. + for (; remL < yL; rem[remL++] = 0); + yz = yc.slice() + yz = [0].concat(yz) + yc0 = yc[0] + if (yc[1] >= base / 2) yc0++ + // Not necessary, but to prevent trial digit n > base, when using base 3. + // else if (base == 3 && yc0 == 1) yc0 = 1 + 1e-15; + + do { + n = 0 + + // Compare divisor and remainder. + cmp = compare(yc, rem, yL, remL) + + // If divisor < remainder. + if (cmp < 0) { + // Calculate trial digit, n. + + rem0 = rem[0] + if (yL != remL) rem0 = rem0 * base + (rem[1] || 0) + + // n is how many times the divisor goes into the current remainder. + n = mathfloor(rem0 / yc0) + + // Algorithm: + // product = divisor multiplied by trial digit (n). + // Compare product and remainder. + // If product is greater than remainder: + // Subtract divisor from product, decrement trial digit. + // Subtract product from remainder. + // If product was less than remainder at the last compare: + // Compare new remainder and divisor. + // If remainder is greater than divisor: + // Subtract divisor from remainder, increment trial digit. + + if (n > 1) { + // n may be > base only when base is 3. + if (n >= base) n = base - 1 + + // product = divisor * trial digit. + prod = multiply(yc, n, base) + prodL = prod.length + remL = rem.length + + // Compare product and remainder. + // If product > remainder then trial digit n too high. + // n is 1 too high about 5% of the time, and is not known to have + // ever been more than 1 too high. + while (compare(prod, rem, prodL, remL) == 1) { + n-- + + // Subtract divisor from product. + subtract(prod, yL < prodL ? yz : yc, prodL, base) + prodL = prod.length + cmp = 1 + } + } else { + // n is 0 or 1, cmp is -1. + // If n is 0, there is no need to compare yc and rem again below, + // so change cmp to 1 to avoid it. + // If n is 1, leave cmp as -1, so yc and rem are compared again. + if (n == 0) { + // divisor < remainder, so n must be at least 1. + cmp = n = 1 + } + + // product = divisor + prod = yc.slice() + prodL = prod.length + } + + if (prodL < remL) prod = [0].concat(prod) + + // Subtract product from remainder. + subtract(rem, prod, remL, base) + remL = rem.length + + // If product was < remainder. + if (cmp == -1) { + // Compare divisor and new remainder. + // If divisor < new remainder, subtract divisor from remainder. + // Trial digit n too low. + // n is 1 too low about 5% of the time, and very rarely 2 too low. + while (compare(yc, rem, yL, remL) < 1) { + n++ + + // Subtract divisor from remainder. + subtract(rem, yL < remL ? yz : yc, remL, base) + remL = rem.length + } + } + } else if (cmp === 0) { + n++ + rem = [0] + } // else cmp === 1 and n will be 0 + + // Add the next digit, n, to the result array. + qc[i++] = n + + // Update the remainder. + if (rem[0]) { + rem[remL++] = xc[xi] || 0 + } else { + rem = [xc[xi]] + remL = 1 + } + } while ((xi++ < xL || rem[0] != null) && s--) + + more = rem[0] != null + + // Leading zero? + if (!qc[0]) qc.splice(0, 1) + } + + if (base == BASE) { + // To calculate q.e, first get the number of digits of qc[0]. + for (i = 1, s = qc[0]; s >= 10; s /= 10, i++); + + round(q, dp + (q.e = i + e * LOG_BASE - 1) + 1, rm, more) + + // Caller is convertBase. + } else { + q.e = e + q.r = +more + } + + return q + } + })() + + /* + * Return a string representing the value of BigNumber n in fixed-point or exponential + * notation rounded to the specified decimal places or significant digits. + * + * n: a BigNumber. + * i: the index of the last digit required (i.e. the digit that may be rounded up). + * rm: the rounding mode. + * id: 1 (toExponential) or 2 (toPrecision). + */ + function format(n, i, rm, id) { + var c0, e, ne, len, str + + if (rm == null) rm = ROUNDING_MODE + else intCheck(rm, 0, 8) + + if (!n.c) return n.toString() + + c0 = n.c[0] + ne = n.e + + if (i == null) { + str = coeffToString(n.c) + str = + id == 1 || (id == 2 && (ne <= TO_EXP_NEG || ne >= TO_EXP_POS)) + ? toExponential(str, ne) + : toFixedPoint(str, ne, '0') + } else { + n = round(new BigNumber(n), i, rm) + + // n.e may have changed if the value was rounded up. + e = n.e + + str = coeffToString(n.c) + len = str.length + + // toPrecision returns exponential notation if the number of significant digits + // specified is less than the number of digits necessary to represent the integer + // part of the value in fixed-point notation. + + // Exponential notation. + if (id == 1 || (id == 2 && (i <= e || e <= TO_EXP_NEG))) { + // Append zeros? + for (; len < i; str += '0', len++); + str = toExponential(str, e) + + // Fixed-point notation. + } else { + i -= ne + str = toFixedPoint(str, e, '0') + + // Append zeros? + if (e + 1 > len) { + if (--i > 0) for (str += '.'; i--; str += '0'); + } else { + i += e - len + if (i > 0) { + if (e + 1 == len) str += '.' + for (; i--; str += '0'); + } + } + } + } + + return n.s < 0 && c0 ? '-' + str : str + } + + // Handle BigNumber.max and BigNumber.min. + function maxOrMin(args, method) { + var n, + i = 1, + m = new BigNumber(args[0]) + + for (; i < args.length; i++) { + n = new BigNumber(args[i]) + + // If any number is NaN, return NaN. + if (!n.s) { + m = n + break + } else if (method.call(m, n)) { + m = n + } + } + + return m + } + + /* + * Strip trailing zeros, calculate base 10 exponent and check against MIN_EXP and MAX_EXP. + * Called by minus, plus and times. + */ + function normalise(n, c, e) { + var i = 1, + j = c.length + + // Remove trailing zeros. + for (; !c[--j]; c.pop()); + + // Calculate the base 10 exponent. First get the number of digits of c[0]. + for (j = c[0]; j >= 10; j /= 10, i++); + + // Overflow? + if ((e = i + e * LOG_BASE - 1) > MAX_EXP) { + // Infinity. + n.c = n.e = null + + // Underflow? + } else if (e < MIN_EXP) { + // Zero. + n.c = [(n.e = 0)] + } else { + n.e = e + n.c = c + } + + return n + } + + // Handle values that fail the validity test in BigNumber. + parseNumeric = (function () { + var basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i, + dotAfter = /^([^.]+)\.$/, + dotBefore = /^\.([^.]+)$/, + isInfinityOrNaN = /^-?(Infinity|NaN)$/, + whitespaceOrPlus = /^\s*\+(?=[\w.])|^\s+|\s+$/g + + return function (x, str, isNum, b) { + var base, + s = isNum ? str : str.replace(whitespaceOrPlus, '') + + // No exception on ±Infinity or NaN. + if (isInfinityOrNaN.test(s)) { + x.s = isNaN(s) ? null : s < 0 ? -1 : 1 + } else { + if (!isNum) { + // basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i + s = s.replace(basePrefix, function (m, p1, p2) { + base = + (p2 = p2.toLowerCase()) == 'x' ? 16 : p2 == 'b' ? 2 : 8 + return !b || b == base ? p1 : m + }) + + if (b) { + base = b + + // E.g. '1.' to '1', '.1' to '0.1' + s = s.replace(dotAfter, '$1').replace(dotBefore, '0.$1') + } + + if (str != s) return new BigNumber(s, base) + } + + // '[BigNumber Error] Not a number: {n}' + // '[BigNumber Error] Not a base {b} number: {n}' + if (BigNumber.DEBUG) { + throw Error( + bignumberError + + 'Not a' + + (b ? ' base ' + b : '') + + ' number: ' + + str + ) + } + + // NaN + x.s = null + } + + x.c = x.e = null + } + })() + + /* + * Round x to sd significant digits using rounding mode rm. Check for over/under-flow. + * If r is truthy, it is known that there are more digits after the rounding digit. + */ + function round(x, sd, rm, r) { + var d, + i, + j, + k, + n, + ni, + rd, + xc = x.c, + pows10 = POWS_TEN + + // if x is not Infinity or NaN... + if (xc) { + // rd is the rounding digit, i.e. the digit after the digit that may be rounded up. + // n is a base 1e14 number, the value of the element of array x.c containing rd. + // ni is the index of n within x.c. + // d is the number of digits of n. + // i is the index of rd within n including leading zeros. + // j is the actual index of rd within n (if < 0, rd is a leading zero). + out: { + // Get the number of digits of the first element of xc. + for (d = 1, k = xc[0]; k >= 10; k /= 10, d++); + i = sd - d + + // If the rounding digit is in the first element of xc... + if (i < 0) { + i += LOG_BASE + j = sd + n = xc[(ni = 0)] + + // Get the rounding digit at index j of n. + rd = (n / pows10[d - j - 1]) % 10 | 0 + } else { + ni = mathceil((i + 1) / LOG_BASE) + + if (ni >= xc.length) { + if (r) { + // Needed by sqrt. + for (; xc.length <= ni; xc.push(0)); + n = rd = 0 + d = 1 + i %= LOG_BASE + j = i - LOG_BASE + 1 + } else { + break out + } + } else { + n = k = xc[ni] + + // Get the number of digits of n. + for (d = 1; k >= 10; k /= 10, d++); + + // Get the index of rd within n. + i %= LOG_BASE + + // Get the index of rd within n, adjusted for leading zeros. + // The number of leading zeros of n is given by LOG_BASE - d. + j = i - LOG_BASE + d + + // Get the rounding digit at index j of n. + rd = j < 0 ? 0 : (n / pows10[d - j - 1]) % 10 | 0 + } + } + + r = + r || + sd < 0 || + // Are there any non-zero digits after the rounding digit? + // The expression n % pows10[d - j - 1] returns all digits of n to the right + // of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714. + xc[ni + 1] != null || + (j < 0 ? n : n % pows10[d - j - 1]) + + r = + rm < 4 + ? (rd || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) + : rd > 5 || + (rd == 5 && + (rm == 4 || + r || + (rm == 6 && + // Check whether the digit to the left of the rounding digit is odd. + (i > 0 + ? j > 0 + ? n / pows10[d - j] + : 0 + : xc[ni - 1]) % + 10 & + 1) || + rm == (x.s < 0 ? 8 : 7))) + + if (sd < 1 || !xc[0]) { + xc.length = 0 + + if (r) { + // Convert sd to decimal places. + sd -= x.e + 1 + + // 1, 0.1, 0.01, 0.001, 0.0001 etc. + xc[0] = pows10[(LOG_BASE - (sd % LOG_BASE)) % LOG_BASE] + x.e = -sd || 0 + } else { + // Zero. + xc[0] = x.e = 0 + } + + return x + } + + // Remove excess digits. + if (i == 0) { + xc.length = ni + k = 1 + ni-- + } else { + xc.length = ni + 1 + k = pows10[LOG_BASE - i] + + // E.g. 56700 becomes 56000 if 7 is the rounding digit. + // j > 0 means i > number of leading zeros of n. + xc[ni] = + j > 0 ? mathfloor((n / pows10[d - j]) % pows10[j]) * k : 0 + } + + // Round up? + if (r) { + for (;;) { + // If the digit to be rounded up is in the first element of xc... + if (ni == 0) { + // i will be the length of xc[0] before k is added. + for (i = 1, j = xc[0]; j >= 10; j /= 10, i++); + j = xc[0] += k + for (k = 1; j >= 10; j /= 10, k++); + + // if i != k the length has increased. + if (i != k) { + x.e++ + if (xc[0] == BASE) xc[0] = 1 + } + + break + } else { + xc[ni] += k + if (xc[ni] != BASE) break + xc[ni--] = 0 + k = 1 + } + } + } + + // Remove trailing zeros. + for (i = xc.length; xc[--i] === 0; xc.pop()); + } + + // Overflow? Infinity. + if (x.e > MAX_EXP) { + x.c = x.e = null + + // Underflow? Zero. + } else if (x.e < MIN_EXP) { + x.c = [(x.e = 0)] + } + } + + return x + } + + function valueOf(n) { + var str, + e = n.e + + if (e === null) return n.toString() + + str = coeffToString(n.c) + + str = + e <= TO_EXP_NEG || e >= TO_EXP_POS + ? toExponential(str, e) + : toFixedPoint(str, e, '0') + + return n.s < 0 ? '-' + str : str + } + + // PROTOTYPE/INSTANCE METHODS + + /* + * Return a new BigNumber whose value is the absolute value of this BigNumber. + */ + P.absoluteValue = P.abs = function () { + var x = new BigNumber(this) + if (x.s < 0) x.s = 1 + return x + } + + /* + * Return + * 1 if the value of this BigNumber is greater than the value of BigNumber(y, b), + * -1 if the value of this BigNumber is less than the value of BigNumber(y, b), + * 0 if they have the same value, + * or null if the value of either is NaN. + */ + P.comparedTo = function (y, b) { + return compare(this, new BigNumber(y, b)) + } + + /* + * If dp is undefined or null or true or false, return the number of decimal places of the + * value of this BigNumber, or null if the value of this BigNumber is ±Infinity or NaN. + * + * Otherwise, if dp is a number, return a new BigNumber whose value is the value of this + * BigNumber rounded to a maximum of dp decimal places using rounding mode rm, or + * ROUNDING_MODE if rm is omitted. + * + * [dp] {number} Decimal places: integer, 0 to MAX inclusive. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * + * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}' + */ + P.decimalPlaces = P.dp = function (dp, rm) { + var c, + n, + v, + x = this + + if (dp != null) { + intCheck(dp, 0, MAX) + if (rm == null) rm = ROUNDING_MODE + else intCheck(rm, 0, 8) + + return round(new BigNumber(x), dp + x.e + 1, rm) + } + + if (!(c = x.c)) return null + n = ((v = c.length - 1) - bitFloor(this.e / LOG_BASE)) * LOG_BASE + + // Subtract the number of trailing zeros of the last number. + if ((v = c[v])) for (; v % 10 == 0; v /= 10, n--); + if (n < 0) n = 0 + + return n + } + + /* + * n / 0 = I + * n / N = N + * n / I = 0 + * 0 / n = 0 + * 0 / 0 = N + * 0 / N = N + * 0 / I = 0 + * N / n = N + * N / 0 = N + * N / N = N + * N / I = N + * I / n = I + * I / 0 = I + * I / N = N + * I / I = N + * + * Return a new BigNumber whose value is the value of this BigNumber divided by the value of + * BigNumber(y, b), rounded according to DECIMAL_PLACES and ROUNDING_MODE. + */ + P.dividedBy = P.div = function (y, b) { + return div(this, new BigNumber(y, b), DECIMAL_PLACES, ROUNDING_MODE) + } + + /* + * Return a new BigNumber whose value is the integer part of dividing the value of this + * BigNumber by the value of BigNumber(y, b). + */ + P.dividedToIntegerBy = P.idiv = function (y, b) { + return div(this, new BigNumber(y, b), 0, 1) + } + + /* + * Return a BigNumber whose value is the value of this BigNumber exponentiated by n. + * + * If m is present, return the result modulo m. + * If n is negative round according to DECIMAL_PLACES and ROUNDING_MODE. + * If POW_PRECISION is non-zero and m is not present, round to POW_PRECISION using ROUNDING_MODE. + * + * The modular power operation works efficiently when x, n, and m are integers, otherwise it + * is equivalent to calculating x.exponentiatedBy(n).modulo(m) with a POW_PRECISION of 0. + * + * n {number|string|BigNumber} The exponent. An integer. + * [m] {number|string|BigNumber} The modulus. + * + * '[BigNumber Error] Exponent not an integer: {n}' + */ + P.exponentiatedBy = P.pow = function (n, m) { + var half, + isModExp, + i, + k, + more, + nIsBig, + nIsNeg, + nIsOdd, + y, + x = this + + n = new BigNumber(n) + + // Allow NaN and ±Infinity, but not other non-integers. + if (n.c && !n.isInteger()) { + throw Error( + bignumberError + 'Exponent not an integer: ' + valueOf(n) + ) + } + + if (m != null) m = new BigNumber(m) + + // Exponent of MAX_SAFE_INTEGER is 15. + nIsBig = n.e > 14 + + // If x is NaN, ±Infinity, ±0 or ±1, or n is ±Infinity, NaN or ±0. + if ( + !x.c || + !x.c[0] || + (x.c[0] == 1 && !x.e && x.c.length == 1) || + !n.c || + !n.c[0] + ) { + // The sign of the result of pow when x is negative depends on the evenness of n. + // If +n overflows to ±Infinity, the evenness of n would be not be known. + y = new BigNumber( + Math.pow(+valueOf(x), nIsBig ? 2 - isOdd(n) : +valueOf(n)) + ) + return m ? y.mod(m) : y + } + + nIsNeg = n.s < 0 + + if (m) { + // x % m returns NaN if abs(m) is zero, or m is NaN. + if (m.c ? !m.c[0] : !m.s) return new BigNumber(NaN) + + isModExp = !nIsNeg && x.isInteger() && m.isInteger() + + if (isModExp) x = x.mod(m) + + // Overflow to ±Infinity: >=2**1e10 or >=1.0000024**1e15. + // Underflow to ±0: <=0.79**1e10 or <=0.9999975**1e15. + } else if ( + n.e > 9 && + (x.e > 0 || + x.e < -1 || + (x.e == 0 + ? // [1, 240000000] + x.c[0] > 1 || (nIsBig && x.c[1] >= 24e7) + : // [80000000000000] [99999750000000] + x.c[0] < 8e13 || (nIsBig && x.c[0] <= 9999975e7))) + ) { + // If x is negative and n is odd, k = -0, else k = 0. + k = x.s < 0 && isOdd(n) ? -0 : 0 + + // If x >= 1, k = ±Infinity. + if (x.e > -1) k = 1 / k + + // If n is negative return ±0, else return ±Infinity. + return new BigNumber(nIsNeg ? 1 / k : k) + } else if (POW_PRECISION) { + // Truncating each coefficient array to a length of k after each multiplication + // equates to truncating significant digits to POW_PRECISION + [28, 41], + // i.e. there will be a minimum of 28 guard digits retained. + k = mathceil(POW_PRECISION / LOG_BASE + 2) + } + + if (nIsBig) { + half = new BigNumber(0.5) + if (nIsNeg) n.s = 1 + nIsOdd = isOdd(n) + } else { + i = Math.abs(+valueOf(n)) + nIsOdd = i % 2 + } + + y = new BigNumber(ONE) + + // Performs 54 loop iterations for n of 9007199254740991. + for (;;) { + if (nIsOdd) { + y = y.times(x) + if (!y.c) break + + if (k) { + if (y.c.length > k) y.c.length = k + } else if (isModExp) { + y = y.mod(m) //y = y.minus(div(y, m, 0, MODULO_MODE).times(m)); + } + } + + if (i) { + i = mathfloor(i / 2) + if (i === 0) break + nIsOdd = i % 2 + } else { + n = n.times(half) + round(n, n.e + 1, 1) + + if (n.e > 14) { + nIsOdd = isOdd(n) + } else { + i = +valueOf(n) + if (i === 0) break + nIsOdd = i % 2 + } + } + + x = x.times(x) + + if (k) { + if (x.c && x.c.length > k) x.c.length = k + } else if (isModExp) { + x = x.mod(m) //x = x.minus(div(x, m, 0, MODULO_MODE).times(m)); + } + } + + if (isModExp) return y + if (nIsNeg) y = ONE.div(y) + + return m + ? y.mod(m) + : k + ? round(y, POW_PRECISION, ROUNDING_MODE, more) + : y + } + + /* + * Return a new BigNumber whose value is the value of this BigNumber rounded to an integer + * using rounding mode rm, or ROUNDING_MODE if rm is omitted. + * + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * + * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {rm}' + */ + P.integerValue = function (rm) { + var n = new BigNumber(this) + if (rm == null) rm = ROUNDING_MODE + else intCheck(rm, 0, 8) + return round(n, n.e + 1, rm) + } + + /* + * Return true if the value of this BigNumber is equal to the value of BigNumber(y, b), + * otherwise return false. + */ + P.isEqualTo = P.eq = function (y, b) { + return compare(this, new BigNumber(y, b)) === 0 + } + + /* + * Return true if the value of this BigNumber is a finite number, otherwise return false. + */ + P.isFinite = function () { + return !!this.c + } + + /* + * Return true if the value of this BigNumber is greater than the value of BigNumber(y, b), + * otherwise return false. + */ + P.isGreaterThan = P.gt = function (y, b) { + return compare(this, new BigNumber(y, b)) > 0 + } + + /* + * Return true if the value of this BigNumber is greater than or equal to the value of + * BigNumber(y, b), otherwise return false. + */ + P.isGreaterThanOrEqualTo = P.gte = function (y, b) { + return (b = compare(this, new BigNumber(y, b))) === 1 || b === 0 + } + + /* + * Return true if the value of this BigNumber is an integer, otherwise return false. + */ + P.isInteger = function () { + return !!this.c && bitFloor(this.e / LOG_BASE) > this.c.length - 2 + } + + /* + * Return true if the value of this BigNumber is less than the value of BigNumber(y, b), + * otherwise return false. + */ + P.isLessThan = P.lt = function (y, b) { + return compare(this, new BigNumber(y, b)) < 0 + } + + /* + * Return true if the value of this BigNumber is less than or equal to the value of + * BigNumber(y, b), otherwise return false. + */ + P.isLessThanOrEqualTo = P.lte = function (y, b) { + return (b = compare(this, new BigNumber(y, b))) === -1 || b === 0 + } + + /* + * Return true if the value of this BigNumber is NaN, otherwise return false. + */ + P.isNaN = function () { + return !this.s + } + + /* + * Return true if the value of this BigNumber is negative, otherwise return false. + */ + P.isNegative = function () { + return this.s < 0 + } + + /* + * Return true if the value of this BigNumber is positive, otherwise return false. + */ + P.isPositive = function () { + return this.s > 0 + } + + /* + * Return true if the value of this BigNumber is 0 or -0, otherwise return false. + */ + P.isZero = function () { + return !!this.c && this.c[0] == 0 + } + + /* + * n - 0 = n + * n - N = N + * n - I = -I + * 0 - n = -n + * 0 - 0 = 0 + * 0 - N = N + * 0 - I = -I + * N - n = N + * N - 0 = N + * N - N = N + * N - I = N + * I - n = I + * I - 0 = I + * I - N = N + * I - I = N + * + * Return a new BigNumber whose value is the value of this BigNumber minus the value of + * BigNumber(y, b). + */ + P.minus = function (y, b) { + var i, + j, + t, + xLTy, + x = this, + a = x.s + + y = new BigNumber(y, b) + b = y.s + + // Either NaN? + if (!a || !b) return new BigNumber(NaN) + + // Signs differ? + if (a != b) { + y.s = -b + return x.plus(y) + } + + var xe = x.e / LOG_BASE, + ye = y.e / LOG_BASE, + xc = x.c, + yc = y.c + + if (!xe || !ye) { + // Either Infinity? + if (!xc || !yc) + return xc ? ((y.s = -b), y) : new BigNumber(yc ? x : NaN) + + // Either zero? + if (!xc[0] || !yc[0]) { + // Return y if y is non-zero, x if x is non-zero, or zero if both are zero. + return yc[0] + ? ((y.s = -b), y) + : new BigNumber( + xc[0] + ? x + : // IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity + ROUNDING_MODE == 3 + ? -0 + : 0 + ) + } + } + + xe = bitFloor(xe) + ye = bitFloor(ye) + xc = xc.slice() + + // Determine which is the bigger number. + if ((a = xe - ye)) { + if ((xLTy = a < 0)) { + a = -a + t = xc + } else { + ye = xe + t = yc + } + + t.reverse() + + // Prepend zeros to equalise exponents. + for (b = a; b--; t.push(0)); + t.reverse() + } else { + // Exponents equal. Check digit by digit. + j = (xLTy = (a = xc.length) < (b = yc.length)) ? a : b + + for (a = b = 0; b < j; b++) { + if (xc[b] != yc[b]) { + xLTy = xc[b] < yc[b] + break + } + } + } + + // x < y? Point xc to the array of the bigger number. + if (xLTy) (t = xc), (xc = yc), (yc = t), (y.s = -y.s) + + b = (j = yc.length) - (i = xc.length) + + // Append zeros to xc if shorter. + // No need to add zeros to yc if shorter as subtract only needs to start at yc.length. + if (b > 0) for (; b--; xc[i++] = 0); + b = BASE - 1 + + // Subtract yc from xc. + for (; j > a; ) { + if (xc[--j] < yc[j]) { + for (i = j; i && !xc[--i]; xc[i] = b); + --xc[i] + xc[j] += BASE + } + + xc[j] -= yc[j] + } + + // Remove leading zeros and adjust exponent accordingly. + for (; xc[0] == 0; xc.splice(0, 1), --ye); + + // Zero? + if (!xc[0]) { + // Following IEEE 754 (2008) 6.3, + // n - n = +0 but n - n = -0 when rounding towards -Infinity. + y.s = ROUNDING_MODE == 3 ? -1 : 1 + y.c = [(y.e = 0)] + return y + } + + // No need to check for Infinity as +x - +y != Infinity && -x - -y != Infinity + // for finite x and y. + return normalise(y, xc, ye) + } + + /* + * n % 0 = N + * n % N = N + * n % I = n + * 0 % n = 0 + * -0 % n = -0 + * 0 % 0 = N + * 0 % N = N + * 0 % I = 0 + * N % n = N + * N % 0 = N + * N % N = N + * N % I = N + * I % n = N + * I % 0 = N + * I % N = N + * I % I = N + * + * Return a new BigNumber whose value is the value of this BigNumber modulo the value of + * BigNumber(y, b). The result depends on the value of MODULO_MODE. + */ + P.modulo = P.mod = function (y, b) { + var q, + s, + x = this + + y = new BigNumber(y, b) + + // Return NaN if x is Infinity or NaN, or y is NaN or zero. + if (!x.c || !y.s || (y.c && !y.c[0])) { + return new BigNumber(NaN) + + // Return x if y is Infinity or x is zero. + } else if (!y.c || (x.c && !x.c[0])) { + return new BigNumber(x) + } + + if (MODULO_MODE == 9) { + // Euclidian division: q = sign(y) * floor(x / abs(y)) + // r = x - qy where 0 <= r < abs(y) + s = y.s + y.s = 1 + q = div(x, y, 0, 3) + y.s = s + q.s *= s + } else { + q = div(x, y, 0, MODULO_MODE) + } + + y = x.minus(q.times(y)) + + // To match JavaScript %, ensure sign of zero is sign of dividend. + if (!y.c[0] && MODULO_MODE == 1) y.s = x.s + + return y + } + + /* + * n * 0 = 0 + * n * N = N + * n * I = I + * 0 * n = 0 + * 0 * 0 = 0 + * 0 * N = N + * 0 * I = N + * N * n = N + * N * 0 = N + * N * N = N + * N * I = N + * I * n = I + * I * 0 = N + * I * N = N + * I * I = I + * + * Return a new BigNumber whose value is the value of this BigNumber multiplied by the value + * of BigNumber(y, b). + */ + P.multipliedBy = P.times = function (y, b) { + var c, + e, + i, + j, + k, + m, + xcL, + xlo, + xhi, + ycL, + ylo, + yhi, + zc, + base, + sqrtBase, + x = this, + xc = x.c, + yc = (y = new BigNumber(y, b)).c + + // Either NaN, ±Infinity or ±0? + if (!xc || !yc || !xc[0] || !yc[0]) { + // Return NaN if either is NaN, or one is 0 and the other is Infinity. + if ( + !x.s || + !y.s || + (xc && !xc[0] && !yc) || + (yc && !yc[0] && !xc) + ) { + y.c = y.e = y.s = null + } else { + y.s *= x.s + + // Return ±Infinity if either is ±Infinity. + if (!xc || !yc) { + y.c = y.e = null + + // Return ±0 if either is ±0. + } else { + y.c = [0] + y.e = 0 + } + } + + return y + } + + e = bitFloor(x.e / LOG_BASE) + bitFloor(y.e / LOG_BASE) + y.s *= x.s + xcL = xc.length + ycL = yc.length + + // Ensure xc points to longer array and xcL to its length. + if (xcL < ycL) + (zc = xc), (xc = yc), (yc = zc), (i = xcL), (xcL = ycL), (ycL = i) + + // Initialise the result array with zeros. + for (i = xcL + ycL, zc = []; i--; zc.push(0)); + + base = BASE + sqrtBase = SQRT_BASE + + for (i = ycL; --i >= 0; ) { + c = 0 + ylo = yc[i] % sqrtBase + yhi = (yc[i] / sqrtBase) | 0 + + for (k = xcL, j = i + k; j > i; ) { + xlo = xc[--k] % sqrtBase + xhi = (xc[k] / sqrtBase) | 0 + m = yhi * xlo + xhi * ylo + xlo = ylo * xlo + (m % sqrtBase) * sqrtBase + zc[j] + c + c = ((xlo / base) | 0) + ((m / sqrtBase) | 0) + yhi * xhi + zc[j--] = xlo % base + } + + zc[j] = c + } + + if (c) { + ++e + } else { + zc.splice(0, 1) + } + + return normalise(y, zc, e) + } + + /* + * Return a new BigNumber whose value is the value of this BigNumber negated, + * i.e. multiplied by -1. + */ + P.negated = function () { + var x = new BigNumber(this) + x.s = -x.s || null + return x + } + + /* + * n + 0 = n + * n + N = N + * n + I = I + * 0 + n = n + * 0 + 0 = 0 + * 0 + N = N + * 0 + I = I + * N + n = N + * N + 0 = N + * N + N = N + * N + I = N + * I + n = I + * I + 0 = I + * I + N = N + * I + I = I + * + * Return a new BigNumber whose value is the value of this BigNumber plus the value of + * BigNumber(y, b). + */ + P.plus = function (y, b) { + var t, + x = this, + a = x.s + + y = new BigNumber(y, b) + b = y.s + + // Either NaN? + if (!a || !b) return new BigNumber(NaN) + + // Signs differ? + if (a != b) { + y.s = -b + return x.minus(y) + } + + var xe = x.e / LOG_BASE, + ye = y.e / LOG_BASE, + xc = x.c, + yc = y.c + + if (!xe || !ye) { + // Return ±Infinity if either ±Infinity. + if (!xc || !yc) return new BigNumber(a / 0) + + // Either zero? + // Return y if y is non-zero, x if x is non-zero, or zero if both are zero. + if (!xc[0] || !yc[0]) + return yc[0] ? y : new BigNumber(xc[0] ? x : a * 0) + } + + xe = bitFloor(xe) + ye = bitFloor(ye) + xc = xc.slice() + + // Prepend zeros to equalise exponents. Faster to use reverse then do unshifts. + if ((a = xe - ye)) { + if (a > 0) { + ye = xe + t = yc + } else { + a = -a + t = xc + } + + t.reverse() + for (; a--; t.push(0)); + t.reverse() + } + + a = xc.length + b = yc.length + + // Point xc to the longer array, and b to the shorter length. + if (a - b < 0) (t = yc), (yc = xc), (xc = t), (b = a) + + // Only start adding at yc.length - 1 as the further digits of xc can be ignored. + for (a = 0; b; ) { + a = ((xc[--b] = xc[b] + yc[b] + a) / BASE) | 0 + xc[b] = BASE === xc[b] ? 0 : xc[b] % BASE + } + + if (a) { + xc = [a].concat(xc) + ++ye + } + + // No need to check for zero, as +x + +y != 0 && -x + -y != 0 + // ye = MAX_EXP + 1 possible + return normalise(y, xc, ye) + } + + /* + * If sd is undefined or null or true or false, return the number of significant digits of + * the value of this BigNumber, or null if the value of this BigNumber is ±Infinity or NaN. + * If sd is true include integer-part trailing zeros in the count. + * + * Otherwise, if sd is a number, return a new BigNumber whose value is the value of this + * BigNumber rounded to a maximum of sd significant digits using rounding mode rm, or + * ROUNDING_MODE if rm is omitted. + * + * sd {number|boolean} number: significant digits: integer, 1 to MAX inclusive. + * boolean: whether to count integer-part trailing zeros: true or false. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * + * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {sd|rm}' + */ + P.precision = P.sd = function (sd, rm) { + var c, + n, + v, + x = this + + if (sd != null && sd !== !!sd) { + intCheck(sd, 1, MAX) + if (rm == null) rm = ROUNDING_MODE + else intCheck(rm, 0, 8) + + return round(new BigNumber(x), sd, rm) + } + + if (!(c = x.c)) return null + v = c.length - 1 + n = v * LOG_BASE + 1 + + if ((v = c[v])) { + // Subtract the number of trailing zeros of the last element. + for (; v % 10 == 0; v /= 10, n--); + + // Add the number of digits of the first element. + for (v = c[0]; v >= 10; v /= 10, n++); + } + + if (sd && x.e + 1 > n) n = x.e + 1 + + return n + } + + /* + * Return a new BigNumber whose value is the value of this BigNumber shifted by k places + * (powers of 10). Shift to the right if n > 0, and to the left if n < 0. + * + * k {number} Integer, -MAX_SAFE_INTEGER to MAX_SAFE_INTEGER inclusive. + * + * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {k}' + */ + P.shiftedBy = function (k) { + intCheck(k, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER) + return this.times('1e' + k) + } + + /* + * sqrt(-n) = N + * sqrt(N) = N + * sqrt(-I) = N + * sqrt(I) = I + * sqrt(0) = 0 + * sqrt(-0) = -0 + * + * Return a new BigNumber whose value is the square root of the value of this BigNumber, + * rounded according to DECIMAL_PLACES and ROUNDING_MODE. + */ + P.squareRoot = P.sqrt = function () { + var m, + n, + r, + rep, + t, + x = this, + c = x.c, + s = x.s, + e = x.e, + dp = DECIMAL_PLACES + 4, + half = new BigNumber('0.5') + + // Negative/NaN/Infinity/zero? + if (s !== 1 || !c || !c[0]) { + return new BigNumber( + !s || (s < 0 && (!c || c[0])) ? NaN : c ? x : 1 / 0 + ) + } + + // Initial estimate. + s = Math.sqrt(+valueOf(x)) + + // Math.sqrt underflow/overflow? + // Pass x to Math.sqrt as integer, then adjust the exponent of the result. + if (s == 0 || s == 1 / 0) { + n = coeffToString(c) + if ((n.length + e) % 2 == 0) n += '0' + s = Math.sqrt(+n) + e = bitFloor((e + 1) / 2) - (e < 0 || e % 2) + + if (s == 1 / 0) { + n = '5e' + e + } else { + n = s.toExponential() + n = n.slice(0, n.indexOf('e') + 1) + e + } + + r = new BigNumber(n) + } else { + r = new BigNumber(s + '') + } + + // Check for zero. + // r could be zero if MIN_EXP is changed after the this value was created. + // This would cause a division by zero (x/t) and hence Infinity below, which would cause + // coeffToString to throw. + if (r.c[0]) { + e = r.e + s = e + dp + if (s < 3) s = 0 + + // Newton-Raphson iteration. + for (;;) { + t = r + r = half.times(t.plus(div(x, t, dp, 1))) + + if ( + coeffToString(t.c).slice(0, s) === + (n = coeffToString(r.c)).slice(0, s) + ) { + // The exponent of r may here be one less than the final result exponent, + // e.g 0.0009999 (e-4) --> 0.001 (e-3), so adjust s so the rounding digits + // are indexed correctly. + if (r.e < e) --s + n = n.slice(s - 3, s + 1) + + // The 4th rounding digit may be in error by -1 so if the 4 rounding digits + // are 9999 or 4999 (i.e. approaching a rounding boundary) continue the + // iteration. + if (n == '9999' || (!rep && n == '4999')) { + // On the first iteration only, check to see if rounding up gives the + // exact result as the nines may infinitely repeat. + if (!rep) { + round(t, t.e + DECIMAL_PLACES + 2, 0) + + if (t.times(t).eq(x)) { + r = t + break + } + } + + dp += 4 + s += 4 + rep = 1 + } else { + // If rounding digits are null, 0{0,4} or 50{0,3}, check for exact + // result. If not, then there are further digits and m will be truthy. + if (!+n || (!+n.slice(1) && n.charAt(0) == '5')) { + // Truncate to the first rounding digit. + round(r, r.e + DECIMAL_PLACES + 2, 1) + m = !r.times(r).eq(x) + } + + break + } + } + } + } + + return round(r, r.e + DECIMAL_PLACES + 1, ROUNDING_MODE, m) + } + + /* + * Return a string representing the value of this BigNumber in exponential notation and + * rounded using ROUNDING_MODE to dp fixed decimal places. + * + * [dp] {number} Decimal places. Integer, 0 to MAX inclusive. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * + * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}' + */ + P.toExponential = function (dp, rm) { + if (dp != null) { + intCheck(dp, 0, MAX) + dp++ + } + return format(this, dp, rm, 1) + } + + /* + * Return a string representing the value of this BigNumber in fixed-point notation rounding + * to dp fixed decimal places using rounding mode rm, or ROUNDING_MODE if rm is omitted. + * + * Note: as with JavaScript's number type, (-0).toFixed(0) is '0', + * but e.g. (-0.00001).toFixed(0) is '-0'. + * + * [dp] {number} Decimal places. Integer, 0 to MAX inclusive. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * + * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}' + */ + P.toFixed = function (dp, rm) { + if (dp != null) { + intCheck(dp, 0, MAX) + dp = dp + this.e + 1 + } + return format(this, dp, rm) + } + + /* + * Return a string representing the value of this BigNumber in fixed-point notation rounded + * using rm or ROUNDING_MODE to dp decimal places, and formatted according to the properties + * of the format or FORMAT object (see BigNumber.set). + * + * The formatting object may contain some or all of the properties shown below. + * + * FORMAT = { + * prefix: '', + * groupSize: 3, + * secondaryGroupSize: 0, + * groupSeparator: ',', + * decimalSeparator: '.', + * fractionGroupSize: 0, + * fractionGroupSeparator: '\xA0', // non-breaking space + * suffix: '' + * }; + * + * [dp] {number} Decimal places. Integer, 0 to MAX inclusive. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * [format] {object} Formatting options. See FORMAT pbject above. + * + * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}' + * '[BigNumber Error] Argument not an object: {format}' + */ + P.toFormat = function (dp, rm, format) { + var str, + x = this + + if (format == null) { + if (dp != null && rm && typeof rm == 'object') { + format = rm + rm = null + } else if (dp && typeof dp == 'object') { + format = dp + dp = rm = null + } else { + format = FORMAT + } + } else if (typeof format != 'object') { + throw Error(bignumberError + 'Argument not an object: ' + format) + } + + str = x.toFixed(dp, rm) + + if (x.c) { + var i, + arr = str.split('.'), + g1 = +format.groupSize, + g2 = +format.secondaryGroupSize, + groupSeparator = format.groupSeparator || '', + intPart = arr[0], + fractionPart = arr[1], + isNeg = x.s < 0, + intDigits = isNeg ? intPart.slice(1) : intPart, + len = intDigits.length + + if (g2) (i = g1), (g1 = g2), (g2 = i), (len -= i) + + if (g1 > 0 && len > 0) { + i = len % g1 || g1 + intPart = intDigits.substr(0, i) + for (; i < len; i += g1) + intPart += groupSeparator + intDigits.substr(i, g1) + if (g2 > 0) intPart += groupSeparator + intDigits.slice(i) + if (isNeg) intPart = '-' + intPart + } + + str = fractionPart + ? intPart + + (format.decimalSeparator || '') + + ((g2 = +format.fractionGroupSize) + ? fractionPart.replace( + new RegExp('\\d{' + g2 + '}\\B', 'g'), + '$&' + (format.fractionGroupSeparator || '') + ) + : fractionPart) + : intPart + } + + return (format.prefix || '') + str + (format.suffix || '') + } + + /* + * Return an array of two BigNumbers representing the value of this BigNumber as a simple + * fraction with an integer numerator and an integer denominator. + * The denominator will be a positive non-zero value less than or equal to the specified + * maximum denominator. If a maximum denominator is not specified, the denominator will be + * the lowest value necessary to represent the number exactly. + * + * [md] {number|string|BigNumber} Integer >= 1, or Infinity. The maximum denominator. + * + * '[BigNumber Error] Argument {not an integer|out of range} : {md}' + */ + P.toFraction = function (md) { + var d, + d0, + d1, + d2, + e, + exp, + n, + n0, + n1, + q, + r, + s, + x = this, + xc = x.c + + if (md != null) { + n = new BigNumber(md) + + // Throw if md is less than one or is not an integer, unless it is Infinity. + if ((!n.isInteger() && (n.c || n.s !== 1)) || n.lt(ONE)) { + throw Error( + bignumberError + + 'Argument ' + + (n.isInteger() ? 'out of range: ' : 'not an integer: ') + + valueOf(n) + ) + } + } + + if (!xc) return new BigNumber(x) + + d = new BigNumber(ONE) + n1 = d0 = new BigNumber(ONE) + d1 = n0 = new BigNumber(ONE) + s = coeffToString(xc) + + // Determine initial denominator. + // d is a power of 10 and the minimum max denominator that specifies the value exactly. + e = d.e = s.length - x.e - 1 + d.c[0] = POWS_TEN[(exp = e % LOG_BASE) < 0 ? LOG_BASE + exp : exp] + md = !md || n.comparedTo(d) > 0 ? (e > 0 ? d : n1) : n + + exp = MAX_EXP + MAX_EXP = 1 / 0 + n = new BigNumber(s) + + // n0 = d1 = 0 + n0.c[0] = 0 + + for (;;) { + q = div(n, d, 0, 1) + d2 = d0.plus(q.times(d1)) + if (d2.comparedTo(md) == 1) break + d0 = d1 + d1 = d2 + n1 = n0.plus(q.times((d2 = n1))) + n0 = d2 + d = n.minus(q.times((d2 = d))) + n = d2 + } + + d2 = div(md.minus(d0), d1, 0, 1) + n0 = n0.plus(d2.times(n1)) + d0 = d0.plus(d2.times(d1)) + n0.s = n1.s = x.s + e = e * 2 + + // Determine which fraction is closer to x, n0/d0 or n1/d1 + r = + div(n1, d1, e, ROUNDING_MODE) + .minus(x) + .abs() + .comparedTo(div(n0, d0, e, ROUNDING_MODE).minus(x).abs()) < 1 + ? [n1, d1] + : [n0, d0] + + MAX_EXP = exp + + return r + } + + /* + * Return the value of this BigNumber converted to a number primitive. + */ + P.toNumber = function () { + return +valueOf(this) + } + + /* + * Return a string representing the value of this BigNumber rounded to sd significant digits + * using rounding mode rm or ROUNDING_MODE. If sd is less than the number of digits + * necessary to represent the integer part of the value in fixed-point notation, then use + * exponential notation. + * + * [sd] {number} Significant digits. Integer, 1 to MAX inclusive. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * + * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {sd|rm}' + */ + P.toPrecision = function (sd, rm) { + if (sd != null) intCheck(sd, 1, MAX) + return format(this, sd, rm, 2) + } + + /* + * Return a string representing the value of this BigNumber in base b, or base 10 if b is + * omitted. If a base is specified, including base 10, round according to DECIMAL_PLACES and + * ROUNDING_MODE. If a base is not specified, and this BigNumber has a positive exponent + * that is equal to or greater than TO_EXP_POS, or a negative exponent equal to or less than + * TO_EXP_NEG, return exponential notation. + * + * [b] {number} Integer, 2 to ALPHABET.length inclusive. + * + * '[BigNumber Error] Base {not a primitive number|not an integer|out of range}: {b}' + */ + P.toString = function (b) { + var str, + n = this, + s = n.s, + e = n.e + + // Infinity or NaN? + if (e === null) { + if (s) { + str = 'Infinity' + if (s < 0) str = '-' + str + } else { + str = 'NaN' + } + } else { + if (b == null) { + str = + e <= TO_EXP_NEG || e >= TO_EXP_POS + ? toExponential(coeffToString(n.c), e) + : toFixedPoint(coeffToString(n.c), e, '0') + } else if (b === 10) { + n = round( + new BigNumber(n), + DECIMAL_PLACES + e + 1, + ROUNDING_MODE + ) + str = toFixedPoint(coeffToString(n.c), n.e, '0') + } else { + intCheck(b, 2, ALPHABET.length, 'Base') + str = convertBase( + toFixedPoint(coeffToString(n.c), e, '0'), + 10, + b, + s, + true + ) + } + + if (s < 0 && n.c[0]) str = '-' + str + } + + return str + } + + /* + * Return as toString, but do not accept a base argument, and include the minus sign for + * negative zero. + */ + P.valueOf = P.toJSON = function () { + return valueOf(this) + } + + P._isBigNumber = true + + if (configObject != null) BigNumber.set(configObject) + + return BigNumber + } + + // PRIVATE HELPER FUNCTIONS + + // These functions don't need access to variables, + // e.g. DECIMAL_PLACES, in the scope of the `clone` function above. + + function bitFloor(n) { + var i = n | 0 + return n > 0 || n === i ? i : i - 1 + } + + // Return a coefficient array as a string of base 10 digits. + function coeffToString(a) { + var s, + z, + i = 1, + j = a.length, + r = a[0] + '' + + for (; i < j; ) { + s = a[i++] + '' + z = LOG_BASE - s.length + for (; z--; s = '0' + s); + r += s + } + + // Determine trailing zeros. + for (j = r.length; r.charCodeAt(--j) === 48; ); + + return r.slice(0, j + 1 || 1) + } + + // Compare the value of BigNumbers x and y. + function compare(x, y) { + var a, + b, + xc = x.c, + yc = y.c, + i = x.s, + j = y.s, + k = x.e, + l = y.e + + // Either NaN? + if (!i || !j) return null + + a = xc && !xc[0] + b = yc && !yc[0] + + // Either zero? + if (a || b) return a ? (b ? 0 : -j) : i + + // Signs differ? + if (i != j) return i + + a = i < 0 + b = k == l + + // Either Infinity? + if (!xc || !yc) return b ? 0 : !xc ^ a ? 1 : -1 + + // Compare exponents. + if (!b) return (k > l) ^ a ? 1 : -1 + + j = (k = xc.length) < (l = yc.length) ? k : l + + // Compare digit by digit. + for (i = 0; i < j; i++) + if (xc[i] != yc[i]) return (xc[i] > yc[i]) ^ a ? 1 : -1 + + // Compare lengths. + return k == l ? 0 : (k > l) ^ a ? 1 : -1 + } + + /* + * Check that n is a primitive number, an integer, and in range, otherwise throw. + */ + function intCheck(n, min, max, name) { + if (n < min || n > max || n !== mathfloor(n)) { + throw Error( + bignumberError + + (name || 'Argument') + + (typeof n == 'number' + ? n < min || n > max + ? ' out of range: ' + : ' not an integer: ' + : ' not a primitive number: ') + + String(n) + ) + } + } + + // Assumes finite n. + function isOdd(n) { + var k = n.c.length - 1 + return bitFloor(n.e / LOG_BASE) == k && n.c[k] % 2 != 0 + } + + function toExponential(str, e) { + return ( + (str.length > 1 ? str.charAt(0) + '.' + str.slice(1) : str) + + (e < 0 ? 'e' : 'e+') + + e + ) + } + + function toFixedPoint(str, e, z) { + var len, zs + + // Negative exponent? + if (e < 0) { + // Prepend zeros. + for (zs = z + '.'; ++e; zs += z); + str = zs + str + + // Positive exponent + } else { + len = str.length + + // Append zeros. + if (++e > len) { + for (zs = z, e -= len; --e; zs += z); + str += zs + } else if (e < len) { + str = str.slice(0, e) + '.' + str.slice(e) + } + } + + return str + } + + // EXPORT + + BigNumber = clone() + BigNumber['default'] = BigNumber.BigNumber = BigNumber + + // AMD. + if (typeof define == 'function' && define.amd) { + define(function () { + return BigNumber + }) + + // Node.js and other environments that support module.exports. + } else if (true && module.exports) { + module.exports = BigNumber + + // Browser. + } else { + if (!globalObject) { + globalObject = typeof self != 'undefined' && self ? self : window + } + + globalObject.BigNumber = BigNumber + } + })(this) + + /***/ + }, + + /***/ 33717: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + var concatMap = __webpack_require__(86891) + var balanced = __webpack_require__(9417) + + module.exports = expandTop + + var escSlash = '\0SLASH' + Math.random() + '\0' + var escOpen = '\0OPEN' + Math.random() + '\0' + var escClose = '\0CLOSE' + Math.random() + '\0' + var escComma = '\0COMMA' + Math.random() + '\0' + var escPeriod = '\0PERIOD' + Math.random() + '\0' + + function numeric(str) { + return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0) + } + + function escapeBraces(str) { + return str + .split('\\\\') + .join(escSlash) + .split('\\{') + .join(escOpen) + .split('\\}') + .join(escClose) + .split('\\,') + .join(escComma) + .split('\\.') + .join(escPeriod) + } + + function unescapeBraces(str) { + return str + .split(escSlash) + .join('\\') + .split(escOpen) + .join('{') + .split(escClose) + .join('}') + .split(escComma) + .join(',') + .split(escPeriod) + .join('.') + } + + // Basically just str.split(","), but handling cases + // where we have nested braced sections, which should be + // treated as individual members, like {a,{b,c},d} + function parseCommaParts(str) { + if (!str) return [''] + + var parts = [] + var m = balanced('{', '}', str) + + if (!m) return str.split(',') + + var pre = m.pre + var body = m.body + var post = m.post + var p = pre.split(',') + + p[p.length - 1] += '{' + body + '}' + var postParts = parseCommaParts(post) + if (post.length) { + p[p.length - 1] += postParts.shift() + p.push.apply(p, postParts) + } + + parts.push.apply(parts, p) + + return parts + } + + function expandTop(str) { + if (!str) return [] + + // I don't know why Bash 4.3 does this, but it does. + // Anything starting with {} will have the first two bytes preserved + // but *only* at the top level, so {},a}b will not expand to anything, + // but a{},b}c will be expanded to [a}c,abc]. + // One could argue that this is a bug in Bash, but since the goal of + // this module is to match Bash's rules, we escape a leading {} + if (str.substr(0, 2) === '{}') { + str = '\\{\\}' + str.substr(2) + } + + return expand(escapeBraces(str), true).map(unescapeBraces) + } + + function identity(e) { + return e + } + + function embrace(str) { + return '{' + str + '}' + } + function isPadded(el) { + return /^-?0\d/.test(el) + } + + function lte(i, y) { + return i <= y + } + function gte(i, y) { + return i >= y + } + + function expand(str, isTop) { + var expansions = [] + + var m = balanced('{', '}', str) + if (!m || /\$$/.test(m.pre)) return [str] + + var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body) + var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test( + m.body + ) + var isSequence = isNumericSequence || isAlphaSequence + var isOptions = m.body.indexOf(',') >= 0 + if (!isSequence && !isOptions) { + // {a},b} + if (m.post.match(/,.*\}/)) { + str = m.pre + '{' + m.body + escClose + m.post + return expand(str) + } + return [str] + } + + var n + if (isSequence) { + n = m.body.split(/\.\./) + } else { + n = parseCommaParts(m.body) + if (n.length === 1) { + // x{{a,b}}y ==> x{a}y x{b}y + n = expand(n[0], false).map(embrace) + if (n.length === 1) { + var post = m.post.length ? expand(m.post, false) : [''] + return post.map(function (p) { + return m.pre + n[0] + p + }) + } + } + } + + // at this point, n is the parts, and we know it's not a comma set + // with a single entry. + + // no need to expand pre, since it is guaranteed to be free of brace-sets + var pre = m.pre + var post = m.post.length ? expand(m.post, false) : [''] + + var N + + if (isSequence) { + var x = numeric(n[0]) + var y = numeric(n[1]) + var width = Math.max(n[0].length, n[1].length) + var incr = n.length == 3 ? Math.abs(numeric(n[2])) : 1 + var test = lte + var reverse = y < x + if (reverse) { + incr *= -1 + test = gte + } + var pad = n.some(isPadded) + + N = [] + + for (var i = x; test(i, y); i += incr) { + var c + if (isAlphaSequence) { + c = String.fromCharCode(i) + if (c === '\\') c = '' + } else { + c = String(i) + if (pad) { + var need = width - c.length + if (need > 0) { + var z = new Array(need + 1).join('0') + if (i < 0) c = '-' + z + c.slice(1) + else c = z + c + } + } + } + N.push(c) + } + } else { + N = concatMap(n, function (el) { + return expand(el, false) + }) + } + + for (var j = 0; j < N.length; j++) { + for (var k = 0; k < post.length; k++) { + var expansion = pre + N[j] + post[k] + if (!isTop || isSequence || expansion) expansions.push(expansion) + } + } + + return expansions + } + + /***/ + }, + + /***/ 72358: /***/ module => { + module.exports = function btoa(str) { + return new Buffer(str).toString('base64') + } + + /***/ + }, + + /***/ 9239: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + 'use strict' + /*jshint node:true */ + + var Buffer = __webpack_require__(64293).Buffer // browserify + var SlowBuffer = __webpack_require__(64293).SlowBuffer + + module.exports = bufferEq + + function bufferEq(a, b) { + // shortcutting on type is necessary for correctness + if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { + return false + } + + // buffer sizes should be well-known information, so despite this + // shortcutting, it doesn't leak any information about the *contents* of the + // buffers. + if (a.length !== b.length) { + return false + } + + var c = 0 + for (var i = 0; i < a.length; i++) { + /*jshint bitwise:false */ + c |= a[i] ^ b[i] // XOR + } + return c === 0 + } + + bufferEq.install = function () { + Buffer.prototype.equal = SlowBuffer.prototype.equal = function equal( + that + ) { + return bufferEq(this, that) + } + } + + var origBufEqual = Buffer.prototype.equal + var origSlowBufEqual = SlowBuffer.prototype.equal + bufferEq.restore = function () { + Buffer.prototype.equal = origBufEqual + SlowBuffer.prototype.equal = origSlowBufEqual + } + + /***/ + }, + + /***/ 35684: /***/ module => { + function Caseless(dict) { + this.dict = dict || {} + } + Caseless.prototype.set = function (name, value, clobber) { + if (typeof name === 'object') { + for (var i in name) { + this.set(i, name[i], value) + } + } else { + if (typeof clobber === 'undefined') clobber = true + var has = this.has(name) + + if (!clobber && has) this.dict[has] = this.dict[has] + ',' + value + else this.dict[has || name] = value + return has + } + } + Caseless.prototype.has = function (name) { + var keys = Object.keys(this.dict), + name = name.toLowerCase() + for (var i = 0; i < keys.length; i++) { + if (keys[i].toLowerCase() === name) return keys[i] + } + return false + } + Caseless.prototype.get = function (name) { + name = name.toLowerCase() + var result, _key + var headers = this.dict + Object.keys(headers).forEach(function (key) { + _key = key.toLowerCase() + if (name === _key) result = headers[key] + }) + return result + } + Caseless.prototype.swap = function (name) { + var has = this.has(name) + if (has === name) return + if (!has) + throw new Error('There is no header than matches "' + name + '"') + this.dict[name] = this.dict[has] + delete this.dict[has] + } + Caseless.prototype.del = function (name) { + var has = this.has(name) + return delete this.dict[has || name] + } + + module.exports = function (dict) { + return new Caseless(dict) + } + module.exports.httpify = function (resp, headers) { + var c = new Caseless(headers) + resp.setHeader = function (key, value, clobber) { + if (typeof value === 'undefined') return + return c.set(key, value, clobber) + } + resp.hasHeader = function (key) { + return c.has(key) + } + resp.getHeader = function (key) { + return c.get(key) + } + resp.removeHeader = function (key) { + return c.del(key) + } + resp.headers = c.dict + return c + } + + /***/ + }, + + /***/ 78818: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + 'use strict' + + const ansiStyles = __webpack_require__(52068) + const { stdout: stdoutColor, stderr: stderrColor } = __webpack_require__( + 59318 + ) + const { + stringReplaceAll, + stringEncaseCRLFWithFirstIndex + } = __webpack_require__(82415) + + const { isArray } = Array + + // `supportsColor.level` → `ansiStyles.color[name]` mapping + const levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m'] + + const styles = Object.create(null) + + const applyOptions = (object, options = {}) => { + if ( + options.level && + !( + Number.isInteger(options.level) && + options.level >= 0 && + options.level <= 3 + ) + ) { + throw new Error('The `level` option should be an integer from 0 to 3') + } + + // Detect level if not set manually + const colorLevel = stdoutColor ? stdoutColor.level : 0 + object.level = options.level === undefined ? colorLevel : options.level + } + + class ChalkClass { + constructor(options) { + // eslint-disable-next-line no-constructor-return + return chalkFactory(options) + } + } + + const chalkFactory = options => { + const chalk = {} + applyOptions(chalk, options) + + chalk.template = (...arguments_) => + chalkTag(chalk.template, ...arguments_) + + Object.setPrototypeOf(chalk, Chalk.prototype) + Object.setPrototypeOf(chalk.template, chalk) + + chalk.template.constructor = () => { + throw new Error( + '`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.' + ) + } + + chalk.template.Instance = ChalkClass + + return chalk.template + } + + function Chalk(options) { + return chalkFactory(options) + } + + for (const [styleName, style] of Object.entries(ansiStyles)) { + styles[styleName] = { + get() { + const builder = createBuilder( + this, + createStyler(style.open, style.close, this._styler), + this._isEmpty + ) + Object.defineProperty(this, styleName, { value: builder }) + return builder + } + } + } + + styles.visible = { + get() { + const builder = createBuilder(this, this._styler, true) + Object.defineProperty(this, 'visible', { value: builder }) + return builder + } + } + + const usedModels = [ + 'rgb', + 'hex', + 'keyword', + 'hsl', + 'hsv', + 'hwb', + 'ansi', + 'ansi256' + ] + + for (const model of usedModels) { + styles[model] = { + get() { + const { level } = this + return function (...arguments_) { + const styler = createStyler( + ansiStyles.color[levelMapping[level]][model](...arguments_), + ansiStyles.color.close, + this._styler + ) + return createBuilder(this, styler, this._isEmpty) + } + } + } + } + + for (const model of usedModels) { + const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1) + styles[bgModel] = { + get() { + const { level } = this + return function (...arguments_) { + const styler = createStyler( + ansiStyles.bgColor[levelMapping[level]][model](...arguments_), + ansiStyles.bgColor.close, + this._styler + ) + return createBuilder(this, styler, this._isEmpty) + } + } + } + } + + const proto = Object.defineProperties(() => {}, { + ...styles, + level: { + enumerable: true, + get() { + return this._generator.level + }, + set(level) { + this._generator.level = level + } + } + }) + + const createStyler = (open, close, parent) => { + let openAll + let closeAll + if (parent === undefined) { + openAll = open + closeAll = close + } else { + openAll = parent.openAll + open + closeAll = close + parent.closeAll + } + + return { + open, + close, + openAll, + closeAll, + parent + } + } + + const createBuilder = (self, _styler, _isEmpty) => { + const builder = (...arguments_) => { + if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) { + // Called as a template literal, for example: chalk.red`2 + 3 = {bold ${2+3}}` + return applyStyle(builder, chalkTag(builder, ...arguments_)) + } + + // Single argument is hot path, implicit coercion is faster than anything + // eslint-disable-next-line no-implicit-coercion + return applyStyle( + builder, + arguments_.length === 1 ? '' + arguments_[0] : arguments_.join(' ') + ) + } + + // We alter the prototype because we must return a function, but there is + // no way to create a function with a different prototype + Object.setPrototypeOf(builder, proto) + + builder._generator = self + builder._styler = _styler + builder._isEmpty = _isEmpty + + return builder + } + + const applyStyle = (self, string) => { + if (self.level <= 0 || !string) { + return self._isEmpty ? '' : string + } + + let styler = self._styler + + if (styler === undefined) { + return string + } + + const { openAll, closeAll } = styler + if (string.indexOf('\u001B') !== -1) { + while (styler !== undefined) { + // Replace any instances already present with a re-opening code + // otherwise only the part of the string until said closing code + // will be colored, and the rest will simply be 'plain'. + string = stringReplaceAll(string, styler.close, styler.open) + + styler = styler.parent + } + } + + // We can move both next actions out of loop, because remaining actions in loop won't have + // any/visible effect on parts we add here. Close the styling before a linebreak and reopen + // after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92 + const lfIndex = string.indexOf('\n') + if (lfIndex !== -1) { + string = stringEncaseCRLFWithFirstIndex( + string, + closeAll, + openAll, + lfIndex + ) + } + + return openAll + string + closeAll + } + + let template + const chalkTag = (chalk, ...strings) => { + const [firstString] = strings + + if (!isArray(firstString) || !isArray(firstString.raw)) { + // If chalk() was called by itself or with a string, + // return the string itself as a string. + return strings.join(' ') + } + + const arguments_ = strings.slice(1) + const parts = [firstString.raw[0]] + + for (let i = 1; i < firstString.length; i++) { + parts.push( + String(arguments_[i - 1]).replace(/[{}\\]/g, '\\$&'), + String(firstString.raw[i]) + ) + } + + if (template === undefined) { + template = __webpack_require__(20500) + } + + return template(chalk, parts.join('')) + } + + Object.defineProperties(Chalk.prototype, styles) + + const chalk = Chalk() // eslint-disable-line new-cap + chalk.supportsColor = stdoutColor + chalk.stderr = Chalk({ level: stderrColor ? stderrColor.level : 0 }) // eslint-disable-line new-cap + chalk.stderr.supportsColor = stderrColor + + module.exports = chalk + + /***/ + }, + + /***/ 20500: /***/ module => { + 'use strict' + + const TEMPLATE_REGEX = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi + const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g + const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/ + const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi + + const ESCAPES = new Map([ + ['n', '\n'], + ['r', '\r'], + ['t', '\t'], + ['b', '\b'], + ['f', '\f'], + ['v', '\v'], + ['0', '\0'], + ['\\', '\\'], + ['e', '\u001B'], + ['a', '\u0007'] + ]) + + function unescape(c) { + const u = c[0] === 'u' + const bracket = c[1] === '{' + + if ( + (u && !bracket && c.length === 5) || + (c[0] === 'x' && c.length === 3) + ) { + return String.fromCharCode(parseInt(c.slice(1), 16)) + } + + if (u && bracket) { + return String.fromCodePoint(parseInt(c.slice(2, -1), 16)) + } + + return ESCAPES.get(c) || c + } + + function parseArguments(name, arguments_) { + const results = [] + const chunks = arguments_.trim().split(/\s*,\s*/g) + let matches + + for (const chunk of chunks) { + const number = Number(chunk) + if (!Number.isNaN(number)) { + results.push(number) + } else if ((matches = chunk.match(STRING_REGEX))) { + results.push( + matches[2].replace(ESCAPE_REGEX, (m, escape, character) => + escape ? unescape(escape) : character + ) + ) + } else { + throw new Error( + `Invalid Chalk template style argument: ${chunk} (in style '${name}')` + ) + } + } + + return results + } + + function parseStyle(style) { + STYLE_REGEX.lastIndex = 0 + + const results = [] + let matches + + while ((matches = STYLE_REGEX.exec(style)) !== null) { + const name = matches[1] + + if (matches[2]) { + const args = parseArguments(name, matches[2]) + results.push([name].concat(args)) + } else { + results.push([name]) + } + } + + return results + } + + function buildStyle(chalk, styles) { + const enabled = {} + + for (const layer of styles) { + for (const style of layer.styles) { + enabled[style[0]] = layer.inverse ? null : style.slice(1) + } + } + + let current = chalk + for (const [styleName, styles] of Object.entries(enabled)) { + if (!Array.isArray(styles)) { + continue + } + + if (!(styleName in current)) { + throw new Error(`Unknown Chalk style: ${styleName}`) + } + + current = + styles.length > 0 + ? current[styleName](...styles) + : current[styleName] + } + + return current + } + + module.exports = (chalk, temporary) => { + const styles = [] + const chunks = [] + let chunk = [] + + // eslint-disable-next-line max-params + temporary.replace( + TEMPLATE_REGEX, + (m, escapeCharacter, inverse, style, close, character) => { + if (escapeCharacter) { + chunk.push(unescape(escapeCharacter)) + } else if (style) { + const string = chunk.join('') + chunk = [] + chunks.push( + styles.length === 0 ? string : buildStyle(chalk, styles)(string) + ) + styles.push({ inverse, styles: parseStyle(style) }) + } else if (close) { + if (styles.length === 0) { + throw new Error('Found extraneous } in Chalk template literal') + } + + chunks.push(buildStyle(chalk, styles)(chunk.join(''))) + chunk = [] + styles.pop() + } else { + chunk.push(character) + } + } + ) + + chunks.push(chunk.join('')) + + if (styles.length > 0) { + const errMessage = `Chalk template literal is missing ${ + styles.length + } closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)` + throw new Error(errMessage) + } + + return chunks.join('') + } + + /***/ + }, + + /***/ 82415: /***/ module => { + 'use strict' + + const stringReplaceAll = (string, substring, replacer) => { + let index = string.indexOf(substring) + if (index === -1) { + return string + } + + const substringLength = substring.length + let endIndex = 0 + let returnValue = '' + do { + returnValue += + string.substr(endIndex, index - endIndex) + substring + replacer + endIndex = index + substringLength + index = string.indexOf(substring, endIndex) + } while (index !== -1) + + returnValue += string.substr(endIndex) + return returnValue + } + + const stringEncaseCRLFWithFirstIndex = ( + string, + prefix, + postfix, + index + ) => { + let endIndex = 0 + let returnValue = '' + do { + const gotCR = string[index - 1] === '\r' + returnValue += + string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + + prefix + + (gotCR ? '\r\n' : '\n') + + postfix + endIndex = index + 1 + index = string.indexOf('\n', endIndex) + } while (index !== -1) + + returnValue += string.substr(endIndex) + return returnValue + } + + module.exports = { + stringReplaceAll, + stringEncaseCRLFWithFirstIndex + } + + /***/ + }, + + /***/ 97391: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + /* MIT license */ + /* eslint-disable no-mixed-operators */ + const cssKeywords = __webpack_require__(78510) + + // NOTE: conversions should only return primitive values (i.e. arrays, or + // values that give correct `typeof` results). + // do not use box values types (i.e. Number(), String(), etc.) + + const reverseKeywords = {} + for (const key of Object.keys(cssKeywords)) { + reverseKeywords[cssKeywords[key]] = key + } + + const convert = { + rgb: { channels: 3, labels: 'rgb' }, + hsl: { channels: 3, labels: 'hsl' }, + hsv: { channels: 3, labels: 'hsv' }, + hwb: { channels: 3, labels: 'hwb' }, + cmyk: { channels: 4, labels: 'cmyk' }, + xyz: { channels: 3, labels: 'xyz' }, + lab: { channels: 3, labels: 'lab' }, + lch: { channels: 3, labels: 'lch' }, + hex: { channels: 1, labels: ['hex'] }, + keyword: { channels: 1, labels: ['keyword'] }, + ansi16: { channels: 1, labels: ['ansi16'] }, + ansi256: { channels: 1, labels: ['ansi256'] }, + hcg: { channels: 3, labels: ['h', 'c', 'g'] }, + apple: { channels: 3, labels: ['r16', 'g16', 'b16'] }, + gray: { channels: 1, labels: ['gray'] } + } + + module.exports = convert + + // Hide .channels and .labels properties + for (const model of Object.keys(convert)) { + if (!('channels' in convert[model])) { + throw new Error('missing channels property: ' + model) + } + + if (!('labels' in convert[model])) { + throw new Error('missing channel labels property: ' + model) + } + + if (convert[model].labels.length !== convert[model].channels) { + throw new Error('channel and label counts mismatch: ' + model) + } + + const { channels, labels } = convert[model] + delete convert[model].channels + delete convert[model].labels + Object.defineProperty(convert[model], 'channels', { value: channels }) + Object.defineProperty(convert[model], 'labels', { value: labels }) + } + + convert.rgb.hsl = function (rgb) { + const r = rgb[0] / 255 + const g = rgb[1] / 255 + const b = rgb[2] / 255 + const min = Math.min(r, g, b) + const max = Math.max(r, g, b) + const delta = max - min + let h + let s + + if (max === min) { + h = 0 + } else if (r === max) { + h = (g - b) / delta + } else if (g === max) { + h = 2 + (b - r) / delta + } else if (b === max) { + h = 4 + (r - g) / delta + } + + h = Math.min(h * 60, 360) + + if (h < 0) { + h += 360 + } + + const l = (min + max) / 2 + + if (max === min) { + s = 0 + } else if (l <= 0.5) { + s = delta / (max + min) + } else { + s = delta / (2 - max - min) + } + + return [h, s * 100, l * 100] + } + + convert.rgb.hsv = function (rgb) { + let rdif + let gdif + let bdif + let h + let s + + const r = rgb[0] / 255 + const g = rgb[1] / 255 + const b = rgb[2] / 255 + const v = Math.max(r, g, b) + const diff = v - Math.min(r, g, b) + const diffc = function (c) { + return (v - c) / 6 / diff + 1 / 2 + } + + if (diff === 0) { + h = 0 + s = 0 + } else { + s = diff / v + rdif = diffc(r) + gdif = diffc(g) + bdif = diffc(b) + + if (r === v) { + h = bdif - gdif + } else if (g === v) { + h = 1 / 3 + rdif - bdif + } else if (b === v) { + h = 2 / 3 + gdif - rdif + } + + if (h < 0) { + h += 1 + } else if (h > 1) { + h -= 1 + } + } + + return [h * 360, s * 100, v * 100] + } + + convert.rgb.hwb = function (rgb) { + const r = rgb[0] + const g = rgb[1] + let b = rgb[2] + const h = convert.rgb.hsl(rgb)[0] + const w = (1 / 255) * Math.min(r, Math.min(g, b)) + + b = 1 - (1 / 255) * Math.max(r, Math.max(g, b)) + + return [h, w * 100, b * 100] + } + + convert.rgb.cmyk = function (rgb) { + const r = rgb[0] / 255 + const g = rgb[1] / 255 + const b = rgb[2] / 255 + + const k = Math.min(1 - r, 1 - g, 1 - b) + const c = (1 - r - k) / (1 - k) || 0 + const m = (1 - g - k) / (1 - k) || 0 + const y = (1 - b - k) / (1 - k) || 0 + + return [c * 100, m * 100, y * 100, k * 100] + } + + function comparativeDistance(x, y) { + /* + See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance + */ + return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2 + } + + convert.rgb.keyword = function (rgb) { + const reversed = reverseKeywords[rgb] + if (reversed) { + return reversed + } + + let currentClosestDistance = Infinity + let currentClosestKeyword + + for (const keyword of Object.keys(cssKeywords)) { + const value = cssKeywords[keyword] + + // Compute comparative distance + const distance = comparativeDistance(rgb, value) + + // Check if its less, if so set as closest + if (distance < currentClosestDistance) { + currentClosestDistance = distance + currentClosestKeyword = keyword + } + } + + return currentClosestKeyword + } + + convert.keyword.rgb = function (keyword) { + return cssKeywords[keyword] + } + + convert.rgb.xyz = function (rgb) { + let r = rgb[0] / 255 + let g = rgb[1] / 255 + let b = rgb[2] / 255 + + // Assume sRGB + r = r > 0.04045 ? ((r + 0.055) / 1.055) ** 2.4 : r / 12.92 + g = g > 0.04045 ? ((g + 0.055) / 1.055) ** 2.4 : g / 12.92 + b = b > 0.04045 ? ((b + 0.055) / 1.055) ** 2.4 : b / 12.92 + + const x = r * 0.4124 + g * 0.3576 + b * 0.1805 + const y = r * 0.2126 + g * 0.7152 + b * 0.0722 + const z = r * 0.0193 + g * 0.1192 + b * 0.9505 + + return [x * 100, y * 100, z * 100] + } + + convert.rgb.lab = function (rgb) { + const xyz = convert.rgb.xyz(rgb) + let x = xyz[0] + let y = xyz[1] + let z = xyz[2] + + x /= 95.047 + y /= 100 + z /= 108.883 + + x = x > 0.008856 ? x ** (1 / 3) : 7.787 * x + 16 / 116 + y = y > 0.008856 ? y ** (1 / 3) : 7.787 * y + 16 / 116 + z = z > 0.008856 ? z ** (1 / 3) : 7.787 * z + 16 / 116 + + const l = 116 * y - 16 + const a = 500 * (x - y) + const b = 200 * (y - z) + + return [l, a, b] + } + + convert.hsl.rgb = function (hsl) { + const h = hsl[0] / 360 + const s = hsl[1] / 100 + const l = hsl[2] / 100 + let t2 + let t3 + let val + + if (s === 0) { + val = l * 255 + return [val, val, val] + } + + if (l < 0.5) { + t2 = l * (1 + s) + } else { + t2 = l + s - l * s + } + + const t1 = 2 * l - t2 + + const rgb = [0, 0, 0] + for (let i = 0; i < 3; i++) { + t3 = h + (1 / 3) * -(i - 1) + if (t3 < 0) { + t3++ + } + + if (t3 > 1) { + t3-- + } + + if (6 * t3 < 1) { + val = t1 + (t2 - t1) * 6 * t3 + } else if (2 * t3 < 1) { + val = t2 + } else if (3 * t3 < 2) { + val = t1 + (t2 - t1) * (2 / 3 - t3) * 6 + } else { + val = t1 + } + + rgb[i] = val * 255 + } + + return rgb + } + + convert.hsl.hsv = function (hsl) { + const h = hsl[0] + let s = hsl[1] / 100 + let l = hsl[2] / 100 + let smin = s + const lmin = Math.max(l, 0.01) + + l *= 2 + s *= l <= 1 ? l : 2 - l + smin *= lmin <= 1 ? lmin : 2 - lmin + const v = (l + s) / 2 + const sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s) + + return [h, sv * 100, v * 100] + } + + convert.hsv.rgb = function (hsv) { + const h = hsv[0] / 60 + const s = hsv[1] / 100 + let v = hsv[2] / 100 + const hi = Math.floor(h) % 6 + + const f = h - Math.floor(h) + const p = 255 * v * (1 - s) + const q = 255 * v * (1 - s * f) + const t = 255 * v * (1 - s * (1 - f)) + v *= 255 + + switch (hi) { + case 0: + return [v, t, p] + case 1: + return [q, v, p] + case 2: + return [p, v, t] + case 3: + return [p, q, v] + case 4: + return [t, p, v] + case 5: + return [v, p, q] + } + } + + convert.hsv.hsl = function (hsv) { + const h = hsv[0] + const s = hsv[1] / 100 + const v = hsv[2] / 100 + const vmin = Math.max(v, 0.01) + let sl + let l + + l = (2 - s) * v + const lmin = (2 - s) * vmin + sl = s * vmin + sl /= lmin <= 1 ? lmin : 2 - lmin + sl = sl || 0 + l /= 2 + + return [h, sl * 100, l * 100] + } + + // http://dev.w3.org/csswg/css-color/#hwb-to-rgb + convert.hwb.rgb = function (hwb) { + const h = hwb[0] / 360 + let wh = hwb[1] / 100 + let bl = hwb[2] / 100 + const ratio = wh + bl + let f + + // Wh + bl cant be > 1 + if (ratio > 1) { + wh /= ratio + bl /= ratio + } + + const i = Math.floor(6 * h) + const v = 1 - bl + f = 6 * h - i + + if ((i & 0x01) !== 0) { + f = 1 - f + } + + const n = wh + f * (v - wh) // Linear interpolation + + let r + let g + let b + /* eslint-disable max-statements-per-line,no-multi-spaces */ + switch (i) { + default: + case 6: + case 0: + r = v + g = n + b = wh + break + case 1: + r = n + g = v + b = wh + break + case 2: + r = wh + g = v + b = n + break + case 3: + r = wh + g = n + b = v + break + case 4: + r = n + g = wh + b = v + break + case 5: + r = v + g = wh + b = n + break + } + /* eslint-enable max-statements-per-line,no-multi-spaces */ + + return [r * 255, g * 255, b * 255] + } + + convert.cmyk.rgb = function (cmyk) { + const c = cmyk[0] / 100 + const m = cmyk[1] / 100 + const y = cmyk[2] / 100 + const k = cmyk[3] / 100 + + const r = 1 - Math.min(1, c * (1 - k) + k) + const g = 1 - Math.min(1, m * (1 - k) + k) + const b = 1 - Math.min(1, y * (1 - k) + k) + + return [r * 255, g * 255, b * 255] + } + + convert.xyz.rgb = function (xyz) { + const x = xyz[0] / 100 + const y = xyz[1] / 100 + const z = xyz[2] / 100 + let r + let g + let b + + r = x * 3.2406 + y * -1.5372 + z * -0.4986 + g = x * -0.9689 + y * 1.8758 + z * 0.0415 + b = x * 0.0557 + y * -0.204 + z * 1.057 + + // Assume sRGB + r = r > 0.0031308 ? 1.055 * r ** (1.0 / 2.4) - 0.055 : r * 12.92 + + g = g > 0.0031308 ? 1.055 * g ** (1.0 / 2.4) - 0.055 : g * 12.92 + + b = b > 0.0031308 ? 1.055 * b ** (1.0 / 2.4) - 0.055 : b * 12.92 + + r = Math.min(Math.max(0, r), 1) + g = Math.min(Math.max(0, g), 1) + b = Math.min(Math.max(0, b), 1) + + return [r * 255, g * 255, b * 255] + } + + convert.xyz.lab = function (xyz) { + let x = xyz[0] + let y = xyz[1] + let z = xyz[2] + + x /= 95.047 + y /= 100 + z /= 108.883 + + x = x > 0.008856 ? x ** (1 / 3) : 7.787 * x + 16 / 116 + y = y > 0.008856 ? y ** (1 / 3) : 7.787 * y + 16 / 116 + z = z > 0.008856 ? z ** (1 / 3) : 7.787 * z + 16 / 116 + + const l = 116 * y - 16 + const a = 500 * (x - y) + const b = 200 * (y - z) + + return [l, a, b] + } + + convert.lab.xyz = function (lab) { + const l = lab[0] + const a = lab[1] + const b = lab[2] + let x + let y + let z + + y = (l + 16) / 116 + x = a / 500 + y + z = y - b / 200 + + const y2 = y ** 3 + const x2 = x ** 3 + const z2 = z ** 3 + y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787 + x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787 + z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787 + + x *= 95.047 + y *= 100 + z *= 108.883 + + return [x, y, z] + } + + convert.lab.lch = function (lab) { + const l = lab[0] + const a = lab[1] + const b = lab[2] + let h + + const hr = Math.atan2(b, a) + h = (hr * 360) / 2 / Math.PI + + if (h < 0) { + h += 360 + } + + const c = Math.sqrt(a * a + b * b) + + return [l, c, h] + } + + convert.lch.lab = function (lch) { + const l = lch[0] + const c = lch[1] + const h = lch[2] + + const hr = (h / 360) * 2 * Math.PI + const a = c * Math.cos(hr) + const b = c * Math.sin(hr) + + return [l, a, b] + } + + convert.rgb.ansi16 = function (args, saturation = null) { + const [r, g, b] = args + let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation // Hsv -> ansi16 optimization + + value = Math.round(value / 50) + + if (value === 0) { + return 30 + } + + let ansi = + 30 + + ((Math.round(b / 255) << 2) | + (Math.round(g / 255) << 1) | + Math.round(r / 255)) + + if (value === 2) { + ansi += 60 + } + + return ansi + } + + convert.hsv.ansi16 = function (args) { + // Optimization here; we already know the value and don't need to get + // it converted for us. + return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]) + } + + convert.rgb.ansi256 = function (args) { + const r = args[0] + const g = args[1] + const b = args[2] + + // We use the extended greyscale palette here, with the exception of + // black and white. normal palette only has 4 greyscale shades. + if (r === g && g === b) { + if (r < 8) { + return 16 + } + + if (r > 248) { + return 231 + } + + return Math.round(((r - 8) / 247) * 24) + 232 + } + + const ansi = + 16 + + 36 * Math.round((r / 255) * 5) + + 6 * Math.round((g / 255) * 5) + + Math.round((b / 255) * 5) + + return ansi + } + + convert.ansi16.rgb = function (args) { + let color = args % 10 + + // Handle greyscale + if (color === 0 || color === 7) { + if (args > 50) { + color += 3.5 + } + + color = (color / 10.5) * 255 + + return [color, color, color] + } + + const mult = (~~(args > 50) + 1) * 0.5 + const r = (color & 1) * mult * 255 + const g = ((color >> 1) & 1) * mult * 255 + const b = ((color >> 2) & 1) * mult * 255 + + return [r, g, b] + } + + convert.ansi256.rgb = function (args) { + // Handle greyscale + if (args >= 232) { + const c = (args - 232) * 10 + 8 + return [c, c, c] + } + + args -= 16 + + let rem + const r = (Math.floor(args / 36) / 5) * 255 + const g = (Math.floor((rem = args % 36) / 6) / 5) * 255 + const b = ((rem % 6) / 5) * 255 + + return [r, g, b] + } + + convert.rgb.hex = function (args) { + const integer = + ((Math.round(args[0]) & 0xff) << 16) + + ((Math.round(args[1]) & 0xff) << 8) + + (Math.round(args[2]) & 0xff) + + const string = integer.toString(16).toUpperCase() + return '000000'.substring(string.length) + string + } + + convert.hex.rgb = function (args) { + const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i) + if (!match) { + return [0, 0, 0] + } + + let colorString = match[0] + + if (match[0].length === 3) { + colorString = colorString + .split('') + .map(char => { + return char + char + }) + .join('') + } + + const integer = parseInt(colorString, 16) + const r = (integer >> 16) & 0xff + const g = (integer >> 8) & 0xff + const b = integer & 0xff + + return [r, g, b] + } + + convert.rgb.hcg = function (rgb) { + const r = rgb[0] / 255 + const g = rgb[1] / 255 + const b = rgb[2] / 255 + const max = Math.max(Math.max(r, g), b) + const min = Math.min(Math.min(r, g), b) + const chroma = max - min + let grayscale + let hue + + if (chroma < 1) { + grayscale = min / (1 - chroma) + } else { + grayscale = 0 + } + + if (chroma <= 0) { + hue = 0 + } else if (max === r) { + hue = ((g - b) / chroma) % 6 + } else if (max === g) { + hue = 2 + (b - r) / chroma + } else { + hue = 4 + (r - g) / chroma + } + + hue /= 6 + hue %= 1 + + return [hue * 360, chroma * 100, grayscale * 100] + } + + convert.hsl.hcg = function (hsl) { + const s = hsl[1] / 100 + const l = hsl[2] / 100 + + const c = l < 0.5 ? 2.0 * s * l : 2.0 * s * (1.0 - l) + + let f = 0 + if (c < 1.0) { + f = (l - 0.5 * c) / (1.0 - c) + } + + return [hsl[0], c * 100, f * 100] + } + + convert.hsv.hcg = function (hsv) { + const s = hsv[1] / 100 + const v = hsv[2] / 100 + + const c = s * v + let f = 0 + + if (c < 1.0) { + f = (v - c) / (1 - c) + } + + return [hsv[0], c * 100, f * 100] + } + + convert.hcg.rgb = function (hcg) { + const h = hcg[0] / 360 + const c = hcg[1] / 100 + const g = hcg[2] / 100 + + if (c === 0.0) { + return [g * 255, g * 255, g * 255] + } + + const pure = [0, 0, 0] + const hi = (h % 1) * 6 + const v = hi % 1 + const w = 1 - v + let mg = 0 + + /* eslint-disable max-statements-per-line */ + switch (Math.floor(hi)) { + case 0: + pure[0] = 1 + pure[1] = v + pure[2] = 0 + break + case 1: + pure[0] = w + pure[1] = 1 + pure[2] = 0 + break + case 2: + pure[0] = 0 + pure[1] = 1 + pure[2] = v + break + case 3: + pure[0] = 0 + pure[1] = w + pure[2] = 1 + break + case 4: + pure[0] = v + pure[1] = 0 + pure[2] = 1 + break + default: + pure[0] = 1 + pure[1] = 0 + pure[2] = w + } + /* eslint-enable max-statements-per-line */ + + mg = (1.0 - c) * g + + return [ + (c * pure[0] + mg) * 255, + (c * pure[1] + mg) * 255, + (c * pure[2] + mg) * 255 + ] + } + + convert.hcg.hsv = function (hcg) { + const c = hcg[1] / 100 + const g = hcg[2] / 100 + + const v = c + g * (1.0 - c) + let f = 0 + + if (v > 0.0) { + f = c / v + } + + return [hcg[0], f * 100, v * 100] + } + + convert.hcg.hsl = function (hcg) { + const c = hcg[1] / 100 + const g = hcg[2] / 100 + + const l = g * (1.0 - c) + 0.5 * c + let s = 0 + + if (l > 0.0 && l < 0.5) { + s = c / (2 * l) + } else if (l >= 0.5 && l < 1.0) { + s = c / (2 * (1 - l)) + } + + return [hcg[0], s * 100, l * 100] + } + + convert.hcg.hwb = function (hcg) { + const c = hcg[1] / 100 + const g = hcg[2] / 100 + const v = c + g * (1.0 - c) + return [hcg[0], (v - c) * 100, (1 - v) * 100] + } + + convert.hwb.hcg = function (hwb) { + const w = hwb[1] / 100 + const b = hwb[2] / 100 + const v = 1 - b + const c = v - w + let g = 0 + + if (c < 1) { + g = (v - c) / (1 - c) + } + + return [hwb[0], c * 100, g * 100] + } + + convert.apple.rgb = function (apple) { + return [ + (apple[0] / 65535) * 255, + (apple[1] / 65535) * 255, + (apple[2] / 65535) * 255 + ] + } + + convert.rgb.apple = function (rgb) { + return [ + (rgb[0] / 255) * 65535, + (rgb[1] / 255) * 65535, + (rgb[2] / 255) * 65535 + ] + } + + convert.gray.rgb = function (args) { + return [ + (args[0] / 100) * 255, + (args[0] / 100) * 255, + (args[0] / 100) * 255 + ] + } + + convert.gray.hsl = function (args) { + return [0, 0, args[0]] + } + + convert.gray.hsv = convert.gray.hsl + + convert.gray.hwb = function (gray) { + return [0, 100, gray[0]] + } + + convert.gray.cmyk = function (gray) { + return [0, 0, 0, gray[0]] + } + + convert.gray.lab = function (gray) { + return [gray[0], 0, 0] + } + + convert.gray.hex = function (gray) { + const val = Math.round((gray[0] / 100) * 255) & 0xff + const integer = (val << 16) + (val << 8) + val + + const string = integer.toString(16).toUpperCase() + return '000000'.substring(string.length) + string + } + + convert.rgb.gray = function (rgb) { + const val = (rgb[0] + rgb[1] + rgb[2]) / 3 + return [(val / 255) * 100] + } + + /***/ + }, + + /***/ 86931: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + const conversions = __webpack_require__(97391) + const route = __webpack_require__(30880) + + const convert = {} + + const models = Object.keys(conversions) + + function wrapRaw(fn) { + const wrappedFn = function (...args) { + const arg0 = args[0] + if (arg0 === undefined || arg0 === null) { + return arg0 + } + + if (arg0.length > 1) { + args = arg0 + } + + return fn(args) + } + + // Preserve .conversion property if there is one + if ('conversion' in fn) { + wrappedFn.conversion = fn.conversion + } + + return wrappedFn + } + + function wrapRounded(fn) { + const wrappedFn = function (...args) { + const arg0 = args[0] + + if (arg0 === undefined || arg0 === null) { + return arg0 + } + + if (arg0.length > 1) { + args = arg0 + } + + const result = fn(args) + + // We're assuming the result is an array here. + // see notice in conversions.js; don't use box types + // in conversion functions. + if (typeof result === 'object') { + for (let len = result.length, i = 0; i < len; i++) { + result[i] = Math.round(result[i]) + } + } + + return result + } + + // Preserve .conversion property if there is one + if ('conversion' in fn) { + wrappedFn.conversion = fn.conversion + } + + return wrappedFn + } + + models.forEach(fromModel => { + convert[fromModel] = {} + + Object.defineProperty(convert[fromModel], 'channels', { + value: conversions[fromModel].channels + }) + Object.defineProperty(convert[fromModel], 'labels', { + value: conversions[fromModel].labels + }) + + const routes = route(fromModel) + const routeModels = Object.keys(routes) + + routeModels.forEach(toModel => { + const fn = routes[toModel] + + convert[fromModel][toModel] = wrapRounded(fn) + convert[fromModel][toModel].raw = wrapRaw(fn) + }) + }) + + module.exports = convert + + /***/ + }, + + /***/ 30880: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + const conversions = __webpack_require__(97391) + + /* + This function routes a model to all other models. + + all functions that are routed have a property `.conversion` attached + to the returned synthetic function. This property is an array + of strings, each with the steps in between the 'from' and 'to' + color models (inclusive). + + conversions that are not possible simply are not included. +*/ + + function buildGraph() { + const graph = {} + // https://jsperf.com/object-keys-vs-for-in-with-closure/3 + const models = Object.keys(conversions) + + for (let len = models.length, i = 0; i < len; i++) { + graph[models[i]] = { + // http://jsperf.com/1-vs-infinity + // micro-opt, but this is simple. + distance: -1, + parent: null + } + } + + return graph + } + + // https://en.wikipedia.org/wiki/Breadth-first_search + function deriveBFS(fromModel) { + const graph = buildGraph() + const queue = [fromModel] // Unshift -> queue -> pop + + graph[fromModel].distance = 0 + + while (queue.length) { + const current = queue.pop() + const adjacents = Object.keys(conversions[current]) + + for (let len = adjacents.length, i = 0; i < len; i++) { + const adjacent = adjacents[i] + const node = graph[adjacent] + + if (node.distance === -1) { + node.distance = graph[current].distance + 1 + node.parent = current + queue.unshift(adjacent) + } + } + } + + return graph + } + + function link(from, to) { + return function (args) { + return to(from(args)) + } + } + + function wrapConversion(toModel, graph) { + const path = [graph[toModel].parent, toModel] + let fn = conversions[graph[toModel].parent][toModel] + + let cur = graph[toModel].parent + while (graph[cur].parent) { + path.unshift(graph[cur].parent) + fn = link(conversions[graph[cur].parent][cur], fn) + cur = graph[cur].parent + } + + fn.conversion = path + return fn + } + + module.exports = function (fromModel) { + const graph = deriveBFS(fromModel) + const conversion = {} + + const models = Object.keys(graph) + for (let len = models.length, i = 0; i < len; i++) { + const toModel = models[i] + const node = graph[toModel] + + if (node.parent === null) { + // No possible conversion, or this node is the source model. + continue + } + + conversion[toModel] = wrapConversion(toModel, graph) + } + + return conversion + } + + /***/ + }, + + /***/ 78510: /***/ module => { + 'use strict' + + module.exports = { + aliceblue: [240, 248, 255], + antiquewhite: [250, 235, 215], + aqua: [0, 255, 255], + aquamarine: [127, 255, 212], + azure: [240, 255, 255], + beige: [245, 245, 220], + bisque: [255, 228, 196], + black: [0, 0, 0], + blanchedalmond: [255, 235, 205], + blue: [0, 0, 255], + blueviolet: [138, 43, 226], + brown: [165, 42, 42], + burlywood: [222, 184, 135], + cadetblue: [95, 158, 160], + chartreuse: [127, 255, 0], + chocolate: [210, 105, 30], + coral: [255, 127, 80], + cornflowerblue: [100, 149, 237], + cornsilk: [255, 248, 220], + crimson: [220, 20, 60], + cyan: [0, 255, 255], + darkblue: [0, 0, 139], + darkcyan: [0, 139, 139], + darkgoldenrod: [184, 134, 11], + darkgray: [169, 169, 169], + darkgreen: [0, 100, 0], + darkgrey: [169, 169, 169], + darkkhaki: [189, 183, 107], + darkmagenta: [139, 0, 139], + darkolivegreen: [85, 107, 47], + darkorange: [255, 140, 0], + darkorchid: [153, 50, 204], + darkred: [139, 0, 0], + darksalmon: [233, 150, 122], + darkseagreen: [143, 188, 143], + darkslateblue: [72, 61, 139], + darkslategray: [47, 79, 79], + darkslategrey: [47, 79, 79], + darkturquoise: [0, 206, 209], + darkviolet: [148, 0, 211], + deeppink: [255, 20, 147], + deepskyblue: [0, 191, 255], + dimgray: [105, 105, 105], + dimgrey: [105, 105, 105], + dodgerblue: [30, 144, 255], + firebrick: [178, 34, 34], + floralwhite: [255, 250, 240], + forestgreen: [34, 139, 34], + fuchsia: [255, 0, 255], + gainsboro: [220, 220, 220], + ghostwhite: [248, 248, 255], + gold: [255, 215, 0], + goldenrod: [218, 165, 32], + gray: [128, 128, 128], + green: [0, 128, 0], + greenyellow: [173, 255, 47], + grey: [128, 128, 128], + honeydew: [240, 255, 240], + hotpink: [255, 105, 180], + indianred: [205, 92, 92], + indigo: [75, 0, 130], + ivory: [255, 255, 240], + khaki: [240, 230, 140], + lavender: [230, 230, 250], + lavenderblush: [255, 240, 245], + lawngreen: [124, 252, 0], + lemonchiffon: [255, 250, 205], + lightblue: [173, 216, 230], + lightcoral: [240, 128, 128], + lightcyan: [224, 255, 255], + lightgoldenrodyellow: [250, 250, 210], + lightgray: [211, 211, 211], + lightgreen: [144, 238, 144], + lightgrey: [211, 211, 211], + lightpink: [255, 182, 193], + lightsalmon: [255, 160, 122], + lightseagreen: [32, 178, 170], + lightskyblue: [135, 206, 250], + lightslategray: [119, 136, 153], + lightslategrey: [119, 136, 153], + lightsteelblue: [176, 196, 222], + lightyellow: [255, 255, 224], + lime: [0, 255, 0], + limegreen: [50, 205, 50], + linen: [250, 240, 230], + magenta: [255, 0, 255], + maroon: [128, 0, 0], + mediumaquamarine: [102, 205, 170], + mediumblue: [0, 0, 205], + mediumorchid: [186, 85, 211], + mediumpurple: [147, 112, 219], + mediumseagreen: [60, 179, 113], + mediumslateblue: [123, 104, 238], + mediumspringgreen: [0, 250, 154], + mediumturquoise: [72, 209, 204], + mediumvioletred: [199, 21, 133], + midnightblue: [25, 25, 112], + mintcream: [245, 255, 250], + mistyrose: [255, 228, 225], + moccasin: [255, 228, 181], + navajowhite: [255, 222, 173], + navy: [0, 0, 128], + oldlace: [253, 245, 230], + olive: [128, 128, 0], + olivedrab: [107, 142, 35], + orange: [255, 165, 0], + orangered: [255, 69, 0], + orchid: [218, 112, 214], + palegoldenrod: [238, 232, 170], + palegreen: [152, 251, 152], + paleturquoise: [175, 238, 238], + palevioletred: [219, 112, 147], + papayawhip: [255, 239, 213], + peachpuff: [255, 218, 185], + peru: [205, 133, 63], + pink: [255, 192, 203], + plum: [221, 160, 221], + powderblue: [176, 224, 230], + purple: [128, 0, 128], + rebeccapurple: [102, 51, 153], + red: [255, 0, 0], + rosybrown: [188, 143, 143], + royalblue: [65, 105, 225], + saddlebrown: [139, 69, 19], + salmon: [250, 128, 114], + sandybrown: [244, 164, 96], + seagreen: [46, 139, 87], + seashell: [255, 245, 238], + sienna: [160, 82, 45], + silver: [192, 192, 192], + skyblue: [135, 206, 235], + slateblue: [106, 90, 205], + slategray: [112, 128, 144], + slategrey: [112, 128, 144], + snow: [255, 250, 250], + springgreen: [0, 255, 127], + steelblue: [70, 130, 180], + tan: [210, 180, 140], + teal: [0, 128, 128], + thistle: [216, 191, 216], + tomato: [255, 99, 71], + turquoise: [64, 224, 208], + violet: [238, 130, 238], + wheat: [245, 222, 179], + white: [255, 255, 255], + whitesmoke: [245, 245, 245], + yellow: [255, 255, 0], + yellowgreen: [154, 205, 50] + } + + /***/ + }, + + /***/ 85443: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + var util = __webpack_require__(31669) + var Stream = __webpack_require__(92413).Stream + var DelayedStream = __webpack_require__(18611) + + module.exports = CombinedStream + function CombinedStream() { + this.writable = false + this.readable = true + this.dataSize = 0 + this.maxDataSize = 2 * 1024 * 1024 + this.pauseStreams = true + + this._released = false + this._streams = [] + this._currentStream = null + this._insideLoop = false + this._pendingNext = false + } + util.inherits(CombinedStream, Stream) + + CombinedStream.create = function (options) { + var combinedStream = new this() + + options = options || {} + for (var option in options) { + combinedStream[option] = options[option] + } + + return combinedStream + } + + CombinedStream.isStreamLike = function (stream) { + return ( + typeof stream !== 'function' && + typeof stream !== 'string' && + typeof stream !== 'boolean' && + typeof stream !== 'number' && + !Buffer.isBuffer(stream) + ) + } + + CombinedStream.prototype.append = function (stream) { + var isStreamLike = CombinedStream.isStreamLike(stream) + + if (isStreamLike) { + if (!(stream instanceof DelayedStream)) { + var newStream = DelayedStream.create(stream, { + maxDataSize: Infinity, + pauseStream: this.pauseStreams + }) + stream.on('data', this._checkDataSize.bind(this)) + stream = newStream + } + + this._handleErrors(stream) + + if (this.pauseStreams) { + stream.pause() + } + } + + this._streams.push(stream) + return this + } + + CombinedStream.prototype.pipe = function (dest, options) { + Stream.prototype.pipe.call(this, dest, options) + this.resume() + return dest + } + + CombinedStream.prototype._getNext = function () { + this._currentStream = null + + if (this._insideLoop) { + this._pendingNext = true + return // defer call + } + + this._insideLoop = true + try { + do { + this._pendingNext = false + this._realGetNext() + } while (this._pendingNext) + } finally { + this._insideLoop = false + } + } + + CombinedStream.prototype._realGetNext = function () { + var stream = this._streams.shift() + + if (typeof stream == 'undefined') { + this.end() + return + } + + if (typeof stream !== 'function') { + this._pipeNext(stream) + return + } + + var getStream = stream + getStream( + function (stream) { + var isStreamLike = CombinedStream.isStreamLike(stream) + if (isStreamLike) { + stream.on('data', this._checkDataSize.bind(this)) + this._handleErrors(stream) + } + + this._pipeNext(stream) + }.bind(this) + ) + } + + CombinedStream.prototype._pipeNext = function (stream) { + this._currentStream = stream + + var isStreamLike = CombinedStream.isStreamLike(stream) + if (isStreamLike) { + stream.on('end', this._getNext.bind(this)) + stream.pipe(this, { end: false }) + return + } + + var value = stream + this.write(value) + this._getNext() + } + + CombinedStream.prototype._handleErrors = function (stream) { + var self = this + stream.on('error', function (err) { + self._emitError(err) + }) + } + + CombinedStream.prototype.write = function (data) { + this.emit('data', data) + } + + CombinedStream.prototype.pause = function () { + if (!this.pauseStreams) { + return + } + + if ( + this.pauseStreams && + this._currentStream && + typeof this._currentStream.pause == 'function' + ) + this._currentStream.pause() + this.emit('pause') + } + + CombinedStream.prototype.resume = function () { + if (!this._released) { + this._released = true + this.writable = true + this._getNext() + } + + if ( + this.pauseStreams && + this._currentStream && + typeof this._currentStream.resume == 'function' + ) + this._currentStream.resume() + this.emit('resume') + } + + CombinedStream.prototype.end = function () { + this._reset() + this.emit('end') + } + + CombinedStream.prototype.destroy = function () { + this._reset() + this.emit('close') + } + + CombinedStream.prototype._reset = function () { + this.writable = false + this._streams = [] + this._currentStream = null + } + + CombinedStream.prototype._checkDataSize = function () { + this._updateDataSize() + if (this.dataSize <= this.maxDataSize) { + return + } + + var message = + 'DelayedStream#maxDataSize of ' + + this.maxDataSize + + ' bytes exceeded.' + this._emitError(new Error(message)) + } + + CombinedStream.prototype._updateDataSize = function () { + this.dataSize = 0 + + var self = this + this._streams.forEach(function (stream) { + if (!stream.dataSize) { + return + } + + self.dataSize += stream.dataSize + }) + + if (this._currentStream && this._currentStream.dataSize) { + this.dataSize += this._currentStream.dataSize + } + } + + CombinedStream.prototype._emitError = function (err) { + this._reset() + this.emit('error', err) + } + + /***/ + }, + + /***/ 86891: /***/ module => { + module.exports = function (xs, fn) { + var res = [] + for (var i = 0; i < xs.length; i++) { + var x = fn(xs[i], i) + if (isArray(x)) res.push.apply(res, x) + else res.push(x) + } + return res + } + + var isArray = + Array.isArray || + function (xs) { + return Object.prototype.toString.call(xs) === '[object Array]' + } + + /***/ + }, + + /***/ 95898: /***/ (__unused_webpack_module, exports) => { + var __webpack_unused_export__ + // Copyright Joyent, Inc. and other Node contributors. + // + // Permission is hereby granted, free of charge, to any person obtaining a + // copy of this software and associated documentation files (the + // "Software"), to deal in the Software without restriction, including + // without limitation the rights to use, copy, modify, merge, publish, + // distribute, sublicense, and/or sell copies of the Software, and to permit + // persons to whom the Software is furnished to do so, subject to the + // following conditions: + // + // The above copyright notice and this permission notice shall be included + // in all copies or substantial portions of the Software. + // + // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + // USE OR OTHER DEALINGS IN THE SOFTWARE. + + // NOTE: These type checking functions intentionally don't use `instanceof` + // because it is fragile and can be easily faked with `Object.create()`. + + function isArray(arg) { + if (Array.isArray) { + return Array.isArray(arg) + } + return objectToString(arg) === '[object Array]' + } + __webpack_unused_export__ = isArray + + function isBoolean(arg) { + return typeof arg === 'boolean' + } + __webpack_unused_export__ = isBoolean + + function isNull(arg) { + return arg === null + } + __webpack_unused_export__ = isNull + + function isNullOrUndefined(arg) { + return arg == null + } + __webpack_unused_export__ = isNullOrUndefined + + function isNumber(arg) { + return typeof arg === 'number' + } + __webpack_unused_export__ = isNumber + + function isString(arg) { + return typeof arg === 'string' + } + __webpack_unused_export__ = isString + + function isSymbol(arg) { + return typeof arg === 'symbol' + } + __webpack_unused_export__ = isSymbol + + function isUndefined(arg) { + return arg === void 0 + } + __webpack_unused_export__ = isUndefined + + function isRegExp(re) { + return objectToString(re) === '[object RegExp]' + } + __webpack_unused_export__ = isRegExp + + function isObject(arg) { + return typeof arg === 'object' && arg !== null + } + __webpack_unused_export__ = isObject + + function isDate(d) { + return objectToString(d) === '[object Date]' + } + __webpack_unused_export__ = isDate + + function isError(e) { + return objectToString(e) === '[object Error]' || e instanceof Error + } + exports.VZ = isError + + function isFunction(arg) { + return typeof arg === 'function' + } + __webpack_unused_export__ = isFunction + + function isPrimitive(arg) { + return ( + arg === null || + typeof arg === 'boolean' || + typeof arg === 'number' || + typeof arg === 'string' || + typeof arg === 'symbol' || // ES6 symbol + typeof arg === 'undefined' + ) + } + __webpack_unused_export__ = isPrimitive + + __webpack_unused_export__ = Buffer.isBuffer + + function objectToString(o) { + return Object.prototype.toString.call(o) + } + + /***/ + }, + + /***/ 72746: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + 'use strict' + + const cp = __webpack_require__(63129) + const parse = __webpack_require__(66855) + const enoent = __webpack_require__(44101) + + function spawn(command, args, options) { + // Parse the arguments + const parsed = parse(command, args, options) + + // Spawn the child process + const spawned = cp.spawn(parsed.command, parsed.args, parsed.options) + + // Hook into child process "exit" event to emit an error if the command + // does not exists, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16 + enoent.hookChildProcess(spawned, parsed) + + return spawned + } + + function spawnSync(command, args, options) { + // Parse the arguments + const parsed = parse(command, args, options) + + // Spawn the child process + const result = cp.spawnSync(parsed.command, parsed.args, parsed.options) + + // Analyze if the command does not exist, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16 + result.error = + result.error || enoent.verifyENOENTSync(result.status, parsed) + + return result + } + + module.exports = spawn + module.exports.spawn = spawn + module.exports.sync = spawnSync + + module.exports._parse = parse + module.exports._enoent = enoent + + /***/ + }, + + /***/ 44101: /***/ module => { + 'use strict' + + const isWin = process.platform === 'win32' + + function notFoundError(original, syscall) { + return Object.assign( + new Error(`${syscall} ${original.command} ENOENT`), + { + code: 'ENOENT', + errno: 'ENOENT', + syscall: `${syscall} ${original.command}`, + path: original.command, + spawnargs: original.args + } + ) + } + + function hookChildProcess(cp, parsed) { + if (!isWin) { + return + } + + const originalEmit = cp.emit + + cp.emit = function (name, arg1) { + // If emitting "exit" event and exit code is 1, we need to check if + // the command exists and emit an "error" instead + // See https://github.com/IndigoUnited/node-cross-spawn/issues/16 + if (name === 'exit') { + const err = verifyENOENT(arg1, parsed, 'spawn') + + if (err) { + return originalEmit.call(cp, 'error', err) + } + } + + return originalEmit.apply(cp, arguments) // eslint-disable-line prefer-rest-params + } + } + + function verifyENOENT(status, parsed) { + if (isWin && status === 1 && !parsed.file) { + return notFoundError(parsed.original, 'spawn') + } + + return null + } + + function verifyENOENTSync(status, parsed) { + if (isWin && status === 1 && !parsed.file) { + return notFoundError(parsed.original, 'spawnSync') + } + + return null + } + + module.exports = { + hookChildProcess, + verifyENOENT, + verifyENOENTSync, + notFoundError + } + + /***/ + }, + + /***/ 66855: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + 'use strict' + + const path = __webpack_require__(85622) + const niceTry = __webpack_require__(38560) + const resolveCommand = __webpack_require__(87274) + const escape = __webpack_require__(34274) + const readShebang = __webpack_require__(41252) + const semver = __webpack_require__(85911) + + const isWin = process.platform === 'win32' + const isExecutableRegExp = /\.(?:com|exe)$/i + const isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i + + // `options.shell` is supported in Node ^4.8.0, ^5.7.0 and >= 6.0.0 + const supportsShellOption = + niceTry(() => + semver.satisfies( + process.version, + '^4.8.0 || ^5.7.0 || >= 6.0.0', + true + ) + ) || false + + function detectShebang(parsed) { + parsed.file = resolveCommand(parsed) + + const shebang = parsed.file && readShebang(parsed.file) + + if (shebang) { + parsed.args.unshift(parsed.file) + parsed.command = shebang + + return resolveCommand(parsed) + } + + return parsed.file + } + + function parseNonShell(parsed) { + if (!isWin) { + return parsed + } + + // Detect & add support for shebangs + const commandFile = detectShebang(parsed) + + // We don't need a shell if the command filename is an executable + const needsShell = !isExecutableRegExp.test(commandFile) + + // If a shell is required, use cmd.exe and take care of escaping everything correctly + // Note that `forceShell` is an hidden option used only in tests + if (parsed.options.forceShell || needsShell) { + // Need to double escape meta chars if the command is a cmd-shim located in `node_modules/.bin/` + // The cmd-shim simply calls execute the package bin file with NodeJS, proxying any argument + // Because the escape of metachars with ^ gets interpreted when the cmd.exe is first called, + // we need to double escape them + const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile) + + // Normalize posix paths into OS compatible paths (e.g.: foo/bar -> foo\bar) + // This is necessary otherwise it will always fail with ENOENT in those cases + parsed.command = path.normalize(parsed.command) + + // Escape command & arguments + parsed.command = escape.command(parsed.command) + parsed.args = parsed.args.map(arg => + escape.argument(arg, needsDoubleEscapeMetaChars) + ) + + const shellCommand = [parsed.command].concat(parsed.args).join(' ') + + parsed.args = ['/d', '/s', '/c', `"${shellCommand}"`] + parsed.command = process.env.comspec || 'cmd.exe' + parsed.options.windowsVerbatimArguments = true // Tell node's spawn that the arguments are already escaped + } + + return parsed + } + + function parseShell(parsed) { + // If node supports the shell option, there's no need to mimic its behavior + if (supportsShellOption) { + return parsed + } + + // Mimic node shell option + // See https://github.com/nodejs/node/blob/b9f6a2dc059a1062776133f3d4fd848c4da7d150/lib/child_process.js#L335 + const shellCommand = [parsed.command].concat(parsed.args).join(' ') + + if (isWin) { + parsed.command = + typeof parsed.options.shell === 'string' + ? parsed.options.shell + : process.env.comspec || 'cmd.exe' + parsed.args = ['/d', '/s', '/c', `"${shellCommand}"`] + parsed.options.windowsVerbatimArguments = true // Tell node's spawn that the arguments are already escaped + } else { + if (typeof parsed.options.shell === 'string') { + parsed.command = parsed.options.shell + } else if (process.platform === 'android') { + parsed.command = '/system/bin/sh' + } else { + parsed.command = '/bin/sh' + } + + parsed.args = ['-c', shellCommand] + } + + return parsed + } + + function parse(command, args, options) { + // Normalize arguments, similar to nodejs + if (args && !Array.isArray(args)) { + options = args + args = null + } + + args = args ? args.slice(0) : [] // Clone array to avoid changing the original + options = Object.assign({}, options) // Clone object to avoid changing the original + + // Build our parsed object + const parsed = { + command, + args, + options, + file: undefined, + original: { + command, + args + } + } + + // Delegate further parsing to shell or non-shell + return options.shell ? parseShell(parsed) : parseNonShell(parsed) + } + + module.exports = parse + + /***/ + }, + + /***/ 34274: /***/ module => { + 'use strict' + + // See http://www.robvanderwoude.com/escapechars.php + const metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g + + function escapeCommand(arg) { + // Escape meta chars + arg = arg.replace(metaCharsRegExp, '^$1') + + return arg + } + + function escapeArgument(arg, doubleEscapeMetaChars) { + // Convert to string + arg = `${arg}` + + // Algorithm below is based on https://qntm.org/cmd + + // Sequence of backslashes followed by a double quote: + // double up all the backslashes and escape the double quote + arg = arg.replace(/(\\*)"/g, '$1$1\\"') + + // Sequence of backslashes followed by the end of the string + // (which will become a double quote later): + // double up all the backslashes + arg = arg.replace(/(\\*)$/, '$1$1') + + // All other backslashes occur literally + + // Quote the whole thing: + arg = `"${arg}"` + + // Escape meta chars + arg = arg.replace(metaCharsRegExp, '^$1') + + // Double escape meta chars if necessary + if (doubleEscapeMetaChars) { + arg = arg.replace(metaCharsRegExp, '^$1') + } + + return arg + } + + module.exports.command = escapeCommand + module.exports.argument = escapeArgument + + /***/ + }, + + /***/ 41252: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + 'use strict' + + const fs = __webpack_require__(35747) + const shebangCommand = __webpack_require__(67032) + + function readShebang(command) { + // Read the first 150 bytes from the file + const size = 150 + let buffer + + if (Buffer.alloc) { + // Node.js v4.5+ / v5.10+ + buffer = Buffer.alloc(size) + } else { + // Old Node.js API + buffer = new Buffer(size) + buffer.fill(0) // zero-fill + } + + let fd + + try { + fd = fs.openSync(command, 'r') + fs.readSync(fd, buffer, 0, size, 0) + fs.closeSync(fd) + } catch (e) { + /* Empty */ + } + + // Attempt to extract shebang (null is returned if not a shebang) + return shebangCommand(buffer.toString()) + } + + module.exports = readShebang + + /***/ + }, + + /***/ 87274: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + 'use strict' + + const path = __webpack_require__(85622) + const which = __webpack_require__(9383) + const pathKey = __webpack_require__(20539)() + + function resolveCommandAttempt(parsed, withoutPathExt) { + const cwd = process.cwd() + const hasCustomCwd = parsed.options.cwd != null + + // If a custom `cwd` was specified, we need to change the process cwd + // because `which` will do stat calls but does not support a custom cwd + if (hasCustomCwd) { + try { + process.chdir(parsed.options.cwd) + } catch (err) { + /* Empty */ + } + } + + let resolved + + try { + resolved = which.sync(parsed.command, { + path: (parsed.options.env || process.env)[pathKey], + pathExt: withoutPathExt ? path.delimiter : undefined + }) + } catch (e) { + /* Empty */ + } finally { + process.chdir(cwd) + } + + // If we successfully resolved, ensure that an absolute path is returned + // Note that when a custom `cwd` was used, we need to resolve to an absolute path based on it + if (resolved) { + resolved = path.resolve( + hasCustomCwd ? parsed.options.cwd : '', + resolved + ) + } + + return resolved + } + + function resolveCommand(parsed) { + return ( + resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true) + ) + } + + module.exports = resolveCommand + + /***/ + }, + + /***/ 9383: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + module.exports = which + which.sync = whichSync + + var isWindows = + process.platform === 'win32' || + process.env.OSTYPE === 'cygwin' || + process.env.OSTYPE === 'msys' + + var path = __webpack_require__(85622) + var COLON = isWindows ? ';' : ':' + var isexe = __webpack_require__(97126) + + function getNotFoundError(cmd) { + var er = new Error('not found: ' + cmd) + er.code = 'ENOENT' + + return er + } + + function getPathInfo(cmd, opt) { + var colon = opt.colon || COLON + var pathEnv = opt.path || process.env.PATH || '' + var pathExt = [''] + + pathEnv = pathEnv.split(colon) + + var pathExtExe = '' + if (isWindows) { + pathEnv.unshift(process.cwd()) + pathExtExe = + opt.pathExt || process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM' + pathExt = pathExtExe.split(colon) + + // Always test the cmd itself first. isexe will check to make sure + // it's found in the pathExt set. + if (cmd.indexOf('.') !== -1 && pathExt[0] !== '') pathExt.unshift('') + } + + // If it has a slash, then we don't bother searching the pathenv. + // just check the file itself, and that's it. + if (cmd.match(/\//) || (isWindows && cmd.match(/\\/))) pathEnv = [''] + + return { + env: pathEnv, + ext: pathExt, + extExe: pathExtExe + } + } + + function which(cmd, opt, cb) { + if (typeof opt === 'function') { + cb = opt + opt = {} + } + + var info = getPathInfo(cmd, opt) + var pathEnv = info.env + var pathExt = info.ext + var pathExtExe = info.extExe + var found = [] + + ;(function F(i, l) { + if (i === l) { + if (opt.all && found.length) return cb(null, found) + else return cb(getNotFoundError(cmd)) + } + + var pathPart = pathEnv[i] + if (pathPart.charAt(0) === '"' && pathPart.slice(-1) === '"') + pathPart = pathPart.slice(1, -1) + + var p = path.join(pathPart, cmd) + if (!pathPart && /^\.[\\\/]/.test(cmd)) { + p = cmd.slice(0, 2) + p + } + ;(function E(ii, ll) { + if (ii === ll) return F(i + 1, l) + var ext = pathExt[ii] + isexe(p + ext, { pathExt: pathExtExe }, function (er, is) { + if (!er && is) { + if (opt.all) found.push(p + ext) + else return cb(null, p + ext) + } + return E(ii + 1, ll) + }) + })(0, pathExt.length) + })(0, pathEnv.length) + } + + function whichSync(cmd, opt) { + opt = opt || {} + + var info = getPathInfo(cmd, opt) + var pathEnv = info.env + var pathExt = info.ext + var pathExtExe = info.extExe + var found = [] + + for (var i = 0, l = pathEnv.length; i < l; i++) { + var pathPart = pathEnv[i] + if (pathPart.charAt(0) === '"' && pathPart.slice(-1) === '"') + pathPart = pathPart.slice(1, -1) + + var p = path.join(pathPart, cmd) + if (!pathPart && /^\.[\\\/]/.test(cmd)) { + p = cmd.slice(0, 2) + p + } + for (var j = 0, ll = pathExt.length; j < ll; j++) { + var cur = p + pathExt[j] + var is + try { + is = isexe.sync(cur, { pathExt: pathExtExe }) + if (is) { + if (opt.all) found.push(cur) + else return cur + } + } catch (ex) {} + } + } + + if (opt.all && found.length) return found + + if (opt.nothrow) return null + + throw getNotFoundError(cmd) + } + + /***/ + }, + + /***/ 12682: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + var Buffer = __webpack_require__(64293).Buffer + + var CHARS = '.PYFGCRLAOEUIDHTNSQJKXBMWVZ_pyfgcrlaoeuidhtnsqjkxbmwvz1234567890' + .split('') + .sort() + .join('') + + module.exports = function (chars, exports) { + chars = chars || CHARS + exports = exports || {} + if (chars.length !== 64) + throw new Error('a base 64 encoding requires 64 chars') + + var codeToIndex = new Buffer(128) + codeToIndex.fill() + + for (var i = 0; i < 64; i++) { + var code = chars.charCodeAt(i) + codeToIndex[code] = i + } + + exports.encode = function (data) { + var s = '', + l = data.length, + hang = 0 + for (var i = 0; i < l; i++) { + var v = data[i] + + switch (i % 3) { + case 0: + s += chars[v >> 2] + hang = (v & 3) << 4 + break + case 1: + s += chars[hang | (v >> 4)] + hang = (v & 0xf) << 2 + break + case 2: + s += chars[hang | (v >> 6)] + s += chars[v & 0x3f] + hang = 0 + break + } + } + if (l % 3) s += chars[hang] + return s + } + exports.decode = function (str) { + var l = str.length, + j = 0 + var b = new Buffer(~~((l / 4) * 3)), + hang = 0 + + for (var i = 0; i < l; i++) { + var v = codeToIndex[str.charCodeAt(i)] + + switch (i % 4) { + case 0: + hang = v << 2 + break + case 1: + b[j++] = hang | (v >> 4) + hang = (v << 4) & 0xff + break + case 2: + b[j++] = hang | (v >> 2) + hang = (v << 6) & 0xff + break + case 3: + b[j++] = hang | v + break + } + } + return b + } + return exports + } + + module.exports(CHARS, module.exports) + + /***/ + }, + + /***/ 28222: /***/ (module, exports, __webpack_require__) => { + /* eslint-env browser */ + + /** + * This is the web browser implementation of `debug()`. + */ + + exports.log = log + exports.formatArgs = formatArgs + exports.save = save + exports.load = load + exports.useColors = useColors + exports.storage = localstorage() + + /** + * Colors. + */ + + exports.colors = [ + '#0000CC', + '#0000FF', + '#0033CC', + '#0033FF', + '#0066CC', + '#0066FF', + '#0099CC', + '#0099FF', + '#00CC00', + '#00CC33', + '#00CC66', + '#00CC99', + '#00CCCC', + '#00CCFF', + '#3300CC', + '#3300FF', + '#3333CC', + '#3333FF', + '#3366CC', + '#3366FF', + '#3399CC', + '#3399FF', + '#33CC00', + '#33CC33', + '#33CC66', + '#33CC99', + '#33CCCC', + '#33CCFF', + '#6600CC', + '#6600FF', + '#6633CC', + '#6633FF', + '#66CC00', + '#66CC33', + '#9900CC', + '#9900FF', + '#9933CC', + '#9933FF', + '#99CC00', + '#99CC33', + '#CC0000', + '#CC0033', + '#CC0066', + '#CC0099', + '#CC00CC', + '#CC00FF', + '#CC3300', + '#CC3333', + '#CC3366', + '#CC3399', + '#CC33CC', + '#CC33FF', + '#CC6600', + '#CC6633', + '#CC9900', + '#CC9933', + '#CCCC00', + '#CCCC33', + '#FF0000', + '#FF0033', + '#FF0066', + '#FF0099', + '#FF00CC', + '#FF00FF', + '#FF3300', + '#FF3333', + '#FF3366', + '#FF3399', + '#FF33CC', + '#FF33FF', + '#FF6600', + '#FF6633', + '#FF9900', + '#FF9933', + '#FFCC00', + '#FFCC33' + ] + + /** + * Currently only WebKit-based Web Inspectors, Firefox >= v31, + * and the Firebug extension (any Firefox version) are known + * to support "%c" CSS customizations. + * + * TODO: add a `localStorage` variable to explicitly enable/disable colors + */ + + // eslint-disable-next-line complexity + function useColors() { + // NB: In an Electron preload script, document will be defined but not fully + // initialized. Since we know we're in Chrome, we'll just detect this case + // explicitly + if ( + typeof window !== 'undefined' && + window.process && + (window.process.type === 'renderer' || window.process.__nwjs) + ) { + return true + } + + // Internet Explorer and Edge do not support colors. + if ( + typeof navigator !== 'undefined' && + navigator.userAgent && + navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/) + ) { + return false + } + + // Is webkit? http://stackoverflow.com/a/16459606/376773 + // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 + return ( + (typeof document !== 'undefined' && + document.documentElement && + document.documentElement.style && + document.documentElement.style.WebkitAppearance) || + // Is firebug? http://stackoverflow.com/a/398120/376773 + (typeof window !== 'undefined' && + window.console && + (window.console.firebug || + (window.console.exception && window.console.table))) || + // Is firefox >= v31? + // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages + (typeof navigator !== 'undefined' && + navigator.userAgent && + navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && + parseInt(RegExp.$1, 10) >= 31) || + // Double check webkit in userAgent just in case we are in a worker + (typeof navigator !== 'undefined' && + navigator.userAgent && + navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)) + ) + } + + /** + * Colorize log arguments if enabled. + * + * @api public + */ + + function formatArgs(args) { + args[0] = + (this.useColors ? '%c' : '') + + this.namespace + + (this.useColors ? ' %c' : ' ') + + args[0] + + (this.useColors ? '%c ' : ' ') + + '+' + + module.exports.humanize(this.diff) + + if (!this.useColors) { + return + } + + const c = 'color: ' + this.color + args.splice(1, 0, c, 'color: inherit') + + // The final "%c" is somewhat tricky, because there could be other + // arguments passed either before or after the %c, so we need to + // figure out the correct index to insert the CSS into + let index = 0 + let lastC = 0 + args[0].replace(/%[a-zA-Z%]/g, match => { + if (match === '%%') { + return + } + index++ + if (match === '%c') { + // We only are interested in the *last* %c + // (the user may have provided their own) + lastC = index + } + }) + + args.splice(lastC, 0, c) + } + + /** + * Invokes `console.log()` when available. + * No-op when `console.log` is not a "function". + * + * @api public + */ + function log(...args) { + // This hackery is required for IE8/9, where + // the `console.log` function doesn't have 'apply' + return ( + typeof console === 'object' && console.log && console.log(...args) + ) + } + + /** + * Save `namespaces`. + * + * @param {String} namespaces + * @api private + */ + function save(namespaces) { + try { + if (namespaces) { + exports.storage.setItem('debug', namespaces) + } else { + exports.storage.removeItem('debug') + } + } catch (error) { + // Swallow + // XXX (@Qix-) should we be logging these? + } + } + + /** + * Load `namespaces`. + * + * @return {String} returns the previously persisted debug modes + * @api private + */ + function load() { + let r + try { + r = exports.storage.getItem('debug') + } catch (error) { + // Swallow + // XXX (@Qix-) should we be logging these? + } + + // If debug isn't set in LS, and we're in Electron, try to load $DEBUG + if (!r && typeof process !== 'undefined' && 'env' in process) { + r = process.env.DEBUG + } + + return r + } + + /** + * Localstorage attempts to return the localstorage. + * + * This is necessary because safari throws + * when a user disables cookies/localstorage + * and you attempt to access it. + * + * @return {LocalStorage} + * @api private + */ + + function localstorage() { + try { + // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context + // The Browser also has localStorage in the global context. + return localStorage + } catch (error) { + // Swallow + // XXX (@Qix-) should we be logging these? + } + } + + module.exports = __webpack_require__(46243)(exports) + + const { formatters } = module.exports + + /** + * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. + */ + + formatters.j = function (v) { + try { + return JSON.stringify(v) + } catch (error) { + return '[UnexpectedJSONParseError]: ' + error.message + } + } + + /***/ + }, + + /***/ 46243: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + /** + * This is the common logic for both the Node.js and web browser + * implementations of `debug()`. + */ + + function setup(env) { + createDebug.debug = createDebug + createDebug.default = createDebug + createDebug.coerce = coerce + createDebug.disable = disable + createDebug.enable = enable + createDebug.enabled = enabled + createDebug.humanize = __webpack_require__(80900) + + Object.keys(env).forEach(key => { + createDebug[key] = env[key] + }) + + /** + * Active `debug` instances. + */ + createDebug.instances = [] + + /** + * The currently active debug mode names, and names to skip. + */ + + createDebug.names = [] + createDebug.skips = [] + + /** + * Map of special "%n" handling functions, for the debug "format" argument. + * + * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". + */ + createDebug.formatters = {} + + /** + * Selects a color for a debug namespace + * @param {String} namespace The namespace string for the for the debug instance to be colored + * @return {Number|String} An ANSI color code for the given namespace + * @api private + */ + function selectColor(namespace) { + let hash = 0 + + for (let i = 0; i < namespace.length; i++) { + hash = (hash << 5) - hash + namespace.charCodeAt(i) + hash |= 0 // Convert to 32bit integer + } + + return createDebug.colors[Math.abs(hash) % createDebug.colors.length] + } + createDebug.selectColor = selectColor + + /** + * Create a debugger with the given `namespace`. + * + * @param {String} namespace + * @return {Function} + * @api public + */ + function createDebug(namespace) { + let prevTime + + function debug(...args) { + // Disabled? + if (!debug.enabled) { + return + } + + const self = debug + + // Set `diff` timestamp + const curr = Number(new Date()) + const ms = curr - (prevTime || curr) + self.diff = ms + self.prev = prevTime + self.curr = curr + prevTime = curr + + args[0] = createDebug.coerce(args[0]) + + if (typeof args[0] !== 'string') { + // Anything else let's inspect with %O + args.unshift('%O') + } + + // Apply any `formatters` transformations + let index = 0 + args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => { + // If we encounter an escaped % then don't increase the array index + if (match === '%%') { + return match + } + index++ + const formatter = createDebug.formatters[format] + if (typeof formatter === 'function') { + const val = args[index] + match = formatter.call(self, val) + + // Now we need to remove `args[index]` since it's inlined in the `format` + args.splice(index, 1) + index-- + } + return match + }) + + // Apply env-specific formatting (colors, etc.) + createDebug.formatArgs.call(self, args) + + const logFn = self.log || createDebug.log + logFn.apply(self, args) + } + + debug.namespace = namespace + debug.enabled = createDebug.enabled(namespace) + debug.useColors = createDebug.useColors() + debug.color = selectColor(namespace) + debug.destroy = destroy + debug.extend = extend + // Debug.formatArgs = formatArgs; + // debug.rawLog = rawLog; + + // env-specific initialization logic for debug instances + if (typeof createDebug.init === 'function') { + createDebug.init(debug) + } + + createDebug.instances.push(debug) + + return debug + } + + function destroy() { + const index = createDebug.instances.indexOf(this) + if (index !== -1) { + createDebug.instances.splice(index, 1) + return true + } + return false + } + + function extend(namespace, delimiter) { + const newDebug = createDebug( + this.namespace + + (typeof delimiter === 'undefined' ? ':' : delimiter) + + namespace + ) + newDebug.log = this.log + return newDebug + } + + /** + * Enables a debug mode by namespaces. This can include modes + * separated by a colon and wildcards. + * + * @param {String} namespaces + * @api public + */ + function enable(namespaces) { + createDebug.save(namespaces) + + createDebug.names = [] + createDebug.skips = [] + + let i + const split = (typeof namespaces === 'string' + ? namespaces + : '' + ).split(/[\s,]+/) + const len = split.length + + for (i = 0; i < len; i++) { + if (!split[i]) { + // ignore empty strings + continue + } + + namespaces = split[i].replace(/\*/g, '.*?') + + if (namespaces[0] === '-') { + createDebug.skips.push( + new RegExp('^' + namespaces.substr(1) + '$') + ) + } else { + createDebug.names.push(new RegExp('^' + namespaces + '$')) + } + } + + for (i = 0; i < createDebug.instances.length; i++) { + const instance = createDebug.instances[i] + instance.enabled = createDebug.enabled(instance.namespace) + } + } + + /** + * Disable debug output. + * + * @return {String} namespaces + * @api public + */ + function disable() { + const namespaces = [ + ...createDebug.names.map(toNamespace), + ...createDebug.skips + .map(toNamespace) + .map(namespace => '-' + namespace) + ].join(',') + createDebug.enable('') + return namespaces + } + + /** + * Returns true if the given mode name is enabled, false otherwise. + * + * @param {String} name + * @return {Boolean} + * @api public + */ + function enabled(name) { + if (name[name.length - 1] === '*') { + return true + } + + let i + let len + + for (i = 0, len = createDebug.skips.length; i < len; i++) { + if (createDebug.skips[i].test(name)) { + return false + } + } + + for (i = 0, len = createDebug.names.length; i < len; i++) { + if (createDebug.names[i].test(name)) { + return true + } + } + + return false + } + + /** + * Convert regexp to namespace + * + * @param {RegExp} regxep + * @return {String} namespace + * @api private + */ + function toNamespace(regexp) { + return regexp + .toString() + .substring(2, regexp.toString().length - 2) + .replace(/\.\*\?$/, '*') + } + + /** + * Coerce `val`. + * + * @param {Mixed} val + * @return {Mixed} + * @api private + */ + function coerce(val) { + if (val instanceof Error) { + return val.stack || val.message + } + return val + } + + createDebug.enable(createDebug.load()) + + return createDebug + } + + module.exports = setup + + /***/ + }, + + /***/ 38237: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + /** + * Detect Electron renderer / nwjs process, which is node, but we should + * treat as a browser. + */ + + if ( + typeof process === 'undefined' || + process.type === 'renderer' || + process.browser === true || + process.__nwjs + ) { + module.exports = __webpack_require__(28222) + } else { + module.exports = __webpack_require__(35332) + } + + /***/ + }, + + /***/ 35332: /***/ (module, exports, __webpack_require__) => { + /** + * Module dependencies. + */ + + const tty = __webpack_require__(33867) + const util = __webpack_require__(31669) + + /** + * This is the Node.js implementation of `debug()`. + */ + + exports.init = init + exports.log = log + exports.formatArgs = formatArgs + exports.save = save + exports.load = load + exports.useColors = useColors + + /** + * Colors. + */ + + exports.colors = [6, 2, 3, 4, 5, 1] + + try { + // Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json) + // eslint-disable-next-line import/no-extraneous-dependencies + const supportsColor = __webpack_require__(59318) + + if ( + supportsColor && + (supportsColor.stderr || supportsColor).level >= 2 + ) { + exports.colors = [ + 20, + 21, + 26, + 27, + 32, + 33, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 56, + 57, + 62, + 63, + 68, + 69, + 74, + 75, + 76, + 77, + 78, + 79, + 80, + 81, + 92, + 93, + 98, + 99, + 112, + 113, + 128, + 129, + 134, + 135, + 148, + 149, + 160, + 161, + 162, + 163, + 164, + 165, + 166, + 167, + 168, + 169, + 170, + 171, + 172, + 173, + 178, + 179, + 184, + 185, + 196, + 197, + 198, + 199, + 200, + 201, + 202, + 203, + 204, + 205, + 206, + 207, + 208, + 209, + 214, + 215, + 220, + 221 + ] + } + } catch (error) { + // Swallow - we only care if `supports-color` is available; it doesn't have to be. + } + + /** + * Build up the default `inspectOpts` object from the environment variables. + * + * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js + */ + + exports.inspectOpts = Object.keys(process.env) + .filter(key => { + return /^debug_/i.test(key) + }) + .reduce((obj, key) => { + // Camel-case + const prop = key + .substring(6) + .toLowerCase() + .replace(/_([a-z])/g, (_, k) => { + return k.toUpperCase() + }) + + // Coerce string value into JS value + let val = process.env[key] + if (/^(yes|on|true|enabled)$/i.test(val)) { + val = true + } else if (/^(no|off|false|disabled)$/i.test(val)) { + val = false + } else if (val === 'null') { + val = null + } else { + val = Number(val) + } + + obj[prop] = val + return obj + }, {}) + + /** + * Is stdout a TTY? Colored output is enabled when `true`. + */ + + function useColors() { + return 'colors' in exports.inspectOpts + ? Boolean(exports.inspectOpts.colors) + : tty.isatty(process.stderr.fd) + } + + /** + * Adds ANSI color escape codes if enabled. + * + * @api public + */ + + function formatArgs(args) { + const { namespace: name, useColors } = this + + if (useColors) { + const c = this.color + const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c) + const prefix = ` ${colorCode};1m${name} \u001B[0m` + + args[0] = prefix + args[0].split('\n').join('\n' + prefix) + args.push( + colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m' + ) + } else { + args[0] = getDate() + name + ' ' + args[0] + } + } + + function getDate() { + if (exports.inspectOpts.hideDate) { + return '' + } + return new Date().toISOString() + ' ' + } + + /** + * Invokes `util.format()` with the specified arguments and writes to stderr. + */ + + function log(...args) { + return process.stderr.write(util.format(...args) + '\n') + } + + /** + * Save `namespaces`. + * + * @param {String} namespaces + * @api private + */ + function save(namespaces) { + if (namespaces) { + process.env.DEBUG = namespaces + } else { + // If you set a process.env field to null or undefined, it gets cast to the + // string 'null' or 'undefined'. Just delete instead. + delete process.env.DEBUG + } + } + + /** + * Load `namespaces`. + * + * @return {String} returns the previously persisted debug modes + * @api private + */ + + function load() { + return process.env.DEBUG + } + + /** + * Init logic for `debug` instances. + * + * Create a new `inspectOpts` object in case `useColors` is set + * differently for a particular `debug` instance. + */ + + function init(debug) { + debug.inspectOpts = {} + + const keys = Object.keys(exports.inspectOpts) + for (let i = 0; i < keys.length; i++) { + debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]] + } + } + + module.exports = __webpack_require__(46243)(exports) + + const { formatters } = module.exports + + /** + * Map %o to `util.inspect()`, all on a single line. + */ + + formatters.o = function (v) { + this.inspectOpts.colors = this.useColors + return util.inspect(v, this.inspectOpts).replace(/\s*\n\s*/g, ' ') + } + + /** + * Map %O to `util.inspect()`, allowing multiple lines if needed. + */ + + formatters.O = function (v) { + this.inspectOpts.colors = this.useColors + return util.inspect(v, this.inspectOpts) + } + + /***/ + }, + + /***/ 18611: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + var Stream = __webpack_require__(92413).Stream + var util = __webpack_require__(31669) + + module.exports = DelayedStream + function DelayedStream() { + this.source = null + this.dataSize = 0 + this.maxDataSize = 1024 * 1024 + this.pauseStream = true + + this._maxDataSizeExceeded = false + this._released = false + this._bufferedEvents = [] + } + util.inherits(DelayedStream, Stream) + + DelayedStream.create = function (source, options) { + var delayedStream = new this() + + options = options || {} + for (var option in options) { + delayedStream[option] = options[option] + } + + delayedStream.source = source + + var realEmit = source.emit + source.emit = function () { + delayedStream._handleEmit(arguments) + return realEmit.apply(source, arguments) + } + + source.on('error', function () {}) + if (delayedStream.pauseStream) { + source.pause() + } + + return delayedStream + } + + Object.defineProperty(DelayedStream.prototype, 'readable', { + configurable: true, + enumerable: true, + get: function () { + return this.source.readable + } + }) + + DelayedStream.prototype.setEncoding = function () { + return this.source.setEncoding.apply(this.source, arguments) + } + + DelayedStream.prototype.resume = function () { + if (!this._released) { + this.release() + } + + this.source.resume() + } + + DelayedStream.prototype.pause = function () { + this.source.pause() + } + + DelayedStream.prototype.release = function () { + this._released = true + + this._bufferedEvents.forEach( + function (args) { + this.emit.apply(this, args) + }.bind(this) + ) + this._bufferedEvents = [] + } + + DelayedStream.prototype.pipe = function () { + var r = Stream.prototype.pipe.apply(this, arguments) + this.resume() + return r + } + + DelayedStream.prototype._handleEmit = function (args) { + if (this._released) { + this.emit.apply(this, args) + return + } + + if (args[0] === 'data') { + this.dataSize += args[1].length + this._checkIfMaxDataSizeExceeded() + } + + this._bufferedEvents.push(args) + } + + DelayedStream.prototype._checkIfMaxDataSizeExceeded = function () { + if (this._maxDataSizeExceeded) { + return + } + + if (this.dataSize <= this.maxDataSize) { + return + } + + this._maxDataSizeExceeded = true + var message = + 'DelayedStream#maxDataSize of ' + + this.maxDataSize + + ' bytes exceeded.' + this.emit('error', new Error(message)) + } + + /***/ + }, + + /***/ 58932: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + Object.defineProperty(exports, '__esModule', { value: true }) + + class Deprecation extends Error { + constructor(message) { + super(message) // Maintains proper stack trace (only available on V8) + + /* istanbul ignore next */ + + if (Error.captureStackTrace) { + Error.captureStackTrace(this, this.constructor) + } + + this.name = 'Deprecation' + } + } + + exports.Deprecation = Deprecation + + /***/ + }, + + /***/ 82042: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + 'use strict' + + const isObj = __webpack_require__(51389) + + const disallowedKeys = new Set(['__proto__', 'prototype', 'constructor']) + + const isValidPath = pathSegments => + !pathSegments.some(segment => disallowedKeys.has(segment)) + + function getPathSegments(path) { + const pathArray = path.split('.') + const parts = [] + + for (let i = 0; i < pathArray.length; i++) { + let p = pathArray[i] + + while (p[p.length - 1] === '\\' && pathArray[i + 1] !== undefined) { + p = p.slice(0, -1) + '.' + p += pathArray[++i] + } + + parts.push(p) + } + + if (!isValidPath(parts)) { + return [] + } + + return parts + } + + module.exports = { + get(object, path, value) { + if (!isObj(object) || typeof path !== 'string') { + return value === undefined ? object : value + } + + const pathArray = getPathSegments(path) + if (pathArray.length === 0) { + return + } + + for (let i = 0; i < pathArray.length; i++) { + object = object[pathArray[i]] + + if (object === undefined || object === null) { + // `object` is either `undefined` or `null` so we want to stop the loop, and + // if this is not the last bit of the path, and + // if it did't return `undefined` + // it would return `null` if `object` is `null` + // but we want `get({foo: null}, 'foo.bar')` to equal `undefined`, or the supplied value, not `null` + if (i !== pathArray.length - 1) { + return value + } + + break + } + } + + return object + }, + + set(object, path, value) { + if (!isObj(object) || typeof path !== 'string') { + return object + } + + const root = object + const pathArray = getPathSegments(path) + + for (let i = 0; i < pathArray.length; i++) { + const p = pathArray[i] + + if (!isObj(object[p])) { + object[p] = {} + } + + if (i === pathArray.length - 1) { + object[p] = value + } + + object = object[p] + } + + return root + }, + + delete(object, path) { + if (!isObj(object) || typeof path !== 'string') { + return false + } + + const pathArray = getPathSegments(path) + + for (let i = 0; i < pathArray.length; i++) { + const p = pathArray[i] + + if (i === pathArray.length - 1) { + delete object[p] + return true + } + + object = object[p] + + if (!isObj(object)) { + return false + } + } + }, + + has(object, path) { + if (!isObj(object) || typeof path !== 'string') { + return false + } + + const pathArray = getPathSegments(path) + if (pathArray.length === 0) { + return false + } + + // eslint-disable-next-line unicorn/no-for-loop + for (let i = 0; i < pathArray.length; i++) { + if (isObj(object)) { + if (!(pathArray[i] in object)) { + return false + } + + object = object[pathArray[i]] + } else { + return false + } + } + + return true + } + } + + /***/ + }, + + /***/ 76599: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + var stream = __webpack_require__(51642) + var eos = __webpack_require__(81205) + var inherits = __webpack_require__(44124) + var shift = __webpack_require__(66121) + + var SIGNAL_FLUSH = + Buffer.from && Buffer.from !== Uint8Array.from + ? Buffer.from([0]) + : new Buffer([0]) + + var onuncork = function (self, fn) { + if (self._corked) self.once('uncork', fn) + else fn() + } + + var autoDestroy = function (self, err) { + if (self._autoDestroy) self.destroy(err) + } + + var destroyer = function (self, end) { + return function (err) { + if (err) + autoDestroy(self, err.message === 'premature close' ? null : err) + else if (end && !self._ended) self.end() + } + } + + var end = function (ws, fn) { + if (!ws) return fn() + if (ws._writableState && ws._writableState.finished) return fn() + if (ws._writableState) return ws.end(fn) + ws.end() + fn() + } + + var noop = function () {} + + var toStreams2 = function (rs) { + return new stream.Readable({ + objectMode: true, + highWaterMark: 16 + }).wrap(rs) + } + + var Duplexify = function (writable, readable, opts) { + if (!(this instanceof Duplexify)) + return new Duplexify(writable, readable, opts) + stream.Duplex.call(this, opts) + + this._writable = null + this._readable = null + this._readable2 = null + + this._autoDestroy = !opts || opts.autoDestroy !== false + this._forwardDestroy = !opts || opts.destroy !== false + this._forwardEnd = !opts || opts.end !== false + this._corked = 1 // start corked + this._ondrain = null + this._drained = false + this._forwarding = false + this._unwrite = null + this._unread = null + this._ended = false + + this.destroyed = false + + if (writable) this.setWritable(writable) + if (readable) this.setReadable(readable) + } + + inherits(Duplexify, stream.Duplex) + + Duplexify.obj = function (writable, readable, opts) { + if (!opts) opts = {} + opts.objectMode = true + opts.highWaterMark = 16 + return new Duplexify(writable, readable, opts) + } + + Duplexify.prototype.cork = function () { + if (++this._corked === 1) this.emit('cork') + } + + Duplexify.prototype.uncork = function () { + if (this._corked && --this._corked === 0) this.emit('uncork') + } + + Duplexify.prototype.setWritable = function (writable) { + if (this._unwrite) this._unwrite() + + if (this.destroyed) { + if (writable && writable.destroy) writable.destroy() + return + } + + if (writable === null || writable === false) { + this.end() + return + } + + var self = this + var unend = eos( + writable, + { writable: true, readable: false }, + destroyer(this, this._forwardEnd) + ) + + var ondrain = function () { + var ondrain = self._ondrain + self._ondrain = null + if (ondrain) ondrain() + } + + var clear = function () { + self._writable.removeListener('drain', ondrain) + unend() + } + + if (this._unwrite) process.nextTick(ondrain) // force a drain on stream reset to avoid livelocks + + this._writable = writable + this._writable.on('drain', ondrain) + this._unwrite = clear + + this.uncork() // always uncork setWritable + } + + Duplexify.prototype.setReadable = function (readable) { + if (this._unread) this._unread() + + if (this.destroyed) { + if (readable && readable.destroy) readable.destroy() + return + } + + if (readable === null || readable === false) { + this.push(null) + this.resume() + return + } + + var self = this + var unend = eos( + readable, + { writable: false, readable: true }, + destroyer(this) + ) + + var onreadable = function () { + self._forward() + } + + var onend = function () { + self.push(null) + } + + var clear = function () { + self._readable2.removeListener('readable', onreadable) + self._readable2.removeListener('end', onend) + unend() + } + + this._drained = true + this._readable = readable + this._readable2 = readable._readableState + ? readable + : toStreams2(readable) + this._readable2.on('readable', onreadable) + this._readable2.on('end', onend) + this._unread = clear + + this._forward() + } + + Duplexify.prototype._read = function () { + this._drained = true + this._forward() + } + + Duplexify.prototype._forward = function () { + if (this._forwarding || !this._readable2 || !this._drained) return + this._forwarding = true + + var data + + while (this._drained && (data = shift(this._readable2)) !== null) { + if (this.destroyed) continue + this._drained = this.push(data) + } + + this._forwarding = false + } + + Duplexify.prototype.destroy = function (err, cb) { + if (!cb) cb = noop + if (this.destroyed) return cb(null) + this.destroyed = true + + var self = this + process.nextTick(function () { + self._destroy(err) + cb(null) + }) + } + + Duplexify.prototype._destroy = function (err) { + if (err) { + var ondrain = this._ondrain + this._ondrain = null + if (ondrain) ondrain(err) + else this.emit('error', err) + } + + if (this._forwardDestroy) { + if (this._readable && this._readable.destroy) this._readable.destroy() + if (this._writable && this._writable.destroy) this._writable.destroy() + } + + this.emit('close') + } + + Duplexify.prototype._write = function (data, enc, cb) { + if (this.destroyed) return + if (this._corked) + return onuncork(this, this._write.bind(this, data, enc, cb)) + if (data === SIGNAL_FLUSH) return this._finish(cb) + if (!this._writable) return cb() + + if (this._writable.write(data) === false) this._ondrain = cb + else if (!this.destroyed) cb() + } + + Duplexify.prototype._finish = function (cb) { + var self = this + this.emit('preend') + onuncork(this, function () { + end(self._forwardEnd && self._writable, function () { + // haxx to not emit prefinish twice + if (self._writableState.prefinished === false) + self._writableState.prefinished = true + self.emit('prefinish') + onuncork(self, cb) + }) + }) + } + + Duplexify.prototype.end = function (data, enc, cb) { + if (typeof data === 'function') return this.end(null, null, data) + if (typeof enc === 'function') return this.end(data, null, enc) + this._ended = true + if (data) this.write(data) + if (!this._writableState.ending) this.write(SIGNAL_FLUSH) + return stream.Writable.prototype.end.call(this, cb) + } + + module.exports = Duplexify + + /***/ + }, + + /***/ 49865: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + var crypto = __webpack_require__(76417) + var BigInteger = __webpack_require__(85587).BigInteger + var ECPointFp = __webpack_require__(3943).ECPointFp + var Buffer = __webpack_require__(15118).Buffer + exports.ECCurves = __webpack_require__(41452) + + // zero prepad + function unstupid(hex, len) { + return hex.length >= len ? hex : unstupid('0' + hex, len) + } + + exports.ECKey = function (curve, key, isPublic) { + var priv + var c = curve() + var n = c.getN() + var bytes = Math.floor(n.bitLength() / 8) + + if (key) { + if (isPublic) { + var curve = c.getCurve() + // var x = key.slice(1,bytes+1); // skip the 04 for uncompressed format + // var y = key.slice(bytes+1); + // this.P = new ECPointFp(curve, + // curve.fromBigInteger(new BigInteger(x.toString("hex"), 16)), + // curve.fromBigInteger(new BigInteger(y.toString("hex"), 16))); + this.P = curve.decodePointHex(key.toString('hex')) + } else { + if (key.length != bytes) return false + priv = new BigInteger(key.toString('hex'), 16) + } + } else { + var n1 = n.subtract(BigInteger.ONE) + var r = new BigInteger(crypto.randomBytes(n.bitLength())) + priv = r.mod(n1).add(BigInteger.ONE) + this.P = c.getG().multiply(priv) + } + if (this.P) { + // var pubhex = unstupid(this.P.getX().toBigInteger().toString(16),bytes*2)+unstupid(this.P.getY().toBigInteger().toString(16),bytes*2); + // this.PublicKey = Buffer.from("04"+pubhex,"hex"); + this.PublicKey = Buffer.from( + c.getCurve().encodeCompressedPointHex(this.P), + 'hex' + ) + } + if (priv) { + this.PrivateKey = Buffer.from( + unstupid(priv.toString(16), bytes * 2), + 'hex' + ) + this.deriveSharedSecret = function (key) { + if (!key || !key.P) return false + var S = key.P.multiply(priv) + return Buffer.from( + unstupid(S.getX().toBigInteger().toString(16), bytes * 2), + 'hex' + ) + } + } + } + + /***/ + }, + + /***/ 3943: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + // Basic Javascript Elliptic Curve implementation + // Ported loosely from BouncyCastle's Java EC code + // Only Fp curves implemented for now + + // Requires jsbn.js and jsbn2.js + var BigInteger = __webpack_require__(85587).BigInteger + var Barrett = BigInteger.prototype.Barrett + + // ---------------- + // ECFieldElementFp + + // constructor + function ECFieldElementFp(q, x) { + this.x = x + // TODO if(x.compareTo(q) >= 0) error + this.q = q + } + + function feFpEquals(other) { + if (other == this) return true + return this.q.equals(other.q) && this.x.equals(other.x) + } + + function feFpToBigInteger() { + return this.x + } + + function feFpNegate() { + return new ECFieldElementFp(this.q, this.x.negate().mod(this.q)) + } + + function feFpAdd(b) { + return new ECFieldElementFp( + this.q, + this.x.add(b.toBigInteger()).mod(this.q) + ) + } + + function feFpSubtract(b) { + return new ECFieldElementFp( + this.q, + this.x.subtract(b.toBigInteger()).mod(this.q) + ) + } + + function feFpMultiply(b) { + return new ECFieldElementFp( + this.q, + this.x.multiply(b.toBigInteger()).mod(this.q) + ) + } + + function feFpSquare() { + return new ECFieldElementFp(this.q, this.x.square().mod(this.q)) + } + + function feFpDivide(b) { + return new ECFieldElementFp( + this.q, + this.x.multiply(b.toBigInteger().modInverse(this.q)).mod(this.q) + ) + } + + ECFieldElementFp.prototype.equals = feFpEquals + ECFieldElementFp.prototype.toBigInteger = feFpToBigInteger + ECFieldElementFp.prototype.negate = feFpNegate + ECFieldElementFp.prototype.add = feFpAdd + ECFieldElementFp.prototype.subtract = feFpSubtract + ECFieldElementFp.prototype.multiply = feFpMultiply + ECFieldElementFp.prototype.square = feFpSquare + ECFieldElementFp.prototype.divide = feFpDivide + + // ---------------- + // ECPointFp + + // constructor + function ECPointFp(curve, x, y, z) { + this.curve = curve + this.x = x + this.y = y + // Projective coordinates: either zinv == null or z * zinv == 1 + // z and zinv are just BigIntegers, not fieldElements + if (z == null) { + this.z = BigInteger.ONE + } else { + this.z = z + } + this.zinv = null + //TODO: compression flag + } + + function pointFpGetX() { + if (this.zinv == null) { + this.zinv = this.z.modInverse(this.curve.q) + } + var r = this.x.toBigInteger().multiply(this.zinv) + this.curve.reduce(r) + return this.curve.fromBigInteger(r) + } + + function pointFpGetY() { + if (this.zinv == null) { + this.zinv = this.z.modInverse(this.curve.q) + } + var r = this.y.toBigInteger().multiply(this.zinv) + this.curve.reduce(r) + return this.curve.fromBigInteger(r) + } + + function pointFpEquals(other) { + if (other == this) return true + if (this.isInfinity()) return other.isInfinity() + if (other.isInfinity()) return this.isInfinity() + var u, v + // u = Y2 * Z1 - Y1 * Z2 + u = other.y + .toBigInteger() + .multiply(this.z) + .subtract(this.y.toBigInteger().multiply(other.z)) + .mod(this.curve.q) + if (!u.equals(BigInteger.ZERO)) return false + // v = X2 * Z1 - X1 * Z2 + v = other.x + .toBigInteger() + .multiply(this.z) + .subtract(this.x.toBigInteger().multiply(other.z)) + .mod(this.curve.q) + return v.equals(BigInteger.ZERO) + } + + function pointFpIsInfinity() { + if (this.x == null && this.y == null) return true + return ( + this.z.equals(BigInteger.ZERO) && + !this.y.toBigInteger().equals(BigInteger.ZERO) + ) + } + + function pointFpNegate() { + return new ECPointFp(this.curve, this.x, this.y.negate(), this.z) + } + + function pointFpAdd(b) { + if (this.isInfinity()) return b + if (b.isInfinity()) return this + + // u = Y2 * Z1 - Y1 * Z2 + var u = b.y + .toBigInteger() + .multiply(this.z) + .subtract(this.y.toBigInteger().multiply(b.z)) + .mod(this.curve.q) + // v = X2 * Z1 - X1 * Z2 + var v = b.x + .toBigInteger() + .multiply(this.z) + .subtract(this.x.toBigInteger().multiply(b.z)) + .mod(this.curve.q) + + if (BigInteger.ZERO.equals(v)) { + if (BigInteger.ZERO.equals(u)) { + return this.twice() // this == b, so double + } + return this.curve.getInfinity() // this = -b, so infinity + } + + var THREE = new BigInteger('3') + var x1 = this.x.toBigInteger() + var y1 = this.y.toBigInteger() + var x2 = b.x.toBigInteger() + var y2 = b.y.toBigInteger() + + var v2 = v.square() + var v3 = v2.multiply(v) + var x1v2 = x1.multiply(v2) + var zu2 = u.square().multiply(this.z) + + // x3 = v * (z2 * (z1 * u^2 - 2 * x1 * v^2) - v^3) + var x3 = zu2 + .subtract(x1v2.shiftLeft(1)) + .multiply(b.z) + .subtract(v3) + .multiply(v) + .mod(this.curve.q) + // y3 = z2 * (3 * x1 * u * v^2 - y1 * v^3 - z1 * u^3) + u * v^3 + var y3 = x1v2 + .multiply(THREE) + .multiply(u) + .subtract(y1.multiply(v3)) + .subtract(zu2.multiply(u)) + .multiply(b.z) + .add(u.multiply(v3)) + .mod(this.curve.q) + // z3 = v^3 * z1 * z2 + var z3 = v3.multiply(this.z).multiply(b.z).mod(this.curve.q) + + return new ECPointFp( + this.curve, + this.curve.fromBigInteger(x3), + this.curve.fromBigInteger(y3), + z3 + ) + } + + function pointFpTwice() { + if (this.isInfinity()) return this + if (this.y.toBigInteger().signum() == 0) return this.curve.getInfinity() + + // TODO: optimized handling of constants + var THREE = new BigInteger('3') + var x1 = this.x.toBigInteger() + var y1 = this.y.toBigInteger() + + var y1z1 = y1.multiply(this.z) + var y1sqz1 = y1z1.multiply(y1).mod(this.curve.q) + var a = this.curve.a.toBigInteger() + + // w = 3 * x1^2 + a * z1^2 + var w = x1.square().multiply(THREE) + if (!BigInteger.ZERO.equals(a)) { + w = w.add(this.z.square().multiply(a)) + } + w = w.mod(this.curve.q) + //this.curve.reduce(w); + // x3 = 2 * y1 * z1 * (w^2 - 8 * x1 * y1^2 * z1) + var x3 = w + .square() + .subtract(x1.shiftLeft(3).multiply(y1sqz1)) + .shiftLeft(1) + .multiply(y1z1) + .mod(this.curve.q) + // y3 = 4 * y1^2 * z1 * (3 * w * x1 - 2 * y1^2 * z1) - w^3 + var y3 = w + .multiply(THREE) + .multiply(x1) + .subtract(y1sqz1.shiftLeft(1)) + .shiftLeft(2) + .multiply(y1sqz1) + .subtract(w.square().multiply(w)) + .mod(this.curve.q) + // z3 = 8 * (y1 * z1)^3 + var z3 = y1z1.square().multiply(y1z1).shiftLeft(3).mod(this.curve.q) + + return new ECPointFp( + this.curve, + this.curve.fromBigInteger(x3), + this.curve.fromBigInteger(y3), + z3 + ) + } + + // Simple NAF (Non-Adjacent Form) multiplication algorithm + // TODO: modularize the multiplication algorithm + function pointFpMultiply(k) { + if (this.isInfinity()) return this + if (k.signum() == 0) return this.curve.getInfinity() + + var e = k + var h = e.multiply(new BigInteger('3')) + + var neg = this.negate() + var R = this + + var i + for (i = h.bitLength() - 2; i > 0; --i) { + R = R.twice() + + var hBit = h.testBit(i) + var eBit = e.testBit(i) + + if (hBit != eBit) { + R = R.add(hBit ? this : neg) + } + } + + return R + } + + // Compute this*j + x*k (simultaneous multiplication) + function pointFpMultiplyTwo(j, x, k) { + var i + if (j.bitLength() > k.bitLength()) i = j.bitLength() - 1 + else i = k.bitLength() - 1 + + var R = this.curve.getInfinity() + var both = this.add(x) + while (i >= 0) { + R = R.twice() + if (j.testBit(i)) { + if (k.testBit(i)) { + R = R.add(both) + } else { + R = R.add(this) + } + } else { + if (k.testBit(i)) { + R = R.add(x) + } + } + --i + } + + return R + } + + ECPointFp.prototype.getX = pointFpGetX + ECPointFp.prototype.getY = pointFpGetY + ECPointFp.prototype.equals = pointFpEquals + ECPointFp.prototype.isInfinity = pointFpIsInfinity + ECPointFp.prototype.negate = pointFpNegate + ECPointFp.prototype.add = pointFpAdd + ECPointFp.prototype.twice = pointFpTwice + ECPointFp.prototype.multiply = pointFpMultiply + ECPointFp.prototype.multiplyTwo = pointFpMultiplyTwo + + // ---------------- + // ECCurveFp + + // constructor + function ECCurveFp(q, a, b) { + this.q = q + this.a = this.fromBigInteger(a) + this.b = this.fromBigInteger(b) + this.infinity = new ECPointFp(this, null, null) + this.reducer = new Barrett(this.q) + } + + function curveFpGetQ() { + return this.q + } + + function curveFpGetA() { + return this.a + } + + function curveFpGetB() { + return this.b + } + + function curveFpEquals(other) { + if (other == this) return true + return ( + this.q.equals(other.q) && + this.a.equals(other.a) && + this.b.equals(other.b) + ) + } + + function curveFpGetInfinity() { + return this.infinity + } + + function curveFpFromBigInteger(x) { + return new ECFieldElementFp(this.q, x) + } + + function curveReduce(x) { + this.reducer.reduce(x) + } + + // for now, work with hex strings because they're easier in JS + function curveFpDecodePointHex(s) { + switch ( + parseInt(s.substr(0, 2), 16) // first byte + ) { + case 0: + return this.infinity + case 2: + case 3: + // point compression not supported yet + return null + case 4: + case 6: + case 7: + var len = (s.length - 2) / 2 + var xHex = s.substr(2, len) + var yHex = s.substr(len + 2, len) + + return new ECPointFp( + this, + this.fromBigInteger(new BigInteger(xHex, 16)), + this.fromBigInteger(new BigInteger(yHex, 16)) + ) + + default: + // unsupported + return null + } + } + + function curveFpEncodePointHex(p) { + if (p.isInfinity()) return '00' + var xHex = p.getX().toBigInteger().toString(16) + var yHex = p.getY().toBigInteger().toString(16) + var oLen = this.getQ().toString(16).length + if (oLen % 2 != 0) oLen++ + while (xHex.length < oLen) { + xHex = '0' + xHex + } + while (yHex.length < oLen) { + yHex = '0' + yHex + } + return '04' + xHex + yHex + } + + ECCurveFp.prototype.getQ = curveFpGetQ + ECCurveFp.prototype.getA = curveFpGetA + ECCurveFp.prototype.getB = curveFpGetB + ECCurveFp.prototype.equals = curveFpEquals + ECCurveFp.prototype.getInfinity = curveFpGetInfinity + ECCurveFp.prototype.fromBigInteger = curveFpFromBigInteger + ECCurveFp.prototype.reduce = curveReduce + //ECCurveFp.prototype.decodePointHex = curveFpDecodePointHex; + ECCurveFp.prototype.encodePointHex = curveFpEncodePointHex + + // from: https://github.com/kaielvin/jsbn-ec-point-compression + ECCurveFp.prototype.decodePointHex = function (s) { + var yIsEven + switch ( + parseInt(s.substr(0, 2), 16) // first byte + ) { + case 0: + return this.infinity + case 2: + yIsEven = false + case 3: + if (yIsEven == undefined) yIsEven = true + var len = s.length - 2 + var xHex = s.substr(2, len) + var x = this.fromBigInteger(new BigInteger(xHex, 16)) + var alpha = x.multiply(x.square().add(this.getA())).add(this.getB()) + var beta = alpha.sqrt() + + if (beta == null) throw 'Invalid point compression' + + var betaValue = beta.toBigInteger() + if (betaValue.testBit(0) != yIsEven) { + // Use the other root + beta = this.fromBigInteger(this.getQ().subtract(betaValue)) + } + return new ECPointFp(this, x, beta) + case 4: + case 6: + case 7: + var len = (s.length - 2) / 2 + var xHex = s.substr(2, len) + var yHex = s.substr(len + 2, len) + + return new ECPointFp( + this, + this.fromBigInteger(new BigInteger(xHex, 16)), + this.fromBigInteger(new BigInteger(yHex, 16)) + ) + + default: + // unsupported + return null + } + } + ECCurveFp.prototype.encodeCompressedPointHex = function (p) { + if (p.isInfinity()) return '00' + var xHex = p.getX().toBigInteger().toString(16) + var oLen = this.getQ().toString(16).length + if (oLen % 2 != 0) oLen++ + while (xHex.length < oLen) xHex = '0' + xHex + var yPrefix + if (p.getY().toBigInteger().isEven()) yPrefix = '02' + else yPrefix = '03' + + return yPrefix + xHex + } + + ECFieldElementFp.prototype.getR = function () { + if (this.r != undefined) return this.r + + this.r = null + var bitLength = this.q.bitLength() + if (bitLength > 128) { + var firstWord = this.q.shiftRight(bitLength - 64) + if (firstWord.intValue() == -1) { + this.r = BigInteger.ONE.shiftLeft(bitLength).subtract(this.q) + } + } + return this.r + } + ECFieldElementFp.prototype.modMult = function (x1, x2) { + return this.modReduce(x1.multiply(x2)) + } + ECFieldElementFp.prototype.modReduce = function (x) { + if (this.getR() != null) { + var qLen = q.bitLength() + while (x.bitLength() > qLen + 1) { + var u = x.shiftRight(qLen) + var v = x.subtract(u.shiftLeft(qLen)) + if (!this.getR().equals(BigInteger.ONE)) { + u = u.multiply(this.getR()) + } + x = u.add(v) + } + while (x.compareTo(q) >= 0) { + x = x.subtract(q) + } + } else { + x = x.mod(q) + } + return x + } + ECFieldElementFp.prototype.sqrt = function () { + if (!this.q.testBit(0)) throw 'unsupported' + + // p mod 4 == 3 + if (this.q.testBit(1)) { + var z = new ECFieldElementFp( + this.q, + this.x.modPow(this.q.shiftRight(2).add(BigInteger.ONE), this.q) + ) + return z.square().equals(this) ? z : null + } + + // p mod 4 == 1 + var qMinusOne = this.q.subtract(BigInteger.ONE) + + var legendreExponent = qMinusOne.shiftRight(1) + if (!this.x.modPow(legendreExponent, this.q).equals(BigInteger.ONE)) { + return null + } + + var u = qMinusOne.shiftRight(2) + var k = u.shiftLeft(1).add(BigInteger.ONE) + + var Q = this.x + var fourQ = modDouble(modDouble(Q)) + + var U, V + do { + var P + do { + P = new BigInteger(this.q.bitLength(), new SecureRandom()) + } while ( + P.compareTo(this.q) >= 0 || + !P.multiply(P) + .subtract(fourQ) + .modPow(legendreExponent, this.q) + .equals(qMinusOne) + ) + + var result = this.lucasSequence(P, Q, k) + U = result[0] + V = result[1] + + if (this.modMult(V, V).equals(fourQ)) { + // Integer division by 2, mod q + if (V.testBit(0)) { + V = V.add(q) + } + + V = V.shiftRight(1) + + return new ECFieldElementFp(q, V) + } + } while (U.equals(BigInteger.ONE) || U.equals(qMinusOne)) + + return null + } + ECFieldElementFp.prototype.lucasSequence = function (P, Q, k) { + var n = k.bitLength() + var s = k.getLowestSetBit() + + var Uh = BigInteger.ONE + var Vl = BigInteger.TWO + var Vh = P + var Ql = BigInteger.ONE + var Qh = BigInteger.ONE + + for (var j = n - 1; j >= s + 1; --j) { + Ql = this.modMult(Ql, Qh) + + if (k.testBit(j)) { + Qh = this.modMult(Ql, Q) + Uh = this.modMult(Uh, Vh) + Vl = this.modReduce(Vh.multiply(Vl).subtract(P.multiply(Ql))) + Vh = this.modReduce(Vh.multiply(Vh).subtract(Qh.shiftLeft(1))) + } else { + Qh = Ql + Uh = this.modReduce(Uh.multiply(Vl).subtract(Ql)) + Vh = this.modReduce(Vh.multiply(Vl).subtract(P.multiply(Ql))) + Vl = this.modReduce(Vl.multiply(Vl).subtract(Ql.shiftLeft(1))) + } + } + + Ql = this.modMult(Ql, Qh) + Qh = this.modMult(Ql, Q) + Uh = this.modReduce(Uh.multiply(Vl).subtract(Ql)) + Vl = this.modReduce(Vh.multiply(Vl).subtract(P.multiply(Ql))) + Ql = this.modMult(Ql, Qh) + + for (var j = 1; j <= s; ++j) { + Uh = this.modMult(Uh, Vl) + Vl = this.modReduce(Vl.multiply(Vl).subtract(Ql.shiftLeft(1))) + Ql = this.modMult(Ql, Ql) + } + + return [Uh, Vl] + } + + var exports = { + ECCurveFp: ECCurveFp, + ECPointFp: ECPointFp, + ECFieldElementFp: ECFieldElementFp + } + + module.exports = exports + + /***/ + }, + + /***/ 41452: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + // Named EC curves + + // Requires ec.js, jsbn.js, and jsbn2.js + var BigInteger = __webpack_require__(85587).BigInteger + var ECCurveFp = __webpack_require__(3943).ECCurveFp + + // ---------------- + // X9ECParameters + + // constructor + function X9ECParameters(curve, g, n, h) { + this.curve = curve + this.g = g + this.n = n + this.h = h + } + + function x9getCurve() { + return this.curve + } + + function x9getG() { + return this.g + } + + function x9getN() { + return this.n + } + + function x9getH() { + return this.h + } + + X9ECParameters.prototype.getCurve = x9getCurve + X9ECParameters.prototype.getG = x9getG + X9ECParameters.prototype.getN = x9getN + X9ECParameters.prototype.getH = x9getH + + // ---------------- + // SECNamedCurves + + function fromHex(s) { + return new BigInteger(s, 16) + } + + function secp128r1() { + // p = 2^128 - 2^97 - 1 + var p = fromHex('FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFF') + var a = fromHex('FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFC') + var b = fromHex('E87579C11079F43DD824993C2CEE5ED3') + //byte[] S = Hex.decode("000E0D4D696E6768756151750CC03A4473D03679"); + var n = fromHex('FFFFFFFE0000000075A30D1B9038A115') + var h = BigInteger.ONE + var curve = new ECCurveFp(p, a, b) + var G = curve.decodePointHex( + '04' + + '161FF7528B899B2D0C28607CA52C5B86' + + 'CF5AC8395BAFEB13C02DA292DDED7A83' + ) + return new X9ECParameters(curve, G, n, h) + } + + function secp160k1() { + // p = 2^160 - 2^32 - 2^14 - 2^12 - 2^9 - 2^8 - 2^7 - 2^3 - 2^2 - 1 + var p = fromHex('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC73') + var a = BigInteger.ZERO + var b = fromHex('7') + //byte[] S = null; + var n = fromHex('0100000000000000000001B8FA16DFAB9ACA16B6B3') + var h = BigInteger.ONE + var curve = new ECCurveFp(p, a, b) + var G = curve.decodePointHex( + '04' + + '3B4C382CE37AA192A4019E763036F4F5DD4D7EBB' + + '938CF935318FDCED6BC28286531733C3F03C4FEE' + ) + return new X9ECParameters(curve, G, n, h) + } + + function secp160r1() { + // p = 2^160 - 2^31 - 1 + var p = fromHex('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFF') + var a = fromHex('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFC') + var b = fromHex('1C97BEFC54BD7A8B65ACF89F81D4D4ADC565FA45') + //byte[] S = Hex.decode("1053CDE42C14D696E67687561517533BF3F83345"); + var n = fromHex('0100000000000000000001F4C8F927AED3CA752257') + var h = BigInteger.ONE + var curve = new ECCurveFp(p, a, b) + var G = curve.decodePointHex( + '04' + + '4A96B5688EF573284664698968C38BB913CBFC82' + + '23A628553168947D59DCC912042351377AC5FB32' + ) + return new X9ECParameters(curve, G, n, h) + } + + function secp192k1() { + // p = 2^192 - 2^32 - 2^12 - 2^8 - 2^7 - 2^6 - 2^3 - 1 + var p = fromHex('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFEE37') + var a = BigInteger.ZERO + var b = fromHex('3') + //byte[] S = null; + var n = fromHex('FFFFFFFFFFFFFFFFFFFFFFFE26F2FC170F69466A74DEFD8D') + var h = BigInteger.ONE + var curve = new ECCurveFp(p, a, b) + var G = curve.decodePointHex( + '04' + + 'DB4FF10EC057E9AE26B07D0280B7F4341DA5D1B1EAE06C7D' + + '9B2F2F6D9C5628A7844163D015BE86344082AA88D95E2F9D' + ) + return new X9ECParameters(curve, G, n, h) + } + + function secp192r1() { + // p = 2^192 - 2^64 - 1 + var p = fromHex('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF') + var a = fromHex('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC') + var b = fromHex('64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1') + //byte[] S = Hex.decode("3045AE6FC8422F64ED579528D38120EAE12196D5"); + var n = fromHex('FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831') + var h = BigInteger.ONE + var curve = new ECCurveFp(p, a, b) + var G = curve.decodePointHex( + '04' + + '188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012' + + '07192B95FFC8DA78631011ED6B24CDD573F977A11E794811' + ) + return new X9ECParameters(curve, G, n, h) + } + + function secp224r1() { + // p = 2^224 - 2^96 + 1 + var p = fromHex( + 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001' + ) + var a = fromHex( + 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFE' + ) + var b = fromHex( + 'B4050A850C04B3ABF54132565044B0B7D7BFD8BA270B39432355FFB4' + ) + //byte[] S = Hex.decode("BD71344799D5C7FCDC45B59FA3B9AB8F6A948BC5"); + var n = fromHex( + 'FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D' + ) + var h = BigInteger.ONE + var curve = new ECCurveFp(p, a, b) + var G = curve.decodePointHex( + '04' + + 'B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21' + + 'BD376388B5F723FB4C22DFE6CD4375A05A07476444D5819985007E34' + ) + return new X9ECParameters(curve, G, n, h) + } + + function secp256r1() { + // p = 2^224 (2^32 - 1) + 2^192 + 2^96 - 1 + var p = fromHex( + 'FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF' + ) + var a = fromHex( + 'FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC' + ) + var b = fromHex( + '5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B' + ) + //byte[] S = Hex.decode("C49D360886E704936A6678E1139D26B7819F7E90"); + var n = fromHex( + 'FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551' + ) + var h = BigInteger.ONE + var curve = new ECCurveFp(p, a, b) + var G = curve.decodePointHex( + '04' + + '6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296' + + '4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5' + ) + return new X9ECParameters(curve, G, n, h) + } + + // TODO: make this into a proper hashtable + function getSECCurveByName(name) { + if (name == 'secp128r1') return secp128r1() + if (name == 'secp160k1') return secp160k1() + if (name == 'secp160r1') return secp160r1() + if (name == 'secp192k1') return secp192k1() + if (name == 'secp192r1') return secp192r1() + if (name == 'secp224r1') return secp224r1() + if (name == 'secp256r1') return secp256r1() + return null + } + + module.exports = { + secp128r1: secp128r1, + secp160k1: secp160k1, + secp160r1: secp160r1, + secp192k1: secp192k1, + secp192r1: secp192r1, + secp224r1: secp224r1, + secp256r1: secp256r1 + } + + /***/ + }, + + /***/ 11728: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + 'use strict' + + var Buffer = __webpack_require__(21867).Buffer + + var getParamBytesForAlg = __webpack_require__(30528) + + var MAX_OCTET = 0x80, + CLASS_UNIVERSAL = 0, + PRIMITIVE_BIT = 0x20, + TAG_SEQ = 0x10, + TAG_INT = 0x02, + ENCODED_TAG_SEQ = TAG_SEQ | PRIMITIVE_BIT | (CLASS_UNIVERSAL << 6), + ENCODED_TAG_INT = TAG_INT | (CLASS_UNIVERSAL << 6) + + function base64Url(base64) { + return base64.replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_') + } + + function signatureAsBuffer(signature) { + if (Buffer.isBuffer(signature)) { + return signature + } else if ('string' === typeof signature) { + return Buffer.from(signature, 'base64') + } + + throw new TypeError( + 'ECDSA signature must be a Base64 string or a Buffer' + ) + } + + function derToJose(signature, alg) { + signature = signatureAsBuffer(signature) + var paramBytes = getParamBytesForAlg(alg) + + // the DER encoded param should at most be the param size, plus a padding + // zero, since due to being a signed integer + var maxEncodedParamLength = paramBytes + 1 + + var inputLength = signature.length + + var offset = 0 + if (signature[offset++] !== ENCODED_TAG_SEQ) { + throw new Error('Could not find expected "seq"') + } + + var seqLength = signature[offset++] + if (seqLength === (MAX_OCTET | 1)) { + seqLength = signature[offset++] + } + + if (inputLength - offset < seqLength) { + throw new Error( + '"seq" specified length of "' + + seqLength + + '", only "' + + (inputLength - offset) + + '" remaining' + ) + } + + if (signature[offset++] !== ENCODED_TAG_INT) { + throw new Error('Could not find expected "int" for "r"') + } + + var rLength = signature[offset++] + + if (inputLength - offset - 2 < rLength) { + throw new Error( + '"r" specified length of "' + + rLength + + '", only "' + + (inputLength - offset - 2) + + '" available' + ) + } + + if (maxEncodedParamLength < rLength) { + throw new Error( + '"r" specified length of "' + + rLength + + '", max of "' + + maxEncodedParamLength + + '" is acceptable' + ) + } + + var rOffset = offset + offset += rLength + + if (signature[offset++] !== ENCODED_TAG_INT) { + throw new Error('Could not find expected "int" for "s"') + } + + var sLength = signature[offset++] + + if (inputLength - offset !== sLength) { + throw new Error( + '"s" specified length of "' + + sLength + + '", expected "' + + (inputLength - offset) + + '"' + ) + } + + if (maxEncodedParamLength < sLength) { + throw new Error( + '"s" specified length of "' + + sLength + + '", max of "' + + maxEncodedParamLength + + '" is acceptable' + ) + } + + var sOffset = offset + offset += sLength + + if (offset !== inputLength) { + throw new Error( + 'Expected to consume entire buffer, but "' + + (inputLength - offset) + + '" bytes remain' + ) + } + + var rPadding = paramBytes - rLength, + sPadding = paramBytes - sLength + + var dst = Buffer.allocUnsafe(rPadding + rLength + sPadding + sLength) + + for (offset = 0; offset < rPadding; ++offset) { + dst[offset] = 0 + } + signature.copy( + dst, + offset, + rOffset + Math.max(-rPadding, 0), + rOffset + rLength + ) + + offset = paramBytes + + for (var o = offset; offset < o + sPadding; ++offset) { + dst[offset] = 0 + } + signature.copy( + dst, + offset, + sOffset + Math.max(-sPadding, 0), + sOffset + sLength + ) + + dst = dst.toString('base64') + dst = base64Url(dst) + + return dst + } + + function countPadding(buf, start, stop) { + var padding = 0 + while (start + padding < stop && buf[start + padding] === 0) { + ++padding + } + + var needsSign = buf[start + padding] >= MAX_OCTET + if (needsSign) { + --padding + } + + return padding + } + + function joseToDer(signature, alg) { + signature = signatureAsBuffer(signature) + var paramBytes = getParamBytesForAlg(alg) + + var signatureBytes = signature.length + if (signatureBytes !== paramBytes * 2) { + throw new TypeError( + '"' + + alg + + '" signatures must be "' + + paramBytes * 2 + + '" bytes, saw "' + + signatureBytes + + '"' + ) + } + + var rPadding = countPadding(signature, 0, paramBytes) + var sPadding = countPadding(signature, paramBytes, signature.length) + var rLength = paramBytes - rPadding + var sLength = paramBytes - sPadding + + var rsBytes = 1 + 1 + rLength + 1 + 1 + sLength + + var shortLength = rsBytes < MAX_OCTET + + var dst = Buffer.allocUnsafe((shortLength ? 2 : 3) + rsBytes) + + var offset = 0 + dst[offset++] = ENCODED_TAG_SEQ + if (shortLength) { + // Bit 8 has value "0" + // bits 7-1 give the length. + dst[offset++] = rsBytes + } else { + // Bit 8 of first octet has value "1" + // bits 7-1 give the number of additional length octets. + dst[offset++] = MAX_OCTET | 1 + // length, base 256 + dst[offset++] = rsBytes & 0xff + } + dst[offset++] = ENCODED_TAG_INT + dst[offset++] = rLength + if (rPadding < 0) { + dst[offset++] = 0 + offset += signature.copy(dst, offset, 0, paramBytes) + } else { + offset += signature.copy(dst, offset, rPadding, paramBytes) + } + dst[offset++] = ENCODED_TAG_INT + dst[offset++] = sLength + if (sPadding < 0) { + dst[offset++] = 0 + signature.copy(dst, offset, paramBytes) + } else { + signature.copy(dst, offset, paramBytes + sPadding) + } + + return dst + } + + module.exports = { + derToJose: derToJose, + joseToDer: joseToDer + } + + /***/ + }, + + /***/ 30528: /***/ module => { + 'use strict' + + function getParamSize(keySize) { + var result = ((keySize / 8) | 0) + (keySize % 8 === 0 ? 0 : 1) + return result + } + + var paramBytesForAlg = { + ES256: getParamSize(256), + ES384: getParamSize(384), + ES512: getParamSize(521) + } + + function getParamBytesForAlg(alg) { + var paramBytes = paramBytesForAlg[alg] + if (paramBytes) { + return paramBytes + } + + throw new Error('Unknown algorithm "' + alg + '"') + } + + module.exports = getParamBytesForAlg + + /***/ + }, + + /***/ 14401: /***/ module => { + 'use strict' + /*! + * ee-first + * Copyright(c) 2014 Jonathan Ong + * MIT Licensed + */ + + /** + * Module exports. + * @public + */ + + module.exports = first + + /** + * Get the first event in a set of event emitters and event pairs. + * + * @param {array} stuff + * @param {function} done + * @public + */ + + function first(stuff, done) { + if (!Array.isArray(stuff)) + throw new TypeError('arg must be an array of [ee, events...] arrays') + + var cleanups = [] + + for (var i = 0; i < stuff.length; i++) { + var arr = stuff[i] + + if (!Array.isArray(arr) || arr.length < 2) + throw new TypeError('each array member must be [ee, events...]') + + var ee = arr[0] + + for (var j = 1; j < arr.length; j++) { + var event = arr[j] + var fn = listener(event, callback) + + // listen to the event + ee.on(event, fn) + // push this listener to the list of cleanups + cleanups.push({ + ee: ee, + event: event, + fn: fn + }) + } + } + + function callback() { + cleanup() + done.apply(null, arguments) + } + + function cleanup() { + var x + for (var i = 0; i < cleanups.length; i++) { + x = cleanups[i] + x.ee.removeListener(x.event, x.fn) + } + } + + function thunk(fn) { + done = fn + } + + thunk.cancel = cleanup + + return thunk + } + + /** + * Create the event listener. + * @private + */ + + function listener(event, done) { + return function onevent(arg1) { + var args = new Array(arguments.length) + var ee = this + var err = event === 'error' ? arg1 : null + + // copy args to prevent arguments escaping scope + for (var i = 0; i < args.length; i++) { + args[i] = arguments[i] + } + + done(err, ee, event, args) + } + } + + /***/ + }, + + /***/ 81205: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + var once = __webpack_require__(1223) + + var noop = function () {} + + var isRequest = function (stream) { + return stream.setHeader && typeof stream.abort === 'function' + } + + var isChildProcess = function (stream) { + return ( + stream.stdio && + Array.isArray(stream.stdio) && + stream.stdio.length === 3 + ) + } + + var eos = function (stream, opts, callback) { + if (typeof opts === 'function') return eos(stream, null, opts) + if (!opts) opts = {} + + callback = once(callback || noop) + + var ws = stream._writableState + var rs = stream._readableState + var readable = + opts.readable || (opts.readable !== false && stream.readable) + var writable = + opts.writable || (opts.writable !== false && stream.writable) + var cancelled = false + + var onlegacyfinish = function () { + if (!stream.writable) onfinish() + } + + var onfinish = function () { + writable = false + if (!readable) callback.call(stream) + } + + var onend = function () { + readable = false + if (!writable) callback.call(stream) + } + + var onexit = function (exitCode) { + callback.call( + stream, + exitCode ? new Error('exited with error code: ' + exitCode) : null + ) + } + + var onerror = function (err) { + callback.call(stream, err) + } + + var onclose = function () { + process.nextTick(onclosenexttick) + } + + var onclosenexttick = function () { + if (cancelled) return + if (readable && !(rs && rs.ended && !rs.destroyed)) + return callback.call(stream, new Error('premature close')) + if (writable && !(ws && ws.ended && !ws.destroyed)) + return callback.call(stream, new Error('premature close')) + } + + var onrequest = function () { + stream.req.on('finish', onfinish) + } + + if (isRequest(stream)) { + stream.on('complete', onfinish) + stream.on('abort', onclose) + if (stream.req) onrequest() + else stream.on('request', onrequest) + } else if (writable && !ws) { + // legacy streams + stream.on('end', onlegacyfinish) + stream.on('close', onlegacyfinish) + } + + if (isChildProcess(stream)) stream.on('exit', onexit) + + stream.on('end', onend) + stream.on('finish', onfinish) + if (opts.error !== false) stream.on('error', onerror) + stream.on('close', onclose) + + return function () { + cancelled = true + stream.removeListener('complete', onfinish) + stream.removeListener('abort', onclose) + stream.removeListener('request', onrequest) + if (stream.req) stream.req.removeListener('finish', onfinish) + stream.removeListener('end', onlegacyfinish) + stream.removeListener('close', onlegacyfinish) + stream.removeListener('finish', onfinish) + stream.removeListener('exit', onexit) + stream.removeListener('end', onend) + stream.removeListener('error', onerror) + stream.removeListener('close', onclose) + } + } + + module.exports = eos + + /***/ + }, + + /***/ 35771: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + var punycode = __webpack_require__(94213) + var entities = __webpack_require__(15615) + + module.exports = decode + + function decode(str) { + if (typeof str !== 'string') { + throw new TypeError('Expected a String') + } + + return str.replace(/&(#?[^;\W]+;?)/g, function (_, match) { + var m + if ((m = /^#(\d+);?$/.exec(match))) { + return punycode.ucs2.encode([parseInt(m[1], 10)]) + } else if ((m = /^#[Xx]([A-Fa-f0-9]+);?/.exec(match))) { + return punycode.ucs2.encode([parseInt(m[1], 16)]) + } else { + // named entity + var hasSemi = /;$/.test(match) + var withoutSemi = hasSemi ? match.replace(/;$/, '') : match + var target = entities[withoutSemi] || (hasSemi && entities[match]) + + if (typeof target === 'number') { + return punycode.ucs2.encode([target]) + } else if (typeof target === 'string') { + return target + } else { + return '&' + match + } + } + }) + } + + /***/ + }, + + /***/ 86521: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + var punycode = __webpack_require__(94213) + var revEntities = __webpack_require__(88245) + + module.exports = encode + + function encode(str, opts) { + if (typeof str !== 'string') { + throw new TypeError('Expected a String') + } + if (!opts) opts = {} + + var numeric = true + if (opts.named) numeric = false + if (opts.numeric !== undefined) numeric = opts.numeric + + var special = opts.special || { + '"': true, + "'": true, + '<': true, + '>': true, + '&': true + } + + var codePoints = punycode.ucs2.decode(str) + var chars = [] + for (var i = 0; i < codePoints.length; i++) { + var cc = codePoints[i] + var c = punycode.ucs2.encode([cc]) + var e = revEntities[cc] + if (e && (cc >= 127 || special[c]) && !numeric) { + chars.push('&' + (/;$/.test(e) ? e : e + ';')) + } else if (cc < 32 || cc >= 127 || special[c]) { + chars.push('&#' + cc + ';') + } else { + chars.push(c) + } + } + return chars.join('') + } + + /***/ + }, + + /***/ 1151: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + exports.encode = __webpack_require__(86521) + exports.decode = __webpack_require__(35771) + + /***/ + }, + + /***/ 84697: /***/ (module, exports) => { + 'use strict' + /** + * @author Toru Nagashima + * @copyright 2015 Toru Nagashima. All rights reserved. + * See LICENSE file in root directory for full license. + */ + + Object.defineProperty(exports, '__esModule', { value: true }) + + /** + * @typedef {object} PrivateData + * @property {EventTarget} eventTarget The event target. + * @property {{type:string}} event The original event object. + * @property {number} eventPhase The current event phase. + * @property {EventTarget|null} currentTarget The current event target. + * @property {boolean} canceled The flag to prevent default. + * @property {boolean} stopped The flag to stop propagation. + * @property {boolean} immediateStopped The flag to stop propagation immediately. + * @property {Function|null} passiveListener The listener if the current listener is passive. Otherwise this is null. + * @property {number} timeStamp The unix time. + * @private + */ + + /** + * Private data for event wrappers. + * @type {WeakMap} + * @private + */ + const privateData = new WeakMap() + + /** + * Cache for wrapper classes. + * @type {WeakMap} + * @private + */ + const wrappers = new WeakMap() + + /** + * Get private data. + * @param {Event} event The event object to get private data. + * @returns {PrivateData} The private data of the event. + * @private + */ + function pd(event) { + const retv = privateData.get(event) + console.assert( + retv != null, + "'this' is expected an Event object, but got", + event + ) + return retv + } + + /** + * https://dom.spec.whatwg.org/#set-the-canceled-flag + * @param data {PrivateData} private data. + */ + function setCancelFlag(data) { + if (data.passiveListener != null) { + if ( + typeof console !== 'undefined' && + typeof console.error === 'function' + ) { + console.error( + 'Unable to preventDefault inside passive event listener invocation.', + data.passiveListener + ) + } + return + } + if (!data.event.cancelable) { + return + } + + data.canceled = true + if (typeof data.event.preventDefault === 'function') { + data.event.preventDefault() + } + } + + /** + * @see https://dom.spec.whatwg.org/#interface-event + * @private + */ + /** + * The event wrapper. + * @constructor + * @param {EventTarget} eventTarget The event target of this dispatching. + * @param {Event|{type:string}} event The original event to wrap. + */ + function Event(eventTarget, event) { + privateData.set(this, { + eventTarget, + event, + eventPhase: 2, + currentTarget: eventTarget, + canceled: false, + stopped: false, + immediateStopped: false, + passiveListener: null, + timeStamp: event.timeStamp || Date.now() + }) + + // https://heycam.github.io/webidl/#Unforgeable + Object.defineProperty(this, 'isTrusted', { + value: false, + enumerable: true + }) + + // Define accessors + const keys = Object.keys(event) + for (let i = 0; i < keys.length; ++i) { + const key = keys[i] + if (!(key in this)) { + Object.defineProperty(this, key, defineRedirectDescriptor(key)) + } + } + } + + // Should be enumerable, but class methods are not enumerable. + Event.prototype = { + /** + * The type of this event. + * @type {string} + */ + get type() { + return pd(this).event.type + }, + + /** + * The target of this event. + * @type {EventTarget} + */ + get target() { + return pd(this).eventTarget + }, + + /** + * The target of this event. + * @type {EventTarget} + */ + get currentTarget() { + return pd(this).currentTarget + }, + + /** + * @returns {EventTarget[]} The composed path of this event. + */ + composedPath() { + const currentTarget = pd(this).currentTarget + if (currentTarget == null) { + return [] + } + return [currentTarget] + }, + + /** + * Constant of NONE. + * @type {number} + */ + get NONE() { + return 0 + }, + + /** + * Constant of CAPTURING_PHASE. + * @type {number} + */ + get CAPTURING_PHASE() { + return 1 + }, + + /** + * Constant of AT_TARGET. + * @type {number} + */ + get AT_TARGET() { + return 2 + }, + + /** + * Constant of BUBBLING_PHASE. + * @type {number} + */ + get BUBBLING_PHASE() { + return 3 + }, + + /** + * The target of this event. + * @type {number} + */ + get eventPhase() { + return pd(this).eventPhase + }, + + /** + * Stop event bubbling. + * @returns {void} + */ + stopPropagation() { + const data = pd(this) + + data.stopped = true + if (typeof data.event.stopPropagation === 'function') { + data.event.stopPropagation() + } + }, + + /** + * Stop event bubbling. + * @returns {void} + */ + stopImmediatePropagation() { + const data = pd(this) + + data.stopped = true + data.immediateStopped = true + if (typeof data.event.stopImmediatePropagation === 'function') { + data.event.stopImmediatePropagation() + } + }, + + /** + * The flag to be bubbling. + * @type {boolean} + */ + get bubbles() { + return Boolean(pd(this).event.bubbles) + }, + + /** + * The flag to be cancelable. + * @type {boolean} + */ + get cancelable() { + return Boolean(pd(this).event.cancelable) + }, + + /** + * Cancel this event. + * @returns {void} + */ + preventDefault() { + setCancelFlag(pd(this)) + }, + + /** + * The flag to indicate cancellation state. + * @type {boolean} + */ + get defaultPrevented() { + return pd(this).canceled + }, + + /** + * The flag to be composed. + * @type {boolean} + */ + get composed() { + return Boolean(pd(this).event.composed) + }, + + /** + * The unix time of this event. + * @type {number} + */ + get timeStamp() { + return pd(this).timeStamp + }, + + /** + * The target of this event. + * @type {EventTarget} + * @deprecated + */ + get srcElement() { + return pd(this).eventTarget + }, + + /** + * The flag to stop event bubbling. + * @type {boolean} + * @deprecated + */ + get cancelBubble() { + return pd(this).stopped + }, + set cancelBubble(value) { + if (!value) { + return + } + const data = pd(this) + + data.stopped = true + if (typeof data.event.cancelBubble === 'boolean') { + data.event.cancelBubble = true + } + }, + + /** + * The flag to indicate cancellation state. + * @type {boolean} + * @deprecated + */ + get returnValue() { + return !pd(this).canceled + }, + set returnValue(value) { + if (!value) { + setCancelFlag(pd(this)) + } + }, + + /** + * Initialize this event object. But do nothing under event dispatching. + * @param {string} type The event type. + * @param {boolean} [bubbles=false] The flag to be possible to bubble up. + * @param {boolean} [cancelable=false] The flag to be possible to cancel. + * @deprecated + */ + initEvent() { + // Do nothing. + } + } + + // `constructor` is not enumerable. + Object.defineProperty(Event.prototype, 'constructor', { + value: Event, + configurable: true, + writable: true + }) + + // Ensure `event instanceof window.Event` is `true`. + if ( + typeof window !== 'undefined' && + typeof window.Event !== 'undefined' + ) { + Object.setPrototypeOf(Event.prototype, window.Event.prototype) + + // Make association for wrappers. + wrappers.set(window.Event.prototype, Event) + } + + /** + * Get the property descriptor to redirect a given property. + * @param {string} key Property name to define property descriptor. + * @returns {PropertyDescriptor} The property descriptor to redirect the property. + * @private + */ + function defineRedirectDescriptor(key) { + return { + get() { + return pd(this).event[key] + }, + set(value) { + pd(this).event[key] = value + }, + configurable: true, + enumerable: true + } + } + + /** + * Get the property descriptor to call a given method property. + * @param {string} key Property name to define property descriptor. + * @returns {PropertyDescriptor} The property descriptor to call the method property. + * @private + */ + function defineCallDescriptor(key) { + return { + value() { + const event = pd(this).event + return event[key].apply(event, arguments) + }, + configurable: true, + enumerable: true + } + } + + /** + * Define new wrapper class. + * @param {Function} BaseEvent The base wrapper class. + * @param {Object} proto The prototype of the original event. + * @returns {Function} The defined wrapper class. + * @private + */ + function defineWrapper(BaseEvent, proto) { + const keys = Object.keys(proto) + if (keys.length === 0) { + return BaseEvent + } + + /** CustomEvent */ + function CustomEvent(eventTarget, event) { + BaseEvent.call(this, eventTarget, event) + } + + CustomEvent.prototype = Object.create(BaseEvent.prototype, { + constructor: { + value: CustomEvent, + configurable: true, + writable: true + } + }) + + // Define accessors. + for (let i = 0; i < keys.length; ++i) { + const key = keys[i] + if (!(key in BaseEvent.prototype)) { + const descriptor = Object.getOwnPropertyDescriptor(proto, key) + const isFunc = typeof descriptor.value === 'function' + Object.defineProperty( + CustomEvent.prototype, + key, + isFunc ? defineCallDescriptor(key) : defineRedirectDescriptor(key) + ) + } + } + + return CustomEvent + } + + /** + * Get the wrapper class of a given prototype. + * @param {Object} proto The prototype of the original event to get its wrapper. + * @returns {Function} The wrapper class. + * @private + */ + function getWrapper(proto) { + if (proto == null || proto === Object.prototype) { + return Event + } + + let wrapper = wrappers.get(proto) + if (wrapper == null) { + wrapper = defineWrapper( + getWrapper(Object.getPrototypeOf(proto)), + proto + ) + wrappers.set(proto, wrapper) + } + return wrapper + } + + /** + * Wrap a given event to management a dispatching. + * @param {EventTarget} eventTarget The event target of this dispatching. + * @param {Object} event The event to wrap. + * @returns {Event} The wrapper instance. + * @private + */ + function wrapEvent(eventTarget, event) { + const Wrapper = getWrapper(Object.getPrototypeOf(event)) + return new Wrapper(eventTarget, event) + } + + /** + * Get the immediateStopped flag of a given event. + * @param {Event} event The event to get. + * @returns {boolean} The flag to stop propagation immediately. + * @private + */ + function isStopped(event) { + return pd(event).immediateStopped + } + + /** + * Set the current event phase of a given event. + * @param {Event} event The event to set current target. + * @param {number} eventPhase New event phase. + * @returns {void} + * @private + */ + function setEventPhase(event, eventPhase) { + pd(event).eventPhase = eventPhase + } + + /** + * Set the current target of a given event. + * @param {Event} event The event to set current target. + * @param {EventTarget|null} currentTarget New current target. + * @returns {void} + * @private + */ + function setCurrentTarget(event, currentTarget) { + pd(event).currentTarget = currentTarget + } + + /** + * Set a passive listener of a given event. + * @param {Event} event The event to set current target. + * @param {Function|null} passiveListener New passive listener. + * @returns {void} + * @private + */ + function setPassiveListener(event, passiveListener) { + pd(event).passiveListener = passiveListener + } + + /** + * @typedef {object} ListenerNode + * @property {Function} listener + * @property {1|2|3} listenerType + * @property {boolean} passive + * @property {boolean} once + * @property {ListenerNode|null} next + * @private + */ + + /** + * @type {WeakMap>} + * @private + */ + const listenersMap = new WeakMap() + + // Listener types + const CAPTURE = 1 + const BUBBLE = 2 + const ATTRIBUTE = 3 + + /** + * Check whether a given value is an object or not. + * @param {any} x The value to check. + * @returns {boolean} `true` if the value is an object. + */ + function isObject(x) { + return x !== null && typeof x === 'object' //eslint-disable-line no-restricted-syntax + } + + /** + * Get listeners. + * @param {EventTarget} eventTarget The event target to get. + * @returns {Map} The listeners. + * @private + */ + function getListeners(eventTarget) { + const listeners = listenersMap.get(eventTarget) + if (listeners == null) { + throw new TypeError( + "'this' is expected an EventTarget object, but got another value." + ) + } + return listeners + } + + /** + * Get the property descriptor for the event attribute of a given event. + * @param {string} eventName The event name to get property descriptor. + * @returns {PropertyDescriptor} The property descriptor. + * @private + */ + function defineEventAttributeDescriptor(eventName) { + return { + get() { + const listeners = getListeners(this) + let node = listeners.get(eventName) + while (node != null) { + if (node.listenerType === ATTRIBUTE) { + return node.listener + } + node = node.next + } + return null + }, + + set(listener) { + if (typeof listener !== 'function' && !isObject(listener)) { + listener = null // eslint-disable-line no-param-reassign + } + const listeners = getListeners(this) + + // Traverse to the tail while removing old value. + let prev = null + let node = listeners.get(eventName) + while (node != null) { + if (node.listenerType === ATTRIBUTE) { + // Remove old value. + if (prev !== null) { + prev.next = node.next + } else if (node.next !== null) { + listeners.set(eventName, node.next) + } else { + listeners.delete(eventName) + } + } else { + prev = node + } + + node = node.next + } + + // Add new value. + if (listener !== null) { + const newNode = { + listener, + listenerType: ATTRIBUTE, + passive: false, + once: false, + next: null + } + if (prev === null) { + listeners.set(eventName, newNode) + } else { + prev.next = newNode + } + } + }, + configurable: true, + enumerable: true + } + } + + /** + * Define an event attribute (e.g. `eventTarget.onclick`). + * @param {Object} eventTargetPrototype The event target prototype to define an event attrbite. + * @param {string} eventName The event name to define. + * @returns {void} + */ + function defineEventAttribute(eventTargetPrototype, eventName) { + Object.defineProperty( + eventTargetPrototype, + `on${eventName}`, + defineEventAttributeDescriptor(eventName) + ) + } + + /** + * Define a custom EventTarget with event attributes. + * @param {string[]} eventNames Event names for event attributes. + * @returns {EventTarget} The custom EventTarget. + * @private + */ + function defineCustomEventTarget(eventNames) { + /** CustomEventTarget */ + function CustomEventTarget() { + EventTarget.call(this) + } + + CustomEventTarget.prototype = Object.create(EventTarget.prototype, { + constructor: { + value: CustomEventTarget, + configurable: true, + writable: true + } + }) + + for (let i = 0; i < eventNames.length; ++i) { + defineEventAttribute(CustomEventTarget.prototype, eventNames[i]) + } + + return CustomEventTarget + } + + /** + * EventTarget. + * + * - This is constructor if no arguments. + * - This is a function which returns a CustomEventTarget constructor if there are arguments. + * + * For example: + * + * class A extends EventTarget {} + * class B extends EventTarget("message") {} + * class C extends EventTarget("message", "error") {} + * class D extends EventTarget(["message", "error"]) {} + */ + function EventTarget() { + /*eslint-disable consistent-return */ + if (this instanceof EventTarget) { + listenersMap.set(this, new Map()) + return + } + if (arguments.length === 1 && Array.isArray(arguments[0])) { + return defineCustomEventTarget(arguments[0]) + } + if (arguments.length > 0) { + const types = new Array(arguments.length) + for (let i = 0; i < arguments.length; ++i) { + types[i] = arguments[i] + } + return defineCustomEventTarget(types) + } + throw new TypeError('Cannot call a class as a function') + /*eslint-enable consistent-return */ + } + + // Should be enumerable, but class methods are not enumerable. + EventTarget.prototype = { + /** + * Add a given listener to this event target. + * @param {string} eventName The event name to add. + * @param {Function} listener The listener to add. + * @param {boolean|{capture?:boolean,passive?:boolean,once?:boolean}} [options] The options for this listener. + * @returns {void} + */ + addEventListener(eventName, listener, options) { + if (listener == null) { + return + } + if (typeof listener !== 'function' && !isObject(listener)) { + throw new TypeError("'listener' should be a function or an object.") + } + + const listeners = getListeners(this) + const optionsIsObj = isObject(options) + const capture = optionsIsObj + ? Boolean(options.capture) + : Boolean(options) + const listenerType = capture ? CAPTURE : BUBBLE + const newNode = { + listener, + listenerType, + passive: optionsIsObj && Boolean(options.passive), + once: optionsIsObj && Boolean(options.once), + next: null + } + + // Set it as the first node if the first node is null. + let node = listeners.get(eventName) + if (node === undefined) { + listeners.set(eventName, newNode) + return + } + + // Traverse to the tail while checking duplication.. + let prev = null + while (node != null) { + if ( + node.listener === listener && + node.listenerType === listenerType + ) { + // Should ignore duplication. + return + } + prev = node + node = node.next + } + + // Add it. + prev.next = newNode + }, + + /** + * Remove a given listener from this event target. + * @param {string} eventName The event name to remove. + * @param {Function} listener The listener to remove. + * @param {boolean|{capture?:boolean,passive?:boolean,once?:boolean}} [options] The options for this listener. + * @returns {void} + */ + removeEventListener(eventName, listener, options) { + if (listener == null) { + return + } + + const listeners = getListeners(this) + const capture = isObject(options) + ? Boolean(options.capture) + : Boolean(options) + const listenerType = capture ? CAPTURE : BUBBLE + + let prev = null + let node = listeners.get(eventName) + while (node != null) { + if ( + node.listener === listener && + node.listenerType === listenerType + ) { + if (prev !== null) { + prev.next = node.next + } else if (node.next !== null) { + listeners.set(eventName, node.next) + } else { + listeners.delete(eventName) + } + return + } + + prev = node + node = node.next + } + }, + + /** + * Dispatch a given event. + * @param {Event|{type:string}} event The event to dispatch. + * @returns {boolean} `false` if canceled. + */ + dispatchEvent(event) { + if (event == null || typeof event.type !== 'string') { + throw new TypeError('"event.type" should be a string.') + } + + // If listeners aren't registered, terminate. + const listeners = getListeners(this) + const eventName = event.type + let node = listeners.get(eventName) + if (node == null) { + return true + } + + // Since we cannot rewrite several properties, so wrap object. + const wrappedEvent = wrapEvent(this, event) + + // This doesn't process capturing phase and bubbling phase. + // This isn't participating in a tree. + let prev = null + while (node != null) { + // Remove this listener if it's once + if (node.once) { + if (prev !== null) { + prev.next = node.next + } else if (node.next !== null) { + listeners.set(eventName, node.next) + } else { + listeners.delete(eventName) + } + } else { + prev = node + } + + // Call this listener + setPassiveListener( + wrappedEvent, + node.passive ? node.listener : null + ) + if (typeof node.listener === 'function') { + try { + node.listener.call(this, wrappedEvent) + } catch (err) { + if ( + typeof console !== 'undefined' && + typeof console.error === 'function' + ) { + console.error(err) + } + } + } else if ( + node.listenerType !== ATTRIBUTE && + typeof node.listener.handleEvent === 'function' + ) { + node.listener.handleEvent(wrappedEvent) + } + + // Break if `event.stopImmediatePropagation` was called. + if (isStopped(wrappedEvent)) { + break + } + + node = node.next + } + setPassiveListener(wrappedEvent, null) + setEventPhase(wrappedEvent, 0) + setCurrentTarget(wrappedEvent, null) + + return !wrappedEvent.defaultPrevented + } + } + + // `constructor` is not enumerable. + Object.defineProperty(EventTarget.prototype, 'constructor', { + value: EventTarget, + configurable: true, + writable: true + }) + + // Ensure `eventTarget instanceof window.EventTarget` is `true`. + if ( + typeof window !== 'undefined' && + typeof window.EventTarget !== 'undefined' + ) { + Object.setPrototypeOf( + EventTarget.prototype, + window.EventTarget.prototype + ) + } + + exports.defineEventAttribute = defineEventAttribute + exports.EventTarget = EventTarget + exports.default = EventTarget + + module.exports = EventTarget + module.exports.EventTarget = module.exports.default = EventTarget + module.exports.defineEventAttribute = defineEventAttribute + //# sourceMappingURL=event-target-shim.js.map + + /***/ + }, + + /***/ 97271: /***/ (module, exports, __webpack_require__) => { + 'use strict' + + /** + * Copyright 2017 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + const d64 = __webpack_require__(12682) + const uuid = __webpack_require__(41499) + class EventId { + constructor() { + this.b = new Uint8Array(24) + uuid(null, this.b, 8) + } + new() { + for (let i = 7; i >= 0; i--) { + if (this.b[i] !== 255) { + this.b[i]++ + break + } + this.b[i] = 0 + } + return d64.encode(this.b) + } + } + exports.EventId = EventId + // preserve `const EventId = require('EventId')` syntax + const existingExports = module.exports + module.exports = EventId + module.exports = Object.assign(module.exports, existingExports) + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 38091: /***/ module => { + /** + * Convert array of 16 byte values to UUID string format of the form: + * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX + */ + var byteToHex = [] + for (var i = 0; i < 256; ++i) { + byteToHex[i] = (i + 0x100).toString(16).substr(1) + } + + function bytesToUuid(buf, offset) { + var i = offset || 0 + var bth = byteToHex + // join used to fix memory issue caused by concatenation: https://bugs.chromium.org/p/v8/issues/detail?id=3175#c4 + return [ + bth[buf[i++]], + bth[buf[i++]], + bth[buf[i++]], + bth[buf[i++]], + '-', + bth[buf[i++]], + bth[buf[i++]], + '-', + bth[buf[i++]], + bth[buf[i++]], + '-', + bth[buf[i++]], + bth[buf[i++]], + '-', + bth[buf[i++]], + bth[buf[i++]], + bth[buf[i++]], + bth[buf[i++]], + bth[buf[i++]], + bth[buf[i++]] + ].join('') + } + + module.exports = bytesToUuid + + /***/ + }, + + /***/ 71124: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + // Unique ID creation requires a high quality random # generator. In node.js + // this is pretty straight-forward - we use the crypto API. + + var crypto = __webpack_require__(76417) + + module.exports = function nodeRNG() { + return crypto.randomBytes(16) + } + + /***/ + }, + + /***/ 41499: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + var rng = __webpack_require__(71124) + var bytesToUuid = __webpack_require__(38091) + + function v4(options, buf, offset) { + var i = (buf && offset) || 0 + + if (typeof options == 'string') { + buf = options === 'binary' ? new Array(16) : null + options = null + } + options = options || {} + + var rnds = options.random || (options.rng || rng)() + + // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` + rnds[6] = (rnds[6] & 0x0f) | 0x40 + rnds[8] = (rnds[8] & 0x3f) | 0x80 + + // Copy bytes to buffer, if provided + if (buf) { + for (var ii = 0; ii < 16; ++ii) { + buf[i + ii] = rnds[ii] + } + } + + return buf || bytesToUuid(rnds) + } + + module.exports = v4 + + /***/ + }, + + /***/ 55447: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + 'use strict' + + const path = __webpack_require__(85622) + const childProcess = __webpack_require__(63129) + const crossSpawn = __webpack_require__(72746) + const stripEof = __webpack_require__(85515) + const npmRunPath = __webpack_require__(20502) + const isStream = __webpack_require__(41554) + const _getStream = __webpack_require__(21766) + const pFinally = __webpack_require__(31330) + const onExit = __webpack_require__(24931) + const errname = __webpack_require__(64689) + const stdio = __webpack_require__(10166) + + const TEN_MEGABYTES = 1000 * 1000 * 10 + + function handleArgs(cmd, args, opts) { + let parsed + + opts = Object.assign( + { + extendEnv: true, + env: {} + }, + opts + ) + + if (opts.extendEnv) { + opts.env = Object.assign({}, process.env, opts.env) + } + + if (opts.__winShell === true) { + delete opts.__winShell + parsed = { + command: cmd, + args, + options: opts, + file: cmd, + original: { + cmd, + args + } + } + } else { + parsed = crossSpawn._parse(cmd, args, opts) + } + + opts = Object.assign( + { + maxBuffer: TEN_MEGABYTES, + buffer: true, + stripEof: true, + preferLocal: true, + localDir: parsed.options.cwd || process.cwd(), + encoding: 'utf8', + reject: true, + cleanup: true + }, + parsed.options + ) + + opts.stdio = stdio(opts) + + if (opts.preferLocal) { + opts.env = npmRunPath.env( + Object.assign({}, opts, { cwd: opts.localDir }) + ) + } + + if (opts.detached) { + // #115 + opts.cleanup = false + } + + if ( + process.platform === 'win32' && + path.basename(parsed.command) === 'cmd.exe' + ) { + // #116 + parsed.args.unshift('/q') + } + + return { + cmd: parsed.command, + args: parsed.args, + opts, + parsed + } + } + + function handleInput(spawned, input) { + if (input === null || input === undefined) { + return + } + + if (isStream(input)) { + input.pipe(spawned.stdin) + } else { + spawned.stdin.end(input) + } + } + + function handleOutput(opts, val) { + if (val && opts.stripEof) { + val = stripEof(val) + } + + return val + } + + function handleShell(fn, cmd, opts) { + let file = '/bin/sh' + let args = ['-c', cmd] + + opts = Object.assign({}, opts) + + if (process.platform === 'win32') { + opts.__winShell = true + file = process.env.comspec || 'cmd.exe' + args = ['/s', '/c', `"${cmd}"`] + opts.windowsVerbatimArguments = true + } + + if (opts.shell) { + file = opts.shell + delete opts.shell + } + + return fn(file, args, opts) + } + + function getStream(process, stream, { encoding, buffer, maxBuffer }) { + if (!process[stream]) { + return null + } + + let ret + + if (!buffer) { + // TODO: Use `ret = util.promisify(stream.finished)(process[stream]);` when targeting Node.js 10 + ret = new Promise((resolve, reject) => { + process[stream].once('end', resolve).once('error', reject) + }) + } else if (encoding) { + ret = _getStream(process[stream], { + encoding, + maxBuffer + }) + } else { + ret = _getStream.buffer(process[stream], { maxBuffer }) + } + + return ret.catch(err => { + err.stream = stream + err.message = `${stream} ${err.message}` + throw err + }) + } + + function makeError(result, options) { + const { stdout, stderr } = result + + let err = result.error + const { code, signal } = result + + const { parsed, joinedCmd } = options + const timedOut = options.timedOut || false + + if (!err) { + let output = '' + + if (Array.isArray(parsed.opts.stdio)) { + if (parsed.opts.stdio[2] !== 'inherit') { + output += output.length > 0 ? stderr : `\n${stderr}` + } + + if (parsed.opts.stdio[1] !== 'inherit') { + output += `\n${stdout}` + } + } else if (parsed.opts.stdio !== 'inherit') { + output = `\n${stderr}${stdout}` + } + + err = new Error(`Command failed: ${joinedCmd}${output}`) + err.code = code < 0 ? errname(code) : code + } + + err.stdout = stdout + err.stderr = stderr + err.failed = true + err.signal = signal || null + err.cmd = joinedCmd + err.timedOut = timedOut + + return err + } + + function joinCmd(cmd, args) { + let joinedCmd = cmd + + if (Array.isArray(args) && args.length > 0) { + joinedCmd += ' ' + args.join(' ') + } + + return joinedCmd + } + + module.exports = (cmd, args, opts) => { + const parsed = handleArgs(cmd, args, opts) + const { encoding, buffer, maxBuffer } = parsed.opts + const joinedCmd = joinCmd(cmd, args) + + let spawned + try { + spawned = childProcess.spawn(parsed.cmd, parsed.args, parsed.opts) + } catch (err) { + return Promise.reject(err) + } + + let removeExitHandler + if (parsed.opts.cleanup) { + removeExitHandler = onExit(() => { + spawned.kill() + }) + } + + let timeoutId = null + let timedOut = false + + const cleanup = () => { + if (timeoutId) { + clearTimeout(timeoutId) + timeoutId = null + } + + if (removeExitHandler) { + removeExitHandler() + } + } + + if (parsed.opts.timeout > 0) { + timeoutId = setTimeout(() => { + timeoutId = null + timedOut = true + spawned.kill(parsed.opts.killSignal) + }, parsed.opts.timeout) + } + + const processDone = new Promise(resolve => { + spawned.on('exit', (code, signal) => { + cleanup() + resolve({ code, signal }) + }) + + spawned.on('error', err => { + cleanup() + resolve({ error: err }) + }) + + if (spawned.stdin) { + spawned.stdin.on('error', err => { + cleanup() + resolve({ error: err }) + }) + } + }) + + function destroy() { + if (spawned.stdout) { + spawned.stdout.destroy() + } + + if (spawned.stderr) { + spawned.stderr.destroy() + } + } + + const handlePromise = () => + pFinally( + Promise.all([ + processDone, + getStream(spawned, 'stdout', { encoding, buffer, maxBuffer }), + getStream(spawned, 'stderr', { encoding, buffer, maxBuffer }) + ]).then(arr => { + const result = arr[0] + result.stdout = arr[1] + result.stderr = arr[2] + + if (result.error || result.code !== 0 || result.signal !== null) { + const err = makeError(result, { + joinedCmd, + parsed, + timedOut + }) + + // TODO: missing some timeout logic for killed + // https://github.com/nodejs/node/blob/master/lib/child_process.js#L203 + // err.killed = spawned.killed || killed; + err.killed = err.killed || spawned.killed + + if (!parsed.opts.reject) { + return err + } + + throw err + } + + return { + stdout: handleOutput(parsed.opts, result.stdout), + stderr: handleOutput(parsed.opts, result.stderr), + code: 0, + failed: false, + killed: false, + signal: null, + cmd: joinedCmd, + timedOut: false + } + }), + destroy + ) + + crossSpawn._enoent.hookChildProcess(spawned, parsed.parsed) + + handleInput(spawned, parsed.opts.input) + + spawned.then = (onfulfilled, onrejected) => + handlePromise().then(onfulfilled, onrejected) + spawned.catch = onrejected => handlePromise().catch(onrejected) + + return spawned + } + + // TODO: set `stderr: 'ignore'` when that option is implemented + module.exports.stdout = (...args) => + module.exports(...args).then(x => x.stdout) + + // TODO: set `stdout: 'ignore'` when that option is implemented + module.exports.stderr = (...args) => + module.exports(...args).then(x => x.stderr) + + module.exports.shell = (cmd, opts) => + handleShell(module.exports, cmd, opts) + + module.exports.sync = (cmd, args, opts) => { + const parsed = handleArgs(cmd, args, opts) + const joinedCmd = joinCmd(cmd, args) + + if (isStream(parsed.opts.input)) { + throw new TypeError( + 'The `input` option cannot be a stream in sync mode' + ) + } + + const result = childProcess.spawnSync( + parsed.cmd, + parsed.args, + parsed.opts + ) + result.code = result.status + + if (result.error || result.status !== 0 || result.signal !== null) { + const err = makeError(result, { + joinedCmd, + parsed + }) + + if (!parsed.opts.reject) { + return err + } + + throw err + } + + return { + stdout: handleOutput(parsed.opts, result.stdout), + stderr: handleOutput(parsed.opts, result.stderr), + code: 0, + failed: false, + signal: null, + cmd: joinedCmd, + timedOut: false + } + } + + module.exports.shellSync = (cmd, opts) => + handleShell(module.exports.sync, cmd, opts) + + /***/ + }, + + /***/ 64689: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + 'use strict' + + // Older verions of Node.js might not have `util.getSystemErrorName()`. + // In that case, fall back to a deprecated internal. + const util = __webpack_require__(31669) + + let uv + + if (typeof util.getSystemErrorName === 'function') { + module.exports = util.getSystemErrorName + } else { + try { + uv = process.binding('uv') + + if (typeof uv.errname !== 'function') { + throw new TypeError('uv.errname is not a function') + } + } catch (err) { + console.error( + "execa/lib/errname: unable to establish process.binding('uv')", + err + ) + uv = null + } + + module.exports = code => errname(uv, code) + } + + // Used for testing the fallback behavior + module.exports.__test__ = errname + + function errname(uv, code) { + if (uv) { + return uv.errname(code) + } + + if (!(code < 0)) { + throw new Error('err >= 0') + } + + return `Unknown system error ${code}` + } + + /***/ + }, + + /***/ 10166: /***/ module => { + 'use strict' + + const alias = ['stdin', 'stdout', 'stderr'] + + const hasAlias = opts => alias.some(x => Boolean(opts[x])) + + module.exports = opts => { + if (!opts) { + return null + } + + if (opts.stdio && hasAlias(opts)) { + throw new Error( + `It's not possible to provide \`stdio\` in combination with one of ${alias + .map(x => `\`${x}\``) + .join(', ')}` + ) + } + + if (typeof opts.stdio === 'string') { + return opts.stdio + } + + const stdio = opts.stdio || [] + + if (!Array.isArray(stdio)) { + throw new TypeError( + `Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof stdio}\`` + ) + } + + const result = [] + const len = Math.max(stdio.length, alias.length) + + for (let i = 0; i < len; i++) { + let value = null + + if (stdio[i] !== undefined) { + value = stdio[i] + } else if (opts[alias[i]] !== undefined) { + value = opts[alias[i]] + } + + result[i] = value + } + + return result + } + + /***/ + }, + + /***/ 38171: /***/ module => { + 'use strict' + + var hasOwn = Object.prototype.hasOwnProperty + var toStr = Object.prototype.toString + var defineProperty = Object.defineProperty + var gOPD = Object.getOwnPropertyDescriptor + + var isArray = function isArray(arr) { + if (typeof Array.isArray === 'function') { + return Array.isArray(arr) + } + + return toStr.call(arr) === '[object Array]' + } + + var isPlainObject = function isPlainObject(obj) { + if (!obj || toStr.call(obj) !== '[object Object]') { + return false + } + + var hasOwnConstructor = hasOwn.call(obj, 'constructor') + var hasIsPrototypeOf = + obj.constructor && + obj.constructor.prototype && + hasOwn.call(obj.constructor.prototype, 'isPrototypeOf') + // Not own constructor property must be Object + if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) { + return false + } + + // Own properties are enumerated firstly, so to speed up, + // if last one is own, then all properties are own. + var key + for (key in obj) { + /**/ + } + + return typeof key === 'undefined' || hasOwn.call(obj, key) + } + + // If name is '__proto__', and Object.defineProperty is available, define __proto__ as an own property on target + var setProperty = function setProperty(target, options) { + if (defineProperty && options.name === '__proto__') { + defineProperty(target, options.name, { + enumerable: true, + configurable: true, + value: options.newValue, + writable: true + }) + } else { + target[options.name] = options.newValue + } + } + + // Return undefined instead of __proto__ if '__proto__' is not an own property + var getProperty = function getProperty(obj, name) { + if (name === '__proto__') { + if (!hasOwn.call(obj, name)) { + return void 0 + } else if (gOPD) { + // In early versions of node, obj['__proto__'] is buggy when obj has + // __proto__ as an own property. Object.getOwnPropertyDescriptor() works. + return gOPD(obj, name).value + } + } + + return obj[name] + } + + module.exports = function extend() { + var options, name, src, copy, copyIsArray, clone + var target = arguments[0] + var i = 1 + var length = arguments.length + var deep = false + + // Handle a deep copy situation + if (typeof target === 'boolean') { + deep = target + target = arguments[1] || {} + // skip the boolean and the target + i = 2 + } + if ( + target == null || + (typeof target !== 'object' && typeof target !== 'function') + ) { + target = {} + } + + for (; i < length; ++i) { + options = arguments[i] + // Only deal with non-null/undefined values + if (options != null) { + // Extend the base object + for (name in options) { + src = getProperty(target, name) + copy = getProperty(options, name) + + // Prevent never-ending loop + if (target !== copy) { + // Recurse if we're merging plain objects or arrays + if ( + deep && + copy && + (isPlainObject(copy) || (copyIsArray = isArray(copy))) + ) { + if (copyIsArray) { + copyIsArray = false + clone = src && isArray(src) ? src : [] + } else { + clone = src && isPlainObject(src) ? src : {} + } + + // Never move original objects, clone them + setProperty(target, { + name: name, + newValue: extend(deep, clone, copy) + }) + + // Don't bring in undefined values + } else if (typeof copy !== 'undefined') { + setProperty(target, { name: name, newValue: copy }) + } + } + } + } + } + + // Return the modified object + return target + } + + /***/ + }, + + /***/ 87264: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + /* + * extsprintf.js: extended POSIX-style sprintf + */ + + var mod_assert = __webpack_require__(42357) + var mod_util = __webpack_require__(31669) + + /* + * Public interface + */ + exports.sprintf = jsSprintf + exports.printf = jsPrintf + exports.fprintf = jsFprintf + + /* + * Stripped down version of s[n]printf(3c). We make a best effort to throw an + * exception when given a format string we don't understand, rather than + * ignoring it, so that we won't break existing programs if/when we go implement + * the rest of this. + * + * This implementation currently supports specifying + * - field alignment ('-' flag), + * - zero-pad ('0' flag) + * - always show numeric sign ('+' flag), + * - field width + * - conversions for strings, decimal integers, and floats (numbers). + * - argument size specifiers. These are all accepted but ignored, since + * Javascript has no notion of the physical size of an argument. + * + * Everything else is currently unsupported, most notably precision, unsigned + * numbers, non-decimal numbers, and characters. + */ + function jsSprintf(fmt) { + var regex = [ + '([^%]*)' /* normal text */, + '%' /* start of format */, + "(['\\-+ #0]*?)" /* flags (optional) */, + '([1-9]\\d*)?' /* width (optional) */, + '(\\.([1-9]\\d*))?' /* precision (optional) */, + '[lhjztL]*?' /* length mods (ignored) */, + '([diouxXfFeEgGaAcCsSp%jr])' /* conversion */ + ].join('') + + var re = new RegExp(regex) + var args = Array.prototype.slice.call(arguments, 1) + var flags, width, precision, conversion + var left, pad, sign, arg, match + var ret = '' + var argn = 1 + + mod_assert.equal('string', typeof fmt) + + while ((match = re.exec(fmt)) !== null) { + ret += match[1] + fmt = fmt.substring(match[0].length) + + flags = match[2] || '' + width = match[3] || 0 + precision = match[4] || '' + conversion = match[6] + left = false + sign = false + pad = ' ' + + if (conversion == '%') { + ret += '%' + continue + } + + if (args.length === 0) throw new Error('too few args to sprintf') + + arg = args.shift() + argn++ + + if (flags.match(/[\' #]/)) + throw new Error('unsupported flags: ' + flags) + + if (precision.length > 0) + throw new Error('non-zero precision not supported') + + if (flags.match(/-/)) left = true + + if (flags.match(/0/)) pad = '0' + + if (flags.match(/\+/)) sign = true + + switch (conversion) { + case 's': + if (arg === undefined || arg === null) + throw new Error( + 'argument ' + + argn + + ': attempted to print undefined or null ' + + 'as a string' + ) + ret += doPad(pad, width, left, arg.toString()) + break + + case 'd': + arg = Math.floor(arg) + /*jsl:fallthru*/ + case 'f': + sign = sign && arg > 0 ? '+' : '' + ret += sign + doPad(pad, width, left, arg.toString()) + break + + case 'x': + ret += doPad(pad, width, left, arg.toString(16)) + break + + case 'j' /* non-standard */: + if (width === 0) width = 10 + ret += mod_util.inspect(arg, false, width) + break + + case 'r' /* non-standard */: + ret += dumpException(arg) + break + + default: + throw new Error('unsupported conversion: ' + conversion) + } + } + + ret += fmt + return ret + } + + function jsPrintf() { + var args = Array.prototype.slice.call(arguments) + args.unshift(process.stdout) + jsFprintf.apply(null, args) + } + + function jsFprintf(stream) { + var args = Array.prototype.slice.call(arguments, 1) + return stream.write(jsSprintf.apply(this, args)) + } + + function doPad(chr, width, left, str) { + var ret = str + + while (ret.length < width) { + if (left) ret += chr + else ret = chr + ret + } + + return ret + } + + /* + * This function dumps long stack traces for exceptions having a cause() method. + * See node-verror for an example. + */ + function dumpException(ex) { + var ret + + if (!(ex instanceof Error)) + throw new Error(jsSprintf('invalid type for %%r: %j', ex)) + + /* Note that V8 prepends "ex.stack" with ex.toString(). */ + ret = 'EXCEPTION: ' + ex.constructor.name + ': ' + ex.stack + + if (ex.cause && typeof ex.cause === 'function') { + var cex = ex.cause() + if (cex) { + ret += '\nCaused by: ' + dumpException(cex) + } + } + + return ret + } + + /***/ + }, + + /***/ 28206: /***/ module => { + 'use strict' + + // do not edit .js files directly - edit src/index.jst + + module.exports = function equal(a, b) { + if (a === b) return true + + if (a && b && typeof a == 'object' && typeof b == 'object') { + if (a.constructor !== b.constructor) return false + + var length, i, keys + if (Array.isArray(a)) { + length = a.length + if (length != b.length) return false + for (i = length; i-- !== 0; ) if (!equal(a[i], b[i])) return false + return true + } + + if (a.constructor === RegExp) + return a.source === b.source && a.flags === b.flags + if (a.valueOf !== Object.prototype.valueOf) + return a.valueOf() === b.valueOf() + if (a.toString !== Object.prototype.toString) + return a.toString() === b.toString() + + keys = Object.keys(a) + length = keys.length + if (length !== Object.keys(b).length) return false + + for (i = length; i-- !== 0; ) + if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false + + for (i = length; i-- !== 0; ) { + var key = keys[i] + + if (!equal(a[key], b[key])) return false + } + + return true + } + + // true if both NaN, false otherwise + return a !== a && b !== b + } + + /***/ + }, + + /***/ 30969: /***/ module => { + 'use strict' + + module.exports = function (data, opts) { + if (!opts) opts = {} + if (typeof opts === 'function') opts = { cmp: opts } + var cycles = typeof opts.cycles === 'boolean' ? opts.cycles : false + + var cmp = + opts.cmp && + (function (f) { + return function (node) { + return function (a, b) { + var aobj = { key: a, value: node[a] } + var bobj = { key: b, value: node[b] } + return f(aobj, bobj) + } + } + })(opts.cmp) + + var seen = [] + return (function stringify(node) { + if (node && node.toJSON && typeof node.toJSON === 'function') { + node = node.toJSON() + } + + if (node === undefined) return + if (typeof node == 'number') + return isFinite(node) ? '' + node : 'null' + if (typeof node !== 'object') return JSON.stringify(node) + + var i, out + if (Array.isArray(node)) { + out = '[' + for (i = 0; i < node.length; i++) { + if (i) out += ',' + out += stringify(node[i]) || 'null' + } + return out + ']' + } + + if (node === null) return 'null' + + if (seen.indexOf(node) !== -1) { + if (cycles) return JSON.stringify('__cycle__') + throw new TypeError('Converting circular structure to JSON') + } + + var seenIndex = seen.push(node) - 1 + var keys = Object.keys(node).sort(cmp && cmp(node)) + out = '' + for (i = 0; i < keys.length; i++) { + var key = keys[i] + var value = stringify(node[key]) + + if (!value) continue + if (out) out += ',' + out += JSON.stringify(key) + ':' + value + } + seen.splice(seenIndex, 1) + return '{' + out + '}' + })(data) + } + + /***/ + }, + + /***/ 21917: /***/ function () { + ;(function (l) { + function m() {} + function k(a, c) { + a = void 0 === a ? 'utf-8' : a + c = void 0 === c ? { fatal: !1 } : c + if (-1 === r.indexOf(a.toLowerCase())) + throw new RangeError( + "Failed to construct 'TextDecoder': The encoding label provided ('" + + a + + "') is invalid." + ) + if (c.fatal) + throw Error( + "Failed to construct 'TextDecoder': the 'fatal' option is unsupported." + ) + } + function t(a) { + return Buffer.from(a.buffer, a.byteOffset, a.byteLength).toString( + 'utf-8' + ) + } + function u(a) { + var c = URL.createObjectURL( + new Blob([a], { type: 'text/plain;charset=UTF-8' }) + ) + try { + var f = new XMLHttpRequest() + f.open('GET', c, !1) + f.send() + return f.responseText + } catch (e) { + return q(a) + } finally { + URL.revokeObjectURL(c) + } + } + function q(a) { + for ( + var c = 0, + f = Math.min(65536, a.length + 1), + e = new Uint16Array(f), + h = [], + d = 0; + ; + + ) { + var b = c < a.length + if (!b || d >= f - 1) { + h.push(String.fromCharCode.apply(null, e.subarray(0, d))) + if (!b) return h.join('') + a = a.subarray(c) + d = c = 0 + } + b = a[c++] + if (0 === (b & 128)) e[d++] = b + else if (192 === (b & 224)) { + var g = a[c++] & 63 + e[d++] = ((b & 31) << 6) | g + } else if (224 === (b & 240)) { + g = a[c++] & 63 + var n = a[c++] & 63 + e[d++] = ((b & 31) << 12) | (g << 6) | n + } else if (240 === (b & 248)) { + g = a[c++] & 63 + n = a[c++] & 63 + var v = a[c++] & 63 + b = ((b & 7) << 18) | (g << 12) | (n << 6) | v + 65535 < b && + ((b -= 65536), + (e[d++] = ((b >>> 10) & 1023) | 55296), + (b = 56320 | (b & 1023))) + e[d++] = b + } + } + } + if (l.TextEncoder && l.TextDecoder) return !1 + var r = ['utf-8', 'utf8', 'unicode-1-1-utf-8'] + Object.defineProperty(m.prototype, 'encoding', { value: 'utf-8' }) + m.prototype.encode = function (a, c) { + c = void 0 === c ? { stream: !1 } : c + if (c.stream) + throw Error("Failed to encode: the 'stream' option is unsupported.") + c = 0 + for ( + var f = a.length, + e = 0, + h = Math.max(32, f + (f >>> 1) + 7), + d = new Uint8Array((h >>> 3) << 3); + c < f; + + ) { + var b = a.charCodeAt(c++) + if (55296 <= b && 56319 >= b) { + if (c < f) { + var g = a.charCodeAt(c) + 56320 === (g & 64512) && + (++c, (b = ((b & 1023) << 10) + (g & 1023) + 65536)) + } + if (55296 <= b && 56319 >= b) continue + } + e + 4 > d.length && + ((h += 8), + (h *= 1 + (c / a.length) * 2), + (h = (h >>> 3) << 3), + (g = new Uint8Array(h)), + g.set(d), + (d = g)) + if (0 === (b & 4294967168)) d[e++] = b + else { + if (0 === (b & 4294965248)) d[e++] = ((b >>> 6) & 31) | 192 + else if (0 === (b & 4294901760)) + (d[e++] = ((b >>> 12) & 15) | 224), + (d[e++] = ((b >>> 6) & 63) | 128) + else if (0 === (b & 4292870144)) + (d[e++] = ((b >>> 18) & 7) | 240), + (d[e++] = ((b >>> 12) & 63) | 128), + (d[e++] = ((b >>> 6) & 63) | 128) + else continue + d[e++] = (b & 63) | 128 + } + } + return d.slice ? d.slice(0, e) : d.subarray(0, e) + } + Object.defineProperty(k.prototype, 'encoding', { value: 'utf-8' }) + Object.defineProperty(k.prototype, 'fatal', { value: !1 }) + Object.defineProperty(k.prototype, 'ignoreBOM', { value: !1 }) + var p = q + 'function' === typeof Buffer && Buffer.from + ? (p = t) + : 'function' === typeof Blob && + 'function' === typeof URL && + 'function' === typeof URL.createObjectURL && + (p = u) + k.prototype.decode = function (a, c) { + c = void 0 === c ? { stream: !1 } : c + if (c.stream) + throw Error("Failed to decode: the 'stream' option is unsupported.") + a = + a instanceof Uint8Array + ? a + : a.buffer instanceof ArrayBuffer + ? new Uint8Array(a.buffer) + : new Uint8Array(a) + return p(a) + } + l.TextEncoder = m + l.TextDecoder = k + })( + 'undefined' !== typeof window + ? window + : 'undefined' !== typeof global + ? global + : this + ) + + /***/ + }, + + /***/ 47568: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + module.exports = ForeverAgent + ForeverAgent.SSL = ForeverAgentSSL + + var util = __webpack_require__(31669), + Agent = __webpack_require__(98605).Agent, + net = __webpack_require__(11631), + tls = __webpack_require__(4016), + AgentSSL = __webpack_require__(57211).Agent + + function getConnectionName(host, port) { + var name = '' + if (typeof host === 'string') { + name = host + ':' + port + } else { + // For node.js v012.0 and iojs-v1.5.1, host is an object. And any existing localAddress is part of the connection name. + name = + host.host + + ':' + + host.port + + ':' + + (host.localAddress ? host.localAddress + ':' : ':') + } + return name + } + + function ForeverAgent(options) { + var self = this + self.options = options || {} + self.requests = {} + self.sockets = {} + self.freeSockets = {} + self.maxSockets = self.options.maxSockets || Agent.defaultMaxSockets + self.minSockets = + self.options.minSockets || ForeverAgent.defaultMinSockets + self.on('free', function (socket, host, port) { + var name = getConnectionName(host, port) + + if (self.requests[name] && self.requests[name].length) { + self.requests[name].shift().onSocket(socket) + } else if (self.sockets[name].length < self.minSockets) { + if (!self.freeSockets[name]) self.freeSockets[name] = [] + self.freeSockets[name].push(socket) + + // if an error happens while we don't use the socket anyway, meh, throw the socket away + var onIdleError = function () { + socket.destroy() + } + socket._onIdleError = onIdleError + socket.on('error', onIdleError) + } else { + // If there are no pending requests just destroy the + // socket and it will get removed from the pool. This + // gets us out of timeout issues and allows us to + // default to Connection:keep-alive. + socket.destroy() + } + }) + } + util.inherits(ForeverAgent, Agent) + + ForeverAgent.defaultMinSockets = 5 + + ForeverAgent.prototype.createConnection = net.createConnection + ForeverAgent.prototype.addRequestNoreuse = Agent.prototype.addRequest + ForeverAgent.prototype.addRequest = function (req, host, port) { + var name = getConnectionName(host, port) + + if (typeof host !== 'string') { + var options = host + port = options.port + host = options.host + } + + if ( + this.freeSockets[name] && + this.freeSockets[name].length > 0 && + !req.useChunkedEncodingByDefault + ) { + var idleSocket = this.freeSockets[name].pop() + idleSocket.removeListener('error', idleSocket._onIdleError) + delete idleSocket._onIdleError + req._reusedSocket = true + req.onSocket(idleSocket) + } else { + this.addRequestNoreuse(req, host, port) + } + } + + ForeverAgent.prototype.removeSocket = function (s, name, host, port) { + if (this.sockets[name]) { + var index = this.sockets[name].indexOf(s) + if (index !== -1) { + this.sockets[name].splice(index, 1) + } + } else if (this.sockets[name] && this.sockets[name].length === 0) { + // don't leak + delete this.sockets[name] + delete this.requests[name] + } + + if (this.freeSockets[name]) { + var index = this.freeSockets[name].indexOf(s) + if (index !== -1) { + this.freeSockets[name].splice(index, 1) + if (this.freeSockets[name].length === 0) { + delete this.freeSockets[name] + } + } + } + + if (this.requests[name] && this.requests[name].length) { + // If we have pending requests and a socket gets closed a new one + // needs to be created to take over in the pool for the one that closed. + this.createSocket(name, host, port).emit('free') + } + } + + function ForeverAgentSSL(options) { + ForeverAgent.call(this, options) + } + util.inherits(ForeverAgentSSL, ForeverAgent) + + ForeverAgentSSL.prototype.createConnection = createConnectionSSL + ForeverAgentSSL.prototype.addRequestNoreuse = + AgentSSL.prototype.addRequest + + function createConnectionSSL(port, host, options) { + if (typeof port === 'object') { + options = port + } else if (typeof host === 'object') { + options = host + } else if (typeof options === 'object') { + options = options + } else { + options = {} + } + + if (typeof port === 'number') { + options.port = port + } + + if (typeof host === 'string') { + options.host = host + } + + return tls.connect(options) + } + + /***/ + }, + + /***/ 64334: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + var CombinedStream = __webpack_require__(85443) + var util = __webpack_require__(31669) + var path = __webpack_require__(85622) + var http = __webpack_require__(98605) + var https = __webpack_require__(57211) + var parseUrl = __webpack_require__(78835).parse + var fs = __webpack_require__(35747) + var mime = __webpack_require__(43583) + var asynckit = __webpack_require__(14812) + var populate = __webpack_require__(17142) + + // Public API + module.exports = FormData + + // make it a Stream + util.inherits(FormData, CombinedStream) + + /** + * Create readable "multipart/form-data" streams. + * Can be used to submit forms + * and file uploads to other web applications. + * + * @constructor + * @param {Object} options - Properties to be added/overriden for FormData and CombinedStream + */ + function FormData(options) { + if (!(this instanceof FormData)) { + return new FormData() + } + + this._overheadLength = 0 + this._valueLength = 0 + this._valuesToMeasure = [] + + CombinedStream.call(this) + + options = options || {} + for (var option in options) { + this[option] = options[option] + } + } + + FormData.LINE_BREAK = '\r\n' + FormData.DEFAULT_CONTENT_TYPE = 'application/octet-stream' + + FormData.prototype.append = function (field, value, options) { + options = options || {} + + // allow filename as single option + if (typeof options == 'string') { + options = { filename: options } + } + + var append = CombinedStream.prototype.append.bind(this) + + // all that streamy business can't handle numbers + if (typeof value == 'number') { + value = '' + value + } + + // https://github.com/felixge/node-form-data/issues/38 + if (util.isArray(value)) { + // Please convert your array into string + // the way web server expects it + this._error(new Error('Arrays are not supported.')) + return + } + + var header = this._multiPartHeader(field, value, options) + var footer = this._multiPartFooter() + + append(header) + append(value) + append(footer) + + // pass along options.knownLength + this._trackLength(header, value, options) + } + + FormData.prototype._trackLength = function (header, value, options) { + var valueLength = 0 + + // used w/ getLengthSync(), when length is known. + // e.g. for streaming directly from a remote server, + // w/ a known file a size, and not wanting to wait for + // incoming file to finish to get its size. + if (options.knownLength != null) { + valueLength += +options.knownLength + } else if (Buffer.isBuffer(value)) { + valueLength = value.length + } else if (typeof value === 'string') { + valueLength = Buffer.byteLength(value) + } + + this._valueLength += valueLength + + // @check why add CRLF? does this account for custom/multiple CRLFs? + this._overheadLength += + Buffer.byteLength(header) + FormData.LINE_BREAK.length + + // empty or either doesn't have path or not an http response + if ( + !value || + (!value.path && + !(value.readable && value.hasOwnProperty('httpVersion'))) + ) { + return + } + + // no need to bother with the length + if (!options.knownLength) { + this._valuesToMeasure.push(value) + } + } + + FormData.prototype._lengthRetriever = function (value, callback) { + if (value.hasOwnProperty('fd')) { + // take read range into a account + // `end` = Infinity –> read file till the end + // + // TODO: Looks like there is bug in Node fs.createReadStream + // it doesn't respect `end` options without `start` options + // Fix it when node fixes it. + // https://github.com/joyent/node/issues/7819 + if ( + value.end != undefined && + value.end != Infinity && + value.start != undefined + ) { + // when end specified + // no need to calculate range + // inclusive, starts with 0 + callback(null, value.end + 1 - (value.start ? value.start : 0)) + + // not that fast snoopy + } else { + // still need to fetch file size from fs + fs.stat(value.path, function (err, stat) { + var fileSize + + if (err) { + callback(err) + return + } + + // update final size based on the range options + fileSize = stat.size - (value.start ? value.start : 0) + callback(null, fileSize) + }) + } + + // or http response + } else if (value.hasOwnProperty('httpVersion')) { + callback(null, +value.headers['content-length']) + + // or request stream http://github.com/mikeal/request + } else if (value.hasOwnProperty('httpModule')) { + // wait till response come back + value.on('response', function (response) { + value.pause() + callback(null, +response.headers['content-length']) + }) + value.resume() + + // something else + } else { + callback('Unknown stream') + } + } + + FormData.prototype._multiPartHeader = function (field, value, options) { + // custom header specified (as string)? + // it becomes responsible for boundary + // (e.g. to handle extra CRLFs on .NET servers) + if (typeof options.header == 'string') { + return options.header + } + + var contentDisposition = this._getContentDisposition(value, options) + var contentType = this._getContentType(value, options) + + var contents = '' + var headers = { + // add custom disposition as third element or keep it two elements if not + 'Content-Disposition': ['form-data', 'name="' + field + '"'].concat( + contentDisposition || [] + ), + // if no content type. allow it to be empty array + 'Content-Type': [].concat(contentType || []) + } + + // allow custom headers. + if (typeof options.header == 'object') { + populate(headers, options.header) + } + + var header + for (var prop in headers) { + if (!headers.hasOwnProperty(prop)) continue + header = headers[prop] + + // skip nullish headers. + if (header == null) { + continue + } + + // convert all headers to arrays. + if (!Array.isArray(header)) { + header = [header] + } + + // add non-empty headers. + if (header.length) { + contents += prop + ': ' + header.join('; ') + FormData.LINE_BREAK + } + } + + return ( + '--' + + this.getBoundary() + + FormData.LINE_BREAK + + contents + + FormData.LINE_BREAK + ) + } + + FormData.prototype._getContentDisposition = function (value, options) { + var filename, contentDisposition + + if (typeof options.filepath === 'string') { + // custom filepath for relative paths + filename = path.normalize(options.filepath).replace(/\\/g, '/') + } else if (options.filename || value.name || value.path) { + // custom filename take precedence + // formidable and the browser add a name property + // fs- and request- streams have path property + filename = path.basename(options.filename || value.name || value.path) + } else if (value.readable && value.hasOwnProperty('httpVersion')) { + // or try http response + filename = path.basename(value.client._httpMessage.path) + } + + if (filename) { + contentDisposition = 'filename="' + filename + '"' + } + + return contentDisposition + } + + FormData.prototype._getContentType = function (value, options) { + // use custom content-type above all + var contentType = options.contentType + + // or try `name` from formidable, browser + if (!contentType && value.name) { + contentType = mime.lookup(value.name) + } + + // or try `path` from fs-, request- streams + if (!contentType && value.path) { + contentType = mime.lookup(value.path) + } + + // or if it's http-reponse + if ( + !contentType && + value.readable && + value.hasOwnProperty('httpVersion') + ) { + contentType = value.headers['content-type'] + } + + // or guess it from the filepath or filename + if (!contentType && (options.filepath || options.filename)) { + contentType = mime.lookup(options.filepath || options.filename) + } + + // fallback to the default content type if `value` is not simple value + if (!contentType && typeof value == 'object') { + contentType = FormData.DEFAULT_CONTENT_TYPE + } + + return contentType + } + + FormData.prototype._multiPartFooter = function () { + return function (next) { + var footer = FormData.LINE_BREAK + + var lastPart = this._streams.length === 0 + if (lastPart) { + footer += this._lastBoundary() + } + + next(footer) + }.bind(this) + } + + FormData.prototype._lastBoundary = function () { + return '--' + this.getBoundary() + '--' + FormData.LINE_BREAK + } + + FormData.prototype.getHeaders = function (userHeaders) { + var header + var formHeaders = { + 'content-type': 'multipart/form-data; boundary=' + this.getBoundary() + } + + for (header in userHeaders) { + if (userHeaders.hasOwnProperty(header)) { + formHeaders[header.toLowerCase()] = userHeaders[header] + } + } + + return formHeaders + } + + FormData.prototype.getBoundary = function () { + if (!this._boundary) { + this._generateBoundary() + } + + return this._boundary + } + + FormData.prototype._generateBoundary = function () { + // This generates a 50 character boundary similar to those used by Firefox. + // They are optimized for boyer-moore parsing. + var boundary = '--------------------------' + for (var i = 0; i < 24; i++) { + boundary += Math.floor(Math.random() * 10).toString(16) + } + + this._boundary = boundary + } + + // Note: getLengthSync DOESN'T calculate streams length + // As workaround one can calculate file size manually + // and add it as knownLength option + FormData.prototype.getLengthSync = function () { + var knownLength = this._overheadLength + this._valueLength + + // Don't get confused, there are 3 "internal" streams for each keyval pair + // so it basically checks if there is any value added to the form + if (this._streams.length) { + knownLength += this._lastBoundary().length + } + + // https://github.com/form-data/form-data/issues/40 + if (!this.hasKnownLength()) { + // Some async length retrievers are present + // therefore synchronous length calculation is false. + // Please use getLength(callback) to get proper length + this._error( + new Error('Cannot calculate proper length in synchronous way.') + ) + } + + return knownLength + } + + // Public API to check if length of added values is known + // https://github.com/form-data/form-data/issues/196 + // https://github.com/form-data/form-data/issues/262 + FormData.prototype.hasKnownLength = function () { + var hasKnownLength = true + + if (this._valuesToMeasure.length) { + hasKnownLength = false + } + + return hasKnownLength + } + + FormData.prototype.getLength = function (cb) { + var knownLength = this._overheadLength + this._valueLength + + if (this._streams.length) { + knownLength += this._lastBoundary().length + } + + if (!this._valuesToMeasure.length) { + process.nextTick(cb.bind(this, null, knownLength)) + return + } + + asynckit.parallel( + this._valuesToMeasure, + this._lengthRetriever, + function (err, values) { + if (err) { + cb(err) + return + } + + values.forEach(function (length) { + knownLength += length + }) + + cb(null, knownLength) + } + ) + } + + FormData.prototype.submit = function (params, cb) { + var request, + options, + defaults = { method: 'post' } + // parse provided url if it's string + // or treat it as options object + if (typeof params == 'string') { + params = parseUrl(params) + options = populate( + { + port: params.port, + path: params.pathname, + host: params.hostname, + protocol: params.protocol + }, + defaults + ) + + // use custom params + } else { + options = populate(params, defaults) + // if no port provided use default one + if (!options.port) { + options.port = options.protocol == 'https:' ? 443 : 80 + } + } + + // put that good code in getHeaders to some use + options.headers = this.getHeaders(params.headers) + + // https if specified, fallback to http in any other case + if (options.protocol == 'https:') { + request = https.request(options) + } else { + request = http.request(options) + } + + // get content length and fire away + this.getLength( + function (err, length) { + if (err) { + this._error(err) + return + } + + // add content length + request.setHeader('Content-Length', length) + + this.pipe(request) + if (cb) { + request.on('error', cb) + request.on('response', cb.bind(this, null)) + } + }.bind(this) + ) + + return request + } + + FormData.prototype._error = function (err) { + if (!this.error) { + this.error = err + this.pause() + this.emit('error', err) + } + } + + FormData.prototype.toString = function () { + return '[object FormData]' + } + + /***/ + }, + + /***/ 17142: /***/ module => { + // populates missing values + module.exports = function (dst, src) { + Object.keys(src).forEach(function (prop) { + dst[prop] = dst[prop] || src[prop] + }) + + return dst + } + + /***/ + }, + + /***/ 66129: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + // Copyright 2018 Google LLC + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + Object.defineProperty(exports, '__esModule', { value: true }) + exports.GaxiosError = void 0 + /* eslint-disable @typescript-eslint/no-explicit-any */ + class GaxiosError extends Error { + constructor(message, options, response) { + super(message) + this.response = response + this.config = options + this.code = response.status.toString() + } + } + exports.GaxiosError = GaxiosError + //# sourceMappingURL=common.js.map + + /***/ + }, + + /***/ 28133: /***/ function ( + __unused_webpack_module, + exports, + __webpack_require__ + ) { + 'use strict' + + // Copyright 2018 Google LLC + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + var __importDefault = + (this && this.__importDefault) || + function (mod) { + return mod && mod.__esModule ? mod : { default: mod } + } + Object.defineProperty(exports, '__esModule', { value: true }) + exports.Gaxios = void 0 + const extend_1 = __importDefault(__webpack_require__(38171)) + const node_fetch_1 = __importDefault(__webpack_require__(80467)) + const querystring_1 = __importDefault(__webpack_require__(71191)) + const is_stream_1 = __importDefault(__webpack_require__(42063)) + const common_1 = __webpack_require__(66129) + const retry_1 = __webpack_require__(31052) + /* eslint-disable @typescript-eslint/no-explicit-any */ + /* eslint-disable node/no-unsupported-features/node-builtins */ + const fetch = hasFetch() ? window.fetch : node_fetch_1.default + function hasWindow() { + return typeof window !== 'undefined' && !!window + } + function hasFetch() { + return hasWindow() && !!window.fetch + } + let HttpsProxyAgent + // Figure out if we should be using a proxy. Only if it's required, load + // the https-proxy-agent module as it adds startup cost. + function loadProxy() { + const proxy = + process.env.HTTPS_PROXY || + process.env.https_proxy || + process.env.HTTP_PROXY || + process.env.http_proxy + if (proxy) { + HttpsProxyAgent = __webpack_require__(77219) + } + return proxy + } + loadProxy() + class Gaxios { + /** + * The Gaxios class is responsible for making HTTP requests. + * @param defaults The default set of options to be used for this instance. + */ + constructor(defaults) { + this.agentCache = new Map() + this.defaults = defaults || {} + } + /** + * Perform an HTTP request with the given options. + * @param opts Set of HTTP options that will be used for this HTTP request. + */ + async request(opts = {}) { + opts = this.validateOpts(opts) + return this._request(opts) + } + async _defaultAdapter(opts) { + const res = await fetch(opts.url, opts) + const data = await this.getResponseData(opts, res) + return this.translateResponse(opts, res, data) + } + /** + * Internal, retryable version of the `request` method. + * @param opts Set of HTTP options that will be used for this HTTP request. + */ + async _request(opts = {}) { + try { + let translatedResponse + if (opts.adapter) { + translatedResponse = await opts.adapter( + opts, + this._defaultAdapter.bind(this) + ) + } else { + translatedResponse = await this._defaultAdapter(opts) + } + if (!opts.validateStatus(translatedResponse.status)) { + throw new common_1.GaxiosError( + `Request failed with status code ${translatedResponse.status}`, + opts, + translatedResponse + ) + } + return translatedResponse + } catch (e) { + const err = e + err.config = opts + const { shouldRetry, config } = await retry_1.getRetryConfig(e) + if (shouldRetry && config) { + err.config.retryConfig.currentRetryAttempt = + config.retryConfig.currentRetryAttempt + return this._request(err.config) + } + throw err + } + } + async getResponseData(opts, res) { + switch (opts.responseType) { + case 'stream': + return res.body + case 'json': { + let data = await res.text() + try { + data = JSON.parse(data) + } catch (_a) { + // continue + } + return data + } + case 'arraybuffer': + return res.arrayBuffer() + case 'blob': + return res.blob() + default: + return res.text() + } + } + /** + * Validates the options, and merges them with defaults. + * @param opts The original options passed from the client. + */ + validateOpts(options) { + const opts = extend_1.default(true, {}, this.defaults, options) + if (!opts.url) { + throw new Error('URL is required.') + } + // baseUrl has been deprecated, remove in 2.0 + const baseUrl = opts.baseUrl || opts.baseURL + if (baseUrl) { + opts.url = baseUrl + opts.url + } + opts.paramsSerializer = opts.paramsSerializer || this.paramsSerializer + if (opts.params && Object.keys(opts.params).length > 0) { + let additionalQueryParams = opts.paramsSerializer(opts.params) + if (additionalQueryParams.startsWith('?')) { + additionalQueryParams = additionalQueryParams.slice(1) + } + const prefix = opts.url.includes('?') ? '&' : '?' + opts.url = opts.url + prefix + additionalQueryParams + } + if (typeof options.maxContentLength === 'number') { + opts.size = options.maxContentLength + } + if (typeof options.maxRedirects === 'number') { + opts.follow = options.maxRedirects + } + opts.headers = opts.headers || {} + if (opts.data) { + if (is_stream_1.default.readable(opts.data)) { + opts.body = opts.data + } else if (typeof opts.data === 'object') { + opts.body = JSON.stringify(opts.data) + // Allow the user to specifiy their own content type, + // such as application/json-patch+json; for historical reasons this + // content type must currently be a json type, as we are relying on + // application/x-www-form-urlencoded (which is incompatible with + // upstream GCP APIs) being rewritten to application/json. + // + // TODO: refactor upstream dependencies to stop relying on this + // side-effect. + if ( + !opts.headers['Content-Type'] || + !opts.headers['Content-Type'].includes('json') + ) { + opts.headers['Content-Type'] = 'application/json' + } + } else { + opts.body = opts.data + } + } + opts.validateStatus = opts.validateStatus || this.validateStatus + opts.responseType = opts.responseType || 'json' + if (!opts.headers['Accept'] && opts.responseType === 'json') { + opts.headers['Accept'] = 'application/json' + } + opts.method = opts.method || 'GET' + const proxy = loadProxy() + if (proxy) { + if (this.agentCache.has(proxy)) { + opts.agent = this.agentCache.get(proxy) + } else { + opts.agent = new HttpsProxyAgent(proxy) + this.agentCache.set(proxy, opts.agent) + } + } + return opts + } + /** + * By default, throw for any non-2xx status code + * @param status status code from the HTTP response + */ + validateStatus(status) { + return status >= 200 && status < 300 + } + /** + * Encode a set of key/value pars into a querystring format (?foo=bar&baz=boo) + * @param params key value pars to encode + */ + paramsSerializer(params) { + return querystring_1.default.stringify(params) + } + translateResponse(opts, res, data) { + // headers need to be converted from a map to an obj + const headers = {} + res.headers.forEach((value, key) => { + headers[key] = value + }) + return { + config: opts, + data: data, + headers, + status: res.status, + statusText: res.statusText, + // XMLHttpRequestLike + request: { + responseURL: res.url + } + } + } + } + exports.Gaxios = Gaxios + //# sourceMappingURL=gaxios.js.map + + /***/ + }, + + /***/ 59555: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + // Copyright 2018 Google LLC + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + Object.defineProperty(exports, '__esModule', { value: true }) + exports.request = exports.instance = exports.Gaxios = void 0 + const gaxios_1 = __webpack_require__(28133) + Object.defineProperty(exports, 'Gaxios', { + enumerable: true, + get: function () { + return gaxios_1.Gaxios + } + }) + var common_1 = __webpack_require__(66129) + Object.defineProperty(exports, 'GaxiosError', { + enumerable: true, + get: function () { + return common_1.GaxiosError + } + }) + /** + * The default instance used when the `request` method is directly + * invoked. + */ + exports.instance = new gaxios_1.Gaxios() + /** + * Make an HTTP request using the given options. + * @param opts Options for the request + */ + async function request(opts) { + return exports.instance.request(opts) + } + exports.request = request + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 31052: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + // Copyright 2018 Google LLC + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + Object.defineProperty(exports, '__esModule', { value: true }) + exports.getRetryConfig = void 0 + async function getRetryConfig(err) { + var _a + let config = getConfig(err) + if (!err || !err.config || (!config && !err.config.retry)) { + return { shouldRetry: false } + } + config = config || {} + config.currentRetryAttempt = config.currentRetryAttempt || 0 + config.retry = + config.retry === undefined || config.retry === null ? 3 : config.retry + config.httpMethodsToRetry = config.httpMethodsToRetry || [ + 'GET', + 'HEAD', + 'PUT', + 'OPTIONS', + 'DELETE' + ] + config.noResponseRetries = + config.noResponseRetries === undefined || + config.noResponseRetries === null + ? 2 + : config.noResponseRetries + // If this wasn't in the list of status codes where we want + // to automatically retry, return. + const retryRanges = [ + // https://en.wikipedia.org/wiki/List_of_HTTP_status_codes + // 1xx - Retry (Informational, request still processing) + // 2xx - Do not retry (Success) + // 3xx - Do not retry (Redirect) + // 4xx - Do not retry (Client errors) + // 429 - Retry ("Too Many Requests") + // 5xx - Retry (Server errors) + [100, 199], + [429, 429], + [500, 599] + ] + config.statusCodesToRetry = config.statusCodesToRetry || retryRanges + // Put the config back into the err + err.config.retryConfig = config + // Determine if we should retry the request + const shouldRetryFn = config.shouldRetry || shouldRetryRequest + if (!(await shouldRetryFn(err))) { + return { shouldRetry: false, config: err.config } + } + // Calculate time to wait with exponential backoff. + // If this is the first retry, look for a configured retryDelay. + const retryDelay = config.currentRetryAttempt + ? 0 + : (_a = config.retryDelay) !== null && _a !== void 0 + ? _a + : 100 + // Formula: retryDelay + ((2^c - 1 / 2) * 1000) + const delay = + retryDelay + + ((Math.pow(2, config.currentRetryAttempt) - 1) / 2) * 1000 + // We're going to retry! Incremenent the counter. + err.config.retryConfig.currentRetryAttempt += 1 + // Create a promise that invokes the retry after the backOffDelay + const backoff = new Promise(resolve => { + setTimeout(resolve, delay) + }) + // Notify the user if they added an `onRetryAttempt` handler + if (config.onRetryAttempt) { + config.onRetryAttempt(err) + } + // Return the promise in which recalls Gaxios to retry the request + await backoff + return { shouldRetry: true, config: err.config } + } + exports.getRetryConfig = getRetryConfig + /** + * Determine based on config if we should retry the request. + * @param err The GaxiosError passed to the interceptor. + */ + function shouldRetryRequest(err) { + const config = getConfig(err) + // node-fetch raises an AbortError if signaled: + // https://github.com/bitinn/node-fetch#request-cancellation-with-abortsignal + if (err.name === 'AbortError') { + return false + } + // If there's no config, or retries are disabled, return. + if (!config || config.retry === 0) { + return false + } + // Check if this error has no response (ETIMEDOUT, ENOTFOUND, etc) + if ( + !err.response && + (config.currentRetryAttempt || 0) >= config.noResponseRetries + ) { + return false + } + // Only retry with configured HttpMethods. + if ( + !err.config.method || + config.httpMethodsToRetry.indexOf(err.config.method.toUpperCase()) < 0 + ) { + return false + } + // If this wasn't in the list of status codes where we want + // to automatically retry, return. + if (err.response && err.response.status) { + let isInRange = false + for (const [min, max] of config.statusCodesToRetry) { + const status = err.response.status + if (status >= min && status <= max) { + isInRange = true + break + } + } + if (!isInRange) { + return false + } + } + // If we are out of retry attempts, return + config.currentRetryAttempt = config.currentRetryAttempt || 0 + if (config.currentRetryAttempt >= config.retry) { + return false + } + return true + } + /** + * Acquire the raxConfig object from an GaxiosError if available. + * @param err The Gaxios error with a config object. + */ + function getConfig(err) { + if (err && err.config && err.config.retryConfig) { + return err.config.retryConfig + } + return + } + //# sourceMappingURL=retry.js.map + + /***/ + }, + + /***/ 42063: /***/ module => { + 'use strict' + + const isStream = stream => + stream !== null && + typeof stream === 'object' && + typeof stream.pipe === 'function' + + isStream.writable = stream => + isStream(stream) && + stream.writable !== false && + typeof stream._write === 'function' && + typeof stream._writableState === 'object' + + isStream.readable = stream => + isStream(stream) && + stream.readable !== false && + typeof stream._read === 'function' && + typeof stream._readableState === 'object' + + isStream.duplex = stream => + isStream.writable(stream) && isStream.readable(stream) + + isStream.transform = stream => + isStream.duplex(stream) && + typeof stream._transform === 'function' && + typeof stream._transformState === 'object' + + module.exports = isStream + + /***/ + }, + + /***/ 3563: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /** + * Copyright 2018 Google LLC + * + * Distributed under MIT license. + * See file LICENSE for detail or copy at https://opensource.org/licenses/MIT + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.requestTimeout = exports.resetIsAvailableCache = exports.isAvailable = exports.project = exports.instance = exports.HEADERS = exports.HEADER_VALUE = exports.HEADER_NAME = exports.SECONDARY_HOST_ADDRESS = exports.HOST_ADDRESS = exports.BASE_PATH = void 0 + const gaxios_1 = __webpack_require__(59555) + const jsonBigint = __webpack_require__(55031) // eslint-disable-line + exports.BASE_PATH = '/computeMetadata/v1' + exports.HOST_ADDRESS = 'http://169.254.169.254' + exports.SECONDARY_HOST_ADDRESS = 'http://metadata.google.internal.' + exports.HEADER_NAME = 'Metadata-Flavor' + exports.HEADER_VALUE = 'Google' + exports.HEADERS = Object.freeze({ + [exports.HEADER_NAME]: exports.HEADER_VALUE + }) + /** + * Returns the base URL while taking into account the GCE_METADATA_HOST + * environment variable if it exists. + * + * @returns The base URL, e.g., http://169.254.169.254/computeMetadata/v1. + */ + function getBaseUrl(baseUrl) { + if (!baseUrl) { + baseUrl = + process.env.GCE_METADATA_IP || + process.env.GCE_METADATA_HOST || + exports.HOST_ADDRESS + } + // If no scheme is provided default to HTTP: + if (!/^https?:\/\//.test(baseUrl)) { + baseUrl = `http://${baseUrl}` + } + return new URL(exports.BASE_PATH, baseUrl).href + } + // Accepts an options object passed from the user to the API. In previous + // versions of the API, it referred to a `Request` or an `Axios` request + // options object. Now it refers to an object with very limited property + // names. This is here to help ensure users don't pass invalid options when + // they upgrade from 0.4 to 0.5 to 0.8. + function validate(options) { + Object.keys(options).forEach(key => { + switch (key) { + case 'params': + case 'property': + case 'headers': + break + case 'qs': + throw new Error( + "'qs' is not a valid configuration option. Please use 'params' instead." + ) + default: + throw new Error(`'${key}' is not a valid configuration option.`) + } + }) + } + async function metadataAccessor( + type, + options, + noResponseRetries = 3, + fastFail = false + ) { + options = options || {} + if (typeof options === 'string') { + options = { property: options } + } + let property = '' + if (typeof options === 'object' && options.property) { + property = '/' + options.property + } + validate(options) + try { + const requestMethod = fastFail + ? fastFailMetadataRequest + : gaxios_1.request + const res = await requestMethod({ + url: `${getBaseUrl()}/${type}${property}`, + headers: Object.assign({}, exports.HEADERS, options.headers), + retryConfig: { noResponseRetries }, + params: options.params, + responseType: 'text', + timeout: requestTimeout() + }) + // NOTE: node.js converts all incoming headers to lower case. + if ( + res.headers[exports.HEADER_NAME.toLowerCase()] !== + exports.HEADER_VALUE + ) { + throw new Error( + `Invalid response from metadata service: incorrect ${exports.HEADER_NAME} header.` + ) + } else if (!res.data) { + throw new Error('Invalid response from the metadata service') + } + if (typeof res.data === 'string') { + try { + return jsonBigint.parse(res.data) + } catch (_a) { + /* ignore */ + } + } + return res.data + } catch (e) { + if (e.response && e.response.status !== 200) { + e.message = `Unsuccessful response status code. ${e.message}` + } + throw e + } + } + async function fastFailMetadataRequest(options) { + const secondaryOptions = { + ...options, + url: options.url.replace( + getBaseUrl(), + getBaseUrl(exports.SECONDARY_HOST_ADDRESS) + ) + } + // We race a connection between DNS/IP to metadata server. There are a couple + // reasons for this: + // + // 1. the DNS is slow in some GCP environments; by checking both, we might + // detect the runtime environment signficantly faster. + // 2. we can't just check the IP, which is tarpitted and slow to respond + // on a user's local machine. + // + // Additional logic has been added to make sure that we don't create an + // unhandled rejection in scenarios where a failure happens sometime + // after a success. + // + // Note, however, if a failure happens prior to a success, a rejection should + // occur, this is for folks running locally. + // + let responded = false + const r1 = gaxios_1 + .request(options) + .then(res => { + responded = true + return res + }) + .catch(err => { + if (responded) { + return r2 + } else { + responded = true + throw err + } + }) + const r2 = gaxios_1 + .request(secondaryOptions) + .then(res => { + responded = true + return res + }) + .catch(err => { + if (responded) { + return r1 + } else { + responded = true + throw err + } + }) + return Promise.race([r1, r2]) + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function instance(options) { + return metadataAccessor('instance', options) + } + exports.instance = instance + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function project(options) { + return metadataAccessor('project', options) + } + exports.project = project + /* + * How many times should we retry detecting GCP environment. + */ + function detectGCPAvailableRetries() { + return process.env.DETECT_GCP_RETRIES + ? Number(process.env.DETECT_GCP_RETRIES) + : 0 + } + /** + * Determine if the metadata server is currently available. + */ + let cachedIsAvailableResponse + async function isAvailable() { + try { + // If a user is instantiating several GCP libraries at the same time, + // this may result in multiple calls to isAvailable(), to detect the + // runtime environment. We use the same promise for each of these calls + // to reduce the network load. + if (cachedIsAvailableResponse === undefined) { + cachedIsAvailableResponse = metadataAccessor( + 'instance', + undefined, + detectGCPAvailableRetries(), + // If the default HOST_ADDRESS has been overridden, we should not + // make an effort to try SECONDARY_HOST_ADDRESS (as we are likely in + // a non-GCP environment): + !(process.env.GCE_METADATA_IP || process.env.GCE_METADATA_HOST) + ) + } + await cachedIsAvailableResponse + return true + } catch (err) { + if (process.env.DEBUG_AUTH) { + console.info(err) + } + if (err.type === 'request-timeout') { + // If running in a GCP environment, metadata endpoint should return + // within ms. + return false + } + if (err.response && err.response.status === 404) { + return false + } else { + if ( + !(err.response && err.response.status === 404) && + // A warning is emitted if we see an unexpected err.code, or err.code + // is not populated: + (!err.code || + ![ + 'EHOSTDOWN', + 'EHOSTUNREACH', + 'ENETUNREACH', + 'ENOENT', + 'ENOTFOUND', + 'ECONNREFUSED' + ].includes(err.code)) + ) { + let code = 'UNKNOWN' + if (err.code) code = err.code + process.emitWarning( + `received unexpected error = ${err.message} code = ${code}`, + 'MetadataLookupWarning' + ) + } + // Failure to resolve the metadata service means that it is not available. + return false + } + } + } + exports.isAvailable = isAvailable + /** + * reset the memoized isAvailable() lookup. + */ + function resetIsAvailableCache() { + cachedIsAvailableResponse = undefined + } + exports.resetIsAvailableCache = resetIsAvailableCache + function requestTimeout() { + // In testing, we were able to reproduce behavior similar to + // https://github.com/googleapis/google-auth-library-nodejs/issues/798 + // by making many concurrent network requests. Requests do not actually fail, + // rather they take significantly longer to complete (and we hit our + // default 3000ms timeout). + // + // This logic detects a GCF environment, using the documented environment + // variables K_SERVICE and FUNCTION_NAME: + // https://cloud.google.com/functions/docs/env-var and, in a GCF environment + // eliminates timeouts (by setting the value to 0 to disable). + return process.env.K_SERVICE || process.env.FUNCTION_NAME ? 0 : 3000 + } + exports.requestTimeout = requestTimeout + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 91585: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + 'use strict' + + const { PassThrough } = __webpack_require__(92413) + + module.exports = options => { + options = Object.assign({}, options) + + const { array } = options + let { encoding } = options + const buffer = encoding === 'buffer' + let objectMode = false + + if (array) { + objectMode = !(encoding || buffer) + } else { + encoding = encoding || 'utf8' + } + + if (buffer) { + encoding = null + } + + let len = 0 + const ret = [] + const stream = new PassThrough({ objectMode }) + + if (encoding) { + stream.setEncoding(encoding) + } + + stream.on('data', chunk => { + ret.push(chunk) + + if (objectMode) { + len = ret.length + } else { + len += chunk.length + } + }) + + stream.getBufferedValue = () => { + if (array) { + return ret + } + + return buffer ? Buffer.concat(ret, len) : ret.join('') + } + + stream.getBufferedLength = () => len + + return stream + } + + /***/ + }, + + /***/ 21766: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + 'use strict' + + const pump = __webpack_require__(18341) + const bufferStream = __webpack_require__(91585) + + class MaxBufferError extends Error { + constructor() { + super('maxBuffer exceeded') + this.name = 'MaxBufferError' + } + } + + function getStream(inputStream, options) { + if (!inputStream) { + return Promise.reject(new Error('Expected a stream')) + } + + options = Object.assign({ maxBuffer: Infinity }, options) + + const { maxBuffer } = options + + let stream + return new Promise((resolve, reject) => { + const rejectPromise = error => { + if (error) { + // A null check + error.bufferedData = stream.getBufferedValue() + } + reject(error) + } + + stream = pump(inputStream, bufferStream(options), error => { + if (error) { + rejectPromise(error) + return + } + + resolve() + }) + + stream.on('data', () => { + if (stream.getBufferedLength() > maxBuffer) { + rejectPromise(new MaxBufferError()) + } + }) + }).then(() => stream.getBufferedValue()) + } + + module.exports = getStream + module.exports.buffer = (stream, options) => + getStream(stream, Object.assign({}, options, { encoding: 'buffer' })) + module.exports.array = (stream, options) => + getStream(stream, Object.assign({}, options, { array: true })) + module.exports.MaxBufferError = MaxBufferError + + /***/ + }, + + /***/ 44627: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + // Copyright 2012 Google LLC + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + Object.defineProperty(exports, '__esModule', { value: true }) + exports.AuthClient = void 0 + const events_1 = __webpack_require__(28614) + const transporters_1 = __webpack_require__(72649) + class AuthClient extends events_1.EventEmitter { + constructor() { + super(...arguments) + this.transporter = new transporters_1.DefaultTransporter() + this.credentials = {} + } + /** + * Sets the auth credentials. + */ + setCredentials(credentials) { + this.credentials = credentials + } + /** + * Append additional headers, e.g., x-goog-user-project, shared across the + * classes inheriting AuthClient. This method should be used by any method + * that overrides getRequestMetadataAsync(), which is a shared helper for + * setting request information in both gRPC and HTTP API calls. + * + * @param headers objedcdt to append additional headers to. + */ + addSharedMetadataHeaders(headers) { + // quota_project_id, stored in application_default_credentials.json, is set in + // the x-goog-user-project header, to indicate an alternate account for + // billing and quota: + if ( + !headers['x-goog-user-project'] && // don't override a value the user sets. + this.quotaProjectId + ) { + headers['x-goog-user-project'] = this.quotaProjectId + } + return headers + } + } + exports.AuthClient = AuthClient + //# sourceMappingURL=authclient.js.map + + /***/ + }, + + /***/ 96875: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + // Copyright 2013 Google LLC + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + Object.defineProperty(exports, '__esModule', { value: true }) + exports.Compute = void 0 + const arrify = __webpack_require__(61546) + const gcpMetadata = __webpack_require__(3563) + const oauth2client_1 = __webpack_require__(3936) + class Compute extends oauth2client_1.OAuth2Client { + /** + * Google Compute Engine service account credentials. + * + * Retrieve access token from the metadata server. + * See: https://developers.google.com/compute/docs/authentication + */ + constructor(options = {}) { + super(options) + // Start with an expired refresh token, which will automatically be + // refreshed before the first API call is made. + this.credentials = { + expiry_date: 1, + refresh_token: 'compute-placeholder' + } + this.serviceAccountEmail = options.serviceAccountEmail || 'default' + this.scopes = arrify(options.scopes) + } + /** + * Refreshes the access token. + * @param refreshToken Unused parameter + */ + async refreshTokenNoCache( + // eslint-disable-next-line @typescript-eslint/no-unused-vars + refreshToken + ) { + const tokenPath = `service-accounts/${this.serviceAccountEmail}/token` + let data + try { + const instanceOptions = { + property: tokenPath + } + if (this.scopes.length > 0) { + instanceOptions.params = { + scopes: this.scopes.join(',') + } + } + data = await gcpMetadata.instance(instanceOptions) + } catch (e) { + e.message = `Could not refresh access token: ${e.message}` + this.wrapError(e) + throw e + } + const tokens = data + if (data && data.expires_in) { + tokens.expiry_date = new Date().getTime() + data.expires_in * 1000 + delete tokens.expires_in + } + this.emit('tokens', tokens) + return { tokens, res: null } + } + /** + * Fetches an ID token. + * @param targetAudience the audience for the fetched ID token. + */ + async fetchIdToken(targetAudience) { + const idTokenPath = + `service-accounts/${this.serviceAccountEmail}/identity` + + `?format=full&audience=${targetAudience}` + let idToken + try { + const instanceOptions = { + property: idTokenPath + } + idToken = await gcpMetadata.instance(instanceOptions) + } catch (e) { + e.message = `Could not fetch ID token: ${e.message}` + throw e + } + return idToken + } + wrapError(e) { + const res = e.response + if (res && res.status) { + e.code = res.status.toString() + if (res.status === 403) { + e.message = + 'A Forbidden error was returned while attempting to retrieve an access ' + + 'token for the Compute Engine built-in service account. This may be because the Compute ' + + 'Engine instance does not have the correct permission scopes specified: ' + + e.message + } else if (res.status === 404) { + e.message = + 'A Not Found error was returned while attempting to retrieve an access' + + 'token for the Compute Engine built-in service account. This may be because the Compute ' + + 'Engine instance does not have any permission scopes specified: ' + + e.message + } + } + } + } + exports.Compute = Compute + //# sourceMappingURL=computeclient.js.map + + /***/ + }, + + /***/ 21380: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + // Copyright 2018 Google LLC + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + Object.defineProperty(exports, '__esModule', { value: true }) + exports.getEnv = exports.clear = exports.GCPEnv = void 0 + const gcpMetadata = __webpack_require__(3563) + var GCPEnv + ;(function (GCPEnv) { + GCPEnv['APP_ENGINE'] = 'APP_ENGINE' + GCPEnv['KUBERNETES_ENGINE'] = 'KUBERNETES_ENGINE' + GCPEnv['CLOUD_FUNCTIONS'] = 'CLOUD_FUNCTIONS' + GCPEnv['COMPUTE_ENGINE'] = 'COMPUTE_ENGINE' + GCPEnv['NONE'] = 'NONE' + })((GCPEnv = exports.GCPEnv || (exports.GCPEnv = {}))) + let envPromise + function clear() { + envPromise = undefined + } + exports.clear = clear + async function getEnv() { + if (envPromise) { + return envPromise + } + envPromise = getEnvMemoized() + return envPromise + } + exports.getEnv = getEnv + async function getEnvMemoized() { + let env = GCPEnv.NONE + if (isAppEngine()) { + env = GCPEnv.APP_ENGINE + } else if (isCloudFunction()) { + env = GCPEnv.CLOUD_FUNCTIONS + } else if (await isComputeEngine()) { + if (await isKubernetesEngine()) { + env = GCPEnv.KUBERNETES_ENGINE + } else { + env = GCPEnv.COMPUTE_ENGINE + } + } else { + env = GCPEnv.NONE + } + return env + } + function isAppEngine() { + return !!(process.env.GAE_SERVICE || process.env.GAE_MODULE_NAME) + } + function isCloudFunction() { + return !!(process.env.FUNCTION_NAME || process.env.FUNCTION_TARGET) + } + async function isKubernetesEngine() { + try { + await gcpMetadata.instance('attributes/cluster-name') + return true + } catch (e) { + return false + } + } + async function isComputeEngine() { + return gcpMetadata.isAvailable() + } + //# sourceMappingURL=envDetect.js.map + + /***/ + }, + + /***/ 20695: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + // Copyright 2019 Google LLC + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + Object.defineProperty(exports, '__esModule', { value: true }) + exports.GoogleAuth = exports.CLOUD_SDK_CLIENT_ID = void 0 + const child_process_1 = __webpack_require__(63129) + const fs = __webpack_require__(35747) + const gcpMetadata = __webpack_require__(3563) + const os = __webpack_require__(12087) + const path = __webpack_require__(85622) + const crypto_1 = __webpack_require__(78043) + const transporters_1 = __webpack_require__(72649) + const computeclient_1 = __webpack_require__(96875) + const idtokenclient_1 = __webpack_require__(80298) + const envDetect_1 = __webpack_require__(21380) + const jwtclient_1 = __webpack_require__(13959) + const refreshclient_1 = __webpack_require__(98790) + exports.CLOUD_SDK_CLIENT_ID = + '764086051850-6qr4p6gpi6hn506pt8ejuq83di341hur.apps.googleusercontent.com' + class GoogleAuth { + constructor(opts) { + /** + * Caches a value indicating whether the auth layer is running on Google + * Compute Engine. + * @private + */ + this.checkIsGCE = undefined + // To save the contents of the JSON credential file + this.jsonContent = null + this.cachedCredential = null + opts = opts || {} + this._cachedProjectId = opts.projectId || null + this.keyFilename = opts.keyFilename || opts.keyFile + this.scopes = opts.scopes + this.jsonContent = opts.credentials || null + this.clientOptions = opts.clientOptions + } + // Note: this properly is only public to satisify unit tests. + // https://github.com/Microsoft/TypeScript/issues/5228 + get isGCE() { + return this.checkIsGCE + } + getProjectId(callback) { + if (callback) { + this.getProjectIdAsync().then(r => callback(null, r), callback) + } else { + return this.getProjectIdAsync() + } + } + getProjectIdAsync() { + if (this._cachedProjectId) { + return Promise.resolve(this._cachedProjectId) + } + // In implicit case, supports three environments. In order of precedence, + // the implicit environments are: + // - GCLOUD_PROJECT or GOOGLE_CLOUD_PROJECT environment variable + // - GOOGLE_APPLICATION_CREDENTIALS JSON file + // - Cloud SDK: `gcloud config config-helper --format json` + // - GCE project ID from metadata server) + if (!this._getDefaultProjectIdPromise) { + // TODO: refactor the below code so that it doesn't mix and match + // promises and async/await. + this._getDefaultProjectIdPromise = new Promise( + // eslint-disable-next-line no-async-promise-executor + async (resolve, reject) => { + try { + const projectId = + this.getProductionProjectId() || + (await this.getFileProjectId()) || + (await this.getDefaultServiceProjectId()) || + (await this.getGCEProjectId()) + this._cachedProjectId = projectId + if (!projectId) { + throw new Error( + 'Unable to detect a Project Id in the current environment. \n' + + 'To learn more about authentication and Google APIs, visit: \n' + + 'https://cloud.google.com/docs/authentication/getting-started' + ) + } + resolve(projectId) + } catch (e) { + reject(e) + } + } + ) + } + return this._getDefaultProjectIdPromise + } + getApplicationDefault(optionsOrCallback = {}, callback) { + let options + if (typeof optionsOrCallback === 'function') { + callback = optionsOrCallback + } else { + options = optionsOrCallback + } + if (callback) { + this.getApplicationDefaultAsync(options).then( + r => callback(null, r.credential, r.projectId), + callback + ) + } else { + return this.getApplicationDefaultAsync(options) + } + } + async getApplicationDefaultAsync(options = {}) { + // If we've already got a cached credential, just return it. + if (this.cachedCredential) { + return { + credential: this.cachedCredential, + projectId: await this.getProjectIdAsync() + } + } + let credential + let projectId + // Check for the existence of a local environment variable pointing to the + // location of the credential file. This is typically used in local + // developer scenarios. + credential = await this._tryGetApplicationCredentialsFromEnvironmentVariable( + options + ) + if (credential) { + if (credential instanceof jwtclient_1.JWT) { + credential.defaultScopes = this.defaultScopes + credential.scopes = this.scopes + } + this.cachedCredential = credential + projectId = await this.getProjectId() + return { credential, projectId } + } + // Look in the well-known credential file location. + credential = await this._tryGetApplicationCredentialsFromWellKnownFile( + options + ) + if (credential) { + if (credential instanceof jwtclient_1.JWT) { + credential.defaultScopes = this.defaultScopes + credential.scopes = this.scopes + } + this.cachedCredential = credential + projectId = await this.getProjectId() + return { credential, projectId } + } + // Determine if we're running on GCE. + let isGCE + try { + isGCE = await this._checkIsGCE() + } catch (e) { + e.message = `Unexpected error determining execution environment: ${e.message}` + throw e + } + if (!isGCE) { + // We failed to find the default credentials. Bail out with an error. + throw new Error( + 'Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.' + ) + } + // For GCE, just return a default ComputeClient. It will take care of + // the rest. + options.scopes = this.scopes || this.defaultScopes + this.cachedCredential = new computeclient_1.Compute(options) + projectId = await this.getProjectId() + return { projectId, credential: this.cachedCredential } + } + /** + * Determines whether the auth layer is running on Google Compute Engine. + * @returns A promise that resolves with the boolean. + * @api private + */ + async _checkIsGCE() { + if (this.checkIsGCE === undefined) { + this.checkIsGCE = await gcpMetadata.isAvailable() + } + return this.checkIsGCE + } + /** + * Attempts to load default credentials from the environment variable path.. + * @returns Promise that resolves with the OAuth2Client or null. + * @api private + */ + async _tryGetApplicationCredentialsFromEnvironmentVariable(options) { + const credentialsPath = + process.env['GOOGLE_APPLICATION_CREDENTIALS'] || + process.env['google_application_credentials'] + if (!credentialsPath || credentialsPath.length === 0) { + return null + } + try { + return this._getApplicationCredentialsFromFilePath( + credentialsPath, + options + ) + } catch (e) { + e.message = `Unable to read the credential file specified by the GOOGLE_APPLICATION_CREDENTIALS environment variable: ${e.message}` + throw e + } + } + /** + * Attempts to load default credentials from a well-known file location + * @return Promise that resolves with the OAuth2Client or null. + * @api private + */ + async _tryGetApplicationCredentialsFromWellKnownFile(options) { + // First, figure out the location of the file, depending upon the OS type. + let location = null + if (this._isWindows()) { + // Windows + location = process.env['APPDATA'] + } else { + // Linux or Mac + const home = process.env['HOME'] + if (home) { + location = path.join(home, '.config') + } + } + // If we found the root path, expand it. + if (location) { + location = path.join( + location, + 'gcloud', + 'application_default_credentials.json' + ) + if (!fs.existsSync(location)) { + location = null + } + } + // The file does not exist. + if (!location) { + return null + } + // The file seems to exist. Try to use it. + const client = await this._getApplicationCredentialsFromFilePath( + location, + options + ) + return client + } + /** + * Attempts to load default credentials from a file at the given path.. + * @param filePath The path to the file to read. + * @returns Promise that resolves with the OAuth2Client + * @api private + */ + async _getApplicationCredentialsFromFilePath(filePath, options = {}) { + // Make sure the path looks like a string. + if (!filePath || filePath.length === 0) { + throw new Error('The file path is invalid.') + } + // Make sure there is a file at the path. lstatSync will throw if there is + // nothing there. + try { + // Resolve path to actual file in case of symlink. Expect a thrown error + // if not resolvable. + filePath = fs.realpathSync(filePath) + if (!fs.lstatSync(filePath).isFile()) { + throw new Error() + } + } catch (err) { + err.message = `The file at ${filePath} does not exist, or it is not a file. ${err.message}` + throw err + } + // Now open a read stream on the file, and parse it. + const readStream = fs.createReadStream(filePath) + return this.fromStream(readStream, options) + } + /** + * Create a credentials instance using the given input options. + * @param json The input object. + * @param options The JWT or UserRefresh options for the client + * @returns JWT or UserRefresh Client with data + */ + fromJSON(json, options) { + let client + if (!json) { + throw new Error( + 'Must pass in a JSON object containing the Google auth settings.' + ) + } + options = options || {} + if (json.type === 'authorized_user') { + client = new refreshclient_1.UserRefreshClient(options) + } else { + options.scopes = this.scopes + client = new jwtclient_1.JWT(options) + client.defaultScopes = this.defaultScopes + } + client.fromJSON(json) + return client + } + /** + * Return a JWT or UserRefreshClient from JavaScript object, caching both the + * object used to instantiate and the client. + * @param json The input object. + * @param options The JWT or UserRefresh options for the client + * @returns JWT or UserRefresh Client with data + */ + _cacheClientFromJSON(json, options) { + let client + // create either a UserRefreshClient or JWT client. + options = options || {} + if (json.type === 'authorized_user') { + client = new refreshclient_1.UserRefreshClient(options) + } else { + options.scopes = this.scopes + client = new jwtclient_1.JWT(options) + client.defaultScopes = this.defaultScopes + } + client.fromJSON(json) + // cache both raw data used to instantiate client and client itself. + this.jsonContent = json + this.cachedCredential = client + return this.cachedCredential + } + fromStream(inputStream, optionsOrCallback = {}, callback) { + let options = {} + if (typeof optionsOrCallback === 'function') { + callback = optionsOrCallback + } else { + options = optionsOrCallback + } + if (callback) { + this.fromStreamAsync(inputStream, options).then( + r => callback(null, r), + callback + ) + } else { + return this.fromStreamAsync(inputStream, options) + } + } + fromStreamAsync(inputStream, options) { + return new Promise((resolve, reject) => { + if (!inputStream) { + throw new Error( + 'Must pass in a stream containing the Google auth settings.' + ) + } + let s = '' + inputStream + .setEncoding('utf8') + .on('error', reject) + .on('data', chunk => (s += chunk)) + .on('end', () => { + try { + const data = JSON.parse(s) + const r = this._cacheClientFromJSON(data, options) + return resolve(r) + } catch (err) { + return reject(err) + } + }) + }) + } + /** + * Create a credentials instance using the given API key string. + * @param apiKey The API key string + * @param options An optional options object. + * @returns A JWT loaded from the key + */ + fromAPIKey(apiKey, options) { + options = options || {} + const client = new jwtclient_1.JWT(options) + client.fromAPIKey(apiKey) + return client + } + /** + * Determines whether the current operating system is Windows. + * @api private + */ + _isWindows() { + const sys = os.platform() + if (sys && sys.length >= 3) { + if (sys.substring(0, 3).toLowerCase() === 'win') { + return true + } + } + return false + } + /** + * Run the Google Cloud SDK command that prints the default project ID + */ + async getDefaultServiceProjectId() { + return new Promise(resolve => { + child_process_1.exec( + 'gcloud config config-helper --format json', + (err, stdout) => { + if (!err && stdout) { + try { + const projectId = JSON.parse(stdout).configuration + .properties.core.project + resolve(projectId) + return + } catch (e) { + // ignore errors + } + } + resolve(null) + } + ) + }) + } + /** + * Loads the project id from environment variables. + * @api private + */ + getProductionProjectId() { + return ( + process.env['GCLOUD_PROJECT'] || + process.env['GOOGLE_CLOUD_PROJECT'] || + process.env['gcloud_project'] || + process.env['google_cloud_project'] + ) + } + /** + * Loads the project id from the GOOGLE_APPLICATION_CREDENTIALS json file. + * @api private + */ + async getFileProjectId() { + if (this.cachedCredential) { + // Try to read the project ID from the cached credentials file + return this.cachedCredential.projectId + } + // Ensure the projectId is loaded from the keyFile if available. + if (this.keyFilename) { + const creds = await this.getClient() + if (creds && creds.projectId) { + return creds.projectId + } + } + // Try to load a credentials file and read its project ID + const r = await this._tryGetApplicationCredentialsFromEnvironmentVariable() + if (r) { + return r.projectId + } else { + return null + } + } + /** + * Gets the Compute Engine project ID if it can be inferred. + */ + async getGCEProjectId() { + try { + const r = await gcpMetadata.project('project-id') + return r + } catch (e) { + // Ignore any errors + return null + } + } + getCredentials(callback) { + if (callback) { + this.getCredentialsAsync().then(r => callback(null, r), callback) + } else { + return this.getCredentialsAsync() + } + } + async getCredentialsAsync() { + await this.getClient() + if (this.jsonContent) { + const credential = { + client_email: this.jsonContent.client_email, + private_key: this.jsonContent.private_key + } + return credential + } + const isGCE = await this._checkIsGCE() + if (!isGCE) { + throw new Error('Unknown error.') + } + // For GCE, return the service account details from the metadata server + // NOTE: The trailing '/' at the end of service-accounts/ is very important! + // The GCF metadata server doesn't respect querystring params if this / is + // not included. + const data = await gcpMetadata.instance({ + property: 'service-accounts/', + params: { recursive: 'true' } + }) + if (!data || !data.default || !data.default.email) { + throw new Error('Failure from metadata server.') + } + return { client_email: data.default.email } + } + /** + * Automatically obtain a client based on the provided configuration. If no + * options were passed, use Application Default Credentials. + */ + async getClient(options) { + if (options) { + throw new Error( + 'Passing options to getClient is forbidden in v5.0.0. Use new GoogleAuth(opts) instead.' + ) + } + if (!this.cachedCredential) { + if (this.jsonContent) { + this._cacheClientFromJSON(this.jsonContent, this.clientOptions) + } else if (this.keyFilename) { + const filePath = path.resolve(this.keyFilename) + const stream = fs.createReadStream(filePath) + await this.fromStreamAsync(stream, this.clientOptions) + } else { + await this.getApplicationDefaultAsync(this.clientOptions) + } + } + return this.cachedCredential + } + /** + * Creates a client which will fetch an ID token for authorization. + * @param targetAudience the audience for the fetched ID token. + * @returns IdTokenClient for making HTTP calls authenticated with ID tokens. + */ + async getIdTokenClient(targetAudience) { + const client = await this.getClient() + if (!('fetchIdToken' in client)) { + throw new Error( + 'Cannot fetch ID token in this environment, use GCE or set the GOOGLE_APPLICATION_CREDENTIALS environment variable to a service account credentials JSON file.' + ) + } + return new idtokenclient_1.IdTokenClient({ + targetAudience, + idTokenProvider: client + }) + } + /** + * Automatically obtain application default credentials, and return + * an access token for making requests. + */ + async getAccessToken() { + const client = await this.getClient() + return (await client.getAccessToken()).token + } + /** + * Obtain the HTTP headers that will provide authorization for a given + * request. + */ + async getRequestHeaders(url) { + const client = await this.getClient() + return client.getRequestHeaders(url) + } + /** + * Obtain credentials for a request, then attach the appropriate headers to + * the request options. + * @param opts Axios or Request options on which to attach the headers + */ + async authorizeRequest(opts) { + opts = opts || {} + const url = opts.url || opts.uri + const client = await this.getClient() + const headers = await client.getRequestHeaders(url) + opts.headers = Object.assign(opts.headers || {}, headers) + return opts + } + /** + * Automatically obtain application default credentials, and make an + * HTTP request using the given options. + * @param opts Axios request options for the HTTP request. + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + async request(opts) { + const client = await this.getClient() + return client.request(opts) + } + /** + * Determine the compute environment in which the code is running. + */ + getEnv() { + return envDetect_1.getEnv() + } + /** + * Sign the given data with the current private key, or go out + * to the IAM API to sign it. + * @param data The data to be signed. + */ + async sign(data) { + const client = await this.getClient() + const crypto = crypto_1.createCrypto() + if (client instanceof jwtclient_1.JWT && client.key) { + const sign = await crypto.sign(client.key, data) + return sign + } + const projectId = await this.getProjectId() + if (!projectId) { + throw new Error('Cannot sign data without a project ID.') + } + const creds = await this.getCredentials() + if (!creds.client_email) { + throw new Error('Cannot sign data without `client_email`.') + } + const url = `https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/${creds.client_email}:signBlob` + const res = await this.request({ + method: 'POST', + url, + data: { + payload: crypto.encodeBase64StringUtf8(data) + } + }) + return res.data.signedBlob + } + } + exports.GoogleAuth = GoogleAuth + /** + * Export DefaultTransporter as a static property of the class. + */ + GoogleAuth.DefaultTransporter = transporters_1.DefaultTransporter + //# sourceMappingURL=googleauth.js.map + + /***/ + }, + + /***/ 39735: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + // Copyright 2014 Google LLC + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + Object.defineProperty(exports, '__esModule', { value: true }) + exports.IAMAuth = void 0 + class IAMAuth { + /** + * IAM credentials. + * + * @param selector the iam authority selector + * @param token the token + * @constructor + */ + constructor(selector, token) { + this.selector = selector + this.token = token + this.selector = selector + this.token = token + } + /** + * Acquire the HTTP headers required to make an authenticated request. + */ + getRequestHeaders() { + return { + 'x-goog-iam-authority-selector': this.selector, + 'x-goog-iam-authorization-token': this.token + } + } + } + exports.IAMAuth = IAMAuth + //# sourceMappingURL=iam.js.map + + /***/ + }, + + /***/ 80298: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + // Copyright 2020 Google LLC + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + Object.defineProperty(exports, '__esModule', { value: true }) + exports.IdTokenClient = void 0 + const oauth2client_1 = __webpack_require__(3936) + class IdTokenClient extends oauth2client_1.OAuth2Client { + /** + * Google ID Token client + * + * Retrieve access token from the metadata server. + * See: https://developers.google.com/compute/docs/authentication + */ + constructor(options) { + super() + this.targetAudience = options.targetAudience + this.idTokenProvider = options.idTokenProvider + } + async getRequestMetadataAsync( + // eslint-disable-next-line @typescript-eslint/no-unused-vars + url + ) { + if ( + !this.credentials.id_token || + (this.credentials.expiry_date || 0) < Date.now() + ) { + const idToken = await this.idTokenProvider.fetchIdToken( + this.targetAudience + ) + this.credentials = { + id_token: idToken, + expiry_date: this.getIdTokenExpiryDate(idToken) + } + } + const headers = { + Authorization: 'Bearer ' + this.credentials.id_token + } + return { headers } + } + getIdTokenExpiryDate(idToken) { + const payloadB64 = idToken.split('.')[1] + if (payloadB64) { + const payload = JSON.parse( + Buffer.from(payloadB64, 'base64').toString('ascii') + ) + return payload.exp * 1000 + } + } + } + exports.IdTokenClient = IdTokenClient + //# sourceMappingURL=idtokenclient.js.map + + /***/ + }, + + /***/ 68740: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + // Copyright 2015 Google LLC + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + Object.defineProperty(exports, '__esModule', { value: true }) + exports.JWTAccess = void 0 + const jws = __webpack_require__(4636) + const LRU = __webpack_require__(7129) + const DEFAULT_HEADER = { + alg: 'RS256', + typ: 'JWT' + } + class JWTAccess { + /** + * JWTAccess service account credentials. + * + * Create a new access token by using the credential to create a new JWT token + * that's recognized as the access token. + * + * @param email the service account email address. + * @param key the private key that will be used to sign the token. + * @param keyId the ID of the private key used to sign the token. + */ + constructor(email, key, keyId, eagerRefreshThresholdMillis) { + this.cache = new LRU({ + max: 500, + maxAge: 60 * 60 * 1000 + }) + this.email = email + this.key = key + this.keyId = keyId + this.eagerRefreshThresholdMillis = + eagerRefreshThresholdMillis !== null && + eagerRefreshThresholdMillis !== void 0 + ? eagerRefreshThresholdMillis + : 5 * 60 * 1000 + } + /** + * Get a non-expired access token, after refreshing if necessary. + * + * @param url The URI being authorized. + * @param additionalClaims An object with a set of additional claims to + * include in the payload. + * @returns An object that includes the authorization header. + */ + getRequestHeaders(url, additionalClaims) { + // Return cached authorization headers, unless we are within + // eagerRefreshThresholdMillis ms of them expiring: + const cachedToken = this.cache.get(url) + const now = Date.now() + if ( + cachedToken && + cachedToken.expiration - now > this.eagerRefreshThresholdMillis + ) { + return cachedToken.headers + } + const iat = Math.floor(Date.now() / 1000) + const exp = JWTAccess.getExpirationTime(iat) + // The payload used for signed JWT headers has: + // iss == sub == + // aud == + const defaultClaims = { + iss: this.email, + sub: this.email, + aud: url, + exp, + iat + } + // if additionalClaims are provided, ensure they do not collide with + // other required claims. + if (additionalClaims) { + for (const claim in defaultClaims) { + if (additionalClaims[claim]) { + throw new Error( + `The '${claim}' property is not allowed when passing additionalClaims. This claim is included in the JWT by default.` + ) + } + } + } + const header = this.keyId + ? { ...DEFAULT_HEADER, kid: this.keyId } + : DEFAULT_HEADER + const payload = Object.assign(defaultClaims, additionalClaims) + // Sign the jwt and add it to the cache + const signedJWT = jws.sign({ header, payload, secret: this.key }) + const headers = { Authorization: `Bearer ${signedJWT}` } + this.cache.set(url, { + expiration: exp * 1000, + headers + }) + return headers + } + /** + * Returns an expiration time for the JWT token. + * + * @param iat The issued at time for the JWT. + * @returns An expiration time for the JWT. + */ + static getExpirationTime(iat) { + const exp = iat + 3600 // 3600 seconds = 1 hour + return exp + } + /** + * Create a JWTAccess credentials instance using the given input options. + * @param json The input object. + */ + fromJSON(json) { + if (!json) { + throw new Error( + 'Must pass in a JSON object containing the service account auth settings.' + ) + } + if (!json.client_email) { + throw new Error( + 'The incoming JSON object does not contain a client_email field' + ) + } + if (!json.private_key) { + throw new Error( + 'The incoming JSON object does not contain a private_key field' + ) + } + // Extract the relevant information from the json key file. + this.email = json.client_email + this.key = json.private_key + this.keyId = json.private_key_id + this.projectId = json.project_id + } + fromStream(inputStream, callback) { + if (callback) { + this.fromStreamAsync(inputStream).then(() => callback(), callback) + } else { + return this.fromStreamAsync(inputStream) + } + } + fromStreamAsync(inputStream) { + return new Promise((resolve, reject) => { + if (!inputStream) { + reject( + new Error( + 'Must pass in a stream containing the service account auth settings.' + ) + ) + } + let s = '' + inputStream + .setEncoding('utf8') + .on('data', chunk => (s += chunk)) + .on('error', reject) + .on('end', () => { + try { + const data = JSON.parse(s) + this.fromJSON(data) + resolve() + } catch (err) { + reject(err) + } + }) + }) + } + } + exports.JWTAccess = JWTAccess + //# sourceMappingURL=jwtaccess.js.map + + /***/ + }, + + /***/ 13959: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + // Copyright 2013 Google LLC + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + Object.defineProperty(exports, '__esModule', { value: true }) + exports.JWT = void 0 + const gtoken_1 = __webpack_require__(76031) + const jwtaccess_1 = __webpack_require__(68740) + const oauth2client_1 = __webpack_require__(3936) + class JWT extends oauth2client_1.OAuth2Client { + constructor(optionsOrEmail, keyFile, key, scopes, subject, keyId) { + const opts = + optionsOrEmail && typeof optionsOrEmail === 'object' + ? optionsOrEmail + : { email: optionsOrEmail, keyFile, key, keyId, scopes, subject } + super({ + eagerRefreshThresholdMillis: opts.eagerRefreshThresholdMillis, + forceRefreshOnFailure: opts.forceRefreshOnFailure + }) + this.email = opts.email + this.keyFile = opts.keyFile + this.key = opts.key + this.keyId = opts.keyId + this.scopes = opts.scopes + this.subject = opts.subject + this.additionalClaims = opts.additionalClaims + this.credentials = { + refresh_token: 'jwt-placeholder', + expiry_date: 1 + } + } + /** + * Creates a copy of the credential with the specified scopes. + * @param scopes List of requested scopes or a single scope. + * @return The cloned instance. + */ + createScoped(scopes) { + return new JWT({ + email: this.email, + keyFile: this.keyFile, + key: this.key, + keyId: this.keyId, + scopes, + subject: this.subject, + additionalClaims: this.additionalClaims + }) + } + /** + * Obtains the metadata to be sent with the request. + * + * @param url the URI being authorized. + */ + async getRequestMetadataAsync(url) { + if (!this.apiKey && !this.hasUserScopes() && url) { + if ( + this.additionalClaims && + this.additionalClaims.target_audience + ) { + const { tokens } = await this.refreshToken() + return { + headers: this.addSharedMetadataHeaders({ + Authorization: `Bearer ${tokens.id_token}` + }) + } + } else { + // no scopes have been set, but a uri has been provided. Use JWTAccess + // credentials. + if (!this.access) { + this.access = new jwtaccess_1.JWTAccess( + this.email, + this.key, + this.keyId, + this.eagerRefreshThresholdMillis + ) + } + const headers = await this.access.getRequestHeaders( + url, + this.additionalClaims + ) + return { headers: this.addSharedMetadataHeaders(headers) } + } + } else if (this.hasAnyScopes() || this.apiKey) { + return super.getRequestMetadataAsync(url) + } else { + // If no audience, apiKey, or scopes are provided, we should not attempt + // to populate any headers: + return { headers: {} } + } + } + /** + * Fetches an ID token. + * @param targetAudience the audience for the fetched ID token. + */ + async fetchIdToken(targetAudience) { + // Create a new gToken for fetching an ID token + const gtoken = new gtoken_1.GoogleToken({ + iss: this.email, + sub: this.subject, + scope: this.scopes || this.defaultScopes, + keyFile: this.keyFile, + key: this.key, + additionalClaims: { target_audience: targetAudience } + }) + await gtoken.getToken({ + forceRefresh: true + }) + if (!gtoken.idToken) { + throw new Error('Unknown error: Failed to fetch ID token') + } + return gtoken.idToken + } + /** + * Determine if there are currently scopes available. + */ + hasUserScopes() { + if (!this.scopes) { + return false + } + return this.scopes.length > 0 + } + /** + * Are there any default or user scopes defined. + */ + hasAnyScopes() { + if (this.scopes && this.scopes.length > 0) return true + if (this.defaultScopes && this.defaultScopes.length > 0) return true + return false + } + authorize(callback) { + if (callback) { + this.authorizeAsync().then(r => callback(null, r), callback) + } else { + return this.authorizeAsync() + } + } + async authorizeAsync() { + const result = await this.refreshToken() + if (!result) { + throw new Error('No result returned') + } + this.credentials = result.tokens + this.credentials.refresh_token = 'jwt-placeholder' + this.key = this.gtoken.key + this.email = this.gtoken.iss + return result.tokens + } + /** + * Refreshes the access token. + * @param refreshToken ignored + * @private + */ + async refreshTokenNoCache( + // eslint-disable-next-line @typescript-eslint/no-unused-vars + refreshToken + ) { + const gtoken = this.createGToken() + const token = await gtoken.getToken({ + forceRefresh: this.isTokenExpiring() + }) + const tokens = { + access_token: token.access_token, + token_type: 'Bearer', + expiry_date: gtoken.expiresAt, + id_token: gtoken.idToken + } + this.emit('tokens', tokens) + return { res: null, tokens } + } + /** + * Create a gToken if it doesn't already exist. + */ + createGToken() { + if (!this.gtoken) { + this.gtoken = new gtoken_1.GoogleToken({ + iss: this.email, + sub: this.subject, + scope: this.scopes || this.defaultScopes, + keyFile: this.keyFile, + key: this.key, + additionalClaims: this.additionalClaims + }) + } + return this.gtoken + } + /** + * Create a JWT credentials instance using the given input options. + * @param json The input object. + */ + fromJSON(json) { + if (!json) { + throw new Error( + 'Must pass in a JSON object containing the service account auth settings.' + ) + } + if (!json.client_email) { + throw new Error( + 'The incoming JSON object does not contain a client_email field' + ) + } + if (!json.private_key) { + throw new Error( + 'The incoming JSON object does not contain a private_key field' + ) + } + // Extract the relevant information from the json key file. + this.email = json.client_email + this.key = json.private_key + this.keyId = json.private_key_id + this.projectId = json.project_id + this.quotaProjectId = json.quota_project_id + } + fromStream(inputStream, callback) { + if (callback) { + this.fromStreamAsync(inputStream).then(() => callback(), callback) + } else { + return this.fromStreamAsync(inputStream) + } + } + fromStreamAsync(inputStream) { + return new Promise((resolve, reject) => { + if (!inputStream) { + throw new Error( + 'Must pass in a stream containing the service account auth settings.' + ) + } + let s = '' + inputStream + .setEncoding('utf8') + .on('error', reject) + .on('data', chunk => (s += chunk)) + .on('end', () => { + try { + const data = JSON.parse(s) + this.fromJSON(data) + resolve() + } catch (e) { + reject(e) + } + }) + }) + } + /** + * Creates a JWT credentials instance using an API Key for authentication. + * @param apiKey The API Key in string form. + */ + fromAPIKey(apiKey) { + if (typeof apiKey !== 'string') { + throw new Error('Must provide an API Key string.') + } + this.apiKey = apiKey + } + /** + * Using the key or keyFile on the JWT client, obtain an object that contains + * the key and the client email. + */ + async getCredentials() { + if (this.key) { + return { private_key: this.key, client_email: this.email } + } else if (this.keyFile) { + const gtoken = this.createGToken() + const creds = await gtoken.getCredentials(this.keyFile) + return { + private_key: creds.privateKey, + client_email: creds.clientEmail + } + } + throw new Error( + 'A key or a keyFile must be provided to getCredentials.' + ) + } + } + exports.JWT = JWT + //# sourceMappingURL=jwtclient.js.map + + /***/ + }, + + /***/ 74524: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + // Copyright 2014 Google LLC + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + Object.defineProperty(exports, '__esModule', { value: true }) + exports.LoginTicket = void 0 + class LoginTicket { + /** + * Create a simple class to extract user ID from an ID Token + * + * @param {string} env Envelope of the jwt + * @param {TokenPayload} pay Payload of the jwt + * @constructor + */ + constructor(env, pay) { + this.envelope = env + this.payload = pay + } + getEnvelope() { + return this.envelope + } + getPayload() { + return this.payload + } + /** + * Create a simple class to extract user ID from an ID Token + * + * @return The user ID + */ + getUserId() { + const payload = this.getPayload() + if (payload && payload.sub) { + return payload.sub + } + return null + } + /** + * Returns attributes from the login ticket. This can contain + * various information about the user session. + * + * @return The envelope and payload + */ + getAttributes() { + return { envelope: this.getEnvelope(), payload: this.getPayload() } + } + } + exports.LoginTicket = LoginTicket + //# sourceMappingURL=loginticket.js.map + + /***/ + }, + + /***/ 3936: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + // Copyright 2019 Google LLC + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + Object.defineProperty(exports, '__esModule', { value: true }) + exports.OAuth2Client = exports.CertificateFormat = exports.CodeChallengeMethod = void 0 + const querystring = __webpack_require__(71191) + const stream = __webpack_require__(92413) + const formatEcdsa = __webpack_require__(11728) + const crypto_1 = __webpack_require__(78043) + const authclient_1 = __webpack_require__(44627) + const loginticket_1 = __webpack_require__(74524) + var CodeChallengeMethod + ;(function (CodeChallengeMethod) { + CodeChallengeMethod['Plain'] = 'plain' + CodeChallengeMethod['S256'] = 'S256' + })( + (CodeChallengeMethod = + exports.CodeChallengeMethod || (exports.CodeChallengeMethod = {})) + ) + var CertificateFormat + ;(function (CertificateFormat) { + CertificateFormat['PEM'] = 'PEM' + CertificateFormat['JWK'] = 'JWK' + })( + (CertificateFormat = + exports.CertificateFormat || (exports.CertificateFormat = {})) + ) + class OAuth2Client extends authclient_1.AuthClient { + constructor(optionsOrClientId, clientSecret, redirectUri) { + super() + this.certificateCache = {} + this.certificateExpiry = null + this.certificateCacheFormat = CertificateFormat.PEM + this.refreshTokenPromises = new Map() + const opts = + optionsOrClientId && typeof optionsOrClientId === 'object' + ? optionsOrClientId + : { clientId: optionsOrClientId, clientSecret, redirectUri } + this._clientId = opts.clientId + this._clientSecret = opts.clientSecret + this.redirectUri = opts.redirectUri + this.eagerRefreshThresholdMillis = + opts.eagerRefreshThresholdMillis || 5 * 60 * 1000 + this.forceRefreshOnFailure = !!opts.forceRefreshOnFailure + } + /** + * Generates URL for consent page landing. + * @param opts Options. + * @return URL to consent page. + */ + generateAuthUrl(opts = {}) { + if (opts.code_challenge_method && !opts.code_challenge) { + throw new Error( + 'If a code_challenge_method is provided, code_challenge must be included.' + ) + } + opts.response_type = opts.response_type || 'code' + opts.client_id = opts.client_id || this._clientId + opts.redirect_uri = opts.redirect_uri || this.redirectUri + // Allow scopes to be passed either as array or a string + if (opts.scope instanceof Array) { + opts.scope = opts.scope.join(' ') + } + const rootUrl = OAuth2Client.GOOGLE_OAUTH2_AUTH_BASE_URL_ + return rootUrl + '?' + querystring.stringify(opts) + } + generateCodeVerifier() { + // To make the code compatible with browser SubtleCrypto we need to make + // this method async. + throw new Error( + 'generateCodeVerifier is removed, please use generateCodeVerifierAsync instead.' + ) + } + /** + * Convenience method to automatically generate a code_verifier, and its + * resulting SHA256. If used, this must be paired with a S256 + * code_challenge_method. + * + * For a full example see: + * https://github.com/googleapis/google-auth-library-nodejs/blob/master/samples/oauth2-codeVerifier.js + */ + async generateCodeVerifierAsync() { + // base64 encoding uses 6 bits per character, and we want to generate128 + // characters. 6*128/8 = 96. + const crypto = crypto_1.createCrypto() + const randomString = crypto.randomBytesBase64(96) + // The valid characters in the code_verifier are [A-Z]/[a-z]/[0-9]/ + // "-"/"."/"_"/"~". Base64 encoded strings are pretty close, so we're just + // swapping out a few chars. + const codeVerifier = randomString + .replace(/\+/g, '~') + .replace(/=/g, '_') + .replace(/\//g, '-') + // Generate the base64 encoded SHA256 + const unencodedCodeChallenge = await crypto.sha256DigestBase64( + codeVerifier + ) + // We need to use base64UrlEncoding instead of standard base64 + const codeChallenge = unencodedCodeChallenge + .split('=')[0] + .replace(/\+/g, '-') + .replace(/\//g, '_') + return { codeVerifier, codeChallenge } + } + getToken(codeOrOptions, callback) { + const options = + typeof codeOrOptions === 'string' + ? { code: codeOrOptions } + : codeOrOptions + if (callback) { + this.getTokenAsync(options).then( + r => callback(null, r.tokens, r.res), + e => callback(e, null, e.response) + ) + } else { + return this.getTokenAsync(options) + } + } + async getTokenAsync(options) { + const url = OAuth2Client.GOOGLE_OAUTH2_TOKEN_URL_ + const values = { + code: options.code, + client_id: options.client_id || this._clientId, + client_secret: this._clientSecret, + redirect_uri: options.redirect_uri || this.redirectUri, + grant_type: 'authorization_code', + code_verifier: options.codeVerifier + } + const res = await this.transporter.request({ + method: 'POST', + url, + data: querystring.stringify(values), + headers: { 'Content-Type': 'application/x-www-form-urlencoded' } + }) + const tokens = res.data + if (res.data && res.data.expires_in) { + tokens.expiry_date = + new Date().getTime() + res.data.expires_in * 1000 + delete tokens.expires_in + } + this.emit('tokens', tokens) + return { tokens, res } + } + /** + * Refreshes the access token. + * @param refresh_token Existing refresh token. + * @private + */ + async refreshToken(refreshToken) { + if (!refreshToken) { + return this.refreshTokenNoCache(refreshToken) + } + // If a request to refresh using the same token has started, + // return the same promise. + if (this.refreshTokenPromises.has(refreshToken)) { + return this.refreshTokenPromises.get(refreshToken) + } + const p = this.refreshTokenNoCache(refreshToken).then( + r => { + this.refreshTokenPromises.delete(refreshToken) + return r + }, + e => { + this.refreshTokenPromises.delete(refreshToken) + throw e + } + ) + this.refreshTokenPromises.set(refreshToken, p) + return p + } + async refreshTokenNoCache(refreshToken) { + if (!refreshToken) { + throw new Error('No refresh token is set.') + } + const url = OAuth2Client.GOOGLE_OAUTH2_TOKEN_URL_ + const data = { + refresh_token: refreshToken, + client_id: this._clientId, + client_secret: this._clientSecret, + grant_type: 'refresh_token' + } + // request for new token + const res = await this.transporter.request({ + method: 'POST', + url, + data: querystring.stringify(data), + headers: { 'Content-Type': 'application/x-www-form-urlencoded' } + }) + const tokens = res.data + // TODO: de-duplicate this code from a few spots + if (res.data && res.data.expires_in) { + tokens.expiry_date = + new Date().getTime() + res.data.expires_in * 1000 + delete tokens.expires_in + } + this.emit('tokens', tokens) + return { tokens, res } + } + refreshAccessToken(callback) { + if (callback) { + this.refreshAccessTokenAsync().then( + r => callback(null, r.credentials, r.res), + callback + ) + } else { + return this.refreshAccessTokenAsync() + } + } + async refreshAccessTokenAsync() { + const r = await this.refreshToken(this.credentials.refresh_token) + const tokens = r.tokens + tokens.refresh_token = this.credentials.refresh_token + this.credentials = tokens + return { credentials: this.credentials, res: r.res } + } + getAccessToken(callback) { + if (callback) { + this.getAccessTokenAsync().then( + r => callback(null, r.token, r.res), + callback + ) + } else { + return this.getAccessTokenAsync() + } + } + async getAccessTokenAsync() { + const shouldRefresh = + !this.credentials.access_token || this.isTokenExpiring() + if (shouldRefresh) { + if (!this.credentials.refresh_token) { + throw new Error('No refresh token is set.') + } + const r = await this.refreshAccessTokenAsync() + if ( + !r.credentials || + (r.credentials && !r.credentials.access_token) + ) { + throw new Error('Could not refresh access token.') + } + return { token: r.credentials.access_token, res: r.res } + } else { + return { token: this.credentials.access_token } + } + } + /** + * The main authentication interface. It takes an optional url which when + * present is the endpoint being accessed, and returns a Promise which + * resolves with authorization header fields. + * + * In OAuth2Client, the result has the form: + * { Authorization: 'Bearer ' } + * @param url The optional url being authorized + */ + async getRequestHeaders(url) { + const headers = (await this.getRequestMetadataAsync(url)).headers + return headers + } + async getRequestMetadataAsync( + // eslint-disable-next-line @typescript-eslint/no-unused-vars + url + ) { + const thisCreds = this.credentials + if ( + !thisCreds.access_token && + !thisCreds.refresh_token && + !this.apiKey + ) { + throw new Error('No access, refresh token or API key is set.') + } + if (thisCreds.access_token && !this.isTokenExpiring()) { + thisCreds.token_type = thisCreds.token_type || 'Bearer' + const headers = { + Authorization: thisCreds.token_type + ' ' + thisCreds.access_token + } + return { headers } + } + if (this.apiKey) { + return { headers: { 'X-Goog-Api-Key': this.apiKey } } + } + let r = null + let tokens = null + try { + r = await this.refreshToken(thisCreds.refresh_token) + tokens = r.tokens + } catch (err) { + const e = err + if ( + e.response && + (e.response.status === 403 || e.response.status === 404) + ) { + e.message = `Could not refresh access token: ${e.message}` + } + throw e + } + const credentials = this.credentials + credentials.token_type = credentials.token_type || 'Bearer' + tokens.refresh_token = credentials.refresh_token + this.credentials = tokens + const headers = { + Authorization: credentials.token_type + ' ' + tokens.access_token + } + return { headers: this.addSharedMetadataHeaders(headers), res: r.res } + } + /** + * Generates an URL to revoke the given token. + * @param token The existing token to be revoked. + */ + static getRevokeTokenUrl(token) { + const parameters = querystring.stringify({ token }) + return `${OAuth2Client.GOOGLE_OAUTH2_REVOKE_URL_}?${parameters}` + } + revokeToken(token, callback) { + const opts = { + url: OAuth2Client.getRevokeTokenUrl(token), + method: 'POST' + } + if (callback) { + this.transporter + .request(opts) + .then(r => callback(null, r), callback) + } else { + return this.transporter.request(opts) + } + } + revokeCredentials(callback) { + if (callback) { + this.revokeCredentialsAsync().then( + res => callback(null, res), + callback + ) + } else { + return this.revokeCredentialsAsync() + } + } + async revokeCredentialsAsync() { + const token = this.credentials.access_token + this.credentials = {} + if (token) { + return this.revokeToken(token) + } else { + throw new Error('No access token to revoke.') + } + } + request(opts, callback) { + if (callback) { + this.requestAsync(opts).then( + r => callback(null, r), + e => { + return callback(e, e.response) + } + ) + } else { + return this.requestAsync(opts) + } + } + async requestAsync(opts, retry = false) { + let r2 + try { + const r = await this.getRequestMetadataAsync(opts.url) + opts.headers = opts.headers || {} + if (r.headers && r.headers['x-goog-user-project']) { + opts.headers['x-goog-user-project'] = + r.headers['x-goog-user-project'] + } + if (r.headers && r.headers.Authorization) { + opts.headers.Authorization = r.headers.Authorization + } + if (this.apiKey) { + opts.headers['X-Goog-Api-Key'] = this.apiKey + } + r2 = await this.transporter.request(opts) + } catch (e) { + const res = e.response + if (res) { + const statusCode = res.status + // Retry the request for metadata if the following criteria are true: + // - We haven't already retried. It only makes sense to retry once. + // - The response was a 401 or a 403 + // - The request didn't send a readableStream + // - An access_token and refresh_token were available, but either no + // expiry_date was available or the forceRefreshOnFailure flag is set. + // The absent expiry_date case can happen when developers stash the + // access_token and refresh_token for later use, but the access_token + // fails on the first try because it's expired. Some developers may + // choose to enable forceRefreshOnFailure to mitigate time-related + // errors. + const mayRequireRefresh = + this.credentials && + this.credentials.access_token && + this.credentials.refresh_token && + (!this.credentials.expiry_date || this.forceRefreshOnFailure) + const isReadableStream = + res.config.data instanceof stream.Readable + const isAuthErr = statusCode === 401 || statusCode === 403 + if ( + !retry && + isAuthErr && + !isReadableStream && + mayRequireRefresh + ) { + await this.refreshAccessTokenAsync() + return this.requestAsync(opts, true) + } + } + throw e + } + return r2 + } + verifyIdToken(options, callback) { + // This function used to accept two arguments instead of an options object. + // Check the types to help users upgrade with less pain. + // This check can be removed after a 2.0 release. + if (callback && typeof callback !== 'function') { + throw new Error( + 'This method accepts an options object as the first parameter, which includes the idToken, audience, and maxExpiry.' + ) + } + if (callback) { + this.verifyIdTokenAsync(options).then( + r => callback(null, r), + callback + ) + } else { + return this.verifyIdTokenAsync(options) + } + } + async verifyIdTokenAsync(options) { + if (!options.idToken) { + throw new Error('The verifyIdToken method requires an ID Token') + } + const response = await this.getFederatedSignonCertsAsync() + const login = await this.verifySignedJwtWithCertsAsync( + options.idToken, + response.certs, + options.audience, + OAuth2Client.ISSUERS_, + options.maxExpiry + ) + return login + } + /** + * Obtains information about the provisioned access token. Especially useful + * if you want to check the scopes that were provisioned to a given token. + * + * @param accessToken Required. The Access Token for which you want to get + * user info. + */ + async getTokenInfo(accessToken) { + const { data } = await this.transporter.request({ + method: 'POST', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + }, + url: OAuth2Client.GOOGLE_TOKEN_INFO_URL, + data: querystring.stringify({ access_token: accessToken }) + }) + const info = Object.assign( + { + expiry_date: new Date().getTime() + data.expires_in * 1000, + scopes: data.scope.split(' ') + }, + data + ) + delete info.expires_in + delete info.scope + return info + } + getFederatedSignonCerts(callback) { + if (callback) { + this.getFederatedSignonCertsAsync().then( + r => callback(null, r.certs, r.res), + callback + ) + } else { + return this.getFederatedSignonCertsAsync() + } + } + async getFederatedSignonCertsAsync() { + const nowTime = new Date().getTime() + const format = crypto_1.hasBrowserCrypto() + ? CertificateFormat.JWK + : CertificateFormat.PEM + if ( + this.certificateExpiry && + nowTime < this.certificateExpiry.getTime() && + this.certificateCacheFormat === format + ) { + return { certs: this.certificateCache, format } + } + let res + let url + switch (format) { + case CertificateFormat.PEM: + url = OAuth2Client.GOOGLE_OAUTH2_FEDERATED_SIGNON_PEM_CERTS_URL_ + break + case CertificateFormat.JWK: + url = OAuth2Client.GOOGLE_OAUTH2_FEDERATED_SIGNON_JWK_CERTS_URL_ + break + default: + throw new Error(`Unsupported certificate format ${format}`) + } + try { + res = await this.transporter.request({ url }) + } catch (e) { + e.message = `Failed to retrieve verification certificates: ${e.message}` + throw e + } + const cacheControl = res ? res.headers['cache-control'] : undefined + let cacheAge = -1 + if (cacheControl) { + const pattern = new RegExp('max-age=([0-9]*)') + const regexResult = pattern.exec(cacheControl) + if (regexResult && regexResult.length === 2) { + // Cache results with max-age (in seconds) + cacheAge = Number(regexResult[1]) * 1000 // milliseconds + } + } + let certificates = {} + switch (format) { + case CertificateFormat.PEM: + certificates = res.data + break + case CertificateFormat.JWK: + for (const key of res.data.keys) { + certificates[key.kid] = key + } + break + default: + throw new Error(`Unsupported certificate format ${format}`) + } + const now = new Date() + this.certificateExpiry = + cacheAge === -1 ? null : new Date(now.getTime() + cacheAge) + this.certificateCache = certificates + this.certificateCacheFormat = format + return { certs: certificates, format, res } + } + getIapPublicKeys(callback) { + if (callback) { + this.getIapPublicKeysAsync().then( + r => callback(null, r.pubkeys, r.res), + callback + ) + } else { + return this.getIapPublicKeysAsync() + } + } + async getIapPublicKeysAsync() { + let res + const url = OAuth2Client.GOOGLE_OAUTH2_IAP_PUBLIC_KEY_URL_ + try { + res = await this.transporter.request({ url }) + } catch (e) { + e.message = `Failed to retrieve verification certificates: ${e.message}` + throw e + } + return { pubkeys: res.data, res } + } + verifySignedJwtWithCerts() { + // To make the code compatible with browser SubtleCrypto we need to make + // this method async. + throw new Error( + 'verifySignedJwtWithCerts is removed, please use verifySignedJwtWithCertsAsync instead.' + ) + } + /** + * Verify the id token is signed with the correct certificate + * and is from the correct audience. + * @param jwt The jwt to verify (The ID Token in this case). + * @param certs The array of certs to test the jwt against. + * @param requiredAudience The audience to test the jwt against. + * @param issuers The allowed issuers of the jwt (Optional). + * @param maxExpiry The max expiry the certificate can be (Optional). + * @return Returns a promise resolving to LoginTicket on verification. + */ + async verifySignedJwtWithCertsAsync( + jwt, + certs, + requiredAudience, + issuers, + maxExpiry + ) { + const crypto = crypto_1.createCrypto() + if (!maxExpiry) { + maxExpiry = OAuth2Client.MAX_TOKEN_LIFETIME_SECS_ + } + const segments = jwt.split('.') + if (segments.length !== 3) { + throw new Error('Wrong number of segments in token: ' + jwt) + } + const signed = segments[0] + '.' + segments[1] + let signature = segments[2] + let envelope + let payload + try { + envelope = JSON.parse(crypto.decodeBase64StringUtf8(segments[0])) + } catch (err) { + err.message = `Can't parse token envelope: ${segments[0]}': ${err.message}` + throw err + } + if (!envelope) { + throw new Error("Can't parse token envelope: " + segments[0]) + } + try { + payload = JSON.parse(crypto.decodeBase64StringUtf8(segments[1])) + } catch (err) { + err.message = `Can't parse token payload '${segments[0]}` + throw err + } + if (!payload) { + throw new Error("Can't parse token payload: " + segments[1]) + } + if (!Object.prototype.hasOwnProperty.call(certs, envelope.kid)) { + // If this is not present, then there's no reason to attempt verification + throw new Error( + 'No pem found for envelope: ' + JSON.stringify(envelope) + ) + } + const cert = certs[envelope.kid] + if (envelope.alg === 'ES256') { + signature = formatEcdsa + .joseToDer(signature, 'ES256') + .toString('base64') + } + const verified = await crypto.verify(cert, signed, signature) + if (!verified) { + throw new Error('Invalid token signature: ' + jwt) + } + if (!payload.iat) { + throw new Error( + 'No issue time in token: ' + JSON.stringify(payload) + ) + } + if (!payload.exp) { + throw new Error( + 'No expiration time in token: ' + JSON.stringify(payload) + ) + } + const iat = Number(payload.iat) + if (isNaN(iat)) throw new Error('iat field using invalid format') + const exp = Number(payload.exp) + if (isNaN(exp)) throw new Error('exp field using invalid format') + const now = new Date().getTime() / 1000 + if (exp >= now + maxExpiry) { + throw new Error( + 'Expiration time too far in future: ' + JSON.stringify(payload) + ) + } + const earliest = iat - OAuth2Client.CLOCK_SKEW_SECS_ + const latest = exp + OAuth2Client.CLOCK_SKEW_SECS_ + if (now < earliest) { + throw new Error( + 'Token used too early, ' + + now + + ' < ' + + earliest + + ': ' + + JSON.stringify(payload) + ) + } + if (now > latest) { + throw new Error( + 'Token used too late, ' + + now + + ' > ' + + latest + + ': ' + + JSON.stringify(payload) + ) + } + if (issuers && issuers.indexOf(payload.iss) < 0) { + throw new Error( + 'Invalid issuer, expected one of [' + + issuers + + '], but got ' + + payload.iss + ) + } + // Check the audience matches if we have one + if ( + typeof requiredAudience !== 'undefined' && + requiredAudience !== null + ) { + const aud = payload.aud + let audVerified = false + // If the requiredAudience is an array, check if it contains token + // audience + if (requiredAudience.constructor === Array) { + audVerified = requiredAudience.indexOf(aud) > -1 + } else { + audVerified = aud === requiredAudience + } + if (!audVerified) { + throw new Error( + 'Wrong recipient, payload audience != requiredAudience' + ) + } + } + return new loginticket_1.LoginTicket(envelope, payload) + } + /** + * Returns true if a token is expired or will expire within + * eagerRefreshThresholdMillismilliseconds. + * If there is no expiry time, assumes the token is not expired or expiring. + */ + isTokenExpiring() { + const expiryDate = this.credentials.expiry_date + return expiryDate + ? expiryDate <= + new Date().getTime() + this.eagerRefreshThresholdMillis + : false + } + } + exports.OAuth2Client = OAuth2Client + OAuth2Client.GOOGLE_TOKEN_INFO_URL = + 'https://oauth2.googleapis.com/tokeninfo' + /** + * The base URL for auth endpoints. + */ + OAuth2Client.GOOGLE_OAUTH2_AUTH_BASE_URL_ = + 'https://accounts.google.com/o/oauth2/v2/auth' + /** + * The base endpoint for token retrieval. + */ + OAuth2Client.GOOGLE_OAUTH2_TOKEN_URL_ = + 'https://oauth2.googleapis.com/token' + /** + * The base endpoint to revoke tokens. + */ + OAuth2Client.GOOGLE_OAUTH2_REVOKE_URL_ = + 'https://oauth2.googleapis.com/revoke' + /** + * Google Sign on certificates in PEM format. + */ + OAuth2Client.GOOGLE_OAUTH2_FEDERATED_SIGNON_PEM_CERTS_URL_ = + 'https://www.googleapis.com/oauth2/v1/certs' + /** + * Google Sign on certificates in JWK format. + */ + OAuth2Client.GOOGLE_OAUTH2_FEDERATED_SIGNON_JWK_CERTS_URL_ = + 'https://www.googleapis.com/oauth2/v3/certs' + /** + * Google Sign on certificates in JWK format. + */ + OAuth2Client.GOOGLE_OAUTH2_IAP_PUBLIC_KEY_URL_ = + 'https://www.gstatic.com/iap/verify/public_key' + /** + * Clock skew - five minutes in seconds + */ + OAuth2Client.CLOCK_SKEW_SECS_ = 300 + /** + * Max Token Lifetime is one day in seconds + */ + OAuth2Client.MAX_TOKEN_LIFETIME_SECS_ = 86400 + /** + * The allowed oauth token issuers. + */ + OAuth2Client.ISSUERS_ = [ + 'accounts.google.com', + 'https://accounts.google.com' + ] + //# sourceMappingURL=oauth2client.js.map + + /***/ + }, + + /***/ 98790: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + // Copyright 2015 Google LLC + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + Object.defineProperty(exports, '__esModule', { value: true }) + exports.UserRefreshClient = void 0 + const oauth2client_1 = __webpack_require__(3936) + class UserRefreshClient extends oauth2client_1.OAuth2Client { + constructor( + optionsOrClientId, + clientSecret, + refreshToken, + eagerRefreshThresholdMillis, + forceRefreshOnFailure + ) { + const opts = + optionsOrClientId && typeof optionsOrClientId === 'object' + ? optionsOrClientId + : { + clientId: optionsOrClientId, + clientSecret, + refreshToken, + eagerRefreshThresholdMillis, + forceRefreshOnFailure + } + super({ + clientId: opts.clientId, + clientSecret: opts.clientSecret, + eagerRefreshThresholdMillis: opts.eagerRefreshThresholdMillis, + forceRefreshOnFailure: opts.forceRefreshOnFailure + }) + this._refreshToken = opts.refreshToken + this.credentials.refresh_token = opts.refreshToken + } + /** + * Refreshes the access token. + * @param refreshToken An ignored refreshToken.. + * @param callback Optional callback. + */ + async refreshTokenNoCache( + // eslint-disable-next-line @typescript-eslint/no-unused-vars + refreshToken + ) { + return super.refreshTokenNoCache(this._refreshToken) + } + /** + * Create a UserRefreshClient credentials instance using the given input + * options. + * @param json The input object. + */ + fromJSON(json) { + if (!json) { + throw new Error( + 'Must pass in a JSON object containing the user refresh token' + ) + } + if (json.type !== 'authorized_user') { + throw new Error( + 'The incoming JSON object does not have the "authorized_user" type' + ) + } + if (!json.client_id) { + throw new Error( + 'The incoming JSON object does not contain a client_id field' + ) + } + if (!json.client_secret) { + throw new Error( + 'The incoming JSON object does not contain a client_secret field' + ) + } + if (!json.refresh_token) { + throw new Error( + 'The incoming JSON object does not contain a refresh_token field' + ) + } + this._clientId = json.client_id + this._clientSecret = json.client_secret + this._refreshToken = json.refresh_token + this.credentials.refresh_token = json.refresh_token + this.quotaProjectId = json.quota_project_id + } + fromStream(inputStream, callback) { + if (callback) { + this.fromStreamAsync(inputStream).then(() => callback(), callback) + } else { + return this.fromStreamAsync(inputStream) + } + } + async fromStreamAsync(inputStream) { + return new Promise((resolve, reject) => { + if (!inputStream) { + return reject( + new Error( + 'Must pass in a stream containing the user refresh token.' + ) + ) + } + let s = '' + inputStream + .setEncoding('utf8') + .on('error', reject) + .on('data', chunk => (s += chunk)) + .on('end', () => { + try { + const data = JSON.parse(s) + this.fromJSON(data) + return resolve() + } catch (err) { + return reject(err) + } + }) + }) + } + } + exports.UserRefreshClient = UserRefreshClient + //# sourceMappingURL=refreshclient.js.map + + /***/ + }, + + /***/ 14693: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + // Copyright 2019 Google LLC + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + /* global window */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.BrowserCrypto = void 0 + // This file implements crypto functions we need using in-browser + // SubtleCrypto interface `window.crypto.subtle`. + const base64js = __webpack_require__(26463) + // Not all browsers support `TextEncoder`. The following `require` will + // provide a fast UTF8-only replacement for those browsers that don't support + // text encoding natively. + // eslint-disable-next-line node/no-unsupported-features/node-builtins + if ( + typeof process === 'undefined' && + typeof TextEncoder === 'undefined' + ) { + __webpack_require__(21917) + } + class BrowserCrypto { + constructor() { + if ( + typeof window === 'undefined' || + window.crypto === undefined || + window.crypto.subtle === undefined + ) { + throw new Error( + "SubtleCrypto not found. Make sure it's an https:// website." + ) + } + } + async sha256DigestBase64(str) { + // SubtleCrypto digest() method is async, so we must make + // this method async as well. + // To calculate SHA256 digest using SubtleCrypto, we first + // need to convert an input string to an ArrayBuffer: + // eslint-disable-next-line node/no-unsupported-features/node-builtins + const inputBuffer = new TextEncoder().encode(str) + // Result is ArrayBuffer as well. + const outputBuffer = await window.crypto.subtle.digest( + 'SHA-256', + inputBuffer + ) + return base64js.fromByteArray(new Uint8Array(outputBuffer)) + } + randomBytesBase64(count) { + const array = new Uint8Array(count) + window.crypto.getRandomValues(array) + return base64js.fromByteArray(array) + } + static padBase64(base64) { + // base64js requires padding, so let's add some '=' + while (base64.length % 4 !== 0) { + base64 += '=' + } + return base64 + } + async verify(pubkey, data, signature) { + const algo = { + name: 'RSASSA-PKCS1-v1_5', + hash: { name: 'SHA-256' } + } + // eslint-disable-next-line node/no-unsupported-features/node-builtins + const dataArray = new TextEncoder().encode(data) + const signatureArray = base64js.toByteArray( + BrowserCrypto.padBase64(signature) + ) + const cryptoKey = await window.crypto.subtle.importKey( + 'jwk', + pubkey, + algo, + true, + ['verify'] + ) + // SubtleCrypto's verify method is async so we must make + // this method async as well. + const result = await window.crypto.subtle.verify( + algo, + cryptoKey, + signatureArray, + dataArray + ) + return result + } + async sign(privateKey, data) { + const algo = { + name: 'RSASSA-PKCS1-v1_5', + hash: { name: 'SHA-256' } + } + // eslint-disable-next-line node/no-unsupported-features/node-builtins + const dataArray = new TextEncoder().encode(data) + const cryptoKey = await window.crypto.subtle.importKey( + 'jwk', + privateKey, + algo, + true, + ['sign'] + ) + // SubtleCrypto's sign method is async so we must make + // this method async as well. + const result = await window.crypto.subtle.sign( + algo, + cryptoKey, + dataArray + ) + return base64js.fromByteArray(new Uint8Array(result)) + } + decodeBase64StringUtf8(base64) { + const uint8array = base64js.toByteArray( + BrowserCrypto.padBase64(base64) + ) + // eslint-disable-next-line node/no-unsupported-features/node-builtins + const result = new TextDecoder().decode(uint8array) + return result + } + encodeBase64StringUtf8(text) { + // eslint-disable-next-line node/no-unsupported-features/node-builtins + const uint8array = new TextEncoder().encode(text) + const result = base64js.fromByteArray(uint8array) + return result + } + } + exports.BrowserCrypto = BrowserCrypto + //# sourceMappingURL=crypto.js.map + + /***/ + }, + + /***/ 78043: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + // Copyright 2019 Google LLC + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + /* global window */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.hasBrowserCrypto = exports.createCrypto = void 0 + const crypto_1 = __webpack_require__(14693) + const crypto_2 = __webpack_require__(30757) + function createCrypto() { + if (hasBrowserCrypto()) { + return new crypto_1.BrowserCrypto() + } + return new crypto_2.NodeCrypto() + } + exports.createCrypto = createCrypto + function hasBrowserCrypto() { + return ( + typeof window !== 'undefined' && + typeof window.crypto !== 'undefined' && + typeof window.crypto.subtle !== 'undefined' + ) + } + exports.hasBrowserCrypto = hasBrowserCrypto + //# sourceMappingURL=crypto.js.map + + /***/ + }, + + /***/ 30757: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + // Copyright 2019 Google LLC + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + Object.defineProperty(exports, '__esModule', { value: true }) + exports.NodeCrypto = void 0 + const crypto = __webpack_require__(76417) + class NodeCrypto { + async sha256DigestBase64(str) { + return crypto.createHash('sha256').update(str).digest('base64') + } + randomBytesBase64(count) { + return crypto.randomBytes(count).toString('base64') + } + async verify(pubkey, data, signature) { + const verifier = crypto.createVerify('sha256') + verifier.update(data) + verifier.end() + return verifier.verify(pubkey, signature, 'base64') + } + async sign(privateKey, data) { + const signer = crypto.createSign('RSA-SHA256') + signer.update(data) + signer.end() + return signer.sign(privateKey, 'base64') + } + decodeBase64StringUtf8(base64) { + return Buffer.from(base64, 'base64').toString('utf-8') + } + encodeBase64StringUtf8(text) { + return Buffer.from(text, 'utf-8').toString('base64') + } + } + exports.NodeCrypto = NodeCrypto + //# sourceMappingURL=crypto.js.map + + /***/ + }, + + /***/ 20810: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + Object.defineProperty(exports, '__esModule', { value: true }) + exports.GoogleAuth = exports.auth = void 0 + // Copyright 2017 Google LLC + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + const googleauth_1 = __webpack_require__(20695) + Object.defineProperty(exports, 'GoogleAuth', { + enumerable: true, + get: function () { + return googleauth_1.GoogleAuth + } + }) + var computeclient_1 = __webpack_require__(96875) + Object.defineProperty(exports, 'Compute', { + enumerable: true, + get: function () { + return computeclient_1.Compute + } + }) + var envDetect_1 = __webpack_require__(21380) + Object.defineProperty(exports, 'GCPEnv', { + enumerable: true, + get: function () { + return envDetect_1.GCPEnv + } + }) + var iam_1 = __webpack_require__(39735) + Object.defineProperty(exports, 'IAMAuth', { + enumerable: true, + get: function () { + return iam_1.IAMAuth + } + }) + var idtokenclient_1 = __webpack_require__(80298) + Object.defineProperty(exports, 'IdTokenClient', { + enumerable: true, + get: function () { + return idtokenclient_1.IdTokenClient + } + }) + var jwtaccess_1 = __webpack_require__(68740) + Object.defineProperty(exports, 'JWTAccess', { + enumerable: true, + get: function () { + return jwtaccess_1.JWTAccess + } + }) + var jwtclient_1 = __webpack_require__(13959) + Object.defineProperty(exports, 'JWT', { + enumerable: true, + get: function () { + return jwtclient_1.JWT + } + }) + var oauth2client_1 = __webpack_require__(3936) + Object.defineProperty(exports, 'CodeChallengeMethod', { + enumerable: true, + get: function () { + return oauth2client_1.CodeChallengeMethod + } + }) + Object.defineProperty(exports, 'OAuth2Client', { + enumerable: true, + get: function () { + return oauth2client_1.OAuth2Client + } + }) + var loginticket_1 = __webpack_require__(74524) + Object.defineProperty(exports, 'LoginTicket', { + enumerable: true, + get: function () { + return loginticket_1.LoginTicket + } + }) + var refreshclient_1 = __webpack_require__(98790) + Object.defineProperty(exports, 'UserRefreshClient', { + enumerable: true, + get: function () { + return refreshclient_1.UserRefreshClient + } + }) + var transporters_1 = __webpack_require__(72649) + Object.defineProperty(exports, 'DefaultTransporter', { + enumerable: true, + get: function () { + return transporters_1.DefaultTransporter + } + }) + const auth = new googleauth_1.GoogleAuth() + exports.auth = auth + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 16608: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + // Copyright 2017 Google LLC + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + Object.defineProperty(exports, '__esModule', { value: true }) + exports.validate = void 0 + // Accepts an options object passed from the user to the API. In the + // previous version of the API, it referred to a `Request` options object. + // Now it refers to an Axiox Request Config object. This is here to help + // ensure users don't pass invalid options when they upgrade from 0.x to 1.x. + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function validate(options) { + const vpairs = [ + { invalid: 'uri', expected: 'url' }, + { invalid: 'json', expected: 'data' }, + { invalid: 'qs', expected: 'params' } + ] + for (const pair of vpairs) { + if (options[pair.invalid]) { + const e = `'${pair.invalid}' is not a valid configuration option. Please use '${pair.expected}' instead. This library is using Axios for requests. Please see https://github.com/axios/axios to learn more about the valid request options.` + throw new Error(e) + } + } + } + exports.validate = validate + //# sourceMappingURL=options.js.map + + /***/ + }, + + /***/ 72649: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + // Copyright 2019 Google LLC + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + Object.defineProperty(exports, '__esModule', { value: true }) + exports.DefaultTransporter = void 0 + const gaxios_1 = __webpack_require__(59555) + const options_1 = __webpack_require__(16608) + // eslint-disable-next-line @typescript-eslint/no-var-requires + const pkg = __webpack_require__(85477) + const PRODUCT_NAME = 'google-api-nodejs-client' + class DefaultTransporter { + /** + * Configures request options before making a request. + * @param opts GaxiosOptions options. + * @return Configured options. + */ + configure(opts = {}) { + opts.headers = opts.headers || {} + if (typeof window === 'undefined') { + // set transporter user agent if not in browser + const uaValue = opts.headers['User-Agent'] + if (!uaValue) { + opts.headers['User-Agent'] = DefaultTransporter.USER_AGENT + } else if (!uaValue.includes(`${PRODUCT_NAME}/`)) { + opts.headers[ + 'User-Agent' + ] = `${uaValue} ${DefaultTransporter.USER_AGENT}` + } + // track google-auth-library-nodejs version: + const authVersion = `auth/${pkg.version}` + if ( + opts.headers['x-goog-api-client'] && + !opts.headers['x-goog-api-client'].includes(authVersion) + ) { + opts.headers[ + 'x-goog-api-client' + ] = `${opts.headers['x-goog-api-client']} ${authVersion}` + } else if (!opts.headers['x-goog-api-client']) { + const nodeVersion = process.version.replace(/^v/, '') + opts.headers[ + 'x-goog-api-client' + ] = `gl-node/${nodeVersion} ${authVersion}` + } + } + return opts + } + request(opts, callback) { + // ensure the user isn't passing in request-style options + opts = this.configure(opts) + try { + options_1.validate(opts) + } catch (e) { + if (callback) { + return callback(e) + } else { + throw e + } + } + if (callback) { + gaxios_1.request(opts).then( + r => { + callback(null, r) + }, + e => { + callback(this.processError(e)) + } + ) + } else { + return gaxios_1.request(opts).catch(e => { + throw this.processError(e) + }) + } + } + /** + * Changes the error to include details from the body. + */ + processError(e) { + const res = e.response + const err = e + const body = res ? res.data : null + if (res && body && body.error && res.status !== 200) { + if (typeof body.error === 'string') { + err.message = body.error + err.code = res.status.toString() + } else if (Array.isArray(body.error.errors)) { + err.message = body.error.errors + .map(err2 => err2.message) + .join('\n') + err.code = body.error.code + err.errors = body.error.errors + } else { + err.message = body.error.message + err.code = body.error.code || res.status + } + } else if (res && res.status >= 400) { + // Consider all 4xx and 5xx responses errors. + err.message = body + err.code = res.status.toString() + } + return err + } + } + exports.DefaultTransporter = DefaultTransporter + /** + * Default user agent. + */ + DefaultTransporter.USER_AGENT = `${PRODUCT_NAME}/${pkg.version}` + //# sourceMappingURL=transporters.js.map + + /***/ + }, + + /***/ 83555: /***/ function ( + module, + __unused_webpack_exports, + __webpack_require__ + ) { + /* module decorator */ module = __webpack_require__.nmd(module) + // Copyright 2020 Google LLC + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + + /*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/ + ;(function (global, factory) { + /* global define, require, module */ + + /* AMD */ if (typeof define === 'function' && define.amd) + define(['protobufjs/minimal'], factory) + /* CommonJS */ else if (true && module && module.exports) + module.exports = factory(__webpack_require__(96916)) + })(this, function ($protobuf) { + 'use strict' + + // Common aliases + var $Reader = $protobuf.Reader, + $Writer = $protobuf.Writer, + $util = $protobuf.util + + // Exported root namespace + var $root = + $protobuf.roots.iam_protos || ($protobuf.roots.iam_protos = {}) + + $root.google = (function () { + /** + * Namespace google. + * @exports google + * @namespace + */ + var google = {} + + google.iam = (function () { + /** + * Namespace iam. + * @memberof google + * @namespace + */ + var iam = {} + + iam.v1 = (function () { + /** + * Namespace v1. + * @memberof google.iam + * @namespace + */ + var v1 = {} + + v1.IAMPolicy = (function () { + /** + * Constructs a new IAMPolicy service. + * @memberof google.iam.v1 + * @classdesc Represents a IAMPolicy + * @extends $protobuf.rpc.Service + * @constructor + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + */ + function IAMPolicy( + rpcImpl, + requestDelimited, + responseDelimited + ) { + $protobuf.rpc.Service.call( + this, + rpcImpl, + requestDelimited, + responseDelimited + ) + } + + ;(IAMPolicy.prototype = Object.create( + $protobuf.rpc.Service.prototype + )).constructor = IAMPolicy + + /** + * Creates new IAMPolicy service using the specified rpc implementation. + * @function create + * @memberof google.iam.v1.IAMPolicy + * @static + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + * @returns {IAMPolicy} RPC service. Useful where requests and/or responses are streamed. + */ + IAMPolicy.create = function create( + rpcImpl, + requestDelimited, + responseDelimited + ) { + return new this(rpcImpl, requestDelimited, responseDelimited) + } + + /** + * Callback as used by {@link google.iam.v1.IAMPolicy#setIamPolicy}. + * @memberof google.iam.v1.IAMPolicy + * @typedef SetIamPolicyCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.iam.v1.Policy} [response] Policy + */ + + /** + * Calls SetIamPolicy. + * @function setIamPolicy + * @memberof google.iam.v1.IAMPolicy + * @instance + * @param {google.iam.v1.ISetIamPolicyRequest} request SetIamPolicyRequest message or plain object + * @param {google.iam.v1.IAMPolicy.SetIamPolicyCallback} callback Node-style callback called with the error, if any, and Policy + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty( + (IAMPolicy.prototype.setIamPolicy = function setIamPolicy( + request, + callback + ) { + return this.rpcCall( + setIamPolicy, + $root.google.iam.v1.SetIamPolicyRequest, + $root.google.iam.v1.Policy, + request, + callback + ) + }), + 'name', + { value: 'SetIamPolicy' } + ) + + /** + * Calls SetIamPolicy. + * @function setIamPolicy + * @memberof google.iam.v1.IAMPolicy + * @instance + * @param {google.iam.v1.ISetIamPolicyRequest} request SetIamPolicyRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.iam.v1.IAMPolicy#getIamPolicy}. + * @memberof google.iam.v1.IAMPolicy + * @typedef GetIamPolicyCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.iam.v1.Policy} [response] Policy + */ + + /** + * Calls GetIamPolicy. + * @function getIamPolicy + * @memberof google.iam.v1.IAMPolicy + * @instance + * @param {google.iam.v1.IGetIamPolicyRequest} request GetIamPolicyRequest message or plain object + * @param {google.iam.v1.IAMPolicy.GetIamPolicyCallback} callback Node-style callback called with the error, if any, and Policy + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty( + (IAMPolicy.prototype.getIamPolicy = function getIamPolicy( + request, + callback + ) { + return this.rpcCall( + getIamPolicy, + $root.google.iam.v1.GetIamPolicyRequest, + $root.google.iam.v1.Policy, + request, + callback + ) + }), + 'name', + { value: 'GetIamPolicy' } + ) + + /** + * Calls GetIamPolicy. + * @function getIamPolicy + * @memberof google.iam.v1.IAMPolicy + * @instance + * @param {google.iam.v1.IGetIamPolicyRequest} request GetIamPolicyRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.iam.v1.IAMPolicy#testIamPermissions}. + * @memberof google.iam.v1.IAMPolicy + * @typedef TestIamPermissionsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.iam.v1.TestIamPermissionsResponse} [response] TestIamPermissionsResponse + */ + + /** + * Calls TestIamPermissions. + * @function testIamPermissions + * @memberof google.iam.v1.IAMPolicy + * @instance + * @param {google.iam.v1.ITestIamPermissionsRequest} request TestIamPermissionsRequest message or plain object + * @param {google.iam.v1.IAMPolicy.TestIamPermissionsCallback} callback Node-style callback called with the error, if any, and TestIamPermissionsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty( + (IAMPolicy.prototype.testIamPermissions = function testIamPermissions( + request, + callback + ) { + return this.rpcCall( + testIamPermissions, + $root.google.iam.v1.TestIamPermissionsRequest, + $root.google.iam.v1.TestIamPermissionsResponse, + request, + callback + ) + }), + 'name', + { value: 'TestIamPermissions' } + ) + + /** + * Calls TestIamPermissions. + * @function testIamPermissions + * @memberof google.iam.v1.IAMPolicy + * @instance + * @param {google.iam.v1.ITestIamPermissionsRequest} request TestIamPermissionsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return IAMPolicy + })() + + v1.SetIamPolicyRequest = (function () { + /** + * Properties of a SetIamPolicyRequest. + * @memberof google.iam.v1 + * @interface ISetIamPolicyRequest + * @property {string|null} [resource] SetIamPolicyRequest resource + * @property {google.iam.v1.IPolicy|null} [policy] SetIamPolicyRequest policy + */ + + /** + * Constructs a new SetIamPolicyRequest. + * @memberof google.iam.v1 + * @classdesc Represents a SetIamPolicyRequest. + * @implements ISetIamPolicyRequest + * @constructor + * @param {google.iam.v1.ISetIamPolicyRequest=} [properties] Properties to set + */ + function SetIamPolicyRequest(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * SetIamPolicyRequest resource. + * @member {string} resource + * @memberof google.iam.v1.SetIamPolicyRequest + * @instance + */ + SetIamPolicyRequest.prototype.resource = '' + + /** + * SetIamPolicyRequest policy. + * @member {google.iam.v1.IPolicy|null|undefined} policy + * @memberof google.iam.v1.SetIamPolicyRequest + * @instance + */ + SetIamPolicyRequest.prototype.policy = null + + /** + * Creates a new SetIamPolicyRequest instance using the specified properties. + * @function create + * @memberof google.iam.v1.SetIamPolicyRequest + * @static + * @param {google.iam.v1.ISetIamPolicyRequest=} [properties] Properties to set + * @returns {google.iam.v1.SetIamPolicyRequest} SetIamPolicyRequest instance + */ + SetIamPolicyRequest.create = function create(properties) { + return new SetIamPolicyRequest(properties) + } + + /** + * Encodes the specified SetIamPolicyRequest message. Does not implicitly {@link google.iam.v1.SetIamPolicyRequest.verify|verify} messages. + * @function encode + * @memberof google.iam.v1.SetIamPolicyRequest + * @static + * @param {google.iam.v1.ISetIamPolicyRequest} message SetIamPolicyRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SetIamPolicyRequest.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.resource != null && + message.hasOwnProperty('resource') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.resource) + if ( + message.policy != null && + message.hasOwnProperty('policy') + ) + $root.google.iam.v1.Policy.encode( + message.policy, + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified SetIamPolicyRequest message, length delimited. Does not implicitly {@link google.iam.v1.SetIamPolicyRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.iam.v1.SetIamPolicyRequest + * @static + * @param {google.iam.v1.ISetIamPolicyRequest} message SetIamPolicyRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SetIamPolicyRequest.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a SetIamPolicyRequest message from the specified reader or buffer. + * @function decode + * @memberof google.iam.v1.SetIamPolicyRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.iam.v1.SetIamPolicyRequest} SetIamPolicyRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SetIamPolicyRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.iam.v1.SetIamPolicyRequest() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.resource = reader.string() + break + case 2: + message.policy = $root.google.iam.v1.Policy.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a SetIamPolicyRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.iam.v1.SetIamPolicyRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.iam.v1.SetIamPolicyRequest} SetIamPolicyRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SetIamPolicyRequest.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a SetIamPolicyRequest message. + * @function verify + * @memberof google.iam.v1.SetIamPolicyRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SetIamPolicyRequest.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.resource != null && + message.hasOwnProperty('resource') + ) + if (!$util.isString(message.resource)) + return 'resource: string expected' + if ( + message.policy != null && + message.hasOwnProperty('policy') + ) { + var error = $root.google.iam.v1.Policy.verify( + message.policy + ) + if (error) return 'policy.' + error + } + return null + } + + /** + * Creates a SetIamPolicyRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.iam.v1.SetIamPolicyRequest + * @static + * @param {Object.} object Plain object + * @returns {google.iam.v1.SetIamPolicyRequest} SetIamPolicyRequest + */ + SetIamPolicyRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.iam.v1.SetIamPolicyRequest) + return object + var message = new $root.google.iam.v1.SetIamPolicyRequest() + if (object.resource != null) + message.resource = String(object.resource) + if (object.policy != null) { + if (typeof object.policy !== 'object') + throw TypeError( + '.google.iam.v1.SetIamPolicyRequest.policy: object expected' + ) + message.policy = $root.google.iam.v1.Policy.fromObject( + object.policy + ) + } + return message + } + + /** + * Creates a plain object from a SetIamPolicyRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.iam.v1.SetIamPolicyRequest + * @static + * @param {google.iam.v1.SetIamPolicyRequest} message SetIamPolicyRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SetIamPolicyRequest.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.resource = '' + object.policy = null + } + if ( + message.resource != null && + message.hasOwnProperty('resource') + ) + object.resource = message.resource + if ( + message.policy != null && + message.hasOwnProperty('policy') + ) + object.policy = $root.google.iam.v1.Policy.toObject( + message.policy, + options + ) + return object + } + + /** + * Converts this SetIamPolicyRequest to JSON. + * @function toJSON + * @memberof google.iam.v1.SetIamPolicyRequest + * @instance + * @returns {Object.} JSON object + */ + SetIamPolicyRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return SetIamPolicyRequest + })() + + v1.GetIamPolicyRequest = (function () { + /** + * Properties of a GetIamPolicyRequest. + * @memberof google.iam.v1 + * @interface IGetIamPolicyRequest + * @property {string|null} [resource] GetIamPolicyRequest resource + * @property {google.iam.v1.IGetPolicyOptions|null} [options] GetIamPolicyRequest options + */ + + /** + * Constructs a new GetIamPolicyRequest. + * @memberof google.iam.v1 + * @classdesc Represents a GetIamPolicyRequest. + * @implements IGetIamPolicyRequest + * @constructor + * @param {google.iam.v1.IGetIamPolicyRequest=} [properties] Properties to set + */ + function GetIamPolicyRequest(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * GetIamPolicyRequest resource. + * @member {string} resource + * @memberof google.iam.v1.GetIamPolicyRequest + * @instance + */ + GetIamPolicyRequest.prototype.resource = '' + + /** + * GetIamPolicyRequest options. + * @member {google.iam.v1.IGetPolicyOptions|null|undefined} options + * @memberof google.iam.v1.GetIamPolicyRequest + * @instance + */ + GetIamPolicyRequest.prototype.options = null + + /** + * Creates a new GetIamPolicyRequest instance using the specified properties. + * @function create + * @memberof google.iam.v1.GetIamPolicyRequest + * @static + * @param {google.iam.v1.IGetIamPolicyRequest=} [properties] Properties to set + * @returns {google.iam.v1.GetIamPolicyRequest} GetIamPolicyRequest instance + */ + GetIamPolicyRequest.create = function create(properties) { + return new GetIamPolicyRequest(properties) + } + + /** + * Encodes the specified GetIamPolicyRequest message. Does not implicitly {@link google.iam.v1.GetIamPolicyRequest.verify|verify} messages. + * @function encode + * @memberof google.iam.v1.GetIamPolicyRequest + * @static + * @param {google.iam.v1.IGetIamPolicyRequest} message GetIamPolicyRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetIamPolicyRequest.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.resource != null && + message.hasOwnProperty('resource') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.resource) + if ( + message.options != null && + message.hasOwnProperty('options') + ) + $root.google.iam.v1.GetPolicyOptions.encode( + message.options, + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified GetIamPolicyRequest message, length delimited. Does not implicitly {@link google.iam.v1.GetIamPolicyRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.iam.v1.GetIamPolicyRequest + * @static + * @param {google.iam.v1.IGetIamPolicyRequest} message GetIamPolicyRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetIamPolicyRequest.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a GetIamPolicyRequest message from the specified reader or buffer. + * @function decode + * @memberof google.iam.v1.GetIamPolicyRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.iam.v1.GetIamPolicyRequest} GetIamPolicyRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetIamPolicyRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.iam.v1.GetIamPolicyRequest() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.resource = reader.string() + break + case 2: + message.options = $root.google.iam.v1.GetPolicyOptions.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a GetIamPolicyRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.iam.v1.GetIamPolicyRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.iam.v1.GetIamPolicyRequest} GetIamPolicyRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetIamPolicyRequest.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a GetIamPolicyRequest message. + * @function verify + * @memberof google.iam.v1.GetIamPolicyRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetIamPolicyRequest.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.resource != null && + message.hasOwnProperty('resource') + ) + if (!$util.isString(message.resource)) + return 'resource: string expected' + if ( + message.options != null && + message.hasOwnProperty('options') + ) { + var error = $root.google.iam.v1.GetPolicyOptions.verify( + message.options + ) + if (error) return 'options.' + error + } + return null + } + + /** + * Creates a GetIamPolicyRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.iam.v1.GetIamPolicyRequest + * @static + * @param {Object.} object Plain object + * @returns {google.iam.v1.GetIamPolicyRequest} GetIamPolicyRequest + */ + GetIamPolicyRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.iam.v1.GetIamPolicyRequest) + return object + var message = new $root.google.iam.v1.GetIamPolicyRequest() + if (object.resource != null) + message.resource = String(object.resource) + if (object.options != null) { + if (typeof object.options !== 'object') + throw TypeError( + '.google.iam.v1.GetIamPolicyRequest.options: object expected' + ) + message.options = $root.google.iam.v1.GetPolicyOptions.fromObject( + object.options + ) + } + return message + } + + /** + * Creates a plain object from a GetIamPolicyRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.iam.v1.GetIamPolicyRequest + * @static + * @param {google.iam.v1.GetIamPolicyRequest} message GetIamPolicyRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetIamPolicyRequest.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.resource = '' + object.options = null + } + if ( + message.resource != null && + message.hasOwnProperty('resource') + ) + object.resource = message.resource + if ( + message.options != null && + message.hasOwnProperty('options') + ) + object.options = $root.google.iam.v1.GetPolicyOptions.toObject( + message.options, + options + ) + return object + } + + /** + * Converts this GetIamPolicyRequest to JSON. + * @function toJSON + * @memberof google.iam.v1.GetIamPolicyRequest + * @instance + * @returns {Object.} JSON object + */ + GetIamPolicyRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return GetIamPolicyRequest + })() + + v1.TestIamPermissionsRequest = (function () { + /** + * Properties of a TestIamPermissionsRequest. + * @memberof google.iam.v1 + * @interface ITestIamPermissionsRequest + * @property {string|null} [resource] TestIamPermissionsRequest resource + * @property {Array.|null} [permissions] TestIamPermissionsRequest permissions + */ + + /** + * Constructs a new TestIamPermissionsRequest. + * @memberof google.iam.v1 + * @classdesc Represents a TestIamPermissionsRequest. + * @implements ITestIamPermissionsRequest + * @constructor + * @param {google.iam.v1.ITestIamPermissionsRequest=} [properties] Properties to set + */ + function TestIamPermissionsRequest(properties) { + this.permissions = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * TestIamPermissionsRequest resource. + * @member {string} resource + * @memberof google.iam.v1.TestIamPermissionsRequest + * @instance + */ + TestIamPermissionsRequest.prototype.resource = '' + + /** + * TestIamPermissionsRequest permissions. + * @member {Array.} permissions + * @memberof google.iam.v1.TestIamPermissionsRequest + * @instance + */ + TestIamPermissionsRequest.prototype.permissions = + $util.emptyArray + + /** + * Creates a new TestIamPermissionsRequest instance using the specified properties. + * @function create + * @memberof google.iam.v1.TestIamPermissionsRequest + * @static + * @param {google.iam.v1.ITestIamPermissionsRequest=} [properties] Properties to set + * @returns {google.iam.v1.TestIamPermissionsRequest} TestIamPermissionsRequest instance + */ + TestIamPermissionsRequest.create = function create(properties) { + return new TestIamPermissionsRequest(properties) + } + + /** + * Encodes the specified TestIamPermissionsRequest message. Does not implicitly {@link google.iam.v1.TestIamPermissionsRequest.verify|verify} messages. + * @function encode + * @memberof google.iam.v1.TestIamPermissionsRequest + * @static + * @param {google.iam.v1.ITestIamPermissionsRequest} message TestIamPermissionsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TestIamPermissionsRequest.encode = function encode( + message, + writer + ) { + if (!writer) writer = $Writer.create() + if ( + message.resource != null && + message.hasOwnProperty('resource') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.resource) + if (message.permissions != null && message.permissions.length) + for (var i = 0; i < message.permissions.length; ++i) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.permissions[i]) + return writer + } + + /** + * Encodes the specified TestIamPermissionsRequest message, length delimited. Does not implicitly {@link google.iam.v1.TestIamPermissionsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.iam.v1.TestIamPermissionsRequest + * @static + * @param {google.iam.v1.ITestIamPermissionsRequest} message TestIamPermissionsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TestIamPermissionsRequest.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a TestIamPermissionsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.iam.v1.TestIamPermissionsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.iam.v1.TestIamPermissionsRequest} TestIamPermissionsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TestIamPermissionsRequest.decode = function decode( + reader, + length + ) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.iam.v1.TestIamPermissionsRequest() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.resource = reader.string() + break + case 2: + if ( + !(message.permissions && message.permissions.length) + ) + message.permissions = [] + message.permissions.push(reader.string()) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a TestIamPermissionsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.iam.v1.TestIamPermissionsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.iam.v1.TestIamPermissionsRequest} TestIamPermissionsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TestIamPermissionsRequest.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a TestIamPermissionsRequest message. + * @function verify + * @memberof google.iam.v1.TestIamPermissionsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + TestIamPermissionsRequest.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.resource != null && + message.hasOwnProperty('resource') + ) + if (!$util.isString(message.resource)) + return 'resource: string expected' + if ( + message.permissions != null && + message.hasOwnProperty('permissions') + ) { + if (!Array.isArray(message.permissions)) + return 'permissions: array expected' + for (var i = 0; i < message.permissions.length; ++i) + if (!$util.isString(message.permissions[i])) + return 'permissions: string[] expected' + } + return null + } + + /** + * Creates a TestIamPermissionsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.iam.v1.TestIamPermissionsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.iam.v1.TestIamPermissionsRequest} TestIamPermissionsRequest + */ + TestIamPermissionsRequest.fromObject = function fromObject( + object + ) { + if ( + object instanceof + $root.google.iam.v1.TestIamPermissionsRequest + ) + return object + var message = new $root.google.iam.v1.TestIamPermissionsRequest() + if (object.resource != null) + message.resource = String(object.resource) + if (object.permissions) { + if (!Array.isArray(object.permissions)) + throw TypeError( + '.google.iam.v1.TestIamPermissionsRequest.permissions: array expected' + ) + message.permissions = [] + for (var i = 0; i < object.permissions.length; ++i) + message.permissions[i] = String(object.permissions[i]) + } + return message + } + + /** + * Creates a plain object from a TestIamPermissionsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.iam.v1.TestIamPermissionsRequest + * @static + * @param {google.iam.v1.TestIamPermissionsRequest} message TestIamPermissionsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + TestIamPermissionsRequest.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) + object.permissions = [] + if (options.defaults) object.resource = '' + if ( + message.resource != null && + message.hasOwnProperty('resource') + ) + object.resource = message.resource + if (message.permissions && message.permissions.length) { + object.permissions = [] + for (var j = 0; j < message.permissions.length; ++j) + object.permissions[j] = message.permissions[j] + } + return object + } + + /** + * Converts this TestIamPermissionsRequest to JSON. + * @function toJSON + * @memberof google.iam.v1.TestIamPermissionsRequest + * @instance + * @returns {Object.} JSON object + */ + TestIamPermissionsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return TestIamPermissionsRequest + })() + + v1.TestIamPermissionsResponse = (function () { + /** + * Properties of a TestIamPermissionsResponse. + * @memberof google.iam.v1 + * @interface ITestIamPermissionsResponse + * @property {Array.|null} [permissions] TestIamPermissionsResponse permissions + */ + + /** + * Constructs a new TestIamPermissionsResponse. + * @memberof google.iam.v1 + * @classdesc Represents a TestIamPermissionsResponse. + * @implements ITestIamPermissionsResponse + * @constructor + * @param {google.iam.v1.ITestIamPermissionsResponse=} [properties] Properties to set + */ + function TestIamPermissionsResponse(properties) { + this.permissions = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * TestIamPermissionsResponse permissions. + * @member {Array.} permissions + * @memberof google.iam.v1.TestIamPermissionsResponse + * @instance + */ + TestIamPermissionsResponse.prototype.permissions = + $util.emptyArray + + /** + * Creates a new TestIamPermissionsResponse instance using the specified properties. + * @function create + * @memberof google.iam.v1.TestIamPermissionsResponse + * @static + * @param {google.iam.v1.ITestIamPermissionsResponse=} [properties] Properties to set + * @returns {google.iam.v1.TestIamPermissionsResponse} TestIamPermissionsResponse instance + */ + TestIamPermissionsResponse.create = function create( + properties + ) { + return new TestIamPermissionsResponse(properties) + } + + /** + * Encodes the specified TestIamPermissionsResponse message. Does not implicitly {@link google.iam.v1.TestIamPermissionsResponse.verify|verify} messages. + * @function encode + * @memberof google.iam.v1.TestIamPermissionsResponse + * @static + * @param {google.iam.v1.ITestIamPermissionsResponse} message TestIamPermissionsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TestIamPermissionsResponse.encode = function encode( + message, + writer + ) { + if (!writer) writer = $Writer.create() + if (message.permissions != null && message.permissions.length) + for (var i = 0; i < message.permissions.length; ++i) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.permissions[i]) + return writer + } + + /** + * Encodes the specified TestIamPermissionsResponse message, length delimited. Does not implicitly {@link google.iam.v1.TestIamPermissionsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.iam.v1.TestIamPermissionsResponse + * @static + * @param {google.iam.v1.ITestIamPermissionsResponse} message TestIamPermissionsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TestIamPermissionsResponse.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a TestIamPermissionsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.iam.v1.TestIamPermissionsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.iam.v1.TestIamPermissionsResponse} TestIamPermissionsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TestIamPermissionsResponse.decode = function decode( + reader, + length + ) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.iam.v1.TestIamPermissionsResponse() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + if ( + !(message.permissions && message.permissions.length) + ) + message.permissions = [] + message.permissions.push(reader.string()) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a TestIamPermissionsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.iam.v1.TestIamPermissionsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.iam.v1.TestIamPermissionsResponse} TestIamPermissionsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TestIamPermissionsResponse.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a TestIamPermissionsResponse message. + * @function verify + * @memberof google.iam.v1.TestIamPermissionsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + TestIamPermissionsResponse.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.permissions != null && + message.hasOwnProperty('permissions') + ) { + if (!Array.isArray(message.permissions)) + return 'permissions: array expected' + for (var i = 0; i < message.permissions.length; ++i) + if (!$util.isString(message.permissions[i])) + return 'permissions: string[] expected' + } + return null + } + + /** + * Creates a TestIamPermissionsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.iam.v1.TestIamPermissionsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.iam.v1.TestIamPermissionsResponse} TestIamPermissionsResponse + */ + TestIamPermissionsResponse.fromObject = function fromObject( + object + ) { + if ( + object instanceof + $root.google.iam.v1.TestIamPermissionsResponse + ) + return object + var message = new $root.google.iam.v1.TestIamPermissionsResponse() + if (object.permissions) { + if (!Array.isArray(object.permissions)) + throw TypeError( + '.google.iam.v1.TestIamPermissionsResponse.permissions: array expected' + ) + message.permissions = [] + for (var i = 0; i < object.permissions.length; ++i) + message.permissions[i] = String(object.permissions[i]) + } + return message + } + + /** + * Creates a plain object from a TestIamPermissionsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.iam.v1.TestIamPermissionsResponse + * @static + * @param {google.iam.v1.TestIamPermissionsResponse} message TestIamPermissionsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + TestIamPermissionsResponse.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) + object.permissions = [] + if (message.permissions && message.permissions.length) { + object.permissions = [] + for (var j = 0; j < message.permissions.length; ++j) + object.permissions[j] = message.permissions[j] + } + return object + } + + /** + * Converts this TestIamPermissionsResponse to JSON. + * @function toJSON + * @memberof google.iam.v1.TestIamPermissionsResponse + * @instance + * @returns {Object.} JSON object + */ + TestIamPermissionsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return TestIamPermissionsResponse + })() + + v1.GetPolicyOptions = (function () { + /** + * Properties of a GetPolicyOptions. + * @memberof google.iam.v1 + * @interface IGetPolicyOptions + * @property {number|null} [requestedPolicyVersion] GetPolicyOptions requestedPolicyVersion + */ + + /** + * Constructs a new GetPolicyOptions. + * @memberof google.iam.v1 + * @classdesc Represents a GetPolicyOptions. + * @implements IGetPolicyOptions + * @constructor + * @param {google.iam.v1.IGetPolicyOptions=} [properties] Properties to set + */ + function GetPolicyOptions(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * GetPolicyOptions requestedPolicyVersion. + * @member {number} requestedPolicyVersion + * @memberof google.iam.v1.GetPolicyOptions + * @instance + */ + GetPolicyOptions.prototype.requestedPolicyVersion = 0 + + /** + * Creates a new GetPolicyOptions instance using the specified properties. + * @function create + * @memberof google.iam.v1.GetPolicyOptions + * @static + * @param {google.iam.v1.IGetPolicyOptions=} [properties] Properties to set + * @returns {google.iam.v1.GetPolicyOptions} GetPolicyOptions instance + */ + GetPolicyOptions.create = function create(properties) { + return new GetPolicyOptions(properties) + } + + /** + * Encodes the specified GetPolicyOptions message. Does not implicitly {@link google.iam.v1.GetPolicyOptions.verify|verify} messages. + * @function encode + * @memberof google.iam.v1.GetPolicyOptions + * @static + * @param {google.iam.v1.IGetPolicyOptions} message GetPolicyOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetPolicyOptions.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.requestedPolicyVersion != null && + message.hasOwnProperty('requestedPolicyVersion') + ) + writer + .uint32(/* id 1, wireType 0 =*/ 8) + .int32(message.requestedPolicyVersion) + return writer + } + + /** + * Encodes the specified GetPolicyOptions message, length delimited. Does not implicitly {@link google.iam.v1.GetPolicyOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.iam.v1.GetPolicyOptions + * @static + * @param {google.iam.v1.IGetPolicyOptions} message GetPolicyOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetPolicyOptions.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a GetPolicyOptions message from the specified reader or buffer. + * @function decode + * @memberof google.iam.v1.GetPolicyOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.iam.v1.GetPolicyOptions} GetPolicyOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetPolicyOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.iam.v1.GetPolicyOptions() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.requestedPolicyVersion = reader.int32() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a GetPolicyOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.iam.v1.GetPolicyOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.iam.v1.GetPolicyOptions} GetPolicyOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetPolicyOptions.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a GetPolicyOptions message. + * @function verify + * @memberof google.iam.v1.GetPolicyOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetPolicyOptions.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.requestedPolicyVersion != null && + message.hasOwnProperty('requestedPolicyVersion') + ) + if (!$util.isInteger(message.requestedPolicyVersion)) + return 'requestedPolicyVersion: integer expected' + return null + } + + /** + * Creates a GetPolicyOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.iam.v1.GetPolicyOptions + * @static + * @param {Object.} object Plain object + * @returns {google.iam.v1.GetPolicyOptions} GetPolicyOptions + */ + GetPolicyOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.iam.v1.GetPolicyOptions) + return object + var message = new $root.google.iam.v1.GetPolicyOptions() + if (object.requestedPolicyVersion != null) + message.requestedPolicyVersion = + object.requestedPolicyVersion | 0 + return message + } + + /** + * Creates a plain object from a GetPolicyOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.iam.v1.GetPolicyOptions + * @static + * @param {google.iam.v1.GetPolicyOptions} message GetPolicyOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetPolicyOptions.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) object.requestedPolicyVersion = 0 + if ( + message.requestedPolicyVersion != null && + message.hasOwnProperty('requestedPolicyVersion') + ) + object.requestedPolicyVersion = + message.requestedPolicyVersion + return object + } + + /** + * Converts this GetPolicyOptions to JSON. + * @function toJSON + * @memberof google.iam.v1.GetPolicyOptions + * @instance + * @returns {Object.} JSON object + */ + GetPolicyOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return GetPolicyOptions + })() + + v1.Policy = (function () { + /** + * Properties of a Policy. + * @memberof google.iam.v1 + * @interface IPolicy + * @property {number|null} [version] Policy version + * @property {Array.|null} [bindings] Policy bindings + * @property {Uint8Array|null} [etag] Policy etag + */ + + /** + * Constructs a new Policy. + * @memberof google.iam.v1 + * @classdesc Represents a Policy. + * @implements IPolicy + * @constructor + * @param {google.iam.v1.IPolicy=} [properties] Properties to set + */ + function Policy(properties) { + this.bindings = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * Policy version. + * @member {number} version + * @memberof google.iam.v1.Policy + * @instance + */ + Policy.prototype.version = 0 + + /** + * Policy bindings. + * @member {Array.} bindings + * @memberof google.iam.v1.Policy + * @instance + */ + Policy.prototype.bindings = $util.emptyArray + + /** + * Policy etag. + * @member {Uint8Array} etag + * @memberof google.iam.v1.Policy + * @instance + */ + Policy.prototype.etag = $util.newBuffer([]) + + /** + * Creates a new Policy instance using the specified properties. + * @function create + * @memberof google.iam.v1.Policy + * @static + * @param {google.iam.v1.IPolicy=} [properties] Properties to set + * @returns {google.iam.v1.Policy} Policy instance + */ + Policy.create = function create(properties) { + return new Policy(properties) + } + + /** + * Encodes the specified Policy message. Does not implicitly {@link google.iam.v1.Policy.verify|verify} messages. + * @function encode + * @memberof google.iam.v1.Policy + * @static + * @param {google.iam.v1.IPolicy} message Policy message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Policy.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.version != null && + message.hasOwnProperty('version') + ) + writer + .uint32(/* id 1, wireType 0 =*/ 8) + .int32(message.version) + if (message.etag != null && message.hasOwnProperty('etag')) + writer + .uint32(/* id 3, wireType 2 =*/ 26) + .bytes(message.etag) + if (message.bindings != null && message.bindings.length) + for (var i = 0; i < message.bindings.length; ++i) + $root.google.iam.v1.Binding.encode( + message.bindings[i], + writer.uint32(/* id 4, wireType 2 =*/ 34).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified Policy message, length delimited. Does not implicitly {@link google.iam.v1.Policy.verify|verify} messages. + * @function encodeDelimited + * @memberof google.iam.v1.Policy + * @static + * @param {google.iam.v1.IPolicy} message Policy message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Policy.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a Policy message from the specified reader or buffer. + * @function decode + * @memberof google.iam.v1.Policy + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.iam.v1.Policy} Policy + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Policy.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.iam.v1.Policy() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.version = reader.int32() + break + case 4: + if (!(message.bindings && message.bindings.length)) + message.bindings = [] + message.bindings.push( + $root.google.iam.v1.Binding.decode( + reader, + reader.uint32() + ) + ) + break + case 3: + message.etag = reader.bytes() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a Policy message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.iam.v1.Policy + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.iam.v1.Policy} Policy + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Policy.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a Policy message. + * @function verify + * @memberof google.iam.v1.Policy + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Policy.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.version != null && + message.hasOwnProperty('version') + ) + if (!$util.isInteger(message.version)) + return 'version: integer expected' + if ( + message.bindings != null && + message.hasOwnProperty('bindings') + ) { + if (!Array.isArray(message.bindings)) + return 'bindings: array expected' + for (var i = 0; i < message.bindings.length; ++i) { + var error = $root.google.iam.v1.Binding.verify( + message.bindings[i] + ) + if (error) return 'bindings.' + error + } + } + if (message.etag != null && message.hasOwnProperty('etag')) + if ( + !( + (message.etag && + typeof message.etag.length === 'number') || + $util.isString(message.etag) + ) + ) + return 'etag: buffer expected' + return null + } + + /** + * Creates a Policy message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.iam.v1.Policy + * @static + * @param {Object.} object Plain object + * @returns {google.iam.v1.Policy} Policy + */ + Policy.fromObject = function fromObject(object) { + if (object instanceof $root.google.iam.v1.Policy) + return object + var message = new $root.google.iam.v1.Policy() + if (object.version != null) + message.version = object.version | 0 + if (object.bindings) { + if (!Array.isArray(object.bindings)) + throw TypeError( + '.google.iam.v1.Policy.bindings: array expected' + ) + message.bindings = [] + for (var i = 0; i < object.bindings.length; ++i) { + if (typeof object.bindings[i] !== 'object') + throw TypeError( + '.google.iam.v1.Policy.bindings: object expected' + ) + message.bindings[ + i + ] = $root.google.iam.v1.Binding.fromObject( + object.bindings[i] + ) + } + } + if (object.etag != null) + if (typeof object.etag === 'string') + $util.base64.decode( + object.etag, + (message.etag = $util.newBuffer( + $util.base64.length(object.etag) + )), + 0 + ) + else if (object.etag.length) message.etag = object.etag + return message + } + + /** + * Creates a plain object from a Policy message. Also converts values to other types if specified. + * @function toObject + * @memberof google.iam.v1.Policy + * @static + * @param {google.iam.v1.Policy} message Policy + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Policy.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) object.bindings = [] + if (options.defaults) { + object.version = 0 + if (options.bytes === String) object.etag = '' + else { + object.etag = [] + if (options.bytes !== Array) + object.etag = $util.newBuffer(object.etag) + } + } + if ( + message.version != null && + message.hasOwnProperty('version') + ) + object.version = message.version + if (message.etag != null && message.hasOwnProperty('etag')) + object.etag = + options.bytes === String + ? $util.base64.encode( + message.etag, + 0, + message.etag.length + ) + : options.bytes === Array + ? Array.prototype.slice.call(message.etag) + : message.etag + if (message.bindings && message.bindings.length) { + object.bindings = [] + for (var j = 0; j < message.bindings.length; ++j) + object.bindings[j] = $root.google.iam.v1.Binding.toObject( + message.bindings[j], + options + ) + } + return object + } + + /** + * Converts this Policy to JSON. + * @function toJSON + * @memberof google.iam.v1.Policy + * @instance + * @returns {Object.} JSON object + */ + Policy.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return Policy + })() + + v1.Binding = (function () { + /** + * Properties of a Binding. + * @memberof google.iam.v1 + * @interface IBinding + * @property {string|null} [role] Binding role + * @property {Array.|null} [members] Binding members + * @property {google.type.IExpr|null} [condition] Binding condition + */ + + /** + * Constructs a new Binding. + * @memberof google.iam.v1 + * @classdesc Represents a Binding. + * @implements IBinding + * @constructor + * @param {google.iam.v1.IBinding=} [properties] Properties to set + */ + function Binding(properties) { + this.members = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * Binding role. + * @member {string} role + * @memberof google.iam.v1.Binding + * @instance + */ + Binding.prototype.role = '' + + /** + * Binding members. + * @member {Array.} members + * @memberof google.iam.v1.Binding + * @instance + */ + Binding.prototype.members = $util.emptyArray + + /** + * Binding condition. + * @member {google.type.IExpr|null|undefined} condition + * @memberof google.iam.v1.Binding + * @instance + */ + Binding.prototype.condition = null + + /** + * Creates a new Binding instance using the specified properties. + * @function create + * @memberof google.iam.v1.Binding + * @static + * @param {google.iam.v1.IBinding=} [properties] Properties to set + * @returns {google.iam.v1.Binding} Binding instance + */ + Binding.create = function create(properties) { + return new Binding(properties) + } + + /** + * Encodes the specified Binding message. Does not implicitly {@link google.iam.v1.Binding.verify|verify} messages. + * @function encode + * @memberof google.iam.v1.Binding + * @static + * @param {google.iam.v1.IBinding} message Binding message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Binding.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.role != null && message.hasOwnProperty('role')) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.role) + if (message.members != null && message.members.length) + for (var i = 0; i < message.members.length; ++i) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.members[i]) + if ( + message.condition != null && + message.hasOwnProperty('condition') + ) + $root.google.type.Expr.encode( + message.condition, + writer.uint32(/* id 3, wireType 2 =*/ 26).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified Binding message, length delimited. Does not implicitly {@link google.iam.v1.Binding.verify|verify} messages. + * @function encodeDelimited + * @memberof google.iam.v1.Binding + * @static + * @param {google.iam.v1.IBinding} message Binding message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Binding.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a Binding message from the specified reader or buffer. + * @function decode + * @memberof google.iam.v1.Binding + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.iam.v1.Binding} Binding + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Binding.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.iam.v1.Binding() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.role = reader.string() + break + case 2: + if (!(message.members && message.members.length)) + message.members = [] + message.members.push(reader.string()) + break + case 3: + message.condition = $root.google.type.Expr.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a Binding message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.iam.v1.Binding + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.iam.v1.Binding} Binding + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Binding.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a Binding message. + * @function verify + * @memberof google.iam.v1.Binding + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Binding.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.role != null && message.hasOwnProperty('role')) + if (!$util.isString(message.role)) + return 'role: string expected' + if ( + message.members != null && + message.hasOwnProperty('members') + ) { + if (!Array.isArray(message.members)) + return 'members: array expected' + for (var i = 0; i < message.members.length; ++i) + if (!$util.isString(message.members[i])) + return 'members: string[] expected' + } + if ( + message.condition != null && + message.hasOwnProperty('condition') + ) { + var error = $root.google.type.Expr.verify(message.condition) + if (error) return 'condition.' + error + } + return null + } + + /** + * Creates a Binding message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.iam.v1.Binding + * @static + * @param {Object.} object Plain object + * @returns {google.iam.v1.Binding} Binding + */ + Binding.fromObject = function fromObject(object) { + if (object instanceof $root.google.iam.v1.Binding) + return object + var message = new $root.google.iam.v1.Binding() + if (object.role != null) message.role = String(object.role) + if (object.members) { + if (!Array.isArray(object.members)) + throw TypeError( + '.google.iam.v1.Binding.members: array expected' + ) + message.members = [] + for (var i = 0; i < object.members.length; ++i) + message.members[i] = String(object.members[i]) + } + if (object.condition != null) { + if (typeof object.condition !== 'object') + throw TypeError( + '.google.iam.v1.Binding.condition: object expected' + ) + message.condition = $root.google.type.Expr.fromObject( + object.condition + ) + } + return message + } + + /** + * Creates a plain object from a Binding message. Also converts values to other types if specified. + * @function toObject + * @memberof google.iam.v1.Binding + * @static + * @param {google.iam.v1.Binding} message Binding + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Binding.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) object.members = [] + if (options.defaults) { + object.role = '' + object.condition = null + } + if (message.role != null && message.hasOwnProperty('role')) + object.role = message.role + if (message.members && message.members.length) { + object.members = [] + for (var j = 0; j < message.members.length; ++j) + object.members[j] = message.members[j] + } + if ( + message.condition != null && + message.hasOwnProperty('condition') + ) + object.condition = $root.google.type.Expr.toObject( + message.condition, + options + ) + return object + } + + /** + * Converts this Binding to JSON. + * @function toJSON + * @memberof google.iam.v1.Binding + * @instance + * @returns {Object.} JSON object + */ + Binding.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return Binding + })() + + v1.PolicyDelta = (function () { + /** + * Properties of a PolicyDelta. + * @memberof google.iam.v1 + * @interface IPolicyDelta + * @property {Array.|null} [bindingDeltas] PolicyDelta bindingDeltas + * @property {Array.|null} [auditConfigDeltas] PolicyDelta auditConfigDeltas + */ + + /** + * Constructs a new PolicyDelta. + * @memberof google.iam.v1 + * @classdesc Represents a PolicyDelta. + * @implements IPolicyDelta + * @constructor + * @param {google.iam.v1.IPolicyDelta=} [properties] Properties to set + */ + function PolicyDelta(properties) { + this.bindingDeltas = [] + this.auditConfigDeltas = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * PolicyDelta bindingDeltas. + * @member {Array.} bindingDeltas + * @memberof google.iam.v1.PolicyDelta + * @instance + */ + PolicyDelta.prototype.bindingDeltas = $util.emptyArray + + /** + * PolicyDelta auditConfigDeltas. + * @member {Array.} auditConfigDeltas + * @memberof google.iam.v1.PolicyDelta + * @instance + */ + PolicyDelta.prototype.auditConfigDeltas = $util.emptyArray + + /** + * Creates a new PolicyDelta instance using the specified properties. + * @function create + * @memberof google.iam.v1.PolicyDelta + * @static + * @param {google.iam.v1.IPolicyDelta=} [properties] Properties to set + * @returns {google.iam.v1.PolicyDelta} PolicyDelta instance + */ + PolicyDelta.create = function create(properties) { + return new PolicyDelta(properties) + } + + /** + * Encodes the specified PolicyDelta message. Does not implicitly {@link google.iam.v1.PolicyDelta.verify|verify} messages. + * @function encode + * @memberof google.iam.v1.PolicyDelta + * @static + * @param {google.iam.v1.IPolicyDelta} message PolicyDelta message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PolicyDelta.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.bindingDeltas != null && + message.bindingDeltas.length + ) + for (var i = 0; i < message.bindingDeltas.length; ++i) + $root.google.iam.v1.BindingDelta.encode( + message.bindingDeltas[i], + writer.uint32(/* id 1, wireType 2 =*/ 10).fork() + ).ldelim() + if ( + message.auditConfigDeltas != null && + message.auditConfigDeltas.length + ) + for (var i = 0; i < message.auditConfigDeltas.length; ++i) + $root.google.iam.v1.AuditConfigDelta.encode( + message.auditConfigDeltas[i], + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified PolicyDelta message, length delimited. Does not implicitly {@link google.iam.v1.PolicyDelta.verify|verify} messages. + * @function encodeDelimited + * @memberof google.iam.v1.PolicyDelta + * @static + * @param {google.iam.v1.IPolicyDelta} message PolicyDelta message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PolicyDelta.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a PolicyDelta message from the specified reader or buffer. + * @function decode + * @memberof google.iam.v1.PolicyDelta + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.iam.v1.PolicyDelta} PolicyDelta + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PolicyDelta.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.iam.v1.PolicyDelta() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + if ( + !( + message.bindingDeltas && + message.bindingDeltas.length + ) + ) + message.bindingDeltas = [] + message.bindingDeltas.push( + $root.google.iam.v1.BindingDelta.decode( + reader, + reader.uint32() + ) + ) + break + case 2: + if ( + !( + message.auditConfigDeltas && + message.auditConfigDeltas.length + ) + ) + message.auditConfigDeltas = [] + message.auditConfigDeltas.push( + $root.google.iam.v1.AuditConfigDelta.decode( + reader, + reader.uint32() + ) + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a PolicyDelta message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.iam.v1.PolicyDelta + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.iam.v1.PolicyDelta} PolicyDelta + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PolicyDelta.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a PolicyDelta message. + * @function verify + * @memberof google.iam.v1.PolicyDelta + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PolicyDelta.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.bindingDeltas != null && + message.hasOwnProperty('bindingDeltas') + ) { + if (!Array.isArray(message.bindingDeltas)) + return 'bindingDeltas: array expected' + for (var i = 0; i < message.bindingDeltas.length; ++i) { + var error = $root.google.iam.v1.BindingDelta.verify( + message.bindingDeltas[i] + ) + if (error) return 'bindingDeltas.' + error + } + } + if ( + message.auditConfigDeltas != null && + message.hasOwnProperty('auditConfigDeltas') + ) { + if (!Array.isArray(message.auditConfigDeltas)) + return 'auditConfigDeltas: array expected' + for (var i = 0; i < message.auditConfigDeltas.length; ++i) { + var error = $root.google.iam.v1.AuditConfigDelta.verify( + message.auditConfigDeltas[i] + ) + if (error) return 'auditConfigDeltas.' + error + } + } + return null + } + + /** + * Creates a PolicyDelta message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.iam.v1.PolicyDelta + * @static + * @param {Object.} object Plain object + * @returns {google.iam.v1.PolicyDelta} PolicyDelta + */ + PolicyDelta.fromObject = function fromObject(object) { + if (object instanceof $root.google.iam.v1.PolicyDelta) + return object + var message = new $root.google.iam.v1.PolicyDelta() + if (object.bindingDeltas) { + if (!Array.isArray(object.bindingDeltas)) + throw TypeError( + '.google.iam.v1.PolicyDelta.bindingDeltas: array expected' + ) + message.bindingDeltas = [] + for (var i = 0; i < object.bindingDeltas.length; ++i) { + if (typeof object.bindingDeltas[i] !== 'object') + throw TypeError( + '.google.iam.v1.PolicyDelta.bindingDeltas: object expected' + ) + message.bindingDeltas[ + i + ] = $root.google.iam.v1.BindingDelta.fromObject( + object.bindingDeltas[i] + ) + } + } + if (object.auditConfigDeltas) { + if (!Array.isArray(object.auditConfigDeltas)) + throw TypeError( + '.google.iam.v1.PolicyDelta.auditConfigDeltas: array expected' + ) + message.auditConfigDeltas = [] + for (var i = 0; i < object.auditConfigDeltas.length; ++i) { + if (typeof object.auditConfigDeltas[i] !== 'object') + throw TypeError( + '.google.iam.v1.PolicyDelta.auditConfigDeltas: object expected' + ) + message.auditConfigDeltas[ + i + ] = $root.google.iam.v1.AuditConfigDelta.fromObject( + object.auditConfigDeltas[i] + ) + } + } + return message + } + + /** + * Creates a plain object from a PolicyDelta message. Also converts values to other types if specified. + * @function toObject + * @memberof google.iam.v1.PolicyDelta + * @static + * @param {google.iam.v1.PolicyDelta} message PolicyDelta + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PolicyDelta.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) { + object.bindingDeltas = [] + object.auditConfigDeltas = [] + } + if (message.bindingDeltas && message.bindingDeltas.length) { + object.bindingDeltas = [] + for (var j = 0; j < message.bindingDeltas.length; ++j) + object.bindingDeltas[ + j + ] = $root.google.iam.v1.BindingDelta.toObject( + message.bindingDeltas[j], + options + ) + } + if ( + message.auditConfigDeltas && + message.auditConfigDeltas.length + ) { + object.auditConfigDeltas = [] + for (var j = 0; j < message.auditConfigDeltas.length; ++j) + object.auditConfigDeltas[ + j + ] = $root.google.iam.v1.AuditConfigDelta.toObject( + message.auditConfigDeltas[j], + options + ) + } + return object + } + + /** + * Converts this PolicyDelta to JSON. + * @function toJSON + * @memberof google.iam.v1.PolicyDelta + * @instance + * @returns {Object.} JSON object + */ + PolicyDelta.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return PolicyDelta + })() + + v1.BindingDelta = (function () { + /** + * Properties of a BindingDelta. + * @memberof google.iam.v1 + * @interface IBindingDelta + * @property {google.iam.v1.BindingDelta.Action|null} [action] BindingDelta action + * @property {string|null} [role] BindingDelta role + * @property {string|null} [member] BindingDelta member + * @property {google.type.IExpr|null} [condition] BindingDelta condition + */ + + /** + * Constructs a new BindingDelta. + * @memberof google.iam.v1 + * @classdesc Represents a BindingDelta. + * @implements IBindingDelta + * @constructor + * @param {google.iam.v1.IBindingDelta=} [properties] Properties to set + */ + function BindingDelta(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * BindingDelta action. + * @member {google.iam.v1.BindingDelta.Action} action + * @memberof google.iam.v1.BindingDelta + * @instance + */ + BindingDelta.prototype.action = 0 + + /** + * BindingDelta role. + * @member {string} role + * @memberof google.iam.v1.BindingDelta + * @instance + */ + BindingDelta.prototype.role = '' + + /** + * BindingDelta member. + * @member {string} member + * @memberof google.iam.v1.BindingDelta + * @instance + */ + BindingDelta.prototype.member = '' + + /** + * BindingDelta condition. + * @member {google.type.IExpr|null|undefined} condition + * @memberof google.iam.v1.BindingDelta + * @instance + */ + BindingDelta.prototype.condition = null + + /** + * Creates a new BindingDelta instance using the specified properties. + * @function create + * @memberof google.iam.v1.BindingDelta + * @static + * @param {google.iam.v1.IBindingDelta=} [properties] Properties to set + * @returns {google.iam.v1.BindingDelta} BindingDelta instance + */ + BindingDelta.create = function create(properties) { + return new BindingDelta(properties) + } + + /** + * Encodes the specified BindingDelta message. Does not implicitly {@link google.iam.v1.BindingDelta.verify|verify} messages. + * @function encode + * @memberof google.iam.v1.BindingDelta + * @static + * @param {google.iam.v1.IBindingDelta} message BindingDelta message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BindingDelta.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.action != null && + message.hasOwnProperty('action') + ) + writer + .uint32(/* id 1, wireType 0 =*/ 8) + .int32(message.action) + if (message.role != null && message.hasOwnProperty('role')) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.role) + if ( + message.member != null && + message.hasOwnProperty('member') + ) + writer + .uint32(/* id 3, wireType 2 =*/ 26) + .string(message.member) + if ( + message.condition != null && + message.hasOwnProperty('condition') + ) + $root.google.type.Expr.encode( + message.condition, + writer.uint32(/* id 4, wireType 2 =*/ 34).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified BindingDelta message, length delimited. Does not implicitly {@link google.iam.v1.BindingDelta.verify|verify} messages. + * @function encodeDelimited + * @memberof google.iam.v1.BindingDelta + * @static + * @param {google.iam.v1.IBindingDelta} message BindingDelta message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BindingDelta.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a BindingDelta message from the specified reader or buffer. + * @function decode + * @memberof google.iam.v1.BindingDelta + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.iam.v1.BindingDelta} BindingDelta + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BindingDelta.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.iam.v1.BindingDelta() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.action = reader.int32() + break + case 2: + message.role = reader.string() + break + case 3: + message.member = reader.string() + break + case 4: + message.condition = $root.google.type.Expr.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a BindingDelta message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.iam.v1.BindingDelta + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.iam.v1.BindingDelta} BindingDelta + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BindingDelta.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a BindingDelta message. + * @function verify + * @memberof google.iam.v1.BindingDelta + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BindingDelta.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.action != null && + message.hasOwnProperty('action') + ) + switch (message.action) { + default: + return 'action: enum value expected' + case 0: + case 1: + case 2: + break + } + if (message.role != null && message.hasOwnProperty('role')) + if (!$util.isString(message.role)) + return 'role: string expected' + if ( + message.member != null && + message.hasOwnProperty('member') + ) + if (!$util.isString(message.member)) + return 'member: string expected' + if ( + message.condition != null && + message.hasOwnProperty('condition') + ) { + var error = $root.google.type.Expr.verify(message.condition) + if (error) return 'condition.' + error + } + return null + } + + /** + * Creates a BindingDelta message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.iam.v1.BindingDelta + * @static + * @param {Object.} object Plain object + * @returns {google.iam.v1.BindingDelta} BindingDelta + */ + BindingDelta.fromObject = function fromObject(object) { + if (object instanceof $root.google.iam.v1.BindingDelta) + return object + var message = new $root.google.iam.v1.BindingDelta() + switch (object.action) { + case 'ACTION_UNSPECIFIED': + case 0: + message.action = 0 + break + case 'ADD': + case 1: + message.action = 1 + break + case 'REMOVE': + case 2: + message.action = 2 + break + } + if (object.role != null) message.role = String(object.role) + if (object.member != null) + message.member = String(object.member) + if (object.condition != null) { + if (typeof object.condition !== 'object') + throw TypeError( + '.google.iam.v1.BindingDelta.condition: object expected' + ) + message.condition = $root.google.type.Expr.fromObject( + object.condition + ) + } + return message + } + + /** + * Creates a plain object from a BindingDelta message. Also converts values to other types if specified. + * @function toObject + * @memberof google.iam.v1.BindingDelta + * @static + * @param {google.iam.v1.BindingDelta} message BindingDelta + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BindingDelta.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.action = + options.enums === String ? 'ACTION_UNSPECIFIED' : 0 + object.role = '' + object.member = '' + object.condition = null + } + if ( + message.action != null && + message.hasOwnProperty('action') + ) + object.action = + options.enums === String + ? $root.google.iam.v1.BindingDelta.Action[ + message.action + ] + : message.action + if (message.role != null && message.hasOwnProperty('role')) + object.role = message.role + if ( + message.member != null && + message.hasOwnProperty('member') + ) + object.member = message.member + if ( + message.condition != null && + message.hasOwnProperty('condition') + ) + object.condition = $root.google.type.Expr.toObject( + message.condition, + options + ) + return object + } + + /** + * Converts this BindingDelta to JSON. + * @function toJSON + * @memberof google.iam.v1.BindingDelta + * @instance + * @returns {Object.} JSON object + */ + BindingDelta.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + /** + * Action enum. + * @name google.iam.v1.BindingDelta.Action + * @enum {string} + * @property {number} ACTION_UNSPECIFIED=0 ACTION_UNSPECIFIED value + * @property {number} ADD=1 ADD value + * @property {number} REMOVE=2 REMOVE value + */ + BindingDelta.Action = (function () { + var valuesById = {}, + values = Object.create(valuesById) + values[(valuesById[0] = 'ACTION_UNSPECIFIED')] = 0 + values[(valuesById[1] = 'ADD')] = 1 + values[(valuesById[2] = 'REMOVE')] = 2 + return values + })() + + return BindingDelta + })() + + v1.AuditConfigDelta = (function () { + /** + * Properties of an AuditConfigDelta. + * @memberof google.iam.v1 + * @interface IAuditConfigDelta + * @property {google.iam.v1.AuditConfigDelta.Action|null} [action] AuditConfigDelta action + * @property {string|null} [service] AuditConfigDelta service + * @property {string|null} [exemptedMember] AuditConfigDelta exemptedMember + * @property {string|null} [logType] AuditConfigDelta logType + */ + + /** + * Constructs a new AuditConfigDelta. + * @memberof google.iam.v1 + * @classdesc Represents an AuditConfigDelta. + * @implements IAuditConfigDelta + * @constructor + * @param {google.iam.v1.IAuditConfigDelta=} [properties] Properties to set + */ + function AuditConfigDelta(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * AuditConfigDelta action. + * @member {google.iam.v1.AuditConfigDelta.Action} action + * @memberof google.iam.v1.AuditConfigDelta + * @instance + */ + AuditConfigDelta.prototype.action = 0 + + /** + * AuditConfigDelta service. + * @member {string} service + * @memberof google.iam.v1.AuditConfigDelta + * @instance + */ + AuditConfigDelta.prototype.service = '' + + /** + * AuditConfigDelta exemptedMember. + * @member {string} exemptedMember + * @memberof google.iam.v1.AuditConfigDelta + * @instance + */ + AuditConfigDelta.prototype.exemptedMember = '' + + /** + * AuditConfigDelta logType. + * @member {string} logType + * @memberof google.iam.v1.AuditConfigDelta + * @instance + */ + AuditConfigDelta.prototype.logType = '' + + /** + * Creates a new AuditConfigDelta instance using the specified properties. + * @function create + * @memberof google.iam.v1.AuditConfigDelta + * @static + * @param {google.iam.v1.IAuditConfigDelta=} [properties] Properties to set + * @returns {google.iam.v1.AuditConfigDelta} AuditConfigDelta instance + */ + AuditConfigDelta.create = function create(properties) { + return new AuditConfigDelta(properties) + } + + /** + * Encodes the specified AuditConfigDelta message. Does not implicitly {@link google.iam.v1.AuditConfigDelta.verify|verify} messages. + * @function encode + * @memberof google.iam.v1.AuditConfigDelta + * @static + * @param {google.iam.v1.IAuditConfigDelta} message AuditConfigDelta message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AuditConfigDelta.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.action != null && + message.hasOwnProperty('action') + ) + writer + .uint32(/* id 1, wireType 0 =*/ 8) + .int32(message.action) + if ( + message.service != null && + message.hasOwnProperty('service') + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.service) + if ( + message.exemptedMember != null && + message.hasOwnProperty('exemptedMember') + ) + writer + .uint32(/* id 3, wireType 2 =*/ 26) + .string(message.exemptedMember) + if ( + message.logType != null && + message.hasOwnProperty('logType') + ) + writer + .uint32(/* id 4, wireType 2 =*/ 34) + .string(message.logType) + return writer + } + + /** + * Encodes the specified AuditConfigDelta message, length delimited. Does not implicitly {@link google.iam.v1.AuditConfigDelta.verify|verify} messages. + * @function encodeDelimited + * @memberof google.iam.v1.AuditConfigDelta + * @static + * @param {google.iam.v1.IAuditConfigDelta} message AuditConfigDelta message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AuditConfigDelta.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an AuditConfigDelta message from the specified reader or buffer. + * @function decode + * @memberof google.iam.v1.AuditConfigDelta + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.iam.v1.AuditConfigDelta} AuditConfigDelta + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AuditConfigDelta.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.iam.v1.AuditConfigDelta() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.action = reader.int32() + break + case 2: + message.service = reader.string() + break + case 3: + message.exemptedMember = reader.string() + break + case 4: + message.logType = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an AuditConfigDelta message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.iam.v1.AuditConfigDelta + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.iam.v1.AuditConfigDelta} AuditConfigDelta + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AuditConfigDelta.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an AuditConfigDelta message. + * @function verify + * @memberof google.iam.v1.AuditConfigDelta + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AuditConfigDelta.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.action != null && + message.hasOwnProperty('action') + ) + switch (message.action) { + default: + return 'action: enum value expected' + case 0: + case 1: + case 2: + break + } + if ( + message.service != null && + message.hasOwnProperty('service') + ) + if (!$util.isString(message.service)) + return 'service: string expected' + if ( + message.exemptedMember != null && + message.hasOwnProperty('exemptedMember') + ) + if (!$util.isString(message.exemptedMember)) + return 'exemptedMember: string expected' + if ( + message.logType != null && + message.hasOwnProperty('logType') + ) + if (!$util.isString(message.logType)) + return 'logType: string expected' + return null + } + + /** + * Creates an AuditConfigDelta message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.iam.v1.AuditConfigDelta + * @static + * @param {Object.} object Plain object + * @returns {google.iam.v1.AuditConfigDelta} AuditConfigDelta + */ + AuditConfigDelta.fromObject = function fromObject(object) { + if (object instanceof $root.google.iam.v1.AuditConfigDelta) + return object + var message = new $root.google.iam.v1.AuditConfigDelta() + switch (object.action) { + case 'ACTION_UNSPECIFIED': + case 0: + message.action = 0 + break + case 'ADD': + case 1: + message.action = 1 + break + case 'REMOVE': + case 2: + message.action = 2 + break + } + if (object.service != null) + message.service = String(object.service) + if (object.exemptedMember != null) + message.exemptedMember = String(object.exemptedMember) + if (object.logType != null) + message.logType = String(object.logType) + return message + } + + /** + * Creates a plain object from an AuditConfigDelta message. Also converts values to other types if specified. + * @function toObject + * @memberof google.iam.v1.AuditConfigDelta + * @static + * @param {google.iam.v1.AuditConfigDelta} message AuditConfigDelta + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AuditConfigDelta.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.action = + options.enums === String ? 'ACTION_UNSPECIFIED' : 0 + object.service = '' + object.exemptedMember = '' + object.logType = '' + } + if ( + message.action != null && + message.hasOwnProperty('action') + ) + object.action = + options.enums === String + ? $root.google.iam.v1.AuditConfigDelta.Action[ + message.action + ] + : message.action + if ( + message.service != null && + message.hasOwnProperty('service') + ) + object.service = message.service + if ( + message.exemptedMember != null && + message.hasOwnProperty('exemptedMember') + ) + object.exemptedMember = message.exemptedMember + if ( + message.logType != null && + message.hasOwnProperty('logType') + ) + object.logType = message.logType + return object + } + + /** + * Converts this AuditConfigDelta to JSON. + * @function toJSON + * @memberof google.iam.v1.AuditConfigDelta + * @instance + * @returns {Object.} JSON object + */ + AuditConfigDelta.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + /** + * Action enum. + * @name google.iam.v1.AuditConfigDelta.Action + * @enum {string} + * @property {number} ACTION_UNSPECIFIED=0 ACTION_UNSPECIFIED value + * @property {number} ADD=1 ADD value + * @property {number} REMOVE=2 REMOVE value + */ + AuditConfigDelta.Action = (function () { + var valuesById = {}, + values = Object.create(valuesById) + values[(valuesById[0] = 'ACTION_UNSPECIFIED')] = 0 + values[(valuesById[1] = 'ADD')] = 1 + values[(valuesById[2] = 'REMOVE')] = 2 + return values + })() + + return AuditConfigDelta + })() + + v1.logging = (function () { + /** + * Namespace logging. + * @memberof google.iam.v1 + * @namespace + */ + var logging = {} + + logging.AuditData = (function () { + /** + * Properties of an AuditData. + * @memberof google.iam.v1.logging + * @interface IAuditData + * @property {google.iam.v1.IPolicyDelta|null} [policyDelta] AuditData policyDelta + */ + + /** + * Constructs a new AuditData. + * @memberof google.iam.v1.logging + * @classdesc Represents an AuditData. + * @implements IAuditData + * @constructor + * @param {google.iam.v1.logging.IAuditData=} [properties] Properties to set + */ + function AuditData(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * AuditData policyDelta. + * @member {google.iam.v1.IPolicyDelta|null|undefined} policyDelta + * @memberof google.iam.v1.logging.AuditData + * @instance + */ + AuditData.prototype.policyDelta = null + + /** + * Creates a new AuditData instance using the specified properties. + * @function create + * @memberof google.iam.v1.logging.AuditData + * @static + * @param {google.iam.v1.logging.IAuditData=} [properties] Properties to set + * @returns {google.iam.v1.logging.AuditData} AuditData instance + */ + AuditData.create = function create(properties) { + return new AuditData(properties) + } + + /** + * Encodes the specified AuditData message. Does not implicitly {@link google.iam.v1.logging.AuditData.verify|verify} messages. + * @function encode + * @memberof google.iam.v1.logging.AuditData + * @static + * @param {google.iam.v1.logging.IAuditData} message AuditData message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AuditData.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.policyDelta != null && + message.hasOwnProperty('policyDelta') + ) + $root.google.iam.v1.PolicyDelta.encode( + message.policyDelta, + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified AuditData message, length delimited. Does not implicitly {@link google.iam.v1.logging.AuditData.verify|verify} messages. + * @function encodeDelimited + * @memberof google.iam.v1.logging.AuditData + * @static + * @param {google.iam.v1.logging.IAuditData} message AuditData message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AuditData.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an AuditData message from the specified reader or buffer. + * @function decode + * @memberof google.iam.v1.logging.AuditData + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.iam.v1.logging.AuditData} AuditData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AuditData.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.iam.v1.logging.AuditData() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 2: + message.policyDelta = $root.google.iam.v1.PolicyDelta.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an AuditData message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.iam.v1.logging.AuditData + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.iam.v1.logging.AuditData} AuditData + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AuditData.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an AuditData message. + * @function verify + * @memberof google.iam.v1.logging.AuditData + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AuditData.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.policyDelta != null && + message.hasOwnProperty('policyDelta') + ) { + var error = $root.google.iam.v1.PolicyDelta.verify( + message.policyDelta + ) + if (error) return 'policyDelta.' + error + } + return null + } + + /** + * Creates an AuditData message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.iam.v1.logging.AuditData + * @static + * @param {Object.} object Plain object + * @returns {google.iam.v1.logging.AuditData} AuditData + */ + AuditData.fromObject = function fromObject(object) { + if (object instanceof $root.google.iam.v1.logging.AuditData) + return object + var message = new $root.google.iam.v1.logging.AuditData() + if (object.policyDelta != null) { + if (typeof object.policyDelta !== 'object') + throw TypeError( + '.google.iam.v1.logging.AuditData.policyDelta: object expected' + ) + message.policyDelta = $root.google.iam.v1.PolicyDelta.fromObject( + object.policyDelta + ) + } + return message + } + + /** + * Creates a plain object from an AuditData message. Also converts values to other types if specified. + * @function toObject + * @memberof google.iam.v1.logging.AuditData + * @static + * @param {google.iam.v1.logging.AuditData} message AuditData + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AuditData.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.defaults) object.policyDelta = null + if ( + message.policyDelta != null && + message.hasOwnProperty('policyDelta') + ) + object.policyDelta = $root.google.iam.v1.PolicyDelta.toObject( + message.policyDelta, + options + ) + return object + } + + /** + * Converts this AuditData to JSON. + * @function toJSON + * @memberof google.iam.v1.logging.AuditData + * @instance + * @returns {Object.} JSON object + */ + AuditData.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return AuditData + })() + + return logging + })() + + return v1 + })() + + return iam + })() + + google.api = (function () { + /** + * Namespace api. + * @memberof google + * @namespace + */ + var api = {} + + api.Http = (function () { + /** + * Properties of a Http. + * @memberof google.api + * @interface IHttp + * @property {Array.|null} [rules] Http rules + * @property {boolean|null} [fullyDecodeReservedExpansion] Http fullyDecodeReservedExpansion + */ + + /** + * Constructs a new Http. + * @memberof google.api + * @classdesc Represents a Http. + * @implements IHttp + * @constructor + * @param {google.api.IHttp=} [properties] Properties to set + */ + function Http(properties) { + this.rules = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * Http rules. + * @member {Array.} rules + * @memberof google.api.Http + * @instance + */ + Http.prototype.rules = $util.emptyArray + + /** + * Http fullyDecodeReservedExpansion. + * @member {boolean} fullyDecodeReservedExpansion + * @memberof google.api.Http + * @instance + */ + Http.prototype.fullyDecodeReservedExpansion = false + + /** + * Creates a new Http instance using the specified properties. + * @function create + * @memberof google.api.Http + * @static + * @param {google.api.IHttp=} [properties] Properties to set + * @returns {google.api.Http} Http instance + */ + Http.create = function create(properties) { + return new Http(properties) + } + + /** + * Encodes the specified Http message. Does not implicitly {@link google.api.Http.verify|verify} messages. + * @function encode + * @memberof google.api.Http + * @static + * @param {google.api.IHttp} message Http message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Http.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.rules != null && message.rules.length) + for (var i = 0; i < message.rules.length; ++i) + $root.google.api.HttpRule.encode( + message.rules[i], + writer.uint32(/* id 1, wireType 2 =*/ 10).fork() + ).ldelim() + if ( + message.fullyDecodeReservedExpansion != null && + message.hasOwnProperty('fullyDecodeReservedExpansion') + ) + writer + .uint32(/* id 2, wireType 0 =*/ 16) + .bool(message.fullyDecodeReservedExpansion) + return writer + } + + /** + * Encodes the specified Http message, length delimited. Does not implicitly {@link google.api.Http.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.Http + * @static + * @param {google.api.IHttp} message Http message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Http.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a Http message from the specified reader or buffer. + * @function decode + * @memberof google.api.Http + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.Http} Http + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Http.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.api.Http() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + if (!(message.rules && message.rules.length)) + message.rules = [] + message.rules.push( + $root.google.api.HttpRule.decode( + reader, + reader.uint32() + ) + ) + break + case 2: + message.fullyDecodeReservedExpansion = reader.bool() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a Http message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.Http + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.Http} Http + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Http.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a Http message. + * @function verify + * @memberof google.api.Http + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Http.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.rules != null && message.hasOwnProperty('rules')) { + if (!Array.isArray(message.rules)) + return 'rules: array expected' + for (var i = 0; i < message.rules.length; ++i) { + var error = $root.google.api.HttpRule.verify( + message.rules[i] + ) + if (error) return 'rules.' + error + } + } + if ( + message.fullyDecodeReservedExpansion != null && + message.hasOwnProperty('fullyDecodeReservedExpansion') + ) + if (typeof message.fullyDecodeReservedExpansion !== 'boolean') + return 'fullyDecodeReservedExpansion: boolean expected' + return null + } + + /** + * Creates a Http message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.Http + * @static + * @param {Object.} object Plain object + * @returns {google.api.Http} Http + */ + Http.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.Http) return object + var message = new $root.google.api.Http() + if (object.rules) { + if (!Array.isArray(object.rules)) + throw TypeError('.google.api.Http.rules: array expected') + message.rules = [] + for (var i = 0; i < object.rules.length; ++i) { + if (typeof object.rules[i] !== 'object') + throw TypeError('.google.api.Http.rules: object expected') + message.rules[i] = $root.google.api.HttpRule.fromObject( + object.rules[i] + ) + } + } + if (object.fullyDecodeReservedExpansion != null) + message.fullyDecodeReservedExpansion = Boolean( + object.fullyDecodeReservedExpansion + ) + return message + } + + /** + * Creates a plain object from a Http message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.Http + * @static + * @param {google.api.Http} message Http + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Http.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) object.rules = [] + if (options.defaults) + object.fullyDecodeReservedExpansion = false + if (message.rules && message.rules.length) { + object.rules = [] + for (var j = 0; j < message.rules.length; ++j) + object.rules[j] = $root.google.api.HttpRule.toObject( + message.rules[j], + options + ) + } + if ( + message.fullyDecodeReservedExpansion != null && + message.hasOwnProperty('fullyDecodeReservedExpansion') + ) + object.fullyDecodeReservedExpansion = + message.fullyDecodeReservedExpansion + return object + } + + /** + * Converts this Http to JSON. + * @function toJSON + * @memberof google.api.Http + * @instance + * @returns {Object.} JSON object + */ + Http.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return Http + })() + + api.HttpRule = (function () { + /** + * Properties of a HttpRule. + * @memberof google.api + * @interface IHttpRule + * @property {string|null} [selector] HttpRule selector + * @property {string|null} [get] HttpRule get + * @property {string|null} [put] HttpRule put + * @property {string|null} [post] HttpRule post + * @property {string|null} ["delete"] HttpRule delete + * @property {string|null} [patch] HttpRule patch + * @property {google.api.ICustomHttpPattern|null} [custom] HttpRule custom + * @property {string|null} [body] HttpRule body + * @property {string|null} [responseBody] HttpRule responseBody + * @property {Array.|null} [additionalBindings] HttpRule additionalBindings + */ + + /** + * Constructs a new HttpRule. + * @memberof google.api + * @classdesc Represents a HttpRule. + * @implements IHttpRule + * @constructor + * @param {google.api.IHttpRule=} [properties] Properties to set + */ + function HttpRule(properties) { + this.additionalBindings = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * HttpRule selector. + * @member {string} selector + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.selector = '' + + /** + * HttpRule get. + * @member {string} get + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.get = '' + + /** + * HttpRule put. + * @member {string} put + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.put = '' + + /** + * HttpRule post. + * @member {string} post + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.post = '' + + /** + * HttpRule delete. + * @member {string} delete + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype['delete'] = '' + + /** + * HttpRule patch. + * @member {string} patch + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.patch = '' + + /** + * HttpRule custom. + * @member {google.api.ICustomHttpPattern|null|undefined} custom + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.custom = null + + /** + * HttpRule body. + * @member {string} body + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.body = '' + + /** + * HttpRule responseBody. + * @member {string} responseBody + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.responseBody = '' + + /** + * HttpRule additionalBindings. + * @member {Array.} additionalBindings + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.additionalBindings = $util.emptyArray + + // OneOf field names bound to virtual getters and setters + var $oneOfFields + + /** + * HttpRule pattern. + * @member {"get"|"put"|"post"|"delete"|"patch"|"custom"|undefined} pattern + * @memberof google.api.HttpRule + * @instance + */ + Object.defineProperty(HttpRule.prototype, 'pattern', { + get: $util.oneOfGetter( + ($oneOfFields = [ + 'get', + 'put', + 'post', + 'delete', + 'patch', + 'custom' + ]) + ), + set: $util.oneOfSetter($oneOfFields) + }) + + /** + * Creates a new HttpRule instance using the specified properties. + * @function create + * @memberof google.api.HttpRule + * @static + * @param {google.api.IHttpRule=} [properties] Properties to set + * @returns {google.api.HttpRule} HttpRule instance + */ + HttpRule.create = function create(properties) { + return new HttpRule(properties) + } + + /** + * Encodes the specified HttpRule message. Does not implicitly {@link google.api.HttpRule.verify|verify} messages. + * @function encode + * @memberof google.api.HttpRule + * @static + * @param {google.api.IHttpRule} message HttpRule message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + HttpRule.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.selector != null && + message.hasOwnProperty('selector') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.selector) + if (message.get != null && message.hasOwnProperty('get')) + writer.uint32(/* id 2, wireType 2 =*/ 18).string(message.get) + if (message.put != null && message.hasOwnProperty('put')) + writer.uint32(/* id 3, wireType 2 =*/ 26).string(message.put) + if (message.post != null && message.hasOwnProperty('post')) + writer.uint32(/* id 4, wireType 2 =*/ 34).string(message.post) + if ( + message['delete'] != null && + message.hasOwnProperty('delete') + ) + writer + .uint32(/* id 5, wireType 2 =*/ 42) + .string(message['delete']) + if (message.patch != null && message.hasOwnProperty('patch')) + writer + .uint32(/* id 6, wireType 2 =*/ 50) + .string(message.patch) + if (message.body != null && message.hasOwnProperty('body')) + writer.uint32(/* id 7, wireType 2 =*/ 58).string(message.body) + if (message.custom != null && message.hasOwnProperty('custom')) + $root.google.api.CustomHttpPattern.encode( + message.custom, + writer.uint32(/* id 8, wireType 2 =*/ 66).fork() + ).ldelim() + if ( + message.additionalBindings != null && + message.additionalBindings.length + ) + for (var i = 0; i < message.additionalBindings.length; ++i) + $root.google.api.HttpRule.encode( + message.additionalBindings[i], + writer.uint32(/* id 11, wireType 2 =*/ 90).fork() + ).ldelim() + if ( + message.responseBody != null && + message.hasOwnProperty('responseBody') + ) + writer + .uint32(/* id 12, wireType 2 =*/ 98) + .string(message.responseBody) + return writer + } + + /** + * Encodes the specified HttpRule message, length delimited. Does not implicitly {@link google.api.HttpRule.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.HttpRule + * @static + * @param {google.api.IHttpRule} message HttpRule message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + HttpRule.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a HttpRule message from the specified reader or buffer. + * @function decode + * @memberof google.api.HttpRule + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.HttpRule} HttpRule + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + HttpRule.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.api.HttpRule() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.selector = reader.string() + break + case 2: + message.get = reader.string() + break + case 3: + message.put = reader.string() + break + case 4: + message.post = reader.string() + break + case 5: + message['delete'] = reader.string() + break + case 6: + message.patch = reader.string() + break + case 8: + message.custom = $root.google.api.CustomHttpPattern.decode( + reader, + reader.uint32() + ) + break + case 7: + message.body = reader.string() + break + case 12: + message.responseBody = reader.string() + break + case 11: + if ( + !( + message.additionalBindings && + message.additionalBindings.length + ) + ) + message.additionalBindings = [] + message.additionalBindings.push( + $root.google.api.HttpRule.decode( + reader, + reader.uint32() + ) + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a HttpRule message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.HttpRule + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.HttpRule} HttpRule + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + HttpRule.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a HttpRule message. + * @function verify + * @memberof google.api.HttpRule + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + HttpRule.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + var properties = {} + if ( + message.selector != null && + message.hasOwnProperty('selector') + ) + if (!$util.isString(message.selector)) + return 'selector: string expected' + if (message.get != null && message.hasOwnProperty('get')) { + properties.pattern = 1 + if (!$util.isString(message.get)) + return 'get: string expected' + } + if (message.put != null && message.hasOwnProperty('put')) { + if (properties.pattern === 1) + return 'pattern: multiple values' + properties.pattern = 1 + if (!$util.isString(message.put)) + return 'put: string expected' + } + if (message.post != null && message.hasOwnProperty('post')) { + if (properties.pattern === 1) + return 'pattern: multiple values' + properties.pattern = 1 + if (!$util.isString(message.post)) + return 'post: string expected' + } + if ( + message['delete'] != null && + message.hasOwnProperty('delete') + ) { + if (properties.pattern === 1) + return 'pattern: multiple values' + properties.pattern = 1 + if (!$util.isString(message['delete'])) + return 'delete: string expected' + } + if (message.patch != null && message.hasOwnProperty('patch')) { + if (properties.pattern === 1) + return 'pattern: multiple values' + properties.pattern = 1 + if (!$util.isString(message.patch)) + return 'patch: string expected' + } + if ( + message.custom != null && + message.hasOwnProperty('custom') + ) { + if (properties.pattern === 1) + return 'pattern: multiple values' + properties.pattern = 1 + { + var error = $root.google.api.CustomHttpPattern.verify( + message.custom + ) + if (error) return 'custom.' + error + } + } + if (message.body != null && message.hasOwnProperty('body')) + if (!$util.isString(message.body)) + return 'body: string expected' + if ( + message.responseBody != null && + message.hasOwnProperty('responseBody') + ) + if (!$util.isString(message.responseBody)) + return 'responseBody: string expected' + if ( + message.additionalBindings != null && + message.hasOwnProperty('additionalBindings') + ) { + if (!Array.isArray(message.additionalBindings)) + return 'additionalBindings: array expected' + for (var i = 0; i < message.additionalBindings.length; ++i) { + var error = $root.google.api.HttpRule.verify( + message.additionalBindings[i] + ) + if (error) return 'additionalBindings.' + error + } + } + return null + } + + /** + * Creates a HttpRule message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.HttpRule + * @static + * @param {Object.} object Plain object + * @returns {google.api.HttpRule} HttpRule + */ + HttpRule.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.HttpRule) return object + var message = new $root.google.api.HttpRule() + if (object.selector != null) + message.selector = String(object.selector) + if (object.get != null) message.get = String(object.get) + if (object.put != null) message.put = String(object.put) + if (object.post != null) message.post = String(object.post) + if (object['delete'] != null) + message['delete'] = String(object['delete']) + if (object.patch != null) message.patch = String(object.patch) + if (object.custom != null) { + if (typeof object.custom !== 'object') + throw TypeError( + '.google.api.HttpRule.custom: object expected' + ) + message.custom = $root.google.api.CustomHttpPattern.fromObject( + object.custom + ) + } + if (object.body != null) message.body = String(object.body) + if (object.responseBody != null) + message.responseBody = String(object.responseBody) + if (object.additionalBindings) { + if (!Array.isArray(object.additionalBindings)) + throw TypeError( + '.google.api.HttpRule.additionalBindings: array expected' + ) + message.additionalBindings = [] + for (var i = 0; i < object.additionalBindings.length; ++i) { + if (typeof object.additionalBindings[i] !== 'object') + throw TypeError( + '.google.api.HttpRule.additionalBindings: object expected' + ) + message.additionalBindings[ + i + ] = $root.google.api.HttpRule.fromObject( + object.additionalBindings[i] + ) + } + } + return message + } + + /** + * Creates a plain object from a HttpRule message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.HttpRule + * @static + * @param {google.api.HttpRule} message HttpRule + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + HttpRule.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) + object.additionalBindings = [] + if (options.defaults) { + object.selector = '' + object.body = '' + object.responseBody = '' + } + if ( + message.selector != null && + message.hasOwnProperty('selector') + ) + object.selector = message.selector + if (message.get != null && message.hasOwnProperty('get')) { + object.get = message.get + if (options.oneofs) object.pattern = 'get' + } + if (message.put != null && message.hasOwnProperty('put')) { + object.put = message.put + if (options.oneofs) object.pattern = 'put' + } + if (message.post != null && message.hasOwnProperty('post')) { + object.post = message.post + if (options.oneofs) object.pattern = 'post' + } + if ( + message['delete'] != null && + message.hasOwnProperty('delete') + ) { + object['delete'] = message['delete'] + if (options.oneofs) object.pattern = 'delete' + } + if (message.patch != null && message.hasOwnProperty('patch')) { + object.patch = message.patch + if (options.oneofs) object.pattern = 'patch' + } + if (message.body != null && message.hasOwnProperty('body')) + object.body = message.body + if ( + message.custom != null && + message.hasOwnProperty('custom') + ) { + object.custom = $root.google.api.CustomHttpPattern.toObject( + message.custom, + options + ) + if (options.oneofs) object.pattern = 'custom' + } + if ( + message.additionalBindings && + message.additionalBindings.length + ) { + object.additionalBindings = [] + for (var j = 0; j < message.additionalBindings.length; ++j) + object.additionalBindings[ + j + ] = $root.google.api.HttpRule.toObject( + message.additionalBindings[j], + options + ) + } + if ( + message.responseBody != null && + message.hasOwnProperty('responseBody') + ) + object.responseBody = message.responseBody + return object + } + + /** + * Converts this HttpRule to JSON. + * @function toJSON + * @memberof google.api.HttpRule + * @instance + * @returns {Object.} JSON object + */ + HttpRule.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return HttpRule + })() + + api.CustomHttpPattern = (function () { + /** + * Properties of a CustomHttpPattern. + * @memberof google.api + * @interface ICustomHttpPattern + * @property {string|null} [kind] CustomHttpPattern kind + * @property {string|null} [path] CustomHttpPattern path + */ + + /** + * Constructs a new CustomHttpPattern. + * @memberof google.api + * @classdesc Represents a CustomHttpPattern. + * @implements ICustomHttpPattern + * @constructor + * @param {google.api.ICustomHttpPattern=} [properties] Properties to set + */ + function CustomHttpPattern(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * CustomHttpPattern kind. + * @member {string} kind + * @memberof google.api.CustomHttpPattern + * @instance + */ + CustomHttpPattern.prototype.kind = '' + + /** + * CustomHttpPattern path. + * @member {string} path + * @memberof google.api.CustomHttpPattern + * @instance + */ + CustomHttpPattern.prototype.path = '' + + /** + * Creates a new CustomHttpPattern instance using the specified properties. + * @function create + * @memberof google.api.CustomHttpPattern + * @static + * @param {google.api.ICustomHttpPattern=} [properties] Properties to set + * @returns {google.api.CustomHttpPattern} CustomHttpPattern instance + */ + CustomHttpPattern.create = function create(properties) { + return new CustomHttpPattern(properties) + } + + /** + * Encodes the specified CustomHttpPattern message. Does not implicitly {@link google.api.CustomHttpPattern.verify|verify} messages. + * @function encode + * @memberof google.api.CustomHttpPattern + * @static + * @param {google.api.ICustomHttpPattern} message CustomHttpPattern message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CustomHttpPattern.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.kind != null && message.hasOwnProperty('kind')) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.kind) + if (message.path != null && message.hasOwnProperty('path')) + writer.uint32(/* id 2, wireType 2 =*/ 18).string(message.path) + return writer + } + + /** + * Encodes the specified CustomHttpPattern message, length delimited. Does not implicitly {@link google.api.CustomHttpPattern.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.CustomHttpPattern + * @static + * @param {google.api.ICustomHttpPattern} message CustomHttpPattern message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CustomHttpPattern.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a CustomHttpPattern message from the specified reader or buffer. + * @function decode + * @memberof google.api.CustomHttpPattern + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.CustomHttpPattern} CustomHttpPattern + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CustomHttpPattern.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.api.CustomHttpPattern() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.kind = reader.string() + break + case 2: + message.path = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a CustomHttpPattern message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.CustomHttpPattern + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.CustomHttpPattern} CustomHttpPattern + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CustomHttpPattern.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a CustomHttpPattern message. + * @function verify + * @memberof google.api.CustomHttpPattern + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CustomHttpPattern.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.kind != null && message.hasOwnProperty('kind')) + if (!$util.isString(message.kind)) + return 'kind: string expected' + if (message.path != null && message.hasOwnProperty('path')) + if (!$util.isString(message.path)) + return 'path: string expected' + return null + } + + /** + * Creates a CustomHttpPattern message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.CustomHttpPattern + * @static + * @param {Object.} object Plain object + * @returns {google.api.CustomHttpPattern} CustomHttpPattern + */ + CustomHttpPattern.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.CustomHttpPattern) + return object + var message = new $root.google.api.CustomHttpPattern() + if (object.kind != null) message.kind = String(object.kind) + if (object.path != null) message.path = String(object.path) + return message + } + + /** + * Creates a plain object from a CustomHttpPattern message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.CustomHttpPattern + * @static + * @param {google.api.CustomHttpPattern} message CustomHttpPattern + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CustomHttpPattern.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.kind = '' + object.path = '' + } + if (message.kind != null && message.hasOwnProperty('kind')) + object.kind = message.kind + if (message.path != null && message.hasOwnProperty('path')) + object.path = message.path + return object + } + + /** + * Converts this CustomHttpPattern to JSON. + * @function toJSON + * @memberof google.api.CustomHttpPattern + * @instance + * @returns {Object.} JSON object + */ + CustomHttpPattern.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return CustomHttpPattern + })() + + /** + * FieldBehavior enum. + * @name google.api.FieldBehavior + * @enum {string} + * @property {number} FIELD_BEHAVIOR_UNSPECIFIED=0 FIELD_BEHAVIOR_UNSPECIFIED value + * @property {number} OPTIONAL=1 OPTIONAL value + * @property {number} REQUIRED=2 REQUIRED value + * @property {number} OUTPUT_ONLY=3 OUTPUT_ONLY value + * @property {number} INPUT_ONLY=4 INPUT_ONLY value + * @property {number} IMMUTABLE=5 IMMUTABLE value + */ + api.FieldBehavior = (function () { + var valuesById = {}, + values = Object.create(valuesById) + values[(valuesById[0] = 'FIELD_BEHAVIOR_UNSPECIFIED')] = 0 + values[(valuesById[1] = 'OPTIONAL')] = 1 + values[(valuesById[2] = 'REQUIRED')] = 2 + values[(valuesById[3] = 'OUTPUT_ONLY')] = 3 + values[(valuesById[4] = 'INPUT_ONLY')] = 4 + values[(valuesById[5] = 'IMMUTABLE')] = 5 + return values + })() + + api.ResourceDescriptor = (function () { + /** + * Properties of a ResourceDescriptor. + * @memberof google.api + * @interface IResourceDescriptor + * @property {string|null} [type] ResourceDescriptor type + * @property {Array.|null} [pattern] ResourceDescriptor pattern + * @property {string|null} [nameField] ResourceDescriptor nameField + * @property {google.api.ResourceDescriptor.History|null} [history] ResourceDescriptor history + * @property {string|null} [plural] ResourceDescriptor plural + * @property {string|null} [singular] ResourceDescriptor singular + */ + + /** + * Constructs a new ResourceDescriptor. + * @memberof google.api + * @classdesc Represents a ResourceDescriptor. + * @implements IResourceDescriptor + * @constructor + * @param {google.api.IResourceDescriptor=} [properties] Properties to set + */ + function ResourceDescriptor(properties) { + this.pattern = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * ResourceDescriptor type. + * @member {string} type + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.type = '' + + /** + * ResourceDescriptor pattern. + * @member {Array.} pattern + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.pattern = $util.emptyArray + + /** + * ResourceDescriptor nameField. + * @member {string} nameField + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.nameField = '' + + /** + * ResourceDescriptor history. + * @member {google.api.ResourceDescriptor.History} history + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.history = 0 + + /** + * ResourceDescriptor plural. + * @member {string} plural + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.plural = '' + + /** + * ResourceDescriptor singular. + * @member {string} singular + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.singular = '' + + /** + * Creates a new ResourceDescriptor instance using the specified properties. + * @function create + * @memberof google.api.ResourceDescriptor + * @static + * @param {google.api.IResourceDescriptor=} [properties] Properties to set + * @returns {google.api.ResourceDescriptor} ResourceDescriptor instance + */ + ResourceDescriptor.create = function create(properties) { + return new ResourceDescriptor(properties) + } + + /** + * Encodes the specified ResourceDescriptor message. Does not implicitly {@link google.api.ResourceDescriptor.verify|verify} messages. + * @function encode + * @memberof google.api.ResourceDescriptor + * @static + * @param {google.api.IResourceDescriptor} message ResourceDescriptor message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResourceDescriptor.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.type != null && message.hasOwnProperty('type')) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.type) + if (message.pattern != null && message.pattern.length) + for (var i = 0; i < message.pattern.length; ++i) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.pattern[i]) + if ( + message.nameField != null && + message.hasOwnProperty('nameField') + ) + writer + .uint32(/* id 3, wireType 2 =*/ 26) + .string(message.nameField) + if ( + message.history != null && + message.hasOwnProperty('history') + ) + writer + .uint32(/* id 4, wireType 0 =*/ 32) + .int32(message.history) + if (message.plural != null && message.hasOwnProperty('plural')) + writer + .uint32(/* id 5, wireType 2 =*/ 42) + .string(message.plural) + if ( + message.singular != null && + message.hasOwnProperty('singular') + ) + writer + .uint32(/* id 6, wireType 2 =*/ 50) + .string(message.singular) + return writer + } + + /** + * Encodes the specified ResourceDescriptor message, length delimited. Does not implicitly {@link google.api.ResourceDescriptor.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.ResourceDescriptor + * @static + * @param {google.api.IResourceDescriptor} message ResourceDescriptor message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResourceDescriptor.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a ResourceDescriptor message from the specified reader or buffer. + * @function decode + * @memberof google.api.ResourceDescriptor + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.ResourceDescriptor} ResourceDescriptor + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResourceDescriptor.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.api.ResourceDescriptor() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.type = reader.string() + break + case 2: + if (!(message.pattern && message.pattern.length)) + message.pattern = [] + message.pattern.push(reader.string()) + break + case 3: + message.nameField = reader.string() + break + case 4: + message.history = reader.int32() + break + case 5: + message.plural = reader.string() + break + case 6: + message.singular = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a ResourceDescriptor message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.ResourceDescriptor + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.ResourceDescriptor} ResourceDescriptor + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResourceDescriptor.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a ResourceDescriptor message. + * @function verify + * @memberof google.api.ResourceDescriptor + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ResourceDescriptor.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.type != null && message.hasOwnProperty('type')) + if (!$util.isString(message.type)) + return 'type: string expected' + if ( + message.pattern != null && + message.hasOwnProperty('pattern') + ) { + if (!Array.isArray(message.pattern)) + return 'pattern: array expected' + for (var i = 0; i < message.pattern.length; ++i) + if (!$util.isString(message.pattern[i])) + return 'pattern: string[] expected' + } + if ( + message.nameField != null && + message.hasOwnProperty('nameField') + ) + if (!$util.isString(message.nameField)) + return 'nameField: string expected' + if ( + message.history != null && + message.hasOwnProperty('history') + ) + switch (message.history) { + default: + return 'history: enum value expected' + case 0: + case 1: + case 2: + break + } + if (message.plural != null && message.hasOwnProperty('plural')) + if (!$util.isString(message.plural)) + return 'plural: string expected' + if ( + message.singular != null && + message.hasOwnProperty('singular') + ) + if (!$util.isString(message.singular)) + return 'singular: string expected' + return null + } + + /** + * Creates a ResourceDescriptor message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.ResourceDescriptor + * @static + * @param {Object.} object Plain object + * @returns {google.api.ResourceDescriptor} ResourceDescriptor + */ + ResourceDescriptor.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.ResourceDescriptor) + return object + var message = new $root.google.api.ResourceDescriptor() + if (object.type != null) message.type = String(object.type) + if (object.pattern) { + if (!Array.isArray(object.pattern)) + throw TypeError( + '.google.api.ResourceDescriptor.pattern: array expected' + ) + message.pattern = [] + for (var i = 0; i < object.pattern.length; ++i) + message.pattern[i] = String(object.pattern[i]) + } + if (object.nameField != null) + message.nameField = String(object.nameField) + switch (object.history) { + case 'HISTORY_UNSPECIFIED': + case 0: + message.history = 0 + break + case 'ORIGINALLY_SINGLE_PATTERN': + case 1: + message.history = 1 + break + case 'FUTURE_MULTI_PATTERN': + case 2: + message.history = 2 + break + } + if (object.plural != null) + message.plural = String(object.plural) + if (object.singular != null) + message.singular = String(object.singular) + return message + } + + /** + * Creates a plain object from a ResourceDescriptor message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.ResourceDescriptor + * @static + * @param {google.api.ResourceDescriptor} message ResourceDescriptor + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ResourceDescriptor.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) object.pattern = [] + if (options.defaults) { + object.type = '' + object.nameField = '' + object.history = + options.enums === String ? 'HISTORY_UNSPECIFIED' : 0 + object.plural = '' + object.singular = '' + } + if (message.type != null && message.hasOwnProperty('type')) + object.type = message.type + if (message.pattern && message.pattern.length) { + object.pattern = [] + for (var j = 0; j < message.pattern.length; ++j) + object.pattern[j] = message.pattern[j] + } + if ( + message.nameField != null && + message.hasOwnProperty('nameField') + ) + object.nameField = message.nameField + if ( + message.history != null && + message.hasOwnProperty('history') + ) + object.history = + options.enums === String + ? $root.google.api.ResourceDescriptor.History[ + message.history + ] + : message.history + if (message.plural != null && message.hasOwnProperty('plural')) + object.plural = message.plural + if ( + message.singular != null && + message.hasOwnProperty('singular') + ) + object.singular = message.singular + return object + } + + /** + * Converts this ResourceDescriptor to JSON. + * @function toJSON + * @memberof google.api.ResourceDescriptor + * @instance + * @returns {Object.} JSON object + */ + ResourceDescriptor.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + /** + * History enum. + * @name google.api.ResourceDescriptor.History + * @enum {string} + * @property {number} HISTORY_UNSPECIFIED=0 HISTORY_UNSPECIFIED value + * @property {number} ORIGINALLY_SINGLE_PATTERN=1 ORIGINALLY_SINGLE_PATTERN value + * @property {number} FUTURE_MULTI_PATTERN=2 FUTURE_MULTI_PATTERN value + */ + ResourceDescriptor.History = (function () { + var valuesById = {}, + values = Object.create(valuesById) + values[(valuesById[0] = 'HISTORY_UNSPECIFIED')] = 0 + values[(valuesById[1] = 'ORIGINALLY_SINGLE_PATTERN')] = 1 + values[(valuesById[2] = 'FUTURE_MULTI_PATTERN')] = 2 + return values + })() + + return ResourceDescriptor + })() + + api.ResourceReference = (function () { + /** + * Properties of a ResourceReference. + * @memberof google.api + * @interface IResourceReference + * @property {string|null} [type] ResourceReference type + * @property {string|null} [childType] ResourceReference childType + */ + + /** + * Constructs a new ResourceReference. + * @memberof google.api + * @classdesc Represents a ResourceReference. + * @implements IResourceReference + * @constructor + * @param {google.api.IResourceReference=} [properties] Properties to set + */ + function ResourceReference(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * ResourceReference type. + * @member {string} type + * @memberof google.api.ResourceReference + * @instance + */ + ResourceReference.prototype.type = '' + + /** + * ResourceReference childType. + * @member {string} childType + * @memberof google.api.ResourceReference + * @instance + */ + ResourceReference.prototype.childType = '' + + /** + * Creates a new ResourceReference instance using the specified properties. + * @function create + * @memberof google.api.ResourceReference + * @static + * @param {google.api.IResourceReference=} [properties] Properties to set + * @returns {google.api.ResourceReference} ResourceReference instance + */ + ResourceReference.create = function create(properties) { + return new ResourceReference(properties) + } + + /** + * Encodes the specified ResourceReference message. Does not implicitly {@link google.api.ResourceReference.verify|verify} messages. + * @function encode + * @memberof google.api.ResourceReference + * @static + * @param {google.api.IResourceReference} message ResourceReference message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResourceReference.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.type != null && message.hasOwnProperty('type')) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.type) + if ( + message.childType != null && + message.hasOwnProperty('childType') + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.childType) + return writer + } + + /** + * Encodes the specified ResourceReference message, length delimited. Does not implicitly {@link google.api.ResourceReference.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.ResourceReference + * @static + * @param {google.api.IResourceReference} message ResourceReference message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResourceReference.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a ResourceReference message from the specified reader or buffer. + * @function decode + * @memberof google.api.ResourceReference + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.ResourceReference} ResourceReference + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResourceReference.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.api.ResourceReference() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.type = reader.string() + break + case 2: + message.childType = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a ResourceReference message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.ResourceReference + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.ResourceReference} ResourceReference + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResourceReference.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a ResourceReference message. + * @function verify + * @memberof google.api.ResourceReference + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ResourceReference.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.type != null && message.hasOwnProperty('type')) + if (!$util.isString(message.type)) + return 'type: string expected' + if ( + message.childType != null && + message.hasOwnProperty('childType') + ) + if (!$util.isString(message.childType)) + return 'childType: string expected' + return null + } + + /** + * Creates a ResourceReference message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.ResourceReference + * @static + * @param {Object.} object Plain object + * @returns {google.api.ResourceReference} ResourceReference + */ + ResourceReference.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.ResourceReference) + return object + var message = new $root.google.api.ResourceReference() + if (object.type != null) message.type = String(object.type) + if (object.childType != null) + message.childType = String(object.childType) + return message + } + + /** + * Creates a plain object from a ResourceReference message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.ResourceReference + * @static + * @param {google.api.ResourceReference} message ResourceReference + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ResourceReference.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.type = '' + object.childType = '' + } + if (message.type != null && message.hasOwnProperty('type')) + object.type = message.type + if ( + message.childType != null && + message.hasOwnProperty('childType') + ) + object.childType = message.childType + return object + } + + /** + * Converts this ResourceReference to JSON. + * @function toJSON + * @memberof google.api.ResourceReference + * @instance + * @returns {Object.} JSON object + */ + ResourceReference.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return ResourceReference + })() + + return api + })() + + google.protobuf = (function () { + /** + * Namespace protobuf. + * @memberof google + * @namespace + */ + var protobuf = {} + + protobuf.FileDescriptorSet = (function () { + /** + * Properties of a FileDescriptorSet. + * @memberof google.protobuf + * @interface IFileDescriptorSet + * @property {Array.|null} [file] FileDescriptorSet file + */ + + /** + * Constructs a new FileDescriptorSet. + * @memberof google.protobuf + * @classdesc Represents a FileDescriptorSet. + * @implements IFileDescriptorSet + * @constructor + * @param {google.protobuf.IFileDescriptorSet=} [properties] Properties to set + */ + function FileDescriptorSet(properties) { + this.file = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * FileDescriptorSet file. + * @member {Array.} file + * @memberof google.protobuf.FileDescriptorSet + * @instance + */ + FileDescriptorSet.prototype.file = $util.emptyArray + + /** + * Creates a new FileDescriptorSet instance using the specified properties. + * @function create + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {google.protobuf.IFileDescriptorSet=} [properties] Properties to set + * @returns {google.protobuf.FileDescriptorSet} FileDescriptorSet instance + */ + FileDescriptorSet.create = function create(properties) { + return new FileDescriptorSet(properties) + } + + /** + * Encodes the specified FileDescriptorSet message. Does not implicitly {@link google.protobuf.FileDescriptorSet.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {google.protobuf.IFileDescriptorSet} message FileDescriptorSet message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FileDescriptorSet.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.file != null && message.file.length) + for (var i = 0; i < message.file.length; ++i) + $root.google.protobuf.FileDescriptorProto.encode( + message.file[i], + writer.uint32(/* id 1, wireType 2 =*/ 10).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified FileDescriptorSet message, length delimited. Does not implicitly {@link google.protobuf.FileDescriptorSet.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {google.protobuf.IFileDescriptorSet} message FileDescriptorSet message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FileDescriptorSet.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a FileDescriptorSet message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FileDescriptorSet} FileDescriptorSet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FileDescriptorSet.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.FileDescriptorSet() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + if (!(message.file && message.file.length)) + message.file = [] + message.file.push( + $root.google.protobuf.FileDescriptorProto.decode( + reader, + reader.uint32() + ) + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a FileDescriptorSet message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FileDescriptorSet} FileDescriptorSet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FileDescriptorSet.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a FileDescriptorSet message. + * @function verify + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FileDescriptorSet.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.file != null && message.hasOwnProperty('file')) { + if (!Array.isArray(message.file)) + return 'file: array expected' + for (var i = 0; i < message.file.length; ++i) { + var error = $root.google.protobuf.FileDescriptorProto.verify( + message.file[i] + ) + if (error) return 'file.' + error + } + } + return null + } + + /** + * Creates a FileDescriptorSet message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FileDescriptorSet} FileDescriptorSet + */ + FileDescriptorSet.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FileDescriptorSet) + return object + var message = new $root.google.protobuf.FileDescriptorSet() + if (object.file) { + if (!Array.isArray(object.file)) + throw TypeError( + '.google.protobuf.FileDescriptorSet.file: array expected' + ) + message.file = [] + for (var i = 0; i < object.file.length; ++i) { + if (typeof object.file[i] !== 'object') + throw TypeError( + '.google.protobuf.FileDescriptorSet.file: object expected' + ) + message.file[ + i + ] = $root.google.protobuf.FileDescriptorProto.fromObject( + object.file[i] + ) + } + } + return message + } + + /** + * Creates a plain object from a FileDescriptorSet message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {google.protobuf.FileDescriptorSet} message FileDescriptorSet + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FileDescriptorSet.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) object.file = [] + if (message.file && message.file.length) { + object.file = [] + for (var j = 0; j < message.file.length; ++j) + object.file[ + j + ] = $root.google.protobuf.FileDescriptorProto.toObject( + message.file[j], + options + ) + } + return object + } + + /** + * Converts this FileDescriptorSet to JSON. + * @function toJSON + * @memberof google.protobuf.FileDescriptorSet + * @instance + * @returns {Object.} JSON object + */ + FileDescriptorSet.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return FileDescriptorSet + })() + + protobuf.FileDescriptorProto = (function () { + /** + * Properties of a FileDescriptorProto. + * @memberof google.protobuf + * @interface IFileDescriptorProto + * @property {string|null} [name] FileDescriptorProto name + * @property {string|null} ["package"] FileDescriptorProto package + * @property {Array.|null} [dependency] FileDescriptorProto dependency + * @property {Array.|null} [publicDependency] FileDescriptorProto publicDependency + * @property {Array.|null} [weakDependency] FileDescriptorProto weakDependency + * @property {Array.|null} [messageType] FileDescriptorProto messageType + * @property {Array.|null} [enumType] FileDescriptorProto enumType + * @property {Array.|null} [service] FileDescriptorProto service + * @property {Array.|null} [extension] FileDescriptorProto extension + * @property {google.protobuf.IFileOptions|null} [options] FileDescriptorProto options + * @property {google.protobuf.ISourceCodeInfo|null} [sourceCodeInfo] FileDescriptorProto sourceCodeInfo + * @property {string|null} [syntax] FileDescriptorProto syntax + */ + + /** + * Constructs a new FileDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a FileDescriptorProto. + * @implements IFileDescriptorProto + * @constructor + * @param {google.protobuf.IFileDescriptorProto=} [properties] Properties to set + */ + function FileDescriptorProto(properties) { + this.dependency = [] + this.publicDependency = [] + this.weakDependency = [] + this.messageType = [] + this.enumType = [] + this.service = [] + this.extension = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * FileDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.name = '' + + /** + * FileDescriptorProto package. + * @member {string} package + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype['package'] = '' + + /** + * FileDescriptorProto dependency. + * @member {Array.} dependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.dependency = $util.emptyArray + + /** + * FileDescriptorProto publicDependency. + * @member {Array.} publicDependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.publicDependency = $util.emptyArray + + /** + * FileDescriptorProto weakDependency. + * @member {Array.} weakDependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.weakDependency = $util.emptyArray + + /** + * FileDescriptorProto messageType. + * @member {Array.} messageType + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.messageType = $util.emptyArray + + /** + * FileDescriptorProto enumType. + * @member {Array.} enumType + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.enumType = $util.emptyArray + + /** + * FileDescriptorProto service. + * @member {Array.} service + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.service = $util.emptyArray + + /** + * FileDescriptorProto extension. + * @member {Array.} extension + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.extension = $util.emptyArray + + /** + * FileDescriptorProto options. + * @member {google.protobuf.IFileOptions|null|undefined} options + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.options = null + + /** + * FileDescriptorProto sourceCodeInfo. + * @member {google.protobuf.ISourceCodeInfo|null|undefined} sourceCodeInfo + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.sourceCodeInfo = null + + /** + * FileDescriptorProto syntax. + * @member {string} syntax + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.syntax = '' + + /** + * Creates a new FileDescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {google.protobuf.IFileDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.FileDescriptorProto} FileDescriptorProto instance + */ + FileDescriptorProto.create = function create(properties) { + return new FileDescriptorProto(properties) + } + + /** + * Encodes the specified FileDescriptorProto message. Does not implicitly {@link google.protobuf.FileDescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {google.protobuf.IFileDescriptorProto} message FileDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FileDescriptorProto.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.name != null && message.hasOwnProperty('name')) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.name) + if ( + message['package'] != null && + message.hasOwnProperty('package') + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message['package']) + if (message.dependency != null && message.dependency.length) + for (var i = 0; i < message.dependency.length; ++i) + writer + .uint32(/* id 3, wireType 2 =*/ 26) + .string(message.dependency[i]) + if (message.messageType != null && message.messageType.length) + for (var i = 0; i < message.messageType.length; ++i) + $root.google.protobuf.DescriptorProto.encode( + message.messageType[i], + writer.uint32(/* id 4, wireType 2 =*/ 34).fork() + ).ldelim() + if (message.enumType != null && message.enumType.length) + for (var i = 0; i < message.enumType.length; ++i) + $root.google.protobuf.EnumDescriptorProto.encode( + message.enumType[i], + writer.uint32(/* id 5, wireType 2 =*/ 42).fork() + ).ldelim() + if (message.service != null && message.service.length) + for (var i = 0; i < message.service.length; ++i) + $root.google.protobuf.ServiceDescriptorProto.encode( + message.service[i], + writer.uint32(/* id 6, wireType 2 =*/ 50).fork() + ).ldelim() + if (message.extension != null && message.extension.length) + for (var i = 0; i < message.extension.length; ++i) + $root.google.protobuf.FieldDescriptorProto.encode( + message.extension[i], + writer.uint32(/* id 7, wireType 2 =*/ 58).fork() + ).ldelim() + if ( + message.options != null && + message.hasOwnProperty('options') + ) + $root.google.protobuf.FileOptions.encode( + message.options, + writer.uint32(/* id 8, wireType 2 =*/ 66).fork() + ).ldelim() + if ( + message.sourceCodeInfo != null && + message.hasOwnProperty('sourceCodeInfo') + ) + $root.google.protobuf.SourceCodeInfo.encode( + message.sourceCodeInfo, + writer.uint32(/* id 9, wireType 2 =*/ 74).fork() + ).ldelim() + if ( + message.publicDependency != null && + message.publicDependency.length + ) + for (var i = 0; i < message.publicDependency.length; ++i) + writer + .uint32(/* id 10, wireType 0 =*/ 80) + .int32(message.publicDependency[i]) + if ( + message.weakDependency != null && + message.weakDependency.length + ) + for (var i = 0; i < message.weakDependency.length; ++i) + writer + .uint32(/* id 11, wireType 0 =*/ 88) + .int32(message.weakDependency[i]) + if (message.syntax != null && message.hasOwnProperty('syntax')) + writer + .uint32(/* id 12, wireType 2 =*/ 98) + .string(message.syntax) + return writer + } + + /** + * Encodes the specified FileDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.FileDescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {google.protobuf.IFileDescriptorProto} message FileDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FileDescriptorProto.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a FileDescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FileDescriptorProto} FileDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FileDescriptorProto.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.FileDescriptorProto() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + case 2: + message['package'] = reader.string() + break + case 3: + if (!(message.dependency && message.dependency.length)) + message.dependency = [] + message.dependency.push(reader.string()) + break + case 10: + if ( + !( + message.publicDependency && + message.publicDependency.length + ) + ) + message.publicDependency = [] + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos + while (reader.pos < end2) + message.publicDependency.push(reader.int32()) + } else message.publicDependency.push(reader.int32()) + break + case 11: + if ( + !( + message.weakDependency && + message.weakDependency.length + ) + ) + message.weakDependency = [] + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos + while (reader.pos < end2) + message.weakDependency.push(reader.int32()) + } else message.weakDependency.push(reader.int32()) + break + case 4: + if (!(message.messageType && message.messageType.length)) + message.messageType = [] + message.messageType.push( + $root.google.protobuf.DescriptorProto.decode( + reader, + reader.uint32() + ) + ) + break + case 5: + if (!(message.enumType && message.enumType.length)) + message.enumType = [] + message.enumType.push( + $root.google.protobuf.EnumDescriptorProto.decode( + reader, + reader.uint32() + ) + ) + break + case 6: + if (!(message.service && message.service.length)) + message.service = [] + message.service.push( + $root.google.protobuf.ServiceDescriptorProto.decode( + reader, + reader.uint32() + ) + ) + break + case 7: + if (!(message.extension && message.extension.length)) + message.extension = [] + message.extension.push( + $root.google.protobuf.FieldDescriptorProto.decode( + reader, + reader.uint32() + ) + ) + break + case 8: + message.options = $root.google.protobuf.FileOptions.decode( + reader, + reader.uint32() + ) + break + case 9: + message.sourceCodeInfo = $root.google.protobuf.SourceCodeInfo.decode( + reader, + reader.uint32() + ) + break + case 12: + message.syntax = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a FileDescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FileDescriptorProto} FileDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FileDescriptorProto.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a FileDescriptorProto message. + * @function verify + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FileDescriptorProto.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + if ( + message['package'] != null && + message.hasOwnProperty('package') + ) + if (!$util.isString(message['package'])) + return 'package: string expected' + if ( + message.dependency != null && + message.hasOwnProperty('dependency') + ) { + if (!Array.isArray(message.dependency)) + return 'dependency: array expected' + for (var i = 0; i < message.dependency.length; ++i) + if (!$util.isString(message.dependency[i])) + return 'dependency: string[] expected' + } + if ( + message.publicDependency != null && + message.hasOwnProperty('publicDependency') + ) { + if (!Array.isArray(message.publicDependency)) + return 'publicDependency: array expected' + for (var i = 0; i < message.publicDependency.length; ++i) + if (!$util.isInteger(message.publicDependency[i])) + return 'publicDependency: integer[] expected' + } + if ( + message.weakDependency != null && + message.hasOwnProperty('weakDependency') + ) { + if (!Array.isArray(message.weakDependency)) + return 'weakDependency: array expected' + for (var i = 0; i < message.weakDependency.length; ++i) + if (!$util.isInteger(message.weakDependency[i])) + return 'weakDependency: integer[] expected' + } + if ( + message.messageType != null && + message.hasOwnProperty('messageType') + ) { + if (!Array.isArray(message.messageType)) + return 'messageType: array expected' + for (var i = 0; i < message.messageType.length; ++i) { + var error = $root.google.protobuf.DescriptorProto.verify( + message.messageType[i] + ) + if (error) return 'messageType.' + error + } + } + if ( + message.enumType != null && + message.hasOwnProperty('enumType') + ) { + if (!Array.isArray(message.enumType)) + return 'enumType: array expected' + for (var i = 0; i < message.enumType.length; ++i) { + var error = $root.google.protobuf.EnumDescriptorProto.verify( + message.enumType[i] + ) + if (error) return 'enumType.' + error + } + } + if ( + message.service != null && + message.hasOwnProperty('service') + ) { + if (!Array.isArray(message.service)) + return 'service: array expected' + for (var i = 0; i < message.service.length; ++i) { + var error = $root.google.protobuf.ServiceDescriptorProto.verify( + message.service[i] + ) + if (error) return 'service.' + error + } + } + if ( + message.extension != null && + message.hasOwnProperty('extension') + ) { + if (!Array.isArray(message.extension)) + return 'extension: array expected' + for (var i = 0; i < message.extension.length; ++i) { + var error = $root.google.protobuf.FieldDescriptorProto.verify( + message.extension[i] + ) + if (error) return 'extension.' + error + } + } + if ( + message.options != null && + message.hasOwnProperty('options') + ) { + var error = $root.google.protobuf.FileOptions.verify( + message.options + ) + if (error) return 'options.' + error + } + if ( + message.sourceCodeInfo != null && + message.hasOwnProperty('sourceCodeInfo') + ) { + var error = $root.google.protobuf.SourceCodeInfo.verify( + message.sourceCodeInfo + ) + if (error) return 'sourceCodeInfo.' + error + } + if (message.syntax != null && message.hasOwnProperty('syntax')) + if (!$util.isString(message.syntax)) + return 'syntax: string expected' + return null + } + + /** + * Creates a FileDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FileDescriptorProto} FileDescriptorProto + */ + FileDescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FileDescriptorProto) + return object + var message = new $root.google.protobuf.FileDescriptorProto() + if (object.name != null) message.name = String(object.name) + if (object['package'] != null) + message['package'] = String(object['package']) + if (object.dependency) { + if (!Array.isArray(object.dependency)) + throw TypeError( + '.google.protobuf.FileDescriptorProto.dependency: array expected' + ) + message.dependency = [] + for (var i = 0; i < object.dependency.length; ++i) + message.dependency[i] = String(object.dependency[i]) + } + if (object.publicDependency) { + if (!Array.isArray(object.publicDependency)) + throw TypeError( + '.google.protobuf.FileDescriptorProto.publicDependency: array expected' + ) + message.publicDependency = [] + for (var i = 0; i < object.publicDependency.length; ++i) + message.publicDependency[i] = object.publicDependency[i] | 0 + } + if (object.weakDependency) { + if (!Array.isArray(object.weakDependency)) + throw TypeError( + '.google.protobuf.FileDescriptorProto.weakDependency: array expected' + ) + message.weakDependency = [] + for (var i = 0; i < object.weakDependency.length; ++i) + message.weakDependency[i] = object.weakDependency[i] | 0 + } + if (object.messageType) { + if (!Array.isArray(object.messageType)) + throw TypeError( + '.google.protobuf.FileDescriptorProto.messageType: array expected' + ) + message.messageType = [] + for (var i = 0; i < object.messageType.length; ++i) { + if (typeof object.messageType[i] !== 'object') + throw TypeError( + '.google.protobuf.FileDescriptorProto.messageType: object expected' + ) + message.messageType[ + i + ] = $root.google.protobuf.DescriptorProto.fromObject( + object.messageType[i] + ) + } + } + if (object.enumType) { + if (!Array.isArray(object.enumType)) + throw TypeError( + '.google.protobuf.FileDescriptorProto.enumType: array expected' + ) + message.enumType = [] + for (var i = 0; i < object.enumType.length; ++i) { + if (typeof object.enumType[i] !== 'object') + throw TypeError( + '.google.protobuf.FileDescriptorProto.enumType: object expected' + ) + message.enumType[ + i + ] = $root.google.protobuf.EnumDescriptorProto.fromObject( + object.enumType[i] + ) + } + } + if (object.service) { + if (!Array.isArray(object.service)) + throw TypeError( + '.google.protobuf.FileDescriptorProto.service: array expected' + ) + message.service = [] + for (var i = 0; i < object.service.length; ++i) { + if (typeof object.service[i] !== 'object') + throw TypeError( + '.google.protobuf.FileDescriptorProto.service: object expected' + ) + message.service[ + i + ] = $root.google.protobuf.ServiceDescriptorProto.fromObject( + object.service[i] + ) + } + } + if (object.extension) { + if (!Array.isArray(object.extension)) + throw TypeError( + '.google.protobuf.FileDescriptorProto.extension: array expected' + ) + message.extension = [] + for (var i = 0; i < object.extension.length; ++i) { + if (typeof object.extension[i] !== 'object') + throw TypeError( + '.google.protobuf.FileDescriptorProto.extension: object expected' + ) + message.extension[ + i + ] = $root.google.protobuf.FieldDescriptorProto.fromObject( + object.extension[i] + ) + } + } + if (object.options != null) { + if (typeof object.options !== 'object') + throw TypeError( + '.google.protobuf.FileDescriptorProto.options: object expected' + ) + message.options = $root.google.protobuf.FileOptions.fromObject( + object.options + ) + } + if (object.sourceCodeInfo != null) { + if (typeof object.sourceCodeInfo !== 'object') + throw TypeError( + '.google.protobuf.FileDescriptorProto.sourceCodeInfo: object expected' + ) + message.sourceCodeInfo = $root.google.protobuf.SourceCodeInfo.fromObject( + object.sourceCodeInfo + ) + } + if (object.syntax != null) + message.syntax = String(object.syntax) + return message + } + + /** + * Creates a plain object from a FileDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {google.protobuf.FileDescriptorProto} message FileDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FileDescriptorProto.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) { + object.dependency = [] + object.messageType = [] + object.enumType = [] + object.service = [] + object.extension = [] + object.publicDependency = [] + object.weakDependency = [] + } + if (options.defaults) { + object.name = '' + object['package'] = '' + object.options = null + object.sourceCodeInfo = null + object.syntax = '' + } + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + if ( + message['package'] != null && + message.hasOwnProperty('package') + ) + object['package'] = message['package'] + if (message.dependency && message.dependency.length) { + object.dependency = [] + for (var j = 0; j < message.dependency.length; ++j) + object.dependency[j] = message.dependency[j] + } + if (message.messageType && message.messageType.length) { + object.messageType = [] + for (var j = 0; j < message.messageType.length; ++j) + object.messageType[ + j + ] = $root.google.protobuf.DescriptorProto.toObject( + message.messageType[j], + options + ) + } + if (message.enumType && message.enumType.length) { + object.enumType = [] + for (var j = 0; j < message.enumType.length; ++j) + object.enumType[ + j + ] = $root.google.protobuf.EnumDescriptorProto.toObject( + message.enumType[j], + options + ) + } + if (message.service && message.service.length) { + object.service = [] + for (var j = 0; j < message.service.length; ++j) + object.service[ + j + ] = $root.google.protobuf.ServiceDescriptorProto.toObject( + message.service[j], + options + ) + } + if (message.extension && message.extension.length) { + object.extension = [] + for (var j = 0; j < message.extension.length; ++j) + object.extension[ + j + ] = $root.google.protobuf.FieldDescriptorProto.toObject( + message.extension[j], + options + ) + } + if ( + message.options != null && + message.hasOwnProperty('options') + ) + object.options = $root.google.protobuf.FileOptions.toObject( + message.options, + options + ) + if ( + message.sourceCodeInfo != null && + message.hasOwnProperty('sourceCodeInfo') + ) + object.sourceCodeInfo = $root.google.protobuf.SourceCodeInfo.toObject( + message.sourceCodeInfo, + options + ) + if ( + message.publicDependency && + message.publicDependency.length + ) { + object.publicDependency = [] + for (var j = 0; j < message.publicDependency.length; ++j) + object.publicDependency[j] = message.publicDependency[j] + } + if (message.weakDependency && message.weakDependency.length) { + object.weakDependency = [] + for (var j = 0; j < message.weakDependency.length; ++j) + object.weakDependency[j] = message.weakDependency[j] + } + if (message.syntax != null && message.hasOwnProperty('syntax')) + object.syntax = message.syntax + return object + } + + /** + * Converts this FileDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.FileDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + FileDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return FileDescriptorProto + })() + + protobuf.DescriptorProto = (function () { + /** + * Properties of a DescriptorProto. + * @memberof google.protobuf + * @interface IDescriptorProto + * @property {string|null} [name] DescriptorProto name + * @property {Array.|null} [field] DescriptorProto field + * @property {Array.|null} [extension] DescriptorProto extension + * @property {Array.|null} [nestedType] DescriptorProto nestedType + * @property {Array.|null} [enumType] DescriptorProto enumType + * @property {Array.|null} [extensionRange] DescriptorProto extensionRange + * @property {Array.|null} [oneofDecl] DescriptorProto oneofDecl + * @property {google.protobuf.IMessageOptions|null} [options] DescriptorProto options + * @property {Array.|null} [reservedRange] DescriptorProto reservedRange + * @property {Array.|null} [reservedName] DescriptorProto reservedName + */ + + /** + * Constructs a new DescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a DescriptorProto. + * @implements IDescriptorProto + * @constructor + * @param {google.protobuf.IDescriptorProto=} [properties] Properties to set + */ + function DescriptorProto(properties) { + this.field = [] + this.extension = [] + this.nestedType = [] + this.enumType = [] + this.extensionRange = [] + this.oneofDecl = [] + this.reservedRange = [] + this.reservedName = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * DescriptorProto name. + * @member {string} name + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.name = '' + + /** + * DescriptorProto field. + * @member {Array.} field + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.field = $util.emptyArray + + /** + * DescriptorProto extension. + * @member {Array.} extension + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.extension = $util.emptyArray + + /** + * DescriptorProto nestedType. + * @member {Array.} nestedType + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.nestedType = $util.emptyArray + + /** + * DescriptorProto enumType. + * @member {Array.} enumType + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.enumType = $util.emptyArray + + /** + * DescriptorProto extensionRange. + * @member {Array.} extensionRange + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.extensionRange = $util.emptyArray + + /** + * DescriptorProto oneofDecl. + * @member {Array.} oneofDecl + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.oneofDecl = $util.emptyArray + + /** + * DescriptorProto options. + * @member {google.protobuf.IMessageOptions|null|undefined} options + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.options = null + + /** + * DescriptorProto reservedRange. + * @member {Array.} reservedRange + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.reservedRange = $util.emptyArray + + /** + * DescriptorProto reservedName. + * @member {Array.} reservedName + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.reservedName = $util.emptyArray + + /** + * Creates a new DescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.DescriptorProto + * @static + * @param {google.protobuf.IDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.DescriptorProto} DescriptorProto instance + */ + DescriptorProto.create = function create(properties) { + return new DescriptorProto(properties) + } + + /** + * Encodes the specified DescriptorProto message. Does not implicitly {@link google.protobuf.DescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.DescriptorProto + * @static + * @param {google.protobuf.IDescriptorProto} message DescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DescriptorProto.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.name != null && message.hasOwnProperty('name')) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.name) + if (message.field != null && message.field.length) + for (var i = 0; i < message.field.length; ++i) + $root.google.protobuf.FieldDescriptorProto.encode( + message.field[i], + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + ).ldelim() + if (message.nestedType != null && message.nestedType.length) + for (var i = 0; i < message.nestedType.length; ++i) + $root.google.protobuf.DescriptorProto.encode( + message.nestedType[i], + writer.uint32(/* id 3, wireType 2 =*/ 26).fork() + ).ldelim() + if (message.enumType != null && message.enumType.length) + for (var i = 0; i < message.enumType.length; ++i) + $root.google.protobuf.EnumDescriptorProto.encode( + message.enumType[i], + writer.uint32(/* id 4, wireType 2 =*/ 34).fork() + ).ldelim() + if ( + message.extensionRange != null && + message.extensionRange.length + ) + for (var i = 0; i < message.extensionRange.length; ++i) + $root.google.protobuf.DescriptorProto.ExtensionRange.encode( + message.extensionRange[i], + writer.uint32(/* id 5, wireType 2 =*/ 42).fork() + ).ldelim() + if (message.extension != null && message.extension.length) + for (var i = 0; i < message.extension.length; ++i) + $root.google.protobuf.FieldDescriptorProto.encode( + message.extension[i], + writer.uint32(/* id 6, wireType 2 =*/ 50).fork() + ).ldelim() + if ( + message.options != null && + message.hasOwnProperty('options') + ) + $root.google.protobuf.MessageOptions.encode( + message.options, + writer.uint32(/* id 7, wireType 2 =*/ 58).fork() + ).ldelim() + if (message.oneofDecl != null && message.oneofDecl.length) + for (var i = 0; i < message.oneofDecl.length; ++i) + $root.google.protobuf.OneofDescriptorProto.encode( + message.oneofDecl[i], + writer.uint32(/* id 8, wireType 2 =*/ 66).fork() + ).ldelim() + if ( + message.reservedRange != null && + message.reservedRange.length + ) + for (var i = 0; i < message.reservedRange.length; ++i) + $root.google.protobuf.DescriptorProto.ReservedRange.encode( + message.reservedRange[i], + writer.uint32(/* id 9, wireType 2 =*/ 74).fork() + ).ldelim() + if (message.reservedName != null && message.reservedName.length) + for (var i = 0; i < message.reservedName.length; ++i) + writer + .uint32(/* id 10, wireType 2 =*/ 82) + .string(message.reservedName[i]) + return writer + } + + /** + * Encodes the specified DescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.DescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.DescriptorProto + * @static + * @param {google.protobuf.IDescriptorProto} message DescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DescriptorProto.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a DescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.DescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.DescriptorProto} DescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DescriptorProto.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.DescriptorProto() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + case 2: + if (!(message.field && message.field.length)) + message.field = [] + message.field.push( + $root.google.protobuf.FieldDescriptorProto.decode( + reader, + reader.uint32() + ) + ) + break + case 6: + if (!(message.extension && message.extension.length)) + message.extension = [] + message.extension.push( + $root.google.protobuf.FieldDescriptorProto.decode( + reader, + reader.uint32() + ) + ) + break + case 3: + if (!(message.nestedType && message.nestedType.length)) + message.nestedType = [] + message.nestedType.push( + $root.google.protobuf.DescriptorProto.decode( + reader, + reader.uint32() + ) + ) + break + case 4: + if (!(message.enumType && message.enumType.length)) + message.enumType = [] + message.enumType.push( + $root.google.protobuf.EnumDescriptorProto.decode( + reader, + reader.uint32() + ) + ) + break + case 5: + if ( + !( + message.extensionRange && + message.extensionRange.length + ) + ) + message.extensionRange = [] + message.extensionRange.push( + $root.google.protobuf.DescriptorProto.ExtensionRange.decode( + reader, + reader.uint32() + ) + ) + break + case 8: + if (!(message.oneofDecl && message.oneofDecl.length)) + message.oneofDecl = [] + message.oneofDecl.push( + $root.google.protobuf.OneofDescriptorProto.decode( + reader, + reader.uint32() + ) + ) + break + case 7: + message.options = $root.google.protobuf.MessageOptions.decode( + reader, + reader.uint32() + ) + break + case 9: + if ( + !(message.reservedRange && message.reservedRange.length) + ) + message.reservedRange = [] + message.reservedRange.push( + $root.google.protobuf.DescriptorProto.ReservedRange.decode( + reader, + reader.uint32() + ) + ) + break + case 10: + if ( + !(message.reservedName && message.reservedName.length) + ) + message.reservedName = [] + message.reservedName.push(reader.string()) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a DescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.DescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.DescriptorProto} DescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DescriptorProto.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a DescriptorProto message. + * @function verify + * @memberof google.protobuf.DescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DescriptorProto.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + if (message.field != null && message.hasOwnProperty('field')) { + if (!Array.isArray(message.field)) + return 'field: array expected' + for (var i = 0; i < message.field.length; ++i) { + var error = $root.google.protobuf.FieldDescriptorProto.verify( + message.field[i] + ) + if (error) return 'field.' + error + } + } + if ( + message.extension != null && + message.hasOwnProperty('extension') + ) { + if (!Array.isArray(message.extension)) + return 'extension: array expected' + for (var i = 0; i < message.extension.length; ++i) { + var error = $root.google.protobuf.FieldDescriptorProto.verify( + message.extension[i] + ) + if (error) return 'extension.' + error + } + } + if ( + message.nestedType != null && + message.hasOwnProperty('nestedType') + ) { + if (!Array.isArray(message.nestedType)) + return 'nestedType: array expected' + for (var i = 0; i < message.nestedType.length; ++i) { + var error = $root.google.protobuf.DescriptorProto.verify( + message.nestedType[i] + ) + if (error) return 'nestedType.' + error + } + } + if ( + message.enumType != null && + message.hasOwnProperty('enumType') + ) { + if (!Array.isArray(message.enumType)) + return 'enumType: array expected' + for (var i = 0; i < message.enumType.length; ++i) { + var error = $root.google.protobuf.EnumDescriptorProto.verify( + message.enumType[i] + ) + if (error) return 'enumType.' + error + } + } + if ( + message.extensionRange != null && + message.hasOwnProperty('extensionRange') + ) { + if (!Array.isArray(message.extensionRange)) + return 'extensionRange: array expected' + for (var i = 0; i < message.extensionRange.length; ++i) { + var error = $root.google.protobuf.DescriptorProto.ExtensionRange.verify( + message.extensionRange[i] + ) + if (error) return 'extensionRange.' + error + } + } + if ( + message.oneofDecl != null && + message.hasOwnProperty('oneofDecl') + ) { + if (!Array.isArray(message.oneofDecl)) + return 'oneofDecl: array expected' + for (var i = 0; i < message.oneofDecl.length; ++i) { + var error = $root.google.protobuf.OneofDescriptorProto.verify( + message.oneofDecl[i] + ) + if (error) return 'oneofDecl.' + error + } + } + if ( + message.options != null && + message.hasOwnProperty('options') + ) { + var error = $root.google.protobuf.MessageOptions.verify( + message.options + ) + if (error) return 'options.' + error + } + if ( + message.reservedRange != null && + message.hasOwnProperty('reservedRange') + ) { + if (!Array.isArray(message.reservedRange)) + return 'reservedRange: array expected' + for (var i = 0; i < message.reservedRange.length; ++i) { + var error = $root.google.protobuf.DescriptorProto.ReservedRange.verify( + message.reservedRange[i] + ) + if (error) return 'reservedRange.' + error + } + } + if ( + message.reservedName != null && + message.hasOwnProperty('reservedName') + ) { + if (!Array.isArray(message.reservedName)) + return 'reservedName: array expected' + for (var i = 0; i < message.reservedName.length; ++i) + if (!$util.isString(message.reservedName[i])) + return 'reservedName: string[] expected' + } + return null + } + + /** + * Creates a DescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.DescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.DescriptorProto} DescriptorProto + */ + DescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.DescriptorProto) + return object + var message = new $root.google.protobuf.DescriptorProto() + if (object.name != null) message.name = String(object.name) + if (object.field) { + if (!Array.isArray(object.field)) + throw TypeError( + '.google.protobuf.DescriptorProto.field: array expected' + ) + message.field = [] + for (var i = 0; i < object.field.length; ++i) { + if (typeof object.field[i] !== 'object') + throw TypeError( + '.google.protobuf.DescriptorProto.field: object expected' + ) + message.field[ + i + ] = $root.google.protobuf.FieldDescriptorProto.fromObject( + object.field[i] + ) + } + } + if (object.extension) { + if (!Array.isArray(object.extension)) + throw TypeError( + '.google.protobuf.DescriptorProto.extension: array expected' + ) + message.extension = [] + for (var i = 0; i < object.extension.length; ++i) { + if (typeof object.extension[i] !== 'object') + throw TypeError( + '.google.protobuf.DescriptorProto.extension: object expected' + ) + message.extension[ + i + ] = $root.google.protobuf.FieldDescriptorProto.fromObject( + object.extension[i] + ) + } + } + if (object.nestedType) { + if (!Array.isArray(object.nestedType)) + throw TypeError( + '.google.protobuf.DescriptorProto.nestedType: array expected' + ) + message.nestedType = [] + for (var i = 0; i < object.nestedType.length; ++i) { + if (typeof object.nestedType[i] !== 'object') + throw TypeError( + '.google.protobuf.DescriptorProto.nestedType: object expected' + ) + message.nestedType[ + i + ] = $root.google.protobuf.DescriptorProto.fromObject( + object.nestedType[i] + ) + } + } + if (object.enumType) { + if (!Array.isArray(object.enumType)) + throw TypeError( + '.google.protobuf.DescriptorProto.enumType: array expected' + ) + message.enumType = [] + for (var i = 0; i < object.enumType.length; ++i) { + if (typeof object.enumType[i] !== 'object') + throw TypeError( + '.google.protobuf.DescriptorProto.enumType: object expected' + ) + message.enumType[ + i + ] = $root.google.protobuf.EnumDescriptorProto.fromObject( + object.enumType[i] + ) + } + } + if (object.extensionRange) { + if (!Array.isArray(object.extensionRange)) + throw TypeError( + '.google.protobuf.DescriptorProto.extensionRange: array expected' + ) + message.extensionRange = [] + for (var i = 0; i < object.extensionRange.length; ++i) { + if (typeof object.extensionRange[i] !== 'object') + throw TypeError( + '.google.protobuf.DescriptorProto.extensionRange: object expected' + ) + message.extensionRange[ + i + ] = $root.google.protobuf.DescriptorProto.ExtensionRange.fromObject( + object.extensionRange[i] + ) + } + } + if (object.oneofDecl) { + if (!Array.isArray(object.oneofDecl)) + throw TypeError( + '.google.protobuf.DescriptorProto.oneofDecl: array expected' + ) + message.oneofDecl = [] + for (var i = 0; i < object.oneofDecl.length; ++i) { + if (typeof object.oneofDecl[i] !== 'object') + throw TypeError( + '.google.protobuf.DescriptorProto.oneofDecl: object expected' + ) + message.oneofDecl[ + i + ] = $root.google.protobuf.OneofDescriptorProto.fromObject( + object.oneofDecl[i] + ) + } + } + if (object.options != null) { + if (typeof object.options !== 'object') + throw TypeError( + '.google.protobuf.DescriptorProto.options: object expected' + ) + message.options = $root.google.protobuf.MessageOptions.fromObject( + object.options + ) + } + if (object.reservedRange) { + if (!Array.isArray(object.reservedRange)) + throw TypeError( + '.google.protobuf.DescriptorProto.reservedRange: array expected' + ) + message.reservedRange = [] + for (var i = 0; i < object.reservedRange.length; ++i) { + if (typeof object.reservedRange[i] !== 'object') + throw TypeError( + '.google.protobuf.DescriptorProto.reservedRange: object expected' + ) + message.reservedRange[ + i + ] = $root.google.protobuf.DescriptorProto.ReservedRange.fromObject( + object.reservedRange[i] + ) + } + } + if (object.reservedName) { + if (!Array.isArray(object.reservedName)) + throw TypeError( + '.google.protobuf.DescriptorProto.reservedName: array expected' + ) + message.reservedName = [] + for (var i = 0; i < object.reservedName.length; ++i) + message.reservedName[i] = String(object.reservedName[i]) + } + return message + } + + /** + * Creates a plain object from a DescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.DescriptorProto + * @static + * @param {google.protobuf.DescriptorProto} message DescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DescriptorProto.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) { + object.field = [] + object.nestedType = [] + object.enumType = [] + object.extensionRange = [] + object.extension = [] + object.oneofDecl = [] + object.reservedRange = [] + object.reservedName = [] + } + if (options.defaults) { + object.name = '' + object.options = null + } + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + if (message.field && message.field.length) { + object.field = [] + for (var j = 0; j < message.field.length; ++j) + object.field[ + j + ] = $root.google.protobuf.FieldDescriptorProto.toObject( + message.field[j], + options + ) + } + if (message.nestedType && message.nestedType.length) { + object.nestedType = [] + for (var j = 0; j < message.nestedType.length; ++j) + object.nestedType[ + j + ] = $root.google.protobuf.DescriptorProto.toObject( + message.nestedType[j], + options + ) + } + if (message.enumType && message.enumType.length) { + object.enumType = [] + for (var j = 0; j < message.enumType.length; ++j) + object.enumType[ + j + ] = $root.google.protobuf.EnumDescriptorProto.toObject( + message.enumType[j], + options + ) + } + if (message.extensionRange && message.extensionRange.length) { + object.extensionRange = [] + for (var j = 0; j < message.extensionRange.length; ++j) + object.extensionRange[ + j + ] = $root.google.protobuf.DescriptorProto.ExtensionRange.toObject( + message.extensionRange[j], + options + ) + } + if (message.extension && message.extension.length) { + object.extension = [] + for (var j = 0; j < message.extension.length; ++j) + object.extension[ + j + ] = $root.google.protobuf.FieldDescriptorProto.toObject( + message.extension[j], + options + ) + } + if ( + message.options != null && + message.hasOwnProperty('options') + ) + object.options = $root.google.protobuf.MessageOptions.toObject( + message.options, + options + ) + if (message.oneofDecl && message.oneofDecl.length) { + object.oneofDecl = [] + for (var j = 0; j < message.oneofDecl.length; ++j) + object.oneofDecl[ + j + ] = $root.google.protobuf.OneofDescriptorProto.toObject( + message.oneofDecl[j], + options + ) + } + if (message.reservedRange && message.reservedRange.length) { + object.reservedRange = [] + for (var j = 0; j < message.reservedRange.length; ++j) + object.reservedRange[ + j + ] = $root.google.protobuf.DescriptorProto.ReservedRange.toObject( + message.reservedRange[j], + options + ) + } + if (message.reservedName && message.reservedName.length) { + object.reservedName = [] + for (var j = 0; j < message.reservedName.length; ++j) + object.reservedName[j] = message.reservedName[j] + } + return object + } + + /** + * Converts this DescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.DescriptorProto + * @instance + * @returns {Object.} JSON object + */ + DescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + DescriptorProto.ExtensionRange = (function () { + /** + * Properties of an ExtensionRange. + * @memberof google.protobuf.DescriptorProto + * @interface IExtensionRange + * @property {number|null} [start] ExtensionRange start + * @property {number|null} [end] ExtensionRange end + * @property {google.protobuf.IExtensionRangeOptions|null} [options] ExtensionRange options + */ + + /** + * Constructs a new ExtensionRange. + * @memberof google.protobuf.DescriptorProto + * @classdesc Represents an ExtensionRange. + * @implements IExtensionRange + * @constructor + * @param {google.protobuf.DescriptorProto.IExtensionRange=} [properties] Properties to set + */ + function ExtensionRange(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * ExtensionRange start. + * @member {number} start + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @instance + */ + ExtensionRange.prototype.start = 0 + + /** + * ExtensionRange end. + * @member {number} end + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @instance + */ + ExtensionRange.prototype.end = 0 + + /** + * ExtensionRange options. + * @member {google.protobuf.IExtensionRangeOptions|null|undefined} options + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @instance + */ + ExtensionRange.prototype.options = null + + /** + * Creates a new ExtensionRange instance using the specified properties. + * @function create + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {google.protobuf.DescriptorProto.IExtensionRange=} [properties] Properties to set + * @returns {google.protobuf.DescriptorProto.ExtensionRange} ExtensionRange instance + */ + ExtensionRange.create = function create(properties) { + return new ExtensionRange(properties) + } + + /** + * Encodes the specified ExtensionRange message. Does not implicitly {@link google.protobuf.DescriptorProto.ExtensionRange.verify|verify} messages. + * @function encode + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {google.protobuf.DescriptorProto.IExtensionRange} message ExtensionRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExtensionRange.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.start != null && message.hasOwnProperty('start')) + writer + .uint32(/* id 1, wireType 0 =*/ 8) + .int32(message.start) + if (message.end != null && message.hasOwnProperty('end')) + writer.uint32(/* id 2, wireType 0 =*/ 16).int32(message.end) + if ( + message.options != null && + message.hasOwnProperty('options') + ) + $root.google.protobuf.ExtensionRangeOptions.encode( + message.options, + writer.uint32(/* id 3, wireType 2 =*/ 26).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified ExtensionRange message, length delimited. Does not implicitly {@link google.protobuf.DescriptorProto.ExtensionRange.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {google.protobuf.DescriptorProto.IExtensionRange} message ExtensionRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExtensionRange.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an ExtensionRange message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.DescriptorProto.ExtensionRange} ExtensionRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExtensionRange.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.DescriptorProto.ExtensionRange() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.start = reader.int32() + break + case 2: + message.end = reader.int32() + break + case 3: + message.options = $root.google.protobuf.ExtensionRangeOptions.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an ExtensionRange message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.DescriptorProto.ExtensionRange} ExtensionRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExtensionRange.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an ExtensionRange message. + * @function verify + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExtensionRange.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.start != null && message.hasOwnProperty('start')) + if (!$util.isInteger(message.start)) + return 'start: integer expected' + if (message.end != null && message.hasOwnProperty('end')) + if (!$util.isInteger(message.end)) + return 'end: integer expected' + if ( + message.options != null && + message.hasOwnProperty('options') + ) { + var error = $root.google.protobuf.ExtensionRangeOptions.verify( + message.options + ) + if (error) return 'options.' + error + } + return null + } + + /** + * Creates an ExtensionRange message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.DescriptorProto.ExtensionRange} ExtensionRange + */ + ExtensionRange.fromObject = function fromObject(object) { + if ( + object instanceof + $root.google.protobuf.DescriptorProto.ExtensionRange + ) + return object + var message = new $root.google.protobuf.DescriptorProto.ExtensionRange() + if (object.start != null) message.start = object.start | 0 + if (object.end != null) message.end = object.end | 0 + if (object.options != null) { + if (typeof object.options !== 'object') + throw TypeError( + '.google.protobuf.DescriptorProto.ExtensionRange.options: object expected' + ) + message.options = $root.google.protobuf.ExtensionRangeOptions.fromObject( + object.options + ) + } + return message + } + + /** + * Creates a plain object from an ExtensionRange message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {google.protobuf.DescriptorProto.ExtensionRange} message ExtensionRange + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExtensionRange.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.start = 0 + object.end = 0 + object.options = null + } + if (message.start != null && message.hasOwnProperty('start')) + object.start = message.start + if (message.end != null && message.hasOwnProperty('end')) + object.end = message.end + if ( + message.options != null && + message.hasOwnProperty('options') + ) + object.options = $root.google.protobuf.ExtensionRangeOptions.toObject( + message.options, + options + ) + return object + } + + /** + * Converts this ExtensionRange to JSON. + * @function toJSON + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @instance + * @returns {Object.} JSON object + */ + ExtensionRange.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return ExtensionRange + })() + + DescriptorProto.ReservedRange = (function () { + /** + * Properties of a ReservedRange. + * @memberof google.protobuf.DescriptorProto + * @interface IReservedRange + * @property {number|null} [start] ReservedRange start + * @property {number|null} [end] ReservedRange end + */ + + /** + * Constructs a new ReservedRange. + * @memberof google.protobuf.DescriptorProto + * @classdesc Represents a ReservedRange. + * @implements IReservedRange + * @constructor + * @param {google.protobuf.DescriptorProto.IReservedRange=} [properties] Properties to set + */ + function ReservedRange(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * ReservedRange start. + * @member {number} start + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @instance + */ + ReservedRange.prototype.start = 0 + + /** + * ReservedRange end. + * @member {number} end + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @instance + */ + ReservedRange.prototype.end = 0 + + /** + * Creates a new ReservedRange instance using the specified properties. + * @function create + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {google.protobuf.DescriptorProto.IReservedRange=} [properties] Properties to set + * @returns {google.protobuf.DescriptorProto.ReservedRange} ReservedRange instance + */ + ReservedRange.create = function create(properties) { + return new ReservedRange(properties) + } + + /** + * Encodes the specified ReservedRange message. Does not implicitly {@link google.protobuf.DescriptorProto.ReservedRange.verify|verify} messages. + * @function encode + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {google.protobuf.DescriptorProto.IReservedRange} message ReservedRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReservedRange.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.start != null && message.hasOwnProperty('start')) + writer + .uint32(/* id 1, wireType 0 =*/ 8) + .int32(message.start) + if (message.end != null && message.hasOwnProperty('end')) + writer.uint32(/* id 2, wireType 0 =*/ 16).int32(message.end) + return writer + } + + /** + * Encodes the specified ReservedRange message, length delimited. Does not implicitly {@link google.protobuf.DescriptorProto.ReservedRange.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {google.protobuf.DescriptorProto.IReservedRange} message ReservedRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReservedRange.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a ReservedRange message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.DescriptorProto.ReservedRange} ReservedRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReservedRange.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.DescriptorProto.ReservedRange() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.start = reader.int32() + break + case 2: + message.end = reader.int32() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a ReservedRange message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.DescriptorProto.ReservedRange} ReservedRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReservedRange.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a ReservedRange message. + * @function verify + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ReservedRange.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.start != null && message.hasOwnProperty('start')) + if (!$util.isInteger(message.start)) + return 'start: integer expected' + if (message.end != null && message.hasOwnProperty('end')) + if (!$util.isInteger(message.end)) + return 'end: integer expected' + return null + } + + /** + * Creates a ReservedRange message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.DescriptorProto.ReservedRange} ReservedRange + */ + ReservedRange.fromObject = function fromObject(object) { + if ( + object instanceof + $root.google.protobuf.DescriptorProto.ReservedRange + ) + return object + var message = new $root.google.protobuf.DescriptorProto.ReservedRange() + if (object.start != null) message.start = object.start | 0 + if (object.end != null) message.end = object.end | 0 + return message + } + + /** + * Creates a plain object from a ReservedRange message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {google.protobuf.DescriptorProto.ReservedRange} message ReservedRange + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ReservedRange.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.start = 0 + object.end = 0 + } + if (message.start != null && message.hasOwnProperty('start')) + object.start = message.start + if (message.end != null && message.hasOwnProperty('end')) + object.end = message.end + return object + } + + /** + * Converts this ReservedRange to JSON. + * @function toJSON + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @instance + * @returns {Object.} JSON object + */ + ReservedRange.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return ReservedRange + })() + + return DescriptorProto + })() + + protobuf.ExtensionRangeOptions = (function () { + /** + * Properties of an ExtensionRangeOptions. + * @memberof google.protobuf + * @interface IExtensionRangeOptions + * @property {Array.|null} [uninterpretedOption] ExtensionRangeOptions uninterpretedOption + */ + + /** + * Constructs a new ExtensionRangeOptions. + * @memberof google.protobuf + * @classdesc Represents an ExtensionRangeOptions. + * @implements IExtensionRangeOptions + * @constructor + * @param {google.protobuf.IExtensionRangeOptions=} [properties] Properties to set + */ + function ExtensionRangeOptions(properties) { + this.uninterpretedOption = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * ExtensionRangeOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.ExtensionRangeOptions + * @instance + */ + ExtensionRangeOptions.prototype.uninterpretedOption = + $util.emptyArray + + /** + * Creates a new ExtensionRangeOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.ExtensionRangeOptions + * @static + * @param {google.protobuf.IExtensionRangeOptions=} [properties] Properties to set + * @returns {google.protobuf.ExtensionRangeOptions} ExtensionRangeOptions instance + */ + ExtensionRangeOptions.create = function create(properties) { + return new ExtensionRangeOptions(properties) + } + + /** + * Encodes the specified ExtensionRangeOptions message. Does not implicitly {@link google.protobuf.ExtensionRangeOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.ExtensionRangeOptions + * @static + * @param {google.protobuf.IExtensionRangeOptions} message ExtensionRangeOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExtensionRangeOptions.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.uninterpretedOption != null && + message.uninterpretedOption.length + ) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode( + message.uninterpretedOption[i], + writer.uint32(/* id 999, wireType 2 =*/ 7994).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified ExtensionRangeOptions message, length delimited. Does not implicitly {@link google.protobuf.ExtensionRangeOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.ExtensionRangeOptions + * @static + * @param {google.protobuf.IExtensionRangeOptions} message ExtensionRangeOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExtensionRangeOptions.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an ExtensionRangeOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.ExtensionRangeOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.ExtensionRangeOptions} ExtensionRangeOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExtensionRangeOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.ExtensionRangeOptions() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 999: + if ( + !( + message.uninterpretedOption && + message.uninterpretedOption.length + ) + ) + message.uninterpretedOption = [] + message.uninterpretedOption.push( + $root.google.protobuf.UninterpretedOption.decode( + reader, + reader.uint32() + ) + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an ExtensionRangeOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.ExtensionRangeOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.ExtensionRangeOptions} ExtensionRangeOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExtensionRangeOptions.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an ExtensionRangeOptions message. + * @function verify + * @memberof google.protobuf.ExtensionRangeOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExtensionRangeOptions.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.uninterpretedOption != null && + message.hasOwnProperty('uninterpretedOption') + ) { + if (!Array.isArray(message.uninterpretedOption)) + return 'uninterpretedOption: array expected' + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify( + message.uninterpretedOption[i] + ) + if (error) return 'uninterpretedOption.' + error + } + } + return null + } + + /** + * Creates an ExtensionRangeOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.ExtensionRangeOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.ExtensionRangeOptions} ExtensionRangeOptions + */ + ExtensionRangeOptions.fromObject = function fromObject(object) { + if ( + object instanceof $root.google.protobuf.ExtensionRangeOptions + ) + return object + var message = new $root.google.protobuf.ExtensionRangeOptions() + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError( + '.google.protobuf.ExtensionRangeOptions.uninterpretedOption: array expected' + ) + message.uninterpretedOption = [] + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== 'object') + throw TypeError( + '.google.protobuf.ExtensionRangeOptions.uninterpretedOption: object expected' + ) + message.uninterpretedOption[ + i + ] = $root.google.protobuf.UninterpretedOption.fromObject( + object.uninterpretedOption[i] + ) + } + } + return message + } + + /** + * Creates a plain object from an ExtensionRangeOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.ExtensionRangeOptions + * @static + * @param {google.protobuf.ExtensionRangeOptions} message ExtensionRangeOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExtensionRangeOptions.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) + object.uninterpretedOption = [] + if ( + message.uninterpretedOption && + message.uninterpretedOption.length + ) { + object.uninterpretedOption = [] + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[ + j + ] = $root.google.protobuf.UninterpretedOption.toObject( + message.uninterpretedOption[j], + options + ) + } + return object + } + + /** + * Converts this ExtensionRangeOptions to JSON. + * @function toJSON + * @memberof google.protobuf.ExtensionRangeOptions + * @instance + * @returns {Object.} JSON object + */ + ExtensionRangeOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return ExtensionRangeOptions + })() + + protobuf.FieldDescriptorProto = (function () { + /** + * Properties of a FieldDescriptorProto. + * @memberof google.protobuf + * @interface IFieldDescriptorProto + * @property {string|null} [name] FieldDescriptorProto name + * @property {number|null} [number] FieldDescriptorProto number + * @property {google.protobuf.FieldDescriptorProto.Label|null} [label] FieldDescriptorProto label + * @property {google.protobuf.FieldDescriptorProto.Type|null} [type] FieldDescriptorProto type + * @property {string|null} [typeName] FieldDescriptorProto typeName + * @property {string|null} [extendee] FieldDescriptorProto extendee + * @property {string|null} [defaultValue] FieldDescriptorProto defaultValue + * @property {number|null} [oneofIndex] FieldDescriptorProto oneofIndex + * @property {string|null} [jsonName] FieldDescriptorProto jsonName + * @property {google.protobuf.IFieldOptions|null} [options] FieldDescriptorProto options + */ + + /** + * Constructs a new FieldDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a FieldDescriptorProto. + * @implements IFieldDescriptorProto + * @constructor + * @param {google.protobuf.IFieldDescriptorProto=} [properties] Properties to set + */ + function FieldDescriptorProto(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * FieldDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.name = '' + + /** + * FieldDescriptorProto number. + * @member {number} number + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.number = 0 + + /** + * FieldDescriptorProto label. + * @member {google.protobuf.FieldDescriptorProto.Label} label + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.label = 1 + + /** + * FieldDescriptorProto type. + * @member {google.protobuf.FieldDescriptorProto.Type} type + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.type = 1 + + /** + * FieldDescriptorProto typeName. + * @member {string} typeName + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.typeName = '' + + /** + * FieldDescriptorProto extendee. + * @member {string} extendee + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.extendee = '' + + /** + * FieldDescriptorProto defaultValue. + * @member {string} defaultValue + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.defaultValue = '' + + /** + * FieldDescriptorProto oneofIndex. + * @member {number} oneofIndex + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.oneofIndex = 0 + + /** + * FieldDescriptorProto jsonName. + * @member {string} jsonName + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.jsonName = '' + + /** + * FieldDescriptorProto options. + * @member {google.protobuf.IFieldOptions|null|undefined} options + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.options = null + + /** + * Creates a new FieldDescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {google.protobuf.IFieldDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.FieldDescriptorProto} FieldDescriptorProto instance + */ + FieldDescriptorProto.create = function create(properties) { + return new FieldDescriptorProto(properties) + } + + /** + * Encodes the specified FieldDescriptorProto message. Does not implicitly {@link google.protobuf.FieldDescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {google.protobuf.IFieldDescriptorProto} message FieldDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FieldDescriptorProto.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.name != null && message.hasOwnProperty('name')) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.name) + if ( + message.extendee != null && + message.hasOwnProperty('extendee') + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.extendee) + if (message.number != null && message.hasOwnProperty('number')) + writer + .uint32(/* id 3, wireType 0 =*/ 24) + .int32(message.number) + if (message.label != null && message.hasOwnProperty('label')) + writer.uint32(/* id 4, wireType 0 =*/ 32).int32(message.label) + if (message.type != null && message.hasOwnProperty('type')) + writer.uint32(/* id 5, wireType 0 =*/ 40).int32(message.type) + if ( + message.typeName != null && + message.hasOwnProperty('typeName') + ) + writer + .uint32(/* id 6, wireType 2 =*/ 50) + .string(message.typeName) + if ( + message.defaultValue != null && + message.hasOwnProperty('defaultValue') + ) + writer + .uint32(/* id 7, wireType 2 =*/ 58) + .string(message.defaultValue) + if ( + message.options != null && + message.hasOwnProperty('options') + ) + $root.google.protobuf.FieldOptions.encode( + message.options, + writer.uint32(/* id 8, wireType 2 =*/ 66).fork() + ).ldelim() + if ( + message.oneofIndex != null && + message.hasOwnProperty('oneofIndex') + ) + writer + .uint32(/* id 9, wireType 0 =*/ 72) + .int32(message.oneofIndex) + if ( + message.jsonName != null && + message.hasOwnProperty('jsonName') + ) + writer + .uint32(/* id 10, wireType 2 =*/ 82) + .string(message.jsonName) + return writer + } + + /** + * Encodes the specified FieldDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.FieldDescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {google.protobuf.IFieldDescriptorProto} message FieldDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FieldDescriptorProto.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a FieldDescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FieldDescriptorProto} FieldDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FieldDescriptorProto.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.FieldDescriptorProto() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + case 3: + message.number = reader.int32() + break + case 4: + message.label = reader.int32() + break + case 5: + message.type = reader.int32() + break + case 6: + message.typeName = reader.string() + break + case 2: + message.extendee = reader.string() + break + case 7: + message.defaultValue = reader.string() + break + case 9: + message.oneofIndex = reader.int32() + break + case 10: + message.jsonName = reader.string() + break + case 8: + message.options = $root.google.protobuf.FieldOptions.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a FieldDescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FieldDescriptorProto} FieldDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FieldDescriptorProto.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a FieldDescriptorProto message. + * @function verify + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FieldDescriptorProto.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + if (message.number != null && message.hasOwnProperty('number')) + if (!$util.isInteger(message.number)) + return 'number: integer expected' + if (message.label != null && message.hasOwnProperty('label')) + switch (message.label) { + default: + return 'label: enum value expected' + case 1: + case 2: + case 3: + break + } + if (message.type != null && message.hasOwnProperty('type')) + switch (message.type) { + default: + return 'type: enum value expected' + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + case 15: + case 16: + case 17: + case 18: + break + } + if ( + message.typeName != null && + message.hasOwnProperty('typeName') + ) + if (!$util.isString(message.typeName)) + return 'typeName: string expected' + if ( + message.extendee != null && + message.hasOwnProperty('extendee') + ) + if (!$util.isString(message.extendee)) + return 'extendee: string expected' + if ( + message.defaultValue != null && + message.hasOwnProperty('defaultValue') + ) + if (!$util.isString(message.defaultValue)) + return 'defaultValue: string expected' + if ( + message.oneofIndex != null && + message.hasOwnProperty('oneofIndex') + ) + if (!$util.isInteger(message.oneofIndex)) + return 'oneofIndex: integer expected' + if ( + message.jsonName != null && + message.hasOwnProperty('jsonName') + ) + if (!$util.isString(message.jsonName)) + return 'jsonName: string expected' + if ( + message.options != null && + message.hasOwnProperty('options') + ) { + var error = $root.google.protobuf.FieldOptions.verify( + message.options + ) + if (error) return 'options.' + error + } + return null + } + + /** + * Creates a FieldDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FieldDescriptorProto} FieldDescriptorProto + */ + FieldDescriptorProto.fromObject = function fromObject(object) { + if ( + object instanceof $root.google.protobuf.FieldDescriptorProto + ) + return object + var message = new $root.google.protobuf.FieldDescriptorProto() + if (object.name != null) message.name = String(object.name) + if (object.number != null) message.number = object.number | 0 + switch (object.label) { + case 'LABEL_OPTIONAL': + case 1: + message.label = 1 + break + case 'LABEL_REQUIRED': + case 2: + message.label = 2 + break + case 'LABEL_REPEATED': + case 3: + message.label = 3 + break + } + switch (object.type) { + case 'TYPE_DOUBLE': + case 1: + message.type = 1 + break + case 'TYPE_FLOAT': + case 2: + message.type = 2 + break + case 'TYPE_INT64': + case 3: + message.type = 3 + break + case 'TYPE_UINT64': + case 4: + message.type = 4 + break + case 'TYPE_INT32': + case 5: + message.type = 5 + break + case 'TYPE_FIXED64': + case 6: + message.type = 6 + break + case 'TYPE_FIXED32': + case 7: + message.type = 7 + break + case 'TYPE_BOOL': + case 8: + message.type = 8 + break + case 'TYPE_STRING': + case 9: + message.type = 9 + break + case 'TYPE_GROUP': + case 10: + message.type = 10 + break + case 'TYPE_MESSAGE': + case 11: + message.type = 11 + break + case 'TYPE_BYTES': + case 12: + message.type = 12 + break + case 'TYPE_UINT32': + case 13: + message.type = 13 + break + case 'TYPE_ENUM': + case 14: + message.type = 14 + break + case 'TYPE_SFIXED32': + case 15: + message.type = 15 + break + case 'TYPE_SFIXED64': + case 16: + message.type = 16 + break + case 'TYPE_SINT32': + case 17: + message.type = 17 + break + case 'TYPE_SINT64': + case 18: + message.type = 18 + break + } + if (object.typeName != null) + message.typeName = String(object.typeName) + if (object.extendee != null) + message.extendee = String(object.extendee) + if (object.defaultValue != null) + message.defaultValue = String(object.defaultValue) + if (object.oneofIndex != null) + message.oneofIndex = object.oneofIndex | 0 + if (object.jsonName != null) + message.jsonName = String(object.jsonName) + if (object.options != null) { + if (typeof object.options !== 'object') + throw TypeError( + '.google.protobuf.FieldDescriptorProto.options: object expected' + ) + message.options = $root.google.protobuf.FieldOptions.fromObject( + object.options + ) + } + return message + } + + /** + * Creates a plain object from a FieldDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {google.protobuf.FieldDescriptorProto} message FieldDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FieldDescriptorProto.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.name = '' + object.extendee = '' + object.number = 0 + object.label = options.enums === String ? 'LABEL_OPTIONAL' : 1 + object.type = options.enums === String ? 'TYPE_DOUBLE' : 1 + object.typeName = '' + object.defaultValue = '' + object.options = null + object.oneofIndex = 0 + object.jsonName = '' + } + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + if ( + message.extendee != null && + message.hasOwnProperty('extendee') + ) + object.extendee = message.extendee + if (message.number != null && message.hasOwnProperty('number')) + object.number = message.number + if (message.label != null && message.hasOwnProperty('label')) + object.label = + options.enums === String + ? $root.google.protobuf.FieldDescriptorProto.Label[ + message.label + ] + : message.label + if (message.type != null && message.hasOwnProperty('type')) + object.type = + options.enums === String + ? $root.google.protobuf.FieldDescriptorProto.Type[ + message.type + ] + : message.type + if ( + message.typeName != null && + message.hasOwnProperty('typeName') + ) + object.typeName = message.typeName + if ( + message.defaultValue != null && + message.hasOwnProperty('defaultValue') + ) + object.defaultValue = message.defaultValue + if ( + message.options != null && + message.hasOwnProperty('options') + ) + object.options = $root.google.protobuf.FieldOptions.toObject( + message.options, + options + ) + if ( + message.oneofIndex != null && + message.hasOwnProperty('oneofIndex') + ) + object.oneofIndex = message.oneofIndex + if ( + message.jsonName != null && + message.hasOwnProperty('jsonName') + ) + object.jsonName = message.jsonName + return object + } + + /** + * Converts this FieldDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.FieldDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + FieldDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + /** + * Type enum. + * @name google.protobuf.FieldDescriptorProto.Type + * @enum {string} + * @property {number} TYPE_DOUBLE=1 TYPE_DOUBLE value + * @property {number} TYPE_FLOAT=2 TYPE_FLOAT value + * @property {number} TYPE_INT64=3 TYPE_INT64 value + * @property {number} TYPE_UINT64=4 TYPE_UINT64 value + * @property {number} TYPE_INT32=5 TYPE_INT32 value + * @property {number} TYPE_FIXED64=6 TYPE_FIXED64 value + * @property {number} TYPE_FIXED32=7 TYPE_FIXED32 value + * @property {number} TYPE_BOOL=8 TYPE_BOOL value + * @property {number} TYPE_STRING=9 TYPE_STRING value + * @property {number} TYPE_GROUP=10 TYPE_GROUP value + * @property {number} TYPE_MESSAGE=11 TYPE_MESSAGE value + * @property {number} TYPE_BYTES=12 TYPE_BYTES value + * @property {number} TYPE_UINT32=13 TYPE_UINT32 value + * @property {number} TYPE_ENUM=14 TYPE_ENUM value + * @property {number} TYPE_SFIXED32=15 TYPE_SFIXED32 value + * @property {number} TYPE_SFIXED64=16 TYPE_SFIXED64 value + * @property {number} TYPE_SINT32=17 TYPE_SINT32 value + * @property {number} TYPE_SINT64=18 TYPE_SINT64 value + */ + FieldDescriptorProto.Type = (function () { + var valuesById = {}, + values = Object.create(valuesById) + values[(valuesById[1] = 'TYPE_DOUBLE')] = 1 + values[(valuesById[2] = 'TYPE_FLOAT')] = 2 + values[(valuesById[3] = 'TYPE_INT64')] = 3 + values[(valuesById[4] = 'TYPE_UINT64')] = 4 + values[(valuesById[5] = 'TYPE_INT32')] = 5 + values[(valuesById[6] = 'TYPE_FIXED64')] = 6 + values[(valuesById[7] = 'TYPE_FIXED32')] = 7 + values[(valuesById[8] = 'TYPE_BOOL')] = 8 + values[(valuesById[9] = 'TYPE_STRING')] = 9 + values[(valuesById[10] = 'TYPE_GROUP')] = 10 + values[(valuesById[11] = 'TYPE_MESSAGE')] = 11 + values[(valuesById[12] = 'TYPE_BYTES')] = 12 + values[(valuesById[13] = 'TYPE_UINT32')] = 13 + values[(valuesById[14] = 'TYPE_ENUM')] = 14 + values[(valuesById[15] = 'TYPE_SFIXED32')] = 15 + values[(valuesById[16] = 'TYPE_SFIXED64')] = 16 + values[(valuesById[17] = 'TYPE_SINT32')] = 17 + values[(valuesById[18] = 'TYPE_SINT64')] = 18 + return values + })() + + /** + * Label enum. + * @name google.protobuf.FieldDescriptorProto.Label + * @enum {string} + * @property {number} LABEL_OPTIONAL=1 LABEL_OPTIONAL value + * @property {number} LABEL_REQUIRED=2 LABEL_REQUIRED value + * @property {number} LABEL_REPEATED=3 LABEL_REPEATED value + */ + FieldDescriptorProto.Label = (function () { + var valuesById = {}, + values = Object.create(valuesById) + values[(valuesById[1] = 'LABEL_OPTIONAL')] = 1 + values[(valuesById[2] = 'LABEL_REQUIRED')] = 2 + values[(valuesById[3] = 'LABEL_REPEATED')] = 3 + return values + })() + + return FieldDescriptorProto + })() + + protobuf.OneofDescriptorProto = (function () { + /** + * Properties of an OneofDescriptorProto. + * @memberof google.protobuf + * @interface IOneofDescriptorProto + * @property {string|null} [name] OneofDescriptorProto name + * @property {google.protobuf.IOneofOptions|null} [options] OneofDescriptorProto options + */ + + /** + * Constructs a new OneofDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents an OneofDescriptorProto. + * @implements IOneofDescriptorProto + * @constructor + * @param {google.protobuf.IOneofDescriptorProto=} [properties] Properties to set + */ + function OneofDescriptorProto(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * OneofDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.OneofDescriptorProto + * @instance + */ + OneofDescriptorProto.prototype.name = '' + + /** + * OneofDescriptorProto options. + * @member {google.protobuf.IOneofOptions|null|undefined} options + * @memberof google.protobuf.OneofDescriptorProto + * @instance + */ + OneofDescriptorProto.prototype.options = null + + /** + * Creates a new OneofDescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {google.protobuf.IOneofDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.OneofDescriptorProto} OneofDescriptorProto instance + */ + OneofDescriptorProto.create = function create(properties) { + return new OneofDescriptorProto(properties) + } + + /** + * Encodes the specified OneofDescriptorProto message. Does not implicitly {@link google.protobuf.OneofDescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {google.protobuf.IOneofDescriptorProto} message OneofDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OneofDescriptorProto.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.name != null && message.hasOwnProperty('name')) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.name) + if ( + message.options != null && + message.hasOwnProperty('options') + ) + $root.google.protobuf.OneofOptions.encode( + message.options, + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified OneofDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.OneofDescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {google.protobuf.IOneofDescriptorProto} message OneofDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OneofDescriptorProto.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an OneofDescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.OneofDescriptorProto} OneofDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OneofDescriptorProto.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.OneofDescriptorProto() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + case 2: + message.options = $root.google.protobuf.OneofOptions.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an OneofDescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.OneofDescriptorProto} OneofDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OneofDescriptorProto.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an OneofDescriptorProto message. + * @function verify + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + OneofDescriptorProto.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + if ( + message.options != null && + message.hasOwnProperty('options') + ) { + var error = $root.google.protobuf.OneofOptions.verify( + message.options + ) + if (error) return 'options.' + error + } + return null + } + + /** + * Creates an OneofDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.OneofDescriptorProto} OneofDescriptorProto + */ + OneofDescriptorProto.fromObject = function fromObject(object) { + if ( + object instanceof $root.google.protobuf.OneofDescriptorProto + ) + return object + var message = new $root.google.protobuf.OneofDescriptorProto() + if (object.name != null) message.name = String(object.name) + if (object.options != null) { + if (typeof object.options !== 'object') + throw TypeError( + '.google.protobuf.OneofDescriptorProto.options: object expected' + ) + message.options = $root.google.protobuf.OneofOptions.fromObject( + object.options + ) + } + return message + } + + /** + * Creates a plain object from an OneofDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {google.protobuf.OneofDescriptorProto} message OneofDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + OneofDescriptorProto.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.name = '' + object.options = null + } + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + if ( + message.options != null && + message.hasOwnProperty('options') + ) + object.options = $root.google.protobuf.OneofOptions.toObject( + message.options, + options + ) + return object + } + + /** + * Converts this OneofDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.OneofDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + OneofDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return OneofDescriptorProto + })() + + protobuf.EnumDescriptorProto = (function () { + /** + * Properties of an EnumDescriptorProto. + * @memberof google.protobuf + * @interface IEnumDescriptorProto + * @property {string|null} [name] EnumDescriptorProto name + * @property {Array.|null} [value] EnumDescriptorProto value + * @property {google.protobuf.IEnumOptions|null} [options] EnumDescriptorProto options + * @property {Array.|null} [reservedRange] EnumDescriptorProto reservedRange + * @property {Array.|null} [reservedName] EnumDescriptorProto reservedName + */ + + /** + * Constructs a new EnumDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents an EnumDescriptorProto. + * @implements IEnumDescriptorProto + * @constructor + * @param {google.protobuf.IEnumDescriptorProto=} [properties] Properties to set + */ + function EnumDescriptorProto(properties) { + this.value = [] + this.reservedRange = [] + this.reservedName = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * EnumDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.name = '' + + /** + * EnumDescriptorProto value. + * @member {Array.} value + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.value = $util.emptyArray + + /** + * EnumDescriptorProto options. + * @member {google.protobuf.IEnumOptions|null|undefined} options + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.options = null + + /** + * EnumDescriptorProto reservedRange. + * @member {Array.} reservedRange + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.reservedRange = $util.emptyArray + + /** + * EnumDescriptorProto reservedName. + * @member {Array.} reservedName + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.reservedName = $util.emptyArray + + /** + * Creates a new EnumDescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {google.protobuf.IEnumDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.EnumDescriptorProto} EnumDescriptorProto instance + */ + EnumDescriptorProto.create = function create(properties) { + return new EnumDescriptorProto(properties) + } + + /** + * Encodes the specified EnumDescriptorProto message. Does not implicitly {@link google.protobuf.EnumDescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {google.protobuf.IEnumDescriptorProto} message EnumDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumDescriptorProto.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.name != null && message.hasOwnProperty('name')) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.name) + if (message.value != null && message.value.length) + for (var i = 0; i < message.value.length; ++i) + $root.google.protobuf.EnumValueDescriptorProto.encode( + message.value[i], + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + ).ldelim() + if ( + message.options != null && + message.hasOwnProperty('options') + ) + $root.google.protobuf.EnumOptions.encode( + message.options, + writer.uint32(/* id 3, wireType 2 =*/ 26).fork() + ).ldelim() + if ( + message.reservedRange != null && + message.reservedRange.length + ) + for (var i = 0; i < message.reservedRange.length; ++i) + $root.google.protobuf.EnumDescriptorProto.EnumReservedRange.encode( + message.reservedRange[i], + writer.uint32(/* id 4, wireType 2 =*/ 34).fork() + ).ldelim() + if (message.reservedName != null && message.reservedName.length) + for (var i = 0; i < message.reservedName.length; ++i) + writer + .uint32(/* id 5, wireType 2 =*/ 42) + .string(message.reservedName[i]) + return writer + } + + /** + * Encodes the specified EnumDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.EnumDescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {google.protobuf.IEnumDescriptorProto} message EnumDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumDescriptorProto.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an EnumDescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.EnumDescriptorProto} EnumDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumDescriptorProto.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.EnumDescriptorProto() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + case 2: + if (!(message.value && message.value.length)) + message.value = [] + message.value.push( + $root.google.protobuf.EnumValueDescriptorProto.decode( + reader, + reader.uint32() + ) + ) + break + case 3: + message.options = $root.google.protobuf.EnumOptions.decode( + reader, + reader.uint32() + ) + break + case 4: + if ( + !(message.reservedRange && message.reservedRange.length) + ) + message.reservedRange = [] + message.reservedRange.push( + $root.google.protobuf.EnumDescriptorProto.EnumReservedRange.decode( + reader, + reader.uint32() + ) + ) + break + case 5: + if ( + !(message.reservedName && message.reservedName.length) + ) + message.reservedName = [] + message.reservedName.push(reader.string()) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an EnumDescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.EnumDescriptorProto} EnumDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumDescriptorProto.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an EnumDescriptorProto message. + * @function verify + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + EnumDescriptorProto.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + if (message.value != null && message.hasOwnProperty('value')) { + if (!Array.isArray(message.value)) + return 'value: array expected' + for (var i = 0; i < message.value.length; ++i) { + var error = $root.google.protobuf.EnumValueDescriptorProto.verify( + message.value[i] + ) + if (error) return 'value.' + error + } + } + if ( + message.options != null && + message.hasOwnProperty('options') + ) { + var error = $root.google.protobuf.EnumOptions.verify( + message.options + ) + if (error) return 'options.' + error + } + if ( + message.reservedRange != null && + message.hasOwnProperty('reservedRange') + ) { + if (!Array.isArray(message.reservedRange)) + return 'reservedRange: array expected' + for (var i = 0; i < message.reservedRange.length; ++i) { + var error = $root.google.protobuf.EnumDescriptorProto.EnumReservedRange.verify( + message.reservedRange[i] + ) + if (error) return 'reservedRange.' + error + } + } + if ( + message.reservedName != null && + message.hasOwnProperty('reservedName') + ) { + if (!Array.isArray(message.reservedName)) + return 'reservedName: array expected' + for (var i = 0; i < message.reservedName.length; ++i) + if (!$util.isString(message.reservedName[i])) + return 'reservedName: string[] expected' + } + return null + } + + /** + * Creates an EnumDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.EnumDescriptorProto} EnumDescriptorProto + */ + EnumDescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.EnumDescriptorProto) + return object + var message = new $root.google.protobuf.EnumDescriptorProto() + if (object.name != null) message.name = String(object.name) + if (object.value) { + if (!Array.isArray(object.value)) + throw TypeError( + '.google.protobuf.EnumDescriptorProto.value: array expected' + ) + message.value = [] + for (var i = 0; i < object.value.length; ++i) { + if (typeof object.value[i] !== 'object') + throw TypeError( + '.google.protobuf.EnumDescriptorProto.value: object expected' + ) + message.value[ + i + ] = $root.google.protobuf.EnumValueDescriptorProto.fromObject( + object.value[i] + ) + } + } + if (object.options != null) { + if (typeof object.options !== 'object') + throw TypeError( + '.google.protobuf.EnumDescriptorProto.options: object expected' + ) + message.options = $root.google.protobuf.EnumOptions.fromObject( + object.options + ) + } + if (object.reservedRange) { + if (!Array.isArray(object.reservedRange)) + throw TypeError( + '.google.protobuf.EnumDescriptorProto.reservedRange: array expected' + ) + message.reservedRange = [] + for (var i = 0; i < object.reservedRange.length; ++i) { + if (typeof object.reservedRange[i] !== 'object') + throw TypeError( + '.google.protobuf.EnumDescriptorProto.reservedRange: object expected' + ) + message.reservedRange[ + i + ] = $root.google.protobuf.EnumDescriptorProto.EnumReservedRange.fromObject( + object.reservedRange[i] + ) + } + } + if (object.reservedName) { + if (!Array.isArray(object.reservedName)) + throw TypeError( + '.google.protobuf.EnumDescriptorProto.reservedName: array expected' + ) + message.reservedName = [] + for (var i = 0; i < object.reservedName.length; ++i) + message.reservedName[i] = String(object.reservedName[i]) + } + return message + } + + /** + * Creates a plain object from an EnumDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {google.protobuf.EnumDescriptorProto} message EnumDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EnumDescriptorProto.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) { + object.value = [] + object.reservedRange = [] + object.reservedName = [] + } + if (options.defaults) { + object.name = '' + object.options = null + } + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + if (message.value && message.value.length) { + object.value = [] + for (var j = 0; j < message.value.length; ++j) + object.value[ + j + ] = $root.google.protobuf.EnumValueDescriptorProto.toObject( + message.value[j], + options + ) + } + if ( + message.options != null && + message.hasOwnProperty('options') + ) + object.options = $root.google.protobuf.EnumOptions.toObject( + message.options, + options + ) + if (message.reservedRange && message.reservedRange.length) { + object.reservedRange = [] + for (var j = 0; j < message.reservedRange.length; ++j) + object.reservedRange[ + j + ] = $root.google.protobuf.EnumDescriptorProto.EnumReservedRange.toObject( + message.reservedRange[j], + options + ) + } + if (message.reservedName && message.reservedName.length) { + object.reservedName = [] + for (var j = 0; j < message.reservedName.length; ++j) + object.reservedName[j] = message.reservedName[j] + } + return object + } + + /** + * Converts this EnumDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.EnumDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + EnumDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + EnumDescriptorProto.EnumReservedRange = (function () { + /** + * Properties of an EnumReservedRange. + * @memberof google.protobuf.EnumDescriptorProto + * @interface IEnumReservedRange + * @property {number|null} [start] EnumReservedRange start + * @property {number|null} [end] EnumReservedRange end + */ + + /** + * Constructs a new EnumReservedRange. + * @memberof google.protobuf.EnumDescriptorProto + * @classdesc Represents an EnumReservedRange. + * @implements IEnumReservedRange + * @constructor + * @param {google.protobuf.EnumDescriptorProto.IEnumReservedRange=} [properties] Properties to set + */ + function EnumReservedRange(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * EnumReservedRange start. + * @member {number} start + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @instance + */ + EnumReservedRange.prototype.start = 0 + + /** + * EnumReservedRange end. + * @member {number} end + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @instance + */ + EnumReservedRange.prototype.end = 0 + + /** + * Creates a new EnumReservedRange instance using the specified properties. + * @function create + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @static + * @param {google.protobuf.EnumDescriptorProto.IEnumReservedRange=} [properties] Properties to set + * @returns {google.protobuf.EnumDescriptorProto.EnumReservedRange} EnumReservedRange instance + */ + EnumReservedRange.create = function create(properties) { + return new EnumReservedRange(properties) + } + + /** + * Encodes the specified EnumReservedRange message. Does not implicitly {@link google.protobuf.EnumDescriptorProto.EnumReservedRange.verify|verify} messages. + * @function encode + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @static + * @param {google.protobuf.EnumDescriptorProto.IEnumReservedRange} message EnumReservedRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumReservedRange.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.start != null && message.hasOwnProperty('start')) + writer + .uint32(/* id 1, wireType 0 =*/ 8) + .int32(message.start) + if (message.end != null && message.hasOwnProperty('end')) + writer.uint32(/* id 2, wireType 0 =*/ 16).int32(message.end) + return writer + } + + /** + * Encodes the specified EnumReservedRange message, length delimited. Does not implicitly {@link google.protobuf.EnumDescriptorProto.EnumReservedRange.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @static + * @param {google.protobuf.EnumDescriptorProto.IEnumReservedRange} message EnumReservedRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumReservedRange.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an EnumReservedRange message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.EnumDescriptorProto.EnumReservedRange} EnumReservedRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumReservedRange.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.EnumDescriptorProto.EnumReservedRange() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.start = reader.int32() + break + case 2: + message.end = reader.int32() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an EnumReservedRange message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.EnumDescriptorProto.EnumReservedRange} EnumReservedRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumReservedRange.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an EnumReservedRange message. + * @function verify + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + EnumReservedRange.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.start != null && message.hasOwnProperty('start')) + if (!$util.isInteger(message.start)) + return 'start: integer expected' + if (message.end != null && message.hasOwnProperty('end')) + if (!$util.isInteger(message.end)) + return 'end: integer expected' + return null + } + + /** + * Creates an EnumReservedRange message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.EnumDescriptorProto.EnumReservedRange} EnumReservedRange + */ + EnumReservedRange.fromObject = function fromObject(object) { + if ( + object instanceof + $root.google.protobuf.EnumDescriptorProto.EnumReservedRange + ) + return object + var message = new $root.google.protobuf.EnumDescriptorProto.EnumReservedRange() + if (object.start != null) message.start = object.start | 0 + if (object.end != null) message.end = object.end | 0 + return message + } + + /** + * Creates a plain object from an EnumReservedRange message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @static + * @param {google.protobuf.EnumDescriptorProto.EnumReservedRange} message EnumReservedRange + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EnumReservedRange.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.start = 0 + object.end = 0 + } + if (message.start != null && message.hasOwnProperty('start')) + object.start = message.start + if (message.end != null && message.hasOwnProperty('end')) + object.end = message.end + return object + } + + /** + * Converts this EnumReservedRange to JSON. + * @function toJSON + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @instance + * @returns {Object.} JSON object + */ + EnumReservedRange.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return EnumReservedRange + })() + + return EnumDescriptorProto + })() + + protobuf.EnumValueDescriptorProto = (function () { + /** + * Properties of an EnumValueDescriptorProto. + * @memberof google.protobuf + * @interface IEnumValueDescriptorProto + * @property {string|null} [name] EnumValueDescriptorProto name + * @property {number|null} [number] EnumValueDescriptorProto number + * @property {google.protobuf.IEnumValueOptions|null} [options] EnumValueDescriptorProto options + */ + + /** + * Constructs a new EnumValueDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents an EnumValueDescriptorProto. + * @implements IEnumValueDescriptorProto + * @constructor + * @param {google.protobuf.IEnumValueDescriptorProto=} [properties] Properties to set + */ + function EnumValueDescriptorProto(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * EnumValueDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.EnumValueDescriptorProto + * @instance + */ + EnumValueDescriptorProto.prototype.name = '' + + /** + * EnumValueDescriptorProto number. + * @member {number} number + * @memberof google.protobuf.EnumValueDescriptorProto + * @instance + */ + EnumValueDescriptorProto.prototype.number = 0 + + /** + * EnumValueDescriptorProto options. + * @member {google.protobuf.IEnumValueOptions|null|undefined} options + * @memberof google.protobuf.EnumValueDescriptorProto + * @instance + */ + EnumValueDescriptorProto.prototype.options = null + + /** + * Creates a new EnumValueDescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {google.protobuf.IEnumValueDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.EnumValueDescriptorProto} EnumValueDescriptorProto instance + */ + EnumValueDescriptorProto.create = function create(properties) { + return new EnumValueDescriptorProto(properties) + } + + /** + * Encodes the specified EnumValueDescriptorProto message. Does not implicitly {@link google.protobuf.EnumValueDescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {google.protobuf.IEnumValueDescriptorProto} message EnumValueDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumValueDescriptorProto.encode = function encode( + message, + writer + ) { + if (!writer) writer = $Writer.create() + if (message.name != null && message.hasOwnProperty('name')) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.name) + if (message.number != null && message.hasOwnProperty('number')) + writer + .uint32(/* id 2, wireType 0 =*/ 16) + .int32(message.number) + if ( + message.options != null && + message.hasOwnProperty('options') + ) + $root.google.protobuf.EnumValueOptions.encode( + message.options, + writer.uint32(/* id 3, wireType 2 =*/ 26).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified EnumValueDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.EnumValueDescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {google.protobuf.IEnumValueDescriptorProto} message EnumValueDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumValueDescriptorProto.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an EnumValueDescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.EnumValueDescriptorProto} EnumValueDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumValueDescriptorProto.decode = function decode( + reader, + length + ) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.EnumValueDescriptorProto() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + case 2: + message.number = reader.int32() + break + case 3: + message.options = $root.google.protobuf.EnumValueOptions.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an EnumValueDescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.EnumValueDescriptorProto} EnumValueDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumValueDescriptorProto.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an EnumValueDescriptorProto message. + * @function verify + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + EnumValueDescriptorProto.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + if (message.number != null && message.hasOwnProperty('number')) + if (!$util.isInteger(message.number)) + return 'number: integer expected' + if ( + message.options != null && + message.hasOwnProperty('options') + ) { + var error = $root.google.protobuf.EnumValueOptions.verify( + message.options + ) + if (error) return 'options.' + error + } + return null + } + + /** + * Creates an EnumValueDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.EnumValueDescriptorProto} EnumValueDescriptorProto + */ + EnumValueDescriptorProto.fromObject = function fromObject( + object + ) { + if ( + object instanceof + $root.google.protobuf.EnumValueDescriptorProto + ) + return object + var message = new $root.google.protobuf.EnumValueDescriptorProto() + if (object.name != null) message.name = String(object.name) + if (object.number != null) message.number = object.number | 0 + if (object.options != null) { + if (typeof object.options !== 'object') + throw TypeError( + '.google.protobuf.EnumValueDescriptorProto.options: object expected' + ) + message.options = $root.google.protobuf.EnumValueOptions.fromObject( + object.options + ) + } + return message + } + + /** + * Creates a plain object from an EnumValueDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {google.protobuf.EnumValueDescriptorProto} message EnumValueDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EnumValueDescriptorProto.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.name = '' + object.number = 0 + object.options = null + } + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + if (message.number != null && message.hasOwnProperty('number')) + object.number = message.number + if ( + message.options != null && + message.hasOwnProperty('options') + ) + object.options = $root.google.protobuf.EnumValueOptions.toObject( + message.options, + options + ) + return object + } + + /** + * Converts this EnumValueDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.EnumValueDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + EnumValueDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return EnumValueDescriptorProto + })() + + protobuf.ServiceDescriptorProto = (function () { + /** + * Properties of a ServiceDescriptorProto. + * @memberof google.protobuf + * @interface IServiceDescriptorProto + * @property {string|null} [name] ServiceDescriptorProto name + * @property {Array.|null} [method] ServiceDescriptorProto method + * @property {google.protobuf.IServiceOptions|null} [options] ServiceDescriptorProto options + */ + + /** + * Constructs a new ServiceDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a ServiceDescriptorProto. + * @implements IServiceDescriptorProto + * @constructor + * @param {google.protobuf.IServiceDescriptorProto=} [properties] Properties to set + */ + function ServiceDescriptorProto(properties) { + this.method = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * ServiceDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.ServiceDescriptorProto + * @instance + */ + ServiceDescriptorProto.prototype.name = '' + + /** + * ServiceDescriptorProto method. + * @member {Array.} method + * @memberof google.protobuf.ServiceDescriptorProto + * @instance + */ + ServiceDescriptorProto.prototype.method = $util.emptyArray + + /** + * ServiceDescriptorProto options. + * @member {google.protobuf.IServiceOptions|null|undefined} options + * @memberof google.protobuf.ServiceDescriptorProto + * @instance + */ + ServiceDescriptorProto.prototype.options = null + + /** + * Creates a new ServiceDescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {google.protobuf.IServiceDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.ServiceDescriptorProto} ServiceDescriptorProto instance + */ + ServiceDescriptorProto.create = function create(properties) { + return new ServiceDescriptorProto(properties) + } + + /** + * Encodes the specified ServiceDescriptorProto message. Does not implicitly {@link google.protobuf.ServiceDescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {google.protobuf.IServiceDescriptorProto} message ServiceDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ServiceDescriptorProto.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.name != null && message.hasOwnProperty('name')) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.name) + if (message.method != null && message.method.length) + for (var i = 0; i < message.method.length; ++i) + $root.google.protobuf.MethodDescriptorProto.encode( + message.method[i], + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + ).ldelim() + if ( + message.options != null && + message.hasOwnProperty('options') + ) + $root.google.protobuf.ServiceOptions.encode( + message.options, + writer.uint32(/* id 3, wireType 2 =*/ 26).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified ServiceDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.ServiceDescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {google.protobuf.IServiceDescriptorProto} message ServiceDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ServiceDescriptorProto.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a ServiceDescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.ServiceDescriptorProto} ServiceDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ServiceDescriptorProto.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.ServiceDescriptorProto() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + case 2: + if (!(message.method && message.method.length)) + message.method = [] + message.method.push( + $root.google.protobuf.MethodDescriptorProto.decode( + reader, + reader.uint32() + ) + ) + break + case 3: + message.options = $root.google.protobuf.ServiceOptions.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a ServiceDescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.ServiceDescriptorProto} ServiceDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ServiceDescriptorProto.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a ServiceDescriptorProto message. + * @function verify + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ServiceDescriptorProto.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + if ( + message.method != null && + message.hasOwnProperty('method') + ) { + if (!Array.isArray(message.method)) + return 'method: array expected' + for (var i = 0; i < message.method.length; ++i) { + var error = $root.google.protobuf.MethodDescriptorProto.verify( + message.method[i] + ) + if (error) return 'method.' + error + } + } + if ( + message.options != null && + message.hasOwnProperty('options') + ) { + var error = $root.google.protobuf.ServiceOptions.verify( + message.options + ) + if (error) return 'options.' + error + } + return null + } + + /** + * Creates a ServiceDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.ServiceDescriptorProto} ServiceDescriptorProto + */ + ServiceDescriptorProto.fromObject = function fromObject(object) { + if ( + object instanceof $root.google.protobuf.ServiceDescriptorProto + ) + return object + var message = new $root.google.protobuf.ServiceDescriptorProto() + if (object.name != null) message.name = String(object.name) + if (object.method) { + if (!Array.isArray(object.method)) + throw TypeError( + '.google.protobuf.ServiceDescriptorProto.method: array expected' + ) + message.method = [] + for (var i = 0; i < object.method.length; ++i) { + if (typeof object.method[i] !== 'object') + throw TypeError( + '.google.protobuf.ServiceDescriptorProto.method: object expected' + ) + message.method[ + i + ] = $root.google.protobuf.MethodDescriptorProto.fromObject( + object.method[i] + ) + } + } + if (object.options != null) { + if (typeof object.options !== 'object') + throw TypeError( + '.google.protobuf.ServiceDescriptorProto.options: object expected' + ) + message.options = $root.google.protobuf.ServiceOptions.fromObject( + object.options + ) + } + return message + } + + /** + * Creates a plain object from a ServiceDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {google.protobuf.ServiceDescriptorProto} message ServiceDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ServiceDescriptorProto.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) object.method = [] + if (options.defaults) { + object.name = '' + object.options = null + } + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + if (message.method && message.method.length) { + object.method = [] + for (var j = 0; j < message.method.length; ++j) + object.method[ + j + ] = $root.google.protobuf.MethodDescriptorProto.toObject( + message.method[j], + options + ) + } + if ( + message.options != null && + message.hasOwnProperty('options') + ) + object.options = $root.google.protobuf.ServiceOptions.toObject( + message.options, + options + ) + return object + } + + /** + * Converts this ServiceDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.ServiceDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + ServiceDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return ServiceDescriptorProto + })() + + protobuf.MethodDescriptorProto = (function () { + /** + * Properties of a MethodDescriptorProto. + * @memberof google.protobuf + * @interface IMethodDescriptorProto + * @property {string|null} [name] MethodDescriptorProto name + * @property {string|null} [inputType] MethodDescriptorProto inputType + * @property {string|null} [outputType] MethodDescriptorProto outputType + * @property {google.protobuf.IMethodOptions|null} [options] MethodDescriptorProto options + * @property {boolean|null} [clientStreaming] MethodDescriptorProto clientStreaming + * @property {boolean|null} [serverStreaming] MethodDescriptorProto serverStreaming + */ + + /** + * Constructs a new MethodDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a MethodDescriptorProto. + * @implements IMethodDescriptorProto + * @constructor + * @param {google.protobuf.IMethodDescriptorProto=} [properties] Properties to set + */ + function MethodDescriptorProto(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * MethodDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.name = '' + + /** + * MethodDescriptorProto inputType. + * @member {string} inputType + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.inputType = '' + + /** + * MethodDescriptorProto outputType. + * @member {string} outputType + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.outputType = '' + + /** + * MethodDescriptorProto options. + * @member {google.protobuf.IMethodOptions|null|undefined} options + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.options = null + + /** + * MethodDescriptorProto clientStreaming. + * @member {boolean} clientStreaming + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.clientStreaming = false + + /** + * MethodDescriptorProto serverStreaming. + * @member {boolean} serverStreaming + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.serverStreaming = false + + /** + * Creates a new MethodDescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {google.protobuf.IMethodDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.MethodDescriptorProto} MethodDescriptorProto instance + */ + MethodDescriptorProto.create = function create(properties) { + return new MethodDescriptorProto(properties) + } + + /** + * Encodes the specified MethodDescriptorProto message. Does not implicitly {@link google.protobuf.MethodDescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {google.protobuf.IMethodDescriptorProto} message MethodDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MethodDescriptorProto.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.name != null && message.hasOwnProperty('name')) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.name) + if ( + message.inputType != null && + message.hasOwnProperty('inputType') + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.inputType) + if ( + message.outputType != null && + message.hasOwnProperty('outputType') + ) + writer + .uint32(/* id 3, wireType 2 =*/ 26) + .string(message.outputType) + if ( + message.options != null && + message.hasOwnProperty('options') + ) + $root.google.protobuf.MethodOptions.encode( + message.options, + writer.uint32(/* id 4, wireType 2 =*/ 34).fork() + ).ldelim() + if ( + message.clientStreaming != null && + message.hasOwnProperty('clientStreaming') + ) + writer + .uint32(/* id 5, wireType 0 =*/ 40) + .bool(message.clientStreaming) + if ( + message.serverStreaming != null && + message.hasOwnProperty('serverStreaming') + ) + writer + .uint32(/* id 6, wireType 0 =*/ 48) + .bool(message.serverStreaming) + return writer + } + + /** + * Encodes the specified MethodDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.MethodDescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {google.protobuf.IMethodDescriptorProto} message MethodDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MethodDescriptorProto.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a MethodDescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.MethodDescriptorProto} MethodDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MethodDescriptorProto.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.MethodDescriptorProto() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + case 2: + message.inputType = reader.string() + break + case 3: + message.outputType = reader.string() + break + case 4: + message.options = $root.google.protobuf.MethodOptions.decode( + reader, + reader.uint32() + ) + break + case 5: + message.clientStreaming = reader.bool() + break + case 6: + message.serverStreaming = reader.bool() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a MethodDescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.MethodDescriptorProto} MethodDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MethodDescriptorProto.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a MethodDescriptorProto message. + * @function verify + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + MethodDescriptorProto.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + if ( + message.inputType != null && + message.hasOwnProperty('inputType') + ) + if (!$util.isString(message.inputType)) + return 'inputType: string expected' + if ( + message.outputType != null && + message.hasOwnProperty('outputType') + ) + if (!$util.isString(message.outputType)) + return 'outputType: string expected' + if ( + message.options != null && + message.hasOwnProperty('options') + ) { + var error = $root.google.protobuf.MethodOptions.verify( + message.options + ) + if (error) return 'options.' + error + } + if ( + message.clientStreaming != null && + message.hasOwnProperty('clientStreaming') + ) + if (typeof message.clientStreaming !== 'boolean') + return 'clientStreaming: boolean expected' + if ( + message.serverStreaming != null && + message.hasOwnProperty('serverStreaming') + ) + if (typeof message.serverStreaming !== 'boolean') + return 'serverStreaming: boolean expected' + return null + } + + /** + * Creates a MethodDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.MethodDescriptorProto} MethodDescriptorProto + */ + MethodDescriptorProto.fromObject = function fromObject(object) { + if ( + object instanceof $root.google.protobuf.MethodDescriptorProto + ) + return object + var message = new $root.google.protobuf.MethodDescriptorProto() + if (object.name != null) message.name = String(object.name) + if (object.inputType != null) + message.inputType = String(object.inputType) + if (object.outputType != null) + message.outputType = String(object.outputType) + if (object.options != null) { + if (typeof object.options !== 'object') + throw TypeError( + '.google.protobuf.MethodDescriptorProto.options: object expected' + ) + message.options = $root.google.protobuf.MethodOptions.fromObject( + object.options + ) + } + if (object.clientStreaming != null) + message.clientStreaming = Boolean(object.clientStreaming) + if (object.serverStreaming != null) + message.serverStreaming = Boolean(object.serverStreaming) + return message + } + + /** + * Creates a plain object from a MethodDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {google.protobuf.MethodDescriptorProto} message MethodDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MethodDescriptorProto.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.name = '' + object.inputType = '' + object.outputType = '' + object.options = null + object.clientStreaming = false + object.serverStreaming = false + } + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + if ( + message.inputType != null && + message.hasOwnProperty('inputType') + ) + object.inputType = message.inputType + if ( + message.outputType != null && + message.hasOwnProperty('outputType') + ) + object.outputType = message.outputType + if ( + message.options != null && + message.hasOwnProperty('options') + ) + object.options = $root.google.protobuf.MethodOptions.toObject( + message.options, + options + ) + if ( + message.clientStreaming != null && + message.hasOwnProperty('clientStreaming') + ) + object.clientStreaming = message.clientStreaming + if ( + message.serverStreaming != null && + message.hasOwnProperty('serverStreaming') + ) + object.serverStreaming = message.serverStreaming + return object + } + + /** + * Converts this MethodDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.MethodDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + MethodDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return MethodDescriptorProto + })() + + protobuf.FileOptions = (function () { + /** + * Properties of a FileOptions. + * @memberof google.protobuf + * @interface IFileOptions + * @property {string|null} [javaPackage] FileOptions javaPackage + * @property {string|null} [javaOuterClassname] FileOptions javaOuterClassname + * @property {boolean|null} [javaMultipleFiles] FileOptions javaMultipleFiles + * @property {boolean|null} [javaGenerateEqualsAndHash] FileOptions javaGenerateEqualsAndHash + * @property {boolean|null} [javaStringCheckUtf8] FileOptions javaStringCheckUtf8 + * @property {google.protobuf.FileOptions.OptimizeMode|null} [optimizeFor] FileOptions optimizeFor + * @property {string|null} [goPackage] FileOptions goPackage + * @property {boolean|null} [ccGenericServices] FileOptions ccGenericServices + * @property {boolean|null} [javaGenericServices] FileOptions javaGenericServices + * @property {boolean|null} [pyGenericServices] FileOptions pyGenericServices + * @property {boolean|null} [phpGenericServices] FileOptions phpGenericServices + * @property {boolean|null} [deprecated] FileOptions deprecated + * @property {boolean|null} [ccEnableArenas] FileOptions ccEnableArenas + * @property {string|null} [objcClassPrefix] FileOptions objcClassPrefix + * @property {string|null} [csharpNamespace] FileOptions csharpNamespace + * @property {string|null} [swiftPrefix] FileOptions swiftPrefix + * @property {string|null} [phpClassPrefix] FileOptions phpClassPrefix + * @property {string|null} [phpNamespace] FileOptions phpNamespace + * @property {string|null} [phpMetadataNamespace] FileOptions phpMetadataNamespace + * @property {string|null} [rubyPackage] FileOptions rubyPackage + * @property {Array.|null} [uninterpretedOption] FileOptions uninterpretedOption + * @property {Array.|null} [".google.api.resourceDefinition"] FileOptions .google.api.resourceDefinition + */ + + /** + * Constructs a new FileOptions. + * @memberof google.protobuf + * @classdesc Represents a FileOptions. + * @implements IFileOptions + * @constructor + * @param {google.protobuf.IFileOptions=} [properties] Properties to set + */ + function FileOptions(properties) { + this.uninterpretedOption = [] + this['.google.api.resourceDefinition'] = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * FileOptions javaPackage. + * @member {string} javaPackage + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaPackage = '' + + /** + * FileOptions javaOuterClassname. + * @member {string} javaOuterClassname + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaOuterClassname = '' + + /** + * FileOptions javaMultipleFiles. + * @member {boolean} javaMultipleFiles + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaMultipleFiles = false + + /** + * FileOptions javaGenerateEqualsAndHash. + * @member {boolean} javaGenerateEqualsAndHash + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaGenerateEqualsAndHash = false + + /** + * FileOptions javaStringCheckUtf8. + * @member {boolean} javaStringCheckUtf8 + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaStringCheckUtf8 = false + + /** + * FileOptions optimizeFor. + * @member {google.protobuf.FileOptions.OptimizeMode} optimizeFor + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.optimizeFor = 1 + + /** + * FileOptions goPackage. + * @member {string} goPackage + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.goPackage = '' + + /** + * FileOptions ccGenericServices. + * @member {boolean} ccGenericServices + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.ccGenericServices = false + + /** + * FileOptions javaGenericServices. + * @member {boolean} javaGenericServices + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaGenericServices = false + + /** + * FileOptions pyGenericServices. + * @member {boolean} pyGenericServices + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.pyGenericServices = false + + /** + * FileOptions phpGenericServices. + * @member {boolean} phpGenericServices + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.phpGenericServices = false + + /** + * FileOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.deprecated = false + + /** + * FileOptions ccEnableArenas. + * @member {boolean} ccEnableArenas + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.ccEnableArenas = false + + /** + * FileOptions objcClassPrefix. + * @member {string} objcClassPrefix + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.objcClassPrefix = '' + + /** + * FileOptions csharpNamespace. + * @member {string} csharpNamespace + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.csharpNamespace = '' + + /** + * FileOptions swiftPrefix. + * @member {string} swiftPrefix + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.swiftPrefix = '' + + /** + * FileOptions phpClassPrefix. + * @member {string} phpClassPrefix + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.phpClassPrefix = '' + + /** + * FileOptions phpNamespace. + * @member {string} phpNamespace + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.phpNamespace = '' + + /** + * FileOptions phpMetadataNamespace. + * @member {string} phpMetadataNamespace + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.phpMetadataNamespace = '' + + /** + * FileOptions rubyPackage. + * @member {string} rubyPackage + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.rubyPackage = '' + + /** + * FileOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.uninterpretedOption = $util.emptyArray + + /** + * FileOptions .google.api.resourceDefinition. + * @member {Array.} .google.api.resourceDefinition + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype['.google.api.resourceDefinition'] = + $util.emptyArray + + /** + * Creates a new FileOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.FileOptions + * @static + * @param {google.protobuf.IFileOptions=} [properties] Properties to set + * @returns {google.protobuf.FileOptions} FileOptions instance + */ + FileOptions.create = function create(properties) { + return new FileOptions(properties) + } + + /** + * Encodes the specified FileOptions message. Does not implicitly {@link google.protobuf.FileOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FileOptions + * @static + * @param {google.protobuf.IFileOptions} message FileOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FileOptions.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.javaPackage != null && + message.hasOwnProperty('javaPackage') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.javaPackage) + if ( + message.javaOuterClassname != null && + message.hasOwnProperty('javaOuterClassname') + ) + writer + .uint32(/* id 8, wireType 2 =*/ 66) + .string(message.javaOuterClassname) + if ( + message.optimizeFor != null && + message.hasOwnProperty('optimizeFor') + ) + writer + .uint32(/* id 9, wireType 0 =*/ 72) + .int32(message.optimizeFor) + if ( + message.javaMultipleFiles != null && + message.hasOwnProperty('javaMultipleFiles') + ) + writer + .uint32(/* id 10, wireType 0 =*/ 80) + .bool(message.javaMultipleFiles) + if ( + message.goPackage != null && + message.hasOwnProperty('goPackage') + ) + writer + .uint32(/* id 11, wireType 2 =*/ 90) + .string(message.goPackage) + if ( + message.ccGenericServices != null && + message.hasOwnProperty('ccGenericServices') + ) + writer + .uint32(/* id 16, wireType 0 =*/ 128) + .bool(message.ccGenericServices) + if ( + message.javaGenericServices != null && + message.hasOwnProperty('javaGenericServices') + ) + writer + .uint32(/* id 17, wireType 0 =*/ 136) + .bool(message.javaGenericServices) + if ( + message.pyGenericServices != null && + message.hasOwnProperty('pyGenericServices') + ) + writer + .uint32(/* id 18, wireType 0 =*/ 144) + .bool(message.pyGenericServices) + if ( + message.javaGenerateEqualsAndHash != null && + message.hasOwnProperty('javaGenerateEqualsAndHash') + ) + writer + .uint32(/* id 20, wireType 0 =*/ 160) + .bool(message.javaGenerateEqualsAndHash) + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + writer + .uint32(/* id 23, wireType 0 =*/ 184) + .bool(message.deprecated) + if ( + message.javaStringCheckUtf8 != null && + message.hasOwnProperty('javaStringCheckUtf8') + ) + writer + .uint32(/* id 27, wireType 0 =*/ 216) + .bool(message.javaStringCheckUtf8) + if ( + message.ccEnableArenas != null && + message.hasOwnProperty('ccEnableArenas') + ) + writer + .uint32(/* id 31, wireType 0 =*/ 248) + .bool(message.ccEnableArenas) + if ( + message.objcClassPrefix != null && + message.hasOwnProperty('objcClassPrefix') + ) + writer + .uint32(/* id 36, wireType 2 =*/ 290) + .string(message.objcClassPrefix) + if ( + message.csharpNamespace != null && + message.hasOwnProperty('csharpNamespace') + ) + writer + .uint32(/* id 37, wireType 2 =*/ 298) + .string(message.csharpNamespace) + if ( + message.swiftPrefix != null && + message.hasOwnProperty('swiftPrefix') + ) + writer + .uint32(/* id 39, wireType 2 =*/ 314) + .string(message.swiftPrefix) + if ( + message.phpClassPrefix != null && + message.hasOwnProperty('phpClassPrefix') + ) + writer + .uint32(/* id 40, wireType 2 =*/ 322) + .string(message.phpClassPrefix) + if ( + message.phpNamespace != null && + message.hasOwnProperty('phpNamespace') + ) + writer + .uint32(/* id 41, wireType 2 =*/ 330) + .string(message.phpNamespace) + if ( + message.phpGenericServices != null && + message.hasOwnProperty('phpGenericServices') + ) + writer + .uint32(/* id 42, wireType 0 =*/ 336) + .bool(message.phpGenericServices) + if ( + message.phpMetadataNamespace != null && + message.hasOwnProperty('phpMetadataNamespace') + ) + writer + .uint32(/* id 44, wireType 2 =*/ 354) + .string(message.phpMetadataNamespace) + if ( + message.rubyPackage != null && + message.hasOwnProperty('rubyPackage') + ) + writer + .uint32(/* id 45, wireType 2 =*/ 362) + .string(message.rubyPackage) + if ( + message.uninterpretedOption != null && + message.uninterpretedOption.length + ) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode( + message.uninterpretedOption[i], + writer.uint32(/* id 999, wireType 2 =*/ 7994).fork() + ).ldelim() + if ( + message['.google.api.resourceDefinition'] != null && + message['.google.api.resourceDefinition'].length + ) + for ( + var i = 0; + i < message['.google.api.resourceDefinition'].length; + ++i + ) + $root.google.api.ResourceDescriptor.encode( + message['.google.api.resourceDefinition'][i], + writer.uint32(/* id 1053, wireType 2 =*/ 8426).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified FileOptions message, length delimited. Does not implicitly {@link google.protobuf.FileOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FileOptions + * @static + * @param {google.protobuf.IFileOptions} message FileOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FileOptions.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a FileOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FileOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FileOptions} FileOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FileOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.FileOptions() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.javaPackage = reader.string() + break + case 8: + message.javaOuterClassname = reader.string() + break + case 10: + message.javaMultipleFiles = reader.bool() + break + case 20: + message.javaGenerateEqualsAndHash = reader.bool() + break + case 27: + message.javaStringCheckUtf8 = reader.bool() + break + case 9: + message.optimizeFor = reader.int32() + break + case 11: + message.goPackage = reader.string() + break + case 16: + message.ccGenericServices = reader.bool() + break + case 17: + message.javaGenericServices = reader.bool() + break + case 18: + message.pyGenericServices = reader.bool() + break + case 42: + message.phpGenericServices = reader.bool() + break + case 23: + message.deprecated = reader.bool() + break + case 31: + message.ccEnableArenas = reader.bool() + break + case 36: + message.objcClassPrefix = reader.string() + break + case 37: + message.csharpNamespace = reader.string() + break + case 39: + message.swiftPrefix = reader.string() + break + case 40: + message.phpClassPrefix = reader.string() + break + case 41: + message.phpNamespace = reader.string() + break + case 44: + message.phpMetadataNamespace = reader.string() + break + case 45: + message.rubyPackage = reader.string() + break + case 999: + if ( + !( + message.uninterpretedOption && + message.uninterpretedOption.length + ) + ) + message.uninterpretedOption = [] + message.uninterpretedOption.push( + $root.google.protobuf.UninterpretedOption.decode( + reader, + reader.uint32() + ) + ) + break + case 1053: + if ( + !( + message['.google.api.resourceDefinition'] && + message['.google.api.resourceDefinition'].length + ) + ) + message['.google.api.resourceDefinition'] = [] + message['.google.api.resourceDefinition'].push( + $root.google.api.ResourceDescriptor.decode( + reader, + reader.uint32() + ) + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a FileOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FileOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FileOptions} FileOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FileOptions.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a FileOptions message. + * @function verify + * @memberof google.protobuf.FileOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FileOptions.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.javaPackage != null && + message.hasOwnProperty('javaPackage') + ) + if (!$util.isString(message.javaPackage)) + return 'javaPackage: string expected' + if ( + message.javaOuterClassname != null && + message.hasOwnProperty('javaOuterClassname') + ) + if (!$util.isString(message.javaOuterClassname)) + return 'javaOuterClassname: string expected' + if ( + message.javaMultipleFiles != null && + message.hasOwnProperty('javaMultipleFiles') + ) + if (typeof message.javaMultipleFiles !== 'boolean') + return 'javaMultipleFiles: boolean expected' + if ( + message.javaGenerateEqualsAndHash != null && + message.hasOwnProperty('javaGenerateEqualsAndHash') + ) + if (typeof message.javaGenerateEqualsAndHash !== 'boolean') + return 'javaGenerateEqualsAndHash: boolean expected' + if ( + message.javaStringCheckUtf8 != null && + message.hasOwnProperty('javaStringCheckUtf8') + ) + if (typeof message.javaStringCheckUtf8 !== 'boolean') + return 'javaStringCheckUtf8: boolean expected' + if ( + message.optimizeFor != null && + message.hasOwnProperty('optimizeFor') + ) + switch (message.optimizeFor) { + default: + return 'optimizeFor: enum value expected' + case 1: + case 2: + case 3: + break + } + if ( + message.goPackage != null && + message.hasOwnProperty('goPackage') + ) + if (!$util.isString(message.goPackage)) + return 'goPackage: string expected' + if ( + message.ccGenericServices != null && + message.hasOwnProperty('ccGenericServices') + ) + if (typeof message.ccGenericServices !== 'boolean') + return 'ccGenericServices: boolean expected' + if ( + message.javaGenericServices != null && + message.hasOwnProperty('javaGenericServices') + ) + if (typeof message.javaGenericServices !== 'boolean') + return 'javaGenericServices: boolean expected' + if ( + message.pyGenericServices != null && + message.hasOwnProperty('pyGenericServices') + ) + if (typeof message.pyGenericServices !== 'boolean') + return 'pyGenericServices: boolean expected' + if ( + message.phpGenericServices != null && + message.hasOwnProperty('phpGenericServices') + ) + if (typeof message.phpGenericServices !== 'boolean') + return 'phpGenericServices: boolean expected' + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + if (typeof message.deprecated !== 'boolean') + return 'deprecated: boolean expected' + if ( + message.ccEnableArenas != null && + message.hasOwnProperty('ccEnableArenas') + ) + if (typeof message.ccEnableArenas !== 'boolean') + return 'ccEnableArenas: boolean expected' + if ( + message.objcClassPrefix != null && + message.hasOwnProperty('objcClassPrefix') + ) + if (!$util.isString(message.objcClassPrefix)) + return 'objcClassPrefix: string expected' + if ( + message.csharpNamespace != null && + message.hasOwnProperty('csharpNamespace') + ) + if (!$util.isString(message.csharpNamespace)) + return 'csharpNamespace: string expected' + if ( + message.swiftPrefix != null && + message.hasOwnProperty('swiftPrefix') + ) + if (!$util.isString(message.swiftPrefix)) + return 'swiftPrefix: string expected' + if ( + message.phpClassPrefix != null && + message.hasOwnProperty('phpClassPrefix') + ) + if (!$util.isString(message.phpClassPrefix)) + return 'phpClassPrefix: string expected' + if ( + message.phpNamespace != null && + message.hasOwnProperty('phpNamespace') + ) + if (!$util.isString(message.phpNamespace)) + return 'phpNamespace: string expected' + if ( + message.phpMetadataNamespace != null && + message.hasOwnProperty('phpMetadataNamespace') + ) + if (!$util.isString(message.phpMetadataNamespace)) + return 'phpMetadataNamespace: string expected' + if ( + message.rubyPackage != null && + message.hasOwnProperty('rubyPackage') + ) + if (!$util.isString(message.rubyPackage)) + return 'rubyPackage: string expected' + if ( + message.uninterpretedOption != null && + message.hasOwnProperty('uninterpretedOption') + ) { + if (!Array.isArray(message.uninterpretedOption)) + return 'uninterpretedOption: array expected' + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify( + message.uninterpretedOption[i] + ) + if (error) return 'uninterpretedOption.' + error + } + } + if ( + message['.google.api.resourceDefinition'] != null && + message.hasOwnProperty('.google.api.resourceDefinition') + ) { + if (!Array.isArray(message['.google.api.resourceDefinition'])) + return '.google.api.resourceDefinition: array expected' + for ( + var i = 0; + i < message['.google.api.resourceDefinition'].length; + ++i + ) { + var error = $root.google.api.ResourceDescriptor.verify( + message['.google.api.resourceDefinition'][i] + ) + if (error) return '.google.api.resourceDefinition.' + error + } + } + return null + } + + /** + * Creates a FileOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FileOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FileOptions} FileOptions + */ + FileOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FileOptions) + return object + var message = new $root.google.protobuf.FileOptions() + if (object.javaPackage != null) + message.javaPackage = String(object.javaPackage) + if (object.javaOuterClassname != null) + message.javaOuterClassname = String(object.javaOuterClassname) + if (object.javaMultipleFiles != null) + message.javaMultipleFiles = Boolean(object.javaMultipleFiles) + if (object.javaGenerateEqualsAndHash != null) + message.javaGenerateEqualsAndHash = Boolean( + object.javaGenerateEqualsAndHash + ) + if (object.javaStringCheckUtf8 != null) + message.javaStringCheckUtf8 = Boolean( + object.javaStringCheckUtf8 + ) + switch (object.optimizeFor) { + case 'SPEED': + case 1: + message.optimizeFor = 1 + break + case 'CODE_SIZE': + case 2: + message.optimizeFor = 2 + break + case 'LITE_RUNTIME': + case 3: + message.optimizeFor = 3 + break + } + if (object.goPackage != null) + message.goPackage = String(object.goPackage) + if (object.ccGenericServices != null) + message.ccGenericServices = Boolean(object.ccGenericServices) + if (object.javaGenericServices != null) + message.javaGenericServices = Boolean( + object.javaGenericServices + ) + if (object.pyGenericServices != null) + message.pyGenericServices = Boolean(object.pyGenericServices) + if (object.phpGenericServices != null) + message.phpGenericServices = Boolean( + object.phpGenericServices + ) + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated) + if (object.ccEnableArenas != null) + message.ccEnableArenas = Boolean(object.ccEnableArenas) + if (object.objcClassPrefix != null) + message.objcClassPrefix = String(object.objcClassPrefix) + if (object.csharpNamespace != null) + message.csharpNamespace = String(object.csharpNamespace) + if (object.swiftPrefix != null) + message.swiftPrefix = String(object.swiftPrefix) + if (object.phpClassPrefix != null) + message.phpClassPrefix = String(object.phpClassPrefix) + if (object.phpNamespace != null) + message.phpNamespace = String(object.phpNamespace) + if (object.phpMetadataNamespace != null) + message.phpMetadataNamespace = String( + object.phpMetadataNamespace + ) + if (object.rubyPackage != null) + message.rubyPackage = String(object.rubyPackage) + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError( + '.google.protobuf.FileOptions.uninterpretedOption: array expected' + ) + message.uninterpretedOption = [] + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== 'object') + throw TypeError( + '.google.protobuf.FileOptions.uninterpretedOption: object expected' + ) + message.uninterpretedOption[ + i + ] = $root.google.protobuf.UninterpretedOption.fromObject( + object.uninterpretedOption[i] + ) + } + } + if (object['.google.api.resourceDefinition']) { + if (!Array.isArray(object['.google.api.resourceDefinition'])) + throw TypeError( + '.google.protobuf.FileOptions..google.api.resourceDefinition: array expected' + ) + message['.google.api.resourceDefinition'] = [] + for ( + var i = 0; + i < object['.google.api.resourceDefinition'].length; + ++i + ) { + if ( + typeof object['.google.api.resourceDefinition'][i] !== + 'object' + ) + throw TypeError( + '.google.protobuf.FileOptions..google.api.resourceDefinition: object expected' + ) + message['.google.api.resourceDefinition'][ + i + ] = $root.google.api.ResourceDescriptor.fromObject( + object['.google.api.resourceDefinition'][i] + ) + } + } + return message + } + + /** + * Creates a plain object from a FileOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FileOptions + * @static + * @param {google.protobuf.FileOptions} message FileOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FileOptions.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) { + object.uninterpretedOption = [] + object['.google.api.resourceDefinition'] = [] + } + if (options.defaults) { + object.javaPackage = '' + object.javaOuterClassname = '' + object.optimizeFor = options.enums === String ? 'SPEED' : 1 + object.javaMultipleFiles = false + object.goPackage = '' + object.ccGenericServices = false + object.javaGenericServices = false + object.pyGenericServices = false + object.javaGenerateEqualsAndHash = false + object.deprecated = false + object.javaStringCheckUtf8 = false + object.ccEnableArenas = false + object.objcClassPrefix = '' + object.csharpNamespace = '' + object.swiftPrefix = '' + object.phpClassPrefix = '' + object.phpNamespace = '' + object.phpGenericServices = false + object.phpMetadataNamespace = '' + object.rubyPackage = '' + } + if ( + message.javaPackage != null && + message.hasOwnProperty('javaPackage') + ) + object.javaPackage = message.javaPackage + if ( + message.javaOuterClassname != null && + message.hasOwnProperty('javaOuterClassname') + ) + object.javaOuterClassname = message.javaOuterClassname + if ( + message.optimizeFor != null && + message.hasOwnProperty('optimizeFor') + ) + object.optimizeFor = + options.enums === String + ? $root.google.protobuf.FileOptions.OptimizeMode[ + message.optimizeFor + ] + : message.optimizeFor + if ( + message.javaMultipleFiles != null && + message.hasOwnProperty('javaMultipleFiles') + ) + object.javaMultipleFiles = message.javaMultipleFiles + if ( + message.goPackage != null && + message.hasOwnProperty('goPackage') + ) + object.goPackage = message.goPackage + if ( + message.ccGenericServices != null && + message.hasOwnProperty('ccGenericServices') + ) + object.ccGenericServices = message.ccGenericServices + if ( + message.javaGenericServices != null && + message.hasOwnProperty('javaGenericServices') + ) + object.javaGenericServices = message.javaGenericServices + if ( + message.pyGenericServices != null && + message.hasOwnProperty('pyGenericServices') + ) + object.pyGenericServices = message.pyGenericServices + if ( + message.javaGenerateEqualsAndHash != null && + message.hasOwnProperty('javaGenerateEqualsAndHash') + ) + object.javaGenerateEqualsAndHash = + message.javaGenerateEqualsAndHash + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + object.deprecated = message.deprecated + if ( + message.javaStringCheckUtf8 != null && + message.hasOwnProperty('javaStringCheckUtf8') + ) + object.javaStringCheckUtf8 = message.javaStringCheckUtf8 + if ( + message.ccEnableArenas != null && + message.hasOwnProperty('ccEnableArenas') + ) + object.ccEnableArenas = message.ccEnableArenas + if ( + message.objcClassPrefix != null && + message.hasOwnProperty('objcClassPrefix') + ) + object.objcClassPrefix = message.objcClassPrefix + if ( + message.csharpNamespace != null && + message.hasOwnProperty('csharpNamespace') + ) + object.csharpNamespace = message.csharpNamespace + if ( + message.swiftPrefix != null && + message.hasOwnProperty('swiftPrefix') + ) + object.swiftPrefix = message.swiftPrefix + if ( + message.phpClassPrefix != null && + message.hasOwnProperty('phpClassPrefix') + ) + object.phpClassPrefix = message.phpClassPrefix + if ( + message.phpNamespace != null && + message.hasOwnProperty('phpNamespace') + ) + object.phpNamespace = message.phpNamespace + if ( + message.phpGenericServices != null && + message.hasOwnProperty('phpGenericServices') + ) + object.phpGenericServices = message.phpGenericServices + if ( + message.phpMetadataNamespace != null && + message.hasOwnProperty('phpMetadataNamespace') + ) + object.phpMetadataNamespace = message.phpMetadataNamespace + if ( + message.rubyPackage != null && + message.hasOwnProperty('rubyPackage') + ) + object.rubyPackage = message.rubyPackage + if ( + message.uninterpretedOption && + message.uninterpretedOption.length + ) { + object.uninterpretedOption = [] + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[ + j + ] = $root.google.protobuf.UninterpretedOption.toObject( + message.uninterpretedOption[j], + options + ) + } + if ( + message['.google.api.resourceDefinition'] && + message['.google.api.resourceDefinition'].length + ) { + object['.google.api.resourceDefinition'] = [] + for ( + var j = 0; + j < message['.google.api.resourceDefinition'].length; + ++j + ) + object['.google.api.resourceDefinition'][ + j + ] = $root.google.api.ResourceDescriptor.toObject( + message['.google.api.resourceDefinition'][j], + options + ) + } + return object + } + + /** + * Converts this FileOptions to JSON. + * @function toJSON + * @memberof google.protobuf.FileOptions + * @instance + * @returns {Object.} JSON object + */ + FileOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + /** + * OptimizeMode enum. + * @name google.protobuf.FileOptions.OptimizeMode + * @enum {string} + * @property {number} SPEED=1 SPEED value + * @property {number} CODE_SIZE=2 CODE_SIZE value + * @property {number} LITE_RUNTIME=3 LITE_RUNTIME value + */ + FileOptions.OptimizeMode = (function () { + var valuesById = {}, + values = Object.create(valuesById) + values[(valuesById[1] = 'SPEED')] = 1 + values[(valuesById[2] = 'CODE_SIZE')] = 2 + values[(valuesById[3] = 'LITE_RUNTIME')] = 3 + return values + })() + + return FileOptions + })() + + protobuf.MessageOptions = (function () { + /** + * Properties of a MessageOptions. + * @memberof google.protobuf + * @interface IMessageOptions + * @property {boolean|null} [messageSetWireFormat] MessageOptions messageSetWireFormat + * @property {boolean|null} [noStandardDescriptorAccessor] MessageOptions noStandardDescriptorAccessor + * @property {boolean|null} [deprecated] MessageOptions deprecated + * @property {boolean|null} [mapEntry] MessageOptions mapEntry + * @property {Array.|null} [uninterpretedOption] MessageOptions uninterpretedOption + * @property {google.api.IResourceDescriptor|null} [".google.api.resource"] MessageOptions .google.api.resource + */ + + /** + * Constructs a new MessageOptions. + * @memberof google.protobuf + * @classdesc Represents a MessageOptions. + * @implements IMessageOptions + * @constructor + * @param {google.protobuf.IMessageOptions=} [properties] Properties to set + */ + function MessageOptions(properties) { + this.uninterpretedOption = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * MessageOptions messageSetWireFormat. + * @member {boolean} messageSetWireFormat + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.messageSetWireFormat = false + + /** + * MessageOptions noStandardDescriptorAccessor. + * @member {boolean} noStandardDescriptorAccessor + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.noStandardDescriptorAccessor = false + + /** + * MessageOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.deprecated = false + + /** + * MessageOptions mapEntry. + * @member {boolean} mapEntry + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.mapEntry = false + + /** + * MessageOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.uninterpretedOption = $util.emptyArray + + /** + * MessageOptions .google.api.resource. + * @member {google.api.IResourceDescriptor|null|undefined} .google.api.resource + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype['.google.api.resource'] = null + + /** + * Creates a new MessageOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.MessageOptions + * @static + * @param {google.protobuf.IMessageOptions=} [properties] Properties to set + * @returns {google.protobuf.MessageOptions} MessageOptions instance + */ + MessageOptions.create = function create(properties) { + return new MessageOptions(properties) + } + + /** + * Encodes the specified MessageOptions message. Does not implicitly {@link google.protobuf.MessageOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.MessageOptions + * @static + * @param {google.protobuf.IMessageOptions} message MessageOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MessageOptions.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.messageSetWireFormat != null && + message.hasOwnProperty('messageSetWireFormat') + ) + writer + .uint32(/* id 1, wireType 0 =*/ 8) + .bool(message.messageSetWireFormat) + if ( + message.noStandardDescriptorAccessor != null && + message.hasOwnProperty('noStandardDescriptorAccessor') + ) + writer + .uint32(/* id 2, wireType 0 =*/ 16) + .bool(message.noStandardDescriptorAccessor) + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + writer + .uint32(/* id 3, wireType 0 =*/ 24) + .bool(message.deprecated) + if ( + message.mapEntry != null && + message.hasOwnProperty('mapEntry') + ) + writer + .uint32(/* id 7, wireType 0 =*/ 56) + .bool(message.mapEntry) + if ( + message.uninterpretedOption != null && + message.uninterpretedOption.length + ) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode( + message.uninterpretedOption[i], + writer.uint32(/* id 999, wireType 2 =*/ 7994).fork() + ).ldelim() + if ( + message['.google.api.resource'] != null && + message.hasOwnProperty('.google.api.resource') + ) + $root.google.api.ResourceDescriptor.encode( + message['.google.api.resource'], + writer.uint32(/* id 1053, wireType 2 =*/ 8426).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified MessageOptions message, length delimited. Does not implicitly {@link google.protobuf.MessageOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.MessageOptions + * @static + * @param {google.protobuf.IMessageOptions} message MessageOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MessageOptions.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a MessageOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.MessageOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.MessageOptions} MessageOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MessageOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.MessageOptions() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.messageSetWireFormat = reader.bool() + break + case 2: + message.noStandardDescriptorAccessor = reader.bool() + break + case 3: + message.deprecated = reader.bool() + break + case 7: + message.mapEntry = reader.bool() + break + case 999: + if ( + !( + message.uninterpretedOption && + message.uninterpretedOption.length + ) + ) + message.uninterpretedOption = [] + message.uninterpretedOption.push( + $root.google.protobuf.UninterpretedOption.decode( + reader, + reader.uint32() + ) + ) + break + case 1053: + message[ + '.google.api.resource' + ] = $root.google.api.ResourceDescriptor.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a MessageOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.MessageOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.MessageOptions} MessageOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MessageOptions.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a MessageOptions message. + * @function verify + * @memberof google.protobuf.MessageOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + MessageOptions.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.messageSetWireFormat != null && + message.hasOwnProperty('messageSetWireFormat') + ) + if (typeof message.messageSetWireFormat !== 'boolean') + return 'messageSetWireFormat: boolean expected' + if ( + message.noStandardDescriptorAccessor != null && + message.hasOwnProperty('noStandardDescriptorAccessor') + ) + if (typeof message.noStandardDescriptorAccessor !== 'boolean') + return 'noStandardDescriptorAccessor: boolean expected' + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + if (typeof message.deprecated !== 'boolean') + return 'deprecated: boolean expected' + if ( + message.mapEntry != null && + message.hasOwnProperty('mapEntry') + ) + if (typeof message.mapEntry !== 'boolean') + return 'mapEntry: boolean expected' + if ( + message.uninterpretedOption != null && + message.hasOwnProperty('uninterpretedOption') + ) { + if (!Array.isArray(message.uninterpretedOption)) + return 'uninterpretedOption: array expected' + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify( + message.uninterpretedOption[i] + ) + if (error) return 'uninterpretedOption.' + error + } + } + if ( + message['.google.api.resource'] != null && + message.hasOwnProperty('.google.api.resource') + ) { + var error = $root.google.api.ResourceDescriptor.verify( + message['.google.api.resource'] + ) + if (error) return '.google.api.resource.' + error + } + return null + } + + /** + * Creates a MessageOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.MessageOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.MessageOptions} MessageOptions + */ + MessageOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.MessageOptions) + return object + var message = new $root.google.protobuf.MessageOptions() + if (object.messageSetWireFormat != null) + message.messageSetWireFormat = Boolean( + object.messageSetWireFormat + ) + if (object.noStandardDescriptorAccessor != null) + message.noStandardDescriptorAccessor = Boolean( + object.noStandardDescriptorAccessor + ) + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated) + if (object.mapEntry != null) + message.mapEntry = Boolean(object.mapEntry) + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError( + '.google.protobuf.MessageOptions.uninterpretedOption: array expected' + ) + message.uninterpretedOption = [] + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== 'object') + throw TypeError( + '.google.protobuf.MessageOptions.uninterpretedOption: object expected' + ) + message.uninterpretedOption[ + i + ] = $root.google.protobuf.UninterpretedOption.fromObject( + object.uninterpretedOption[i] + ) + } + } + if (object['.google.api.resource'] != null) { + if (typeof object['.google.api.resource'] !== 'object') + throw TypeError( + '.google.protobuf.MessageOptions..google.api.resource: object expected' + ) + message[ + '.google.api.resource' + ] = $root.google.api.ResourceDescriptor.fromObject( + object['.google.api.resource'] + ) + } + return message + } + + /** + * Creates a plain object from a MessageOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.MessageOptions + * @static + * @param {google.protobuf.MessageOptions} message MessageOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MessageOptions.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) + object.uninterpretedOption = [] + if (options.defaults) { + object.messageSetWireFormat = false + object.noStandardDescriptorAccessor = false + object.deprecated = false + object.mapEntry = false + object['.google.api.resource'] = null + } + if ( + message.messageSetWireFormat != null && + message.hasOwnProperty('messageSetWireFormat') + ) + object.messageSetWireFormat = message.messageSetWireFormat + if ( + message.noStandardDescriptorAccessor != null && + message.hasOwnProperty('noStandardDescriptorAccessor') + ) + object.noStandardDescriptorAccessor = + message.noStandardDescriptorAccessor + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + object.deprecated = message.deprecated + if ( + message.mapEntry != null && + message.hasOwnProperty('mapEntry') + ) + object.mapEntry = message.mapEntry + if ( + message.uninterpretedOption && + message.uninterpretedOption.length + ) { + object.uninterpretedOption = [] + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[ + j + ] = $root.google.protobuf.UninterpretedOption.toObject( + message.uninterpretedOption[j], + options + ) + } + if ( + message['.google.api.resource'] != null && + message.hasOwnProperty('.google.api.resource') + ) + object[ + '.google.api.resource' + ] = $root.google.api.ResourceDescriptor.toObject( + message['.google.api.resource'], + options + ) + return object + } + + /** + * Converts this MessageOptions to JSON. + * @function toJSON + * @memberof google.protobuf.MessageOptions + * @instance + * @returns {Object.} JSON object + */ + MessageOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return MessageOptions + })() + + protobuf.FieldOptions = (function () { + /** + * Properties of a FieldOptions. + * @memberof google.protobuf + * @interface IFieldOptions + * @property {google.protobuf.FieldOptions.CType|null} [ctype] FieldOptions ctype + * @property {boolean|null} [packed] FieldOptions packed + * @property {google.protobuf.FieldOptions.JSType|null} [jstype] FieldOptions jstype + * @property {boolean|null} [lazy] FieldOptions lazy + * @property {boolean|null} [deprecated] FieldOptions deprecated + * @property {boolean|null} [weak] FieldOptions weak + * @property {Array.|null} [uninterpretedOption] FieldOptions uninterpretedOption + * @property {Array.|null} [".google.api.fieldBehavior"] FieldOptions .google.api.fieldBehavior + * @property {google.api.IResourceReference|null} [".google.api.resourceReference"] FieldOptions .google.api.resourceReference + */ + + /** + * Constructs a new FieldOptions. + * @memberof google.protobuf + * @classdesc Represents a FieldOptions. + * @implements IFieldOptions + * @constructor + * @param {google.protobuf.IFieldOptions=} [properties] Properties to set + */ + function FieldOptions(properties) { + this.uninterpretedOption = [] + this['.google.api.fieldBehavior'] = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * FieldOptions ctype. + * @member {google.protobuf.FieldOptions.CType} ctype + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.ctype = 0 + + /** + * FieldOptions packed. + * @member {boolean} packed + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.packed = false + + /** + * FieldOptions jstype. + * @member {google.protobuf.FieldOptions.JSType} jstype + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.jstype = 0 + + /** + * FieldOptions lazy. + * @member {boolean} lazy + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.lazy = false + + /** + * FieldOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.deprecated = false + + /** + * FieldOptions weak. + * @member {boolean} weak + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.weak = false + + /** + * FieldOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.uninterpretedOption = $util.emptyArray + + /** + * FieldOptions .google.api.fieldBehavior. + * @member {Array.} .google.api.fieldBehavior + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype['.google.api.fieldBehavior'] = + $util.emptyArray + + /** + * FieldOptions .google.api.resourceReference. + * @member {google.api.IResourceReference|null|undefined} .google.api.resourceReference + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype['.google.api.resourceReference'] = null + + /** + * Creates a new FieldOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.FieldOptions + * @static + * @param {google.protobuf.IFieldOptions=} [properties] Properties to set + * @returns {google.protobuf.FieldOptions} FieldOptions instance + */ + FieldOptions.create = function create(properties) { + return new FieldOptions(properties) + } + + /** + * Encodes the specified FieldOptions message. Does not implicitly {@link google.protobuf.FieldOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FieldOptions + * @static + * @param {google.protobuf.IFieldOptions} message FieldOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FieldOptions.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.ctype != null && message.hasOwnProperty('ctype')) + writer.uint32(/* id 1, wireType 0 =*/ 8).int32(message.ctype) + if (message.packed != null && message.hasOwnProperty('packed')) + writer.uint32(/* id 2, wireType 0 =*/ 16).bool(message.packed) + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + writer + .uint32(/* id 3, wireType 0 =*/ 24) + .bool(message.deprecated) + if (message.lazy != null && message.hasOwnProperty('lazy')) + writer.uint32(/* id 5, wireType 0 =*/ 40).bool(message.lazy) + if (message.jstype != null && message.hasOwnProperty('jstype')) + writer + .uint32(/* id 6, wireType 0 =*/ 48) + .int32(message.jstype) + if (message.weak != null && message.hasOwnProperty('weak')) + writer.uint32(/* id 10, wireType 0 =*/ 80).bool(message.weak) + if ( + message.uninterpretedOption != null && + message.uninterpretedOption.length + ) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode( + message.uninterpretedOption[i], + writer.uint32(/* id 999, wireType 2 =*/ 7994).fork() + ).ldelim() + if ( + message['.google.api.fieldBehavior'] != null && + message['.google.api.fieldBehavior'].length + ) { + writer.uint32(/* id 1052, wireType 2 =*/ 8418).fork() + for ( + var i = 0; + i < message['.google.api.fieldBehavior'].length; + ++i + ) + writer.int32(message['.google.api.fieldBehavior'][i]) + writer.ldelim() + } + if ( + message['.google.api.resourceReference'] != null && + message.hasOwnProperty('.google.api.resourceReference') + ) + $root.google.api.ResourceReference.encode( + message['.google.api.resourceReference'], + writer.uint32(/* id 1055, wireType 2 =*/ 8442).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified FieldOptions message, length delimited. Does not implicitly {@link google.protobuf.FieldOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FieldOptions + * @static + * @param {google.protobuf.IFieldOptions} message FieldOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FieldOptions.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a FieldOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FieldOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FieldOptions} FieldOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FieldOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.FieldOptions() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.ctype = reader.int32() + break + case 2: + message.packed = reader.bool() + break + case 6: + message.jstype = reader.int32() + break + case 5: + message.lazy = reader.bool() + break + case 3: + message.deprecated = reader.bool() + break + case 10: + message.weak = reader.bool() + break + case 999: + if ( + !( + message.uninterpretedOption && + message.uninterpretedOption.length + ) + ) + message.uninterpretedOption = [] + message.uninterpretedOption.push( + $root.google.protobuf.UninterpretedOption.decode( + reader, + reader.uint32() + ) + ) + break + case 1052: + if ( + !( + message['.google.api.fieldBehavior'] && + message['.google.api.fieldBehavior'].length + ) + ) + message['.google.api.fieldBehavior'] = [] + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos + while (reader.pos < end2) + message['.google.api.fieldBehavior'].push( + reader.int32() + ) + } else + message['.google.api.fieldBehavior'].push( + reader.int32() + ) + break + case 1055: + message[ + '.google.api.resourceReference' + ] = $root.google.api.ResourceReference.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a FieldOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FieldOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FieldOptions} FieldOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FieldOptions.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a FieldOptions message. + * @function verify + * @memberof google.protobuf.FieldOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FieldOptions.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.ctype != null && message.hasOwnProperty('ctype')) + switch (message.ctype) { + default: + return 'ctype: enum value expected' + case 0: + case 1: + case 2: + break + } + if (message.packed != null && message.hasOwnProperty('packed')) + if (typeof message.packed !== 'boolean') + return 'packed: boolean expected' + if (message.jstype != null && message.hasOwnProperty('jstype')) + switch (message.jstype) { + default: + return 'jstype: enum value expected' + case 0: + case 1: + case 2: + break + } + if (message.lazy != null && message.hasOwnProperty('lazy')) + if (typeof message.lazy !== 'boolean') + return 'lazy: boolean expected' + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + if (typeof message.deprecated !== 'boolean') + return 'deprecated: boolean expected' + if (message.weak != null && message.hasOwnProperty('weak')) + if (typeof message.weak !== 'boolean') + return 'weak: boolean expected' + if ( + message.uninterpretedOption != null && + message.hasOwnProperty('uninterpretedOption') + ) { + if (!Array.isArray(message.uninterpretedOption)) + return 'uninterpretedOption: array expected' + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify( + message.uninterpretedOption[i] + ) + if (error) return 'uninterpretedOption.' + error + } + } + if ( + message['.google.api.fieldBehavior'] != null && + message.hasOwnProperty('.google.api.fieldBehavior') + ) { + if (!Array.isArray(message['.google.api.fieldBehavior'])) + return '.google.api.fieldBehavior: array expected' + for ( + var i = 0; + i < message['.google.api.fieldBehavior'].length; + ++i + ) + switch (message['.google.api.fieldBehavior'][i]) { + default: + return '.google.api.fieldBehavior: enum value[] expected' + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + break + } + } + if ( + message['.google.api.resourceReference'] != null && + message.hasOwnProperty('.google.api.resourceReference') + ) { + var error = $root.google.api.ResourceReference.verify( + message['.google.api.resourceReference'] + ) + if (error) return '.google.api.resourceReference.' + error + } + return null + } + + /** + * Creates a FieldOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FieldOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FieldOptions} FieldOptions + */ + FieldOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FieldOptions) + return object + var message = new $root.google.protobuf.FieldOptions() + switch (object.ctype) { + case 'STRING': + case 0: + message.ctype = 0 + break + case 'CORD': + case 1: + message.ctype = 1 + break + case 'STRING_PIECE': + case 2: + message.ctype = 2 + break + } + if (object.packed != null) + message.packed = Boolean(object.packed) + switch (object.jstype) { + case 'JS_NORMAL': + case 0: + message.jstype = 0 + break + case 'JS_STRING': + case 1: + message.jstype = 1 + break + case 'JS_NUMBER': + case 2: + message.jstype = 2 + break + } + if (object.lazy != null) message.lazy = Boolean(object.lazy) + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated) + if (object.weak != null) message.weak = Boolean(object.weak) + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError( + '.google.protobuf.FieldOptions.uninterpretedOption: array expected' + ) + message.uninterpretedOption = [] + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== 'object') + throw TypeError( + '.google.protobuf.FieldOptions.uninterpretedOption: object expected' + ) + message.uninterpretedOption[ + i + ] = $root.google.protobuf.UninterpretedOption.fromObject( + object.uninterpretedOption[i] + ) + } + } + if (object['.google.api.fieldBehavior']) { + if (!Array.isArray(object['.google.api.fieldBehavior'])) + throw TypeError( + '.google.protobuf.FieldOptions..google.api.fieldBehavior: array expected' + ) + message['.google.api.fieldBehavior'] = [] + for ( + var i = 0; + i < object['.google.api.fieldBehavior'].length; + ++i + ) + switch (object['.google.api.fieldBehavior'][i]) { + default: + case 'FIELD_BEHAVIOR_UNSPECIFIED': + case 0: + message['.google.api.fieldBehavior'][i] = 0 + break + case 'OPTIONAL': + case 1: + message['.google.api.fieldBehavior'][i] = 1 + break + case 'REQUIRED': + case 2: + message['.google.api.fieldBehavior'][i] = 2 + break + case 'OUTPUT_ONLY': + case 3: + message['.google.api.fieldBehavior'][i] = 3 + break + case 'INPUT_ONLY': + case 4: + message['.google.api.fieldBehavior'][i] = 4 + break + case 'IMMUTABLE': + case 5: + message['.google.api.fieldBehavior'][i] = 5 + break + } + } + if (object['.google.api.resourceReference'] != null) { + if ( + typeof object['.google.api.resourceReference'] !== 'object' + ) + throw TypeError( + '.google.protobuf.FieldOptions..google.api.resourceReference: object expected' + ) + message[ + '.google.api.resourceReference' + ] = $root.google.api.ResourceReference.fromObject( + object['.google.api.resourceReference'] + ) + } + return message + } + + /** + * Creates a plain object from a FieldOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FieldOptions + * @static + * @param {google.protobuf.FieldOptions} message FieldOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FieldOptions.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) { + object.uninterpretedOption = [] + object['.google.api.fieldBehavior'] = [] + } + if (options.defaults) { + object.ctype = options.enums === String ? 'STRING' : 0 + object.packed = false + object.deprecated = false + object.lazy = false + object.jstype = options.enums === String ? 'JS_NORMAL' : 0 + object.weak = false + object['.google.api.resourceReference'] = null + } + if (message.ctype != null && message.hasOwnProperty('ctype')) + object.ctype = + options.enums === String + ? $root.google.protobuf.FieldOptions.CType[message.ctype] + : message.ctype + if (message.packed != null && message.hasOwnProperty('packed')) + object.packed = message.packed + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + object.deprecated = message.deprecated + if (message.lazy != null && message.hasOwnProperty('lazy')) + object.lazy = message.lazy + if (message.jstype != null && message.hasOwnProperty('jstype')) + object.jstype = + options.enums === String + ? $root.google.protobuf.FieldOptions.JSType[ + message.jstype + ] + : message.jstype + if (message.weak != null && message.hasOwnProperty('weak')) + object.weak = message.weak + if ( + message.uninterpretedOption && + message.uninterpretedOption.length + ) { + object.uninterpretedOption = [] + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[ + j + ] = $root.google.protobuf.UninterpretedOption.toObject( + message.uninterpretedOption[j], + options + ) + } + if ( + message['.google.api.fieldBehavior'] && + message['.google.api.fieldBehavior'].length + ) { + object['.google.api.fieldBehavior'] = [] + for ( + var j = 0; + j < message['.google.api.fieldBehavior'].length; + ++j + ) + object['.google.api.fieldBehavior'][j] = + options.enums === String + ? $root.google.api.FieldBehavior[ + message['.google.api.fieldBehavior'][j] + ] + : message['.google.api.fieldBehavior'][j] + } + if ( + message['.google.api.resourceReference'] != null && + message.hasOwnProperty('.google.api.resourceReference') + ) + object[ + '.google.api.resourceReference' + ] = $root.google.api.ResourceReference.toObject( + message['.google.api.resourceReference'], + options + ) + return object + } + + /** + * Converts this FieldOptions to JSON. + * @function toJSON + * @memberof google.protobuf.FieldOptions + * @instance + * @returns {Object.} JSON object + */ + FieldOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + /** + * CType enum. + * @name google.protobuf.FieldOptions.CType + * @enum {string} + * @property {number} STRING=0 STRING value + * @property {number} CORD=1 CORD value + * @property {number} STRING_PIECE=2 STRING_PIECE value + */ + FieldOptions.CType = (function () { + var valuesById = {}, + values = Object.create(valuesById) + values[(valuesById[0] = 'STRING')] = 0 + values[(valuesById[1] = 'CORD')] = 1 + values[(valuesById[2] = 'STRING_PIECE')] = 2 + return values + })() + + /** + * JSType enum. + * @name google.protobuf.FieldOptions.JSType + * @enum {string} + * @property {number} JS_NORMAL=0 JS_NORMAL value + * @property {number} JS_STRING=1 JS_STRING value + * @property {number} JS_NUMBER=2 JS_NUMBER value + */ + FieldOptions.JSType = (function () { + var valuesById = {}, + values = Object.create(valuesById) + values[(valuesById[0] = 'JS_NORMAL')] = 0 + values[(valuesById[1] = 'JS_STRING')] = 1 + values[(valuesById[2] = 'JS_NUMBER')] = 2 + return values + })() + + return FieldOptions + })() + + protobuf.OneofOptions = (function () { + /** + * Properties of an OneofOptions. + * @memberof google.protobuf + * @interface IOneofOptions + * @property {Array.|null} [uninterpretedOption] OneofOptions uninterpretedOption + */ + + /** + * Constructs a new OneofOptions. + * @memberof google.protobuf + * @classdesc Represents an OneofOptions. + * @implements IOneofOptions + * @constructor + * @param {google.protobuf.IOneofOptions=} [properties] Properties to set + */ + function OneofOptions(properties) { + this.uninterpretedOption = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * OneofOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.OneofOptions + * @instance + */ + OneofOptions.prototype.uninterpretedOption = $util.emptyArray + + /** + * Creates a new OneofOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.OneofOptions + * @static + * @param {google.protobuf.IOneofOptions=} [properties] Properties to set + * @returns {google.protobuf.OneofOptions} OneofOptions instance + */ + OneofOptions.create = function create(properties) { + return new OneofOptions(properties) + } + + /** + * Encodes the specified OneofOptions message. Does not implicitly {@link google.protobuf.OneofOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.OneofOptions + * @static + * @param {google.protobuf.IOneofOptions} message OneofOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OneofOptions.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.uninterpretedOption != null && + message.uninterpretedOption.length + ) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode( + message.uninterpretedOption[i], + writer.uint32(/* id 999, wireType 2 =*/ 7994).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified OneofOptions message, length delimited. Does not implicitly {@link google.protobuf.OneofOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.OneofOptions + * @static + * @param {google.protobuf.IOneofOptions} message OneofOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OneofOptions.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an OneofOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.OneofOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.OneofOptions} OneofOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OneofOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.OneofOptions() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 999: + if ( + !( + message.uninterpretedOption && + message.uninterpretedOption.length + ) + ) + message.uninterpretedOption = [] + message.uninterpretedOption.push( + $root.google.protobuf.UninterpretedOption.decode( + reader, + reader.uint32() + ) + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an OneofOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.OneofOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.OneofOptions} OneofOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OneofOptions.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an OneofOptions message. + * @function verify + * @memberof google.protobuf.OneofOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + OneofOptions.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.uninterpretedOption != null && + message.hasOwnProperty('uninterpretedOption') + ) { + if (!Array.isArray(message.uninterpretedOption)) + return 'uninterpretedOption: array expected' + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify( + message.uninterpretedOption[i] + ) + if (error) return 'uninterpretedOption.' + error + } + } + return null + } + + /** + * Creates an OneofOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.OneofOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.OneofOptions} OneofOptions + */ + OneofOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.OneofOptions) + return object + var message = new $root.google.protobuf.OneofOptions() + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError( + '.google.protobuf.OneofOptions.uninterpretedOption: array expected' + ) + message.uninterpretedOption = [] + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== 'object') + throw TypeError( + '.google.protobuf.OneofOptions.uninterpretedOption: object expected' + ) + message.uninterpretedOption[ + i + ] = $root.google.protobuf.UninterpretedOption.fromObject( + object.uninterpretedOption[i] + ) + } + } + return message + } + + /** + * Creates a plain object from an OneofOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.OneofOptions + * @static + * @param {google.protobuf.OneofOptions} message OneofOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + OneofOptions.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) + object.uninterpretedOption = [] + if ( + message.uninterpretedOption && + message.uninterpretedOption.length + ) { + object.uninterpretedOption = [] + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[ + j + ] = $root.google.protobuf.UninterpretedOption.toObject( + message.uninterpretedOption[j], + options + ) + } + return object + } + + /** + * Converts this OneofOptions to JSON. + * @function toJSON + * @memberof google.protobuf.OneofOptions + * @instance + * @returns {Object.} JSON object + */ + OneofOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return OneofOptions + })() + + protobuf.EnumOptions = (function () { + /** + * Properties of an EnumOptions. + * @memberof google.protobuf + * @interface IEnumOptions + * @property {boolean|null} [allowAlias] EnumOptions allowAlias + * @property {boolean|null} [deprecated] EnumOptions deprecated + * @property {Array.|null} [uninterpretedOption] EnumOptions uninterpretedOption + */ + + /** + * Constructs a new EnumOptions. + * @memberof google.protobuf + * @classdesc Represents an EnumOptions. + * @implements IEnumOptions + * @constructor + * @param {google.protobuf.IEnumOptions=} [properties] Properties to set + */ + function EnumOptions(properties) { + this.uninterpretedOption = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * EnumOptions allowAlias. + * @member {boolean} allowAlias + * @memberof google.protobuf.EnumOptions + * @instance + */ + EnumOptions.prototype.allowAlias = false + + /** + * EnumOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.EnumOptions + * @instance + */ + EnumOptions.prototype.deprecated = false + + /** + * EnumOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.EnumOptions + * @instance + */ + EnumOptions.prototype.uninterpretedOption = $util.emptyArray + + /** + * Creates a new EnumOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.EnumOptions + * @static + * @param {google.protobuf.IEnumOptions=} [properties] Properties to set + * @returns {google.protobuf.EnumOptions} EnumOptions instance + */ + EnumOptions.create = function create(properties) { + return new EnumOptions(properties) + } + + /** + * Encodes the specified EnumOptions message. Does not implicitly {@link google.protobuf.EnumOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.EnumOptions + * @static + * @param {google.protobuf.IEnumOptions} message EnumOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumOptions.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.allowAlias != null && + message.hasOwnProperty('allowAlias') + ) + writer + .uint32(/* id 2, wireType 0 =*/ 16) + .bool(message.allowAlias) + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + writer + .uint32(/* id 3, wireType 0 =*/ 24) + .bool(message.deprecated) + if ( + message.uninterpretedOption != null && + message.uninterpretedOption.length + ) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode( + message.uninterpretedOption[i], + writer.uint32(/* id 999, wireType 2 =*/ 7994).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified EnumOptions message, length delimited. Does not implicitly {@link google.protobuf.EnumOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.EnumOptions + * @static + * @param {google.protobuf.IEnumOptions} message EnumOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumOptions.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an EnumOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.EnumOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.EnumOptions} EnumOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.EnumOptions() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 2: + message.allowAlias = reader.bool() + break + case 3: + message.deprecated = reader.bool() + break + case 999: + if ( + !( + message.uninterpretedOption && + message.uninterpretedOption.length + ) + ) + message.uninterpretedOption = [] + message.uninterpretedOption.push( + $root.google.protobuf.UninterpretedOption.decode( + reader, + reader.uint32() + ) + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an EnumOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.EnumOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.EnumOptions} EnumOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumOptions.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an EnumOptions message. + * @function verify + * @memberof google.protobuf.EnumOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + EnumOptions.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.allowAlias != null && + message.hasOwnProperty('allowAlias') + ) + if (typeof message.allowAlias !== 'boolean') + return 'allowAlias: boolean expected' + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + if (typeof message.deprecated !== 'boolean') + return 'deprecated: boolean expected' + if ( + message.uninterpretedOption != null && + message.hasOwnProperty('uninterpretedOption') + ) { + if (!Array.isArray(message.uninterpretedOption)) + return 'uninterpretedOption: array expected' + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify( + message.uninterpretedOption[i] + ) + if (error) return 'uninterpretedOption.' + error + } + } + return null + } + + /** + * Creates an EnumOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.EnumOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.EnumOptions} EnumOptions + */ + EnumOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.EnumOptions) + return object + var message = new $root.google.protobuf.EnumOptions() + if (object.allowAlias != null) + message.allowAlias = Boolean(object.allowAlias) + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated) + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError( + '.google.protobuf.EnumOptions.uninterpretedOption: array expected' + ) + message.uninterpretedOption = [] + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== 'object') + throw TypeError( + '.google.protobuf.EnumOptions.uninterpretedOption: object expected' + ) + message.uninterpretedOption[ + i + ] = $root.google.protobuf.UninterpretedOption.fromObject( + object.uninterpretedOption[i] + ) + } + } + return message + } + + /** + * Creates a plain object from an EnumOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.EnumOptions + * @static + * @param {google.protobuf.EnumOptions} message EnumOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EnumOptions.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) + object.uninterpretedOption = [] + if (options.defaults) { + object.allowAlias = false + object.deprecated = false + } + if ( + message.allowAlias != null && + message.hasOwnProperty('allowAlias') + ) + object.allowAlias = message.allowAlias + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + object.deprecated = message.deprecated + if ( + message.uninterpretedOption && + message.uninterpretedOption.length + ) { + object.uninterpretedOption = [] + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[ + j + ] = $root.google.protobuf.UninterpretedOption.toObject( + message.uninterpretedOption[j], + options + ) + } + return object + } + + /** + * Converts this EnumOptions to JSON. + * @function toJSON + * @memberof google.protobuf.EnumOptions + * @instance + * @returns {Object.} JSON object + */ + EnumOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return EnumOptions + })() + + protobuf.EnumValueOptions = (function () { + /** + * Properties of an EnumValueOptions. + * @memberof google.protobuf + * @interface IEnumValueOptions + * @property {boolean|null} [deprecated] EnumValueOptions deprecated + * @property {Array.|null} [uninterpretedOption] EnumValueOptions uninterpretedOption + */ + + /** + * Constructs a new EnumValueOptions. + * @memberof google.protobuf + * @classdesc Represents an EnumValueOptions. + * @implements IEnumValueOptions + * @constructor + * @param {google.protobuf.IEnumValueOptions=} [properties] Properties to set + */ + function EnumValueOptions(properties) { + this.uninterpretedOption = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * EnumValueOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.EnumValueOptions + * @instance + */ + EnumValueOptions.prototype.deprecated = false + + /** + * EnumValueOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.EnumValueOptions + * @instance + */ + EnumValueOptions.prototype.uninterpretedOption = $util.emptyArray + + /** + * Creates a new EnumValueOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {google.protobuf.IEnumValueOptions=} [properties] Properties to set + * @returns {google.protobuf.EnumValueOptions} EnumValueOptions instance + */ + EnumValueOptions.create = function create(properties) { + return new EnumValueOptions(properties) + } + + /** + * Encodes the specified EnumValueOptions message. Does not implicitly {@link google.protobuf.EnumValueOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {google.protobuf.IEnumValueOptions} message EnumValueOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumValueOptions.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + writer + .uint32(/* id 1, wireType 0 =*/ 8) + .bool(message.deprecated) + if ( + message.uninterpretedOption != null && + message.uninterpretedOption.length + ) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode( + message.uninterpretedOption[i], + writer.uint32(/* id 999, wireType 2 =*/ 7994).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified EnumValueOptions message, length delimited. Does not implicitly {@link google.protobuf.EnumValueOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {google.protobuf.IEnumValueOptions} message EnumValueOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumValueOptions.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an EnumValueOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.EnumValueOptions} EnumValueOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumValueOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.EnumValueOptions() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.deprecated = reader.bool() + break + case 999: + if ( + !( + message.uninterpretedOption && + message.uninterpretedOption.length + ) + ) + message.uninterpretedOption = [] + message.uninterpretedOption.push( + $root.google.protobuf.UninterpretedOption.decode( + reader, + reader.uint32() + ) + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an EnumValueOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.EnumValueOptions} EnumValueOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumValueOptions.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an EnumValueOptions message. + * @function verify + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + EnumValueOptions.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + if (typeof message.deprecated !== 'boolean') + return 'deprecated: boolean expected' + if ( + message.uninterpretedOption != null && + message.hasOwnProperty('uninterpretedOption') + ) { + if (!Array.isArray(message.uninterpretedOption)) + return 'uninterpretedOption: array expected' + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify( + message.uninterpretedOption[i] + ) + if (error) return 'uninterpretedOption.' + error + } + } + return null + } + + /** + * Creates an EnumValueOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.EnumValueOptions} EnumValueOptions + */ + EnumValueOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.EnumValueOptions) + return object + var message = new $root.google.protobuf.EnumValueOptions() + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated) + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError( + '.google.protobuf.EnumValueOptions.uninterpretedOption: array expected' + ) + message.uninterpretedOption = [] + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== 'object') + throw TypeError( + '.google.protobuf.EnumValueOptions.uninterpretedOption: object expected' + ) + message.uninterpretedOption[ + i + ] = $root.google.protobuf.UninterpretedOption.fromObject( + object.uninterpretedOption[i] + ) + } + } + return message + } + + /** + * Creates a plain object from an EnumValueOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {google.protobuf.EnumValueOptions} message EnumValueOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EnumValueOptions.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) + object.uninterpretedOption = [] + if (options.defaults) object.deprecated = false + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + object.deprecated = message.deprecated + if ( + message.uninterpretedOption && + message.uninterpretedOption.length + ) { + object.uninterpretedOption = [] + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[ + j + ] = $root.google.protobuf.UninterpretedOption.toObject( + message.uninterpretedOption[j], + options + ) + } + return object + } + + /** + * Converts this EnumValueOptions to JSON. + * @function toJSON + * @memberof google.protobuf.EnumValueOptions + * @instance + * @returns {Object.} JSON object + */ + EnumValueOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return EnumValueOptions + })() + + protobuf.ServiceOptions = (function () { + /** + * Properties of a ServiceOptions. + * @memberof google.protobuf + * @interface IServiceOptions + * @property {boolean|null} [deprecated] ServiceOptions deprecated + * @property {Array.|null} [uninterpretedOption] ServiceOptions uninterpretedOption + * @property {string|null} [".google.api.defaultHost"] ServiceOptions .google.api.defaultHost + * @property {string|null} [".google.api.oauthScopes"] ServiceOptions .google.api.oauthScopes + */ + + /** + * Constructs a new ServiceOptions. + * @memberof google.protobuf + * @classdesc Represents a ServiceOptions. + * @implements IServiceOptions + * @constructor + * @param {google.protobuf.IServiceOptions=} [properties] Properties to set + */ + function ServiceOptions(properties) { + this.uninterpretedOption = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * ServiceOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.ServiceOptions + * @instance + */ + ServiceOptions.prototype.deprecated = false + + /** + * ServiceOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.ServiceOptions + * @instance + */ + ServiceOptions.prototype.uninterpretedOption = $util.emptyArray + + /** + * ServiceOptions .google.api.defaultHost. + * @member {string} .google.api.defaultHost + * @memberof google.protobuf.ServiceOptions + * @instance + */ + ServiceOptions.prototype['.google.api.defaultHost'] = '' + + /** + * ServiceOptions .google.api.oauthScopes. + * @member {string} .google.api.oauthScopes + * @memberof google.protobuf.ServiceOptions + * @instance + */ + ServiceOptions.prototype['.google.api.oauthScopes'] = '' + + /** + * Creates a new ServiceOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.ServiceOptions + * @static + * @param {google.protobuf.IServiceOptions=} [properties] Properties to set + * @returns {google.protobuf.ServiceOptions} ServiceOptions instance + */ + ServiceOptions.create = function create(properties) { + return new ServiceOptions(properties) + } + + /** + * Encodes the specified ServiceOptions message. Does not implicitly {@link google.protobuf.ServiceOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.ServiceOptions + * @static + * @param {google.protobuf.IServiceOptions} message ServiceOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ServiceOptions.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + writer + .uint32(/* id 33, wireType 0 =*/ 264) + .bool(message.deprecated) + if ( + message.uninterpretedOption != null && + message.uninterpretedOption.length + ) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode( + message.uninterpretedOption[i], + writer.uint32(/* id 999, wireType 2 =*/ 7994).fork() + ).ldelim() + if ( + message['.google.api.defaultHost'] != null && + message.hasOwnProperty('.google.api.defaultHost') + ) + writer + .uint32(/* id 1049, wireType 2 =*/ 8394) + .string(message['.google.api.defaultHost']) + if ( + message['.google.api.oauthScopes'] != null && + message.hasOwnProperty('.google.api.oauthScopes') + ) + writer + .uint32(/* id 1050, wireType 2 =*/ 8402) + .string(message['.google.api.oauthScopes']) + return writer + } + + /** + * Encodes the specified ServiceOptions message, length delimited. Does not implicitly {@link google.protobuf.ServiceOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.ServiceOptions + * @static + * @param {google.protobuf.IServiceOptions} message ServiceOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ServiceOptions.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a ServiceOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.ServiceOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.ServiceOptions} ServiceOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ServiceOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.ServiceOptions() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool() + break + case 999: + if ( + !( + message.uninterpretedOption && + message.uninterpretedOption.length + ) + ) + message.uninterpretedOption = [] + message.uninterpretedOption.push( + $root.google.protobuf.UninterpretedOption.decode( + reader, + reader.uint32() + ) + ) + break + case 1049: + message['.google.api.defaultHost'] = reader.string() + break + case 1050: + message['.google.api.oauthScopes'] = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a ServiceOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.ServiceOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.ServiceOptions} ServiceOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ServiceOptions.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a ServiceOptions message. + * @function verify + * @memberof google.protobuf.ServiceOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ServiceOptions.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + if (typeof message.deprecated !== 'boolean') + return 'deprecated: boolean expected' + if ( + message.uninterpretedOption != null && + message.hasOwnProperty('uninterpretedOption') + ) { + if (!Array.isArray(message.uninterpretedOption)) + return 'uninterpretedOption: array expected' + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify( + message.uninterpretedOption[i] + ) + if (error) return 'uninterpretedOption.' + error + } + } + if ( + message['.google.api.defaultHost'] != null && + message.hasOwnProperty('.google.api.defaultHost') + ) + if (!$util.isString(message['.google.api.defaultHost'])) + return '.google.api.defaultHost: string expected' + if ( + message['.google.api.oauthScopes'] != null && + message.hasOwnProperty('.google.api.oauthScopes') + ) + if (!$util.isString(message['.google.api.oauthScopes'])) + return '.google.api.oauthScopes: string expected' + return null + } + + /** + * Creates a ServiceOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.ServiceOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.ServiceOptions} ServiceOptions + */ + ServiceOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.ServiceOptions) + return object + var message = new $root.google.protobuf.ServiceOptions() + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated) + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError( + '.google.protobuf.ServiceOptions.uninterpretedOption: array expected' + ) + message.uninterpretedOption = [] + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== 'object') + throw TypeError( + '.google.protobuf.ServiceOptions.uninterpretedOption: object expected' + ) + message.uninterpretedOption[ + i + ] = $root.google.protobuf.UninterpretedOption.fromObject( + object.uninterpretedOption[i] + ) + } + } + if (object['.google.api.defaultHost'] != null) + message['.google.api.defaultHost'] = String( + object['.google.api.defaultHost'] + ) + if (object['.google.api.oauthScopes'] != null) + message['.google.api.oauthScopes'] = String( + object['.google.api.oauthScopes'] + ) + return message + } + + /** + * Creates a plain object from a ServiceOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.ServiceOptions + * @static + * @param {google.protobuf.ServiceOptions} message ServiceOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ServiceOptions.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) + object.uninterpretedOption = [] + if (options.defaults) { + object.deprecated = false + object['.google.api.defaultHost'] = '' + object['.google.api.oauthScopes'] = '' + } + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + object.deprecated = message.deprecated + if ( + message.uninterpretedOption && + message.uninterpretedOption.length + ) { + object.uninterpretedOption = [] + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[ + j + ] = $root.google.protobuf.UninterpretedOption.toObject( + message.uninterpretedOption[j], + options + ) + } + if ( + message['.google.api.defaultHost'] != null && + message.hasOwnProperty('.google.api.defaultHost') + ) + object['.google.api.defaultHost'] = + message['.google.api.defaultHost'] + if ( + message['.google.api.oauthScopes'] != null && + message.hasOwnProperty('.google.api.oauthScopes') + ) + object['.google.api.oauthScopes'] = + message['.google.api.oauthScopes'] + return object + } + + /** + * Converts this ServiceOptions to JSON. + * @function toJSON + * @memberof google.protobuf.ServiceOptions + * @instance + * @returns {Object.} JSON object + */ + ServiceOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return ServiceOptions + })() + + protobuf.MethodOptions = (function () { + /** + * Properties of a MethodOptions. + * @memberof google.protobuf + * @interface IMethodOptions + * @property {boolean|null} [deprecated] MethodOptions deprecated + * @property {google.protobuf.MethodOptions.IdempotencyLevel|null} [idempotencyLevel] MethodOptions idempotencyLevel + * @property {Array.|null} [uninterpretedOption] MethodOptions uninterpretedOption + * @property {google.api.IHttpRule|null} [".google.api.http"] MethodOptions .google.api.http + * @property {Array.|null} [".google.api.methodSignature"] MethodOptions .google.api.methodSignature + */ + + /** + * Constructs a new MethodOptions. + * @memberof google.protobuf + * @classdesc Represents a MethodOptions. + * @implements IMethodOptions + * @constructor + * @param {google.protobuf.IMethodOptions=} [properties] Properties to set + */ + function MethodOptions(properties) { + this.uninterpretedOption = [] + this['.google.api.methodSignature'] = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * MethodOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype.deprecated = false + + /** + * MethodOptions idempotencyLevel. + * @member {google.protobuf.MethodOptions.IdempotencyLevel} idempotencyLevel + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype.idempotencyLevel = 0 + + /** + * MethodOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype.uninterpretedOption = $util.emptyArray + + /** + * MethodOptions .google.api.http. + * @member {google.api.IHttpRule|null|undefined} .google.api.http + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype['.google.api.http'] = null + + /** + * MethodOptions .google.api.methodSignature. + * @member {Array.} .google.api.methodSignature + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype['.google.api.methodSignature'] = + $util.emptyArray + + /** + * Creates a new MethodOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.MethodOptions + * @static + * @param {google.protobuf.IMethodOptions=} [properties] Properties to set + * @returns {google.protobuf.MethodOptions} MethodOptions instance + */ + MethodOptions.create = function create(properties) { + return new MethodOptions(properties) + } + + /** + * Encodes the specified MethodOptions message. Does not implicitly {@link google.protobuf.MethodOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.MethodOptions + * @static + * @param {google.protobuf.IMethodOptions} message MethodOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MethodOptions.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + writer + .uint32(/* id 33, wireType 0 =*/ 264) + .bool(message.deprecated) + if ( + message.idempotencyLevel != null && + message.hasOwnProperty('idempotencyLevel') + ) + writer + .uint32(/* id 34, wireType 0 =*/ 272) + .int32(message.idempotencyLevel) + if ( + message.uninterpretedOption != null && + message.uninterpretedOption.length + ) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode( + message.uninterpretedOption[i], + writer.uint32(/* id 999, wireType 2 =*/ 7994).fork() + ).ldelim() + if ( + message['.google.api.methodSignature'] != null && + message['.google.api.methodSignature'].length + ) + for ( + var i = 0; + i < message['.google.api.methodSignature'].length; + ++i + ) + writer + .uint32(/* id 1051, wireType 2 =*/ 8410) + .string(message['.google.api.methodSignature'][i]) + if ( + message['.google.api.http'] != null && + message.hasOwnProperty('.google.api.http') + ) + $root.google.api.HttpRule.encode( + message['.google.api.http'], + writer + .uint32(/* id 72295728, wireType 2 =*/ 578365826) + .fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified MethodOptions message, length delimited. Does not implicitly {@link google.protobuf.MethodOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.MethodOptions + * @static + * @param {google.protobuf.IMethodOptions} message MethodOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MethodOptions.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a MethodOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.MethodOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.MethodOptions} MethodOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MethodOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.MethodOptions() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool() + break + case 34: + message.idempotencyLevel = reader.int32() + break + case 999: + if ( + !( + message.uninterpretedOption && + message.uninterpretedOption.length + ) + ) + message.uninterpretedOption = [] + message.uninterpretedOption.push( + $root.google.protobuf.UninterpretedOption.decode( + reader, + reader.uint32() + ) + ) + break + case 72295728: + message[ + '.google.api.http' + ] = $root.google.api.HttpRule.decode( + reader, + reader.uint32() + ) + break + case 1051: + if ( + !( + message['.google.api.methodSignature'] && + message['.google.api.methodSignature'].length + ) + ) + message['.google.api.methodSignature'] = [] + message['.google.api.methodSignature'].push( + reader.string() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a MethodOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.MethodOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.MethodOptions} MethodOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MethodOptions.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a MethodOptions message. + * @function verify + * @memberof google.protobuf.MethodOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + MethodOptions.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + if (typeof message.deprecated !== 'boolean') + return 'deprecated: boolean expected' + if ( + message.idempotencyLevel != null && + message.hasOwnProperty('idempotencyLevel') + ) + switch (message.idempotencyLevel) { + default: + return 'idempotencyLevel: enum value expected' + case 0: + case 1: + case 2: + break + } + if ( + message.uninterpretedOption != null && + message.hasOwnProperty('uninterpretedOption') + ) { + if (!Array.isArray(message.uninterpretedOption)) + return 'uninterpretedOption: array expected' + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify( + message.uninterpretedOption[i] + ) + if (error) return 'uninterpretedOption.' + error + } + } + if ( + message['.google.api.http'] != null && + message.hasOwnProperty('.google.api.http') + ) { + var error = $root.google.api.HttpRule.verify( + message['.google.api.http'] + ) + if (error) return '.google.api.http.' + error + } + if ( + message['.google.api.methodSignature'] != null && + message.hasOwnProperty('.google.api.methodSignature') + ) { + if (!Array.isArray(message['.google.api.methodSignature'])) + return '.google.api.methodSignature: array expected' + for ( + var i = 0; + i < message['.google.api.methodSignature'].length; + ++i + ) + if ( + !$util.isString(message['.google.api.methodSignature'][i]) + ) + return '.google.api.methodSignature: string[] expected' + } + return null + } + + /** + * Creates a MethodOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.MethodOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.MethodOptions} MethodOptions + */ + MethodOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.MethodOptions) + return object + var message = new $root.google.protobuf.MethodOptions() + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated) + switch (object.idempotencyLevel) { + case 'IDEMPOTENCY_UNKNOWN': + case 0: + message.idempotencyLevel = 0 + break + case 'NO_SIDE_EFFECTS': + case 1: + message.idempotencyLevel = 1 + break + case 'IDEMPOTENT': + case 2: + message.idempotencyLevel = 2 + break + } + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError( + '.google.protobuf.MethodOptions.uninterpretedOption: array expected' + ) + message.uninterpretedOption = [] + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== 'object') + throw TypeError( + '.google.protobuf.MethodOptions.uninterpretedOption: object expected' + ) + message.uninterpretedOption[ + i + ] = $root.google.protobuf.UninterpretedOption.fromObject( + object.uninterpretedOption[i] + ) + } + } + if (object['.google.api.http'] != null) { + if (typeof object['.google.api.http'] !== 'object') + throw TypeError( + '.google.protobuf.MethodOptions..google.api.http: object expected' + ) + message[ + '.google.api.http' + ] = $root.google.api.HttpRule.fromObject( + object['.google.api.http'] + ) + } + if (object['.google.api.methodSignature']) { + if (!Array.isArray(object['.google.api.methodSignature'])) + throw TypeError( + '.google.protobuf.MethodOptions..google.api.methodSignature: array expected' + ) + message['.google.api.methodSignature'] = [] + for ( + var i = 0; + i < object['.google.api.methodSignature'].length; + ++i + ) + message['.google.api.methodSignature'][i] = String( + object['.google.api.methodSignature'][i] + ) + } + return message + } + + /** + * Creates a plain object from a MethodOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.MethodOptions + * @static + * @param {google.protobuf.MethodOptions} message MethodOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MethodOptions.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) { + object.uninterpretedOption = [] + object['.google.api.methodSignature'] = [] + } + if (options.defaults) { + object.deprecated = false + object.idempotencyLevel = + options.enums === String ? 'IDEMPOTENCY_UNKNOWN' : 0 + object['.google.api.http'] = null + } + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + object.deprecated = message.deprecated + if ( + message.idempotencyLevel != null && + message.hasOwnProperty('idempotencyLevel') + ) + object.idempotencyLevel = + options.enums === String + ? $root.google.protobuf.MethodOptions.IdempotencyLevel[ + message.idempotencyLevel + ] + : message.idempotencyLevel + if ( + message.uninterpretedOption && + message.uninterpretedOption.length + ) { + object.uninterpretedOption = [] + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[ + j + ] = $root.google.protobuf.UninterpretedOption.toObject( + message.uninterpretedOption[j], + options + ) + } + if ( + message['.google.api.methodSignature'] && + message['.google.api.methodSignature'].length + ) { + object['.google.api.methodSignature'] = [] + for ( + var j = 0; + j < message['.google.api.methodSignature'].length; + ++j + ) + object['.google.api.methodSignature'][j] = + message['.google.api.methodSignature'][j] + } + if ( + message['.google.api.http'] != null && + message.hasOwnProperty('.google.api.http') + ) + object[ + '.google.api.http' + ] = $root.google.api.HttpRule.toObject( + message['.google.api.http'], + options + ) + return object + } + + /** + * Converts this MethodOptions to JSON. + * @function toJSON + * @memberof google.protobuf.MethodOptions + * @instance + * @returns {Object.} JSON object + */ + MethodOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + /** + * IdempotencyLevel enum. + * @name google.protobuf.MethodOptions.IdempotencyLevel + * @enum {string} + * @property {number} IDEMPOTENCY_UNKNOWN=0 IDEMPOTENCY_UNKNOWN value + * @property {number} NO_SIDE_EFFECTS=1 NO_SIDE_EFFECTS value + * @property {number} IDEMPOTENT=2 IDEMPOTENT value + */ + MethodOptions.IdempotencyLevel = (function () { + var valuesById = {}, + values = Object.create(valuesById) + values[(valuesById[0] = 'IDEMPOTENCY_UNKNOWN')] = 0 + values[(valuesById[1] = 'NO_SIDE_EFFECTS')] = 1 + values[(valuesById[2] = 'IDEMPOTENT')] = 2 + return values + })() + + return MethodOptions + })() + + protobuf.UninterpretedOption = (function () { + /** + * Properties of an UninterpretedOption. + * @memberof google.protobuf + * @interface IUninterpretedOption + * @property {Array.|null} [name] UninterpretedOption name + * @property {string|null} [identifierValue] UninterpretedOption identifierValue + * @property {number|Long|null} [positiveIntValue] UninterpretedOption positiveIntValue + * @property {number|Long|null} [negativeIntValue] UninterpretedOption negativeIntValue + * @property {number|null} [doubleValue] UninterpretedOption doubleValue + * @property {Uint8Array|null} [stringValue] UninterpretedOption stringValue + * @property {string|null} [aggregateValue] UninterpretedOption aggregateValue + */ + + /** + * Constructs a new UninterpretedOption. + * @memberof google.protobuf + * @classdesc Represents an UninterpretedOption. + * @implements IUninterpretedOption + * @constructor + * @param {google.protobuf.IUninterpretedOption=} [properties] Properties to set + */ + function UninterpretedOption(properties) { + this.name = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * UninterpretedOption name. + * @member {Array.} name + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.name = $util.emptyArray + + /** + * UninterpretedOption identifierValue. + * @member {string} identifierValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.identifierValue = '' + + /** + * UninterpretedOption positiveIntValue. + * @member {number|Long} positiveIntValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.positiveIntValue = $util.Long + ? $util.Long.fromBits(0, 0, true) + : 0 + + /** + * UninterpretedOption negativeIntValue. + * @member {number|Long} negativeIntValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.negativeIntValue = $util.Long + ? $util.Long.fromBits(0, 0, false) + : 0 + + /** + * UninterpretedOption doubleValue. + * @member {number} doubleValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.doubleValue = 0 + + /** + * UninterpretedOption stringValue. + * @member {Uint8Array} stringValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.stringValue = $util.newBuffer([]) + + /** + * UninterpretedOption aggregateValue. + * @member {string} aggregateValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.aggregateValue = '' + + /** + * Creates a new UninterpretedOption instance using the specified properties. + * @function create + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {google.protobuf.IUninterpretedOption=} [properties] Properties to set + * @returns {google.protobuf.UninterpretedOption} UninterpretedOption instance + */ + UninterpretedOption.create = function create(properties) { + return new UninterpretedOption(properties) + } + + /** + * Encodes the specified UninterpretedOption message. Does not implicitly {@link google.protobuf.UninterpretedOption.verify|verify} messages. + * @function encode + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {google.protobuf.IUninterpretedOption} message UninterpretedOption message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UninterpretedOption.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.name != null && message.name.length) + for (var i = 0; i < message.name.length; ++i) + $root.google.protobuf.UninterpretedOption.NamePart.encode( + message.name[i], + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + ).ldelim() + if ( + message.identifierValue != null && + message.hasOwnProperty('identifierValue') + ) + writer + .uint32(/* id 3, wireType 2 =*/ 26) + .string(message.identifierValue) + if ( + message.positiveIntValue != null && + message.hasOwnProperty('positiveIntValue') + ) + writer + .uint32(/* id 4, wireType 0 =*/ 32) + .uint64(message.positiveIntValue) + if ( + message.negativeIntValue != null && + message.hasOwnProperty('negativeIntValue') + ) + writer + .uint32(/* id 5, wireType 0 =*/ 40) + .int64(message.negativeIntValue) + if ( + message.doubleValue != null && + message.hasOwnProperty('doubleValue') + ) + writer + .uint32(/* id 6, wireType 1 =*/ 49) + .double(message.doubleValue) + if ( + message.stringValue != null && + message.hasOwnProperty('stringValue') + ) + writer + .uint32(/* id 7, wireType 2 =*/ 58) + .bytes(message.stringValue) + if ( + message.aggregateValue != null && + message.hasOwnProperty('aggregateValue') + ) + writer + .uint32(/* id 8, wireType 2 =*/ 66) + .string(message.aggregateValue) + return writer + } + + /** + * Encodes the specified UninterpretedOption message, length delimited. Does not implicitly {@link google.protobuf.UninterpretedOption.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {google.protobuf.IUninterpretedOption} message UninterpretedOption message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UninterpretedOption.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an UninterpretedOption message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.UninterpretedOption} UninterpretedOption + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UninterpretedOption.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.UninterpretedOption() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 2: + if (!(message.name && message.name.length)) + message.name = [] + message.name.push( + $root.google.protobuf.UninterpretedOption.NamePart.decode( + reader, + reader.uint32() + ) + ) + break + case 3: + message.identifierValue = reader.string() + break + case 4: + message.positiveIntValue = reader.uint64() + break + case 5: + message.negativeIntValue = reader.int64() + break + case 6: + message.doubleValue = reader.double() + break + case 7: + message.stringValue = reader.bytes() + break + case 8: + message.aggregateValue = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an UninterpretedOption message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.UninterpretedOption} UninterpretedOption + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UninterpretedOption.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an UninterpretedOption message. + * @function verify + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UninterpretedOption.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) { + if (!Array.isArray(message.name)) + return 'name: array expected' + for (var i = 0; i < message.name.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.NamePart.verify( + message.name[i] + ) + if (error) return 'name.' + error + } + } + if ( + message.identifierValue != null && + message.hasOwnProperty('identifierValue') + ) + if (!$util.isString(message.identifierValue)) + return 'identifierValue: string expected' + if ( + message.positiveIntValue != null && + message.hasOwnProperty('positiveIntValue') + ) + if ( + !$util.isInteger(message.positiveIntValue) && + !( + message.positiveIntValue && + $util.isInteger(message.positiveIntValue.low) && + $util.isInteger(message.positiveIntValue.high) + ) + ) + return 'positiveIntValue: integer|Long expected' + if ( + message.negativeIntValue != null && + message.hasOwnProperty('negativeIntValue') + ) + if ( + !$util.isInteger(message.negativeIntValue) && + !( + message.negativeIntValue && + $util.isInteger(message.negativeIntValue.low) && + $util.isInteger(message.negativeIntValue.high) + ) + ) + return 'negativeIntValue: integer|Long expected' + if ( + message.doubleValue != null && + message.hasOwnProperty('doubleValue') + ) + if (typeof message.doubleValue !== 'number') + return 'doubleValue: number expected' + if ( + message.stringValue != null && + message.hasOwnProperty('stringValue') + ) + if ( + !( + (message.stringValue && + typeof message.stringValue.length === 'number') || + $util.isString(message.stringValue) + ) + ) + return 'stringValue: buffer expected' + if ( + message.aggregateValue != null && + message.hasOwnProperty('aggregateValue') + ) + if (!$util.isString(message.aggregateValue)) + return 'aggregateValue: string expected' + return null + } + + /** + * Creates an UninterpretedOption message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.UninterpretedOption} UninterpretedOption + */ + UninterpretedOption.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.UninterpretedOption) + return object + var message = new $root.google.protobuf.UninterpretedOption() + if (object.name) { + if (!Array.isArray(object.name)) + throw TypeError( + '.google.protobuf.UninterpretedOption.name: array expected' + ) + message.name = [] + for (var i = 0; i < object.name.length; ++i) { + if (typeof object.name[i] !== 'object') + throw TypeError( + '.google.protobuf.UninterpretedOption.name: object expected' + ) + message.name[ + i + ] = $root.google.protobuf.UninterpretedOption.NamePart.fromObject( + object.name[i] + ) + } + } + if (object.identifierValue != null) + message.identifierValue = String(object.identifierValue) + if (object.positiveIntValue != null) + if ($util.Long) + (message.positiveIntValue = $util.Long.fromValue( + object.positiveIntValue + )).unsigned = true + else if (typeof object.positiveIntValue === 'string') + message.positiveIntValue = parseInt( + object.positiveIntValue, + 10 + ) + else if (typeof object.positiveIntValue === 'number') + message.positiveIntValue = object.positiveIntValue + else if (typeof object.positiveIntValue === 'object') + message.positiveIntValue = new $util.LongBits( + object.positiveIntValue.low >>> 0, + object.positiveIntValue.high >>> 0 + ).toNumber(true) + if (object.negativeIntValue != null) + if ($util.Long) + (message.negativeIntValue = $util.Long.fromValue( + object.negativeIntValue + )).unsigned = false + else if (typeof object.negativeIntValue === 'string') + message.negativeIntValue = parseInt( + object.negativeIntValue, + 10 + ) + else if (typeof object.negativeIntValue === 'number') + message.negativeIntValue = object.negativeIntValue + else if (typeof object.negativeIntValue === 'object') + message.negativeIntValue = new $util.LongBits( + object.negativeIntValue.low >>> 0, + object.negativeIntValue.high >>> 0 + ).toNumber() + if (object.doubleValue != null) + message.doubleValue = Number(object.doubleValue) + if (object.stringValue != null) + if (typeof object.stringValue === 'string') + $util.base64.decode( + object.stringValue, + (message.stringValue = $util.newBuffer( + $util.base64.length(object.stringValue) + )), + 0 + ) + else if (object.stringValue.length) + message.stringValue = object.stringValue + if (object.aggregateValue != null) + message.aggregateValue = String(object.aggregateValue) + return message + } + + /** + * Creates a plain object from an UninterpretedOption message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {google.protobuf.UninterpretedOption} message UninterpretedOption + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UninterpretedOption.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) object.name = [] + if (options.defaults) { + object.identifierValue = '' + if ($util.Long) { + var long = new $util.Long(0, 0, true) + object.positiveIntValue = + options.longs === String + ? long.toString() + : options.longs === Number + ? long.toNumber() + : long + } else + object.positiveIntValue = options.longs === String ? '0' : 0 + if ($util.Long) { + var long = new $util.Long(0, 0, false) + object.negativeIntValue = + options.longs === String + ? long.toString() + : options.longs === Number + ? long.toNumber() + : long + } else + object.negativeIntValue = options.longs === String ? '0' : 0 + object.doubleValue = 0 + if (options.bytes === String) object.stringValue = '' + else { + object.stringValue = [] + if (options.bytes !== Array) + object.stringValue = $util.newBuffer(object.stringValue) + } + object.aggregateValue = '' + } + if (message.name && message.name.length) { + object.name = [] + for (var j = 0; j < message.name.length; ++j) + object.name[ + j + ] = $root.google.protobuf.UninterpretedOption.NamePart.toObject( + message.name[j], + options + ) + } + if ( + message.identifierValue != null && + message.hasOwnProperty('identifierValue') + ) + object.identifierValue = message.identifierValue + if ( + message.positiveIntValue != null && + message.hasOwnProperty('positiveIntValue') + ) + if (typeof message.positiveIntValue === 'number') + object.positiveIntValue = + options.longs === String + ? String(message.positiveIntValue) + : message.positiveIntValue + else + object.positiveIntValue = + options.longs === String + ? $util.Long.prototype.toString.call( + message.positiveIntValue + ) + : options.longs === Number + ? new $util.LongBits( + message.positiveIntValue.low >>> 0, + message.positiveIntValue.high >>> 0 + ).toNumber(true) + : message.positiveIntValue + if ( + message.negativeIntValue != null && + message.hasOwnProperty('negativeIntValue') + ) + if (typeof message.negativeIntValue === 'number') + object.negativeIntValue = + options.longs === String + ? String(message.negativeIntValue) + : message.negativeIntValue + else + object.negativeIntValue = + options.longs === String + ? $util.Long.prototype.toString.call( + message.negativeIntValue + ) + : options.longs === Number + ? new $util.LongBits( + message.negativeIntValue.low >>> 0, + message.negativeIntValue.high >>> 0 + ).toNumber() + : message.negativeIntValue + if ( + message.doubleValue != null && + message.hasOwnProperty('doubleValue') + ) + object.doubleValue = + options.json && !isFinite(message.doubleValue) + ? String(message.doubleValue) + : message.doubleValue + if ( + message.stringValue != null && + message.hasOwnProperty('stringValue') + ) + object.stringValue = + options.bytes === String + ? $util.base64.encode( + message.stringValue, + 0, + message.stringValue.length + ) + : options.bytes === Array + ? Array.prototype.slice.call(message.stringValue) + : message.stringValue + if ( + message.aggregateValue != null && + message.hasOwnProperty('aggregateValue') + ) + object.aggregateValue = message.aggregateValue + return object + } + + /** + * Converts this UninterpretedOption to JSON. + * @function toJSON + * @memberof google.protobuf.UninterpretedOption + * @instance + * @returns {Object.} JSON object + */ + UninterpretedOption.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + UninterpretedOption.NamePart = (function () { + /** + * Properties of a NamePart. + * @memberof google.protobuf.UninterpretedOption + * @interface INamePart + * @property {string} namePart NamePart namePart + * @property {boolean} isExtension NamePart isExtension + */ + + /** + * Constructs a new NamePart. + * @memberof google.protobuf.UninterpretedOption + * @classdesc Represents a NamePart. + * @implements INamePart + * @constructor + * @param {google.protobuf.UninterpretedOption.INamePart=} [properties] Properties to set + */ + function NamePart(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * NamePart namePart. + * @member {string} namePart + * @memberof google.protobuf.UninterpretedOption.NamePart + * @instance + */ + NamePart.prototype.namePart = '' + + /** + * NamePart isExtension. + * @member {boolean} isExtension + * @memberof google.protobuf.UninterpretedOption.NamePart + * @instance + */ + NamePart.prototype.isExtension = false + + /** + * Creates a new NamePart instance using the specified properties. + * @function create + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {google.protobuf.UninterpretedOption.INamePart=} [properties] Properties to set + * @returns {google.protobuf.UninterpretedOption.NamePart} NamePart instance + */ + NamePart.create = function create(properties) { + return new NamePart(properties) + } + + /** + * Encodes the specified NamePart message. Does not implicitly {@link google.protobuf.UninterpretedOption.NamePart.verify|verify} messages. + * @function encode + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {google.protobuf.UninterpretedOption.INamePart} message NamePart message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + NamePart.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.namePart) + writer + .uint32(/* id 2, wireType 0 =*/ 16) + .bool(message.isExtension) + return writer + } + + /** + * Encodes the specified NamePart message, length delimited. Does not implicitly {@link google.protobuf.UninterpretedOption.NamePart.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {google.protobuf.UninterpretedOption.INamePart} message NamePart message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + NamePart.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a NamePart message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.UninterpretedOption.NamePart} NamePart + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + NamePart.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.UninterpretedOption.NamePart() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.namePart = reader.string() + break + case 2: + message.isExtension = reader.bool() + break + default: + reader.skipType(tag & 7) + break + } + } + if (!message.hasOwnProperty('namePart')) + throw $util.ProtocolError("missing required 'namePart'", { + instance: message + }) + if (!message.hasOwnProperty('isExtension')) + throw $util.ProtocolError( + "missing required 'isExtension'", + { instance: message } + ) + return message + } + + /** + * Decodes a NamePart message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.UninterpretedOption.NamePart} NamePart + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + NamePart.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a NamePart message. + * @function verify + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + NamePart.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (!$util.isString(message.namePart)) + return 'namePart: string expected' + if (typeof message.isExtension !== 'boolean') + return 'isExtension: boolean expected' + return null + } + + /** + * Creates a NamePart message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.UninterpretedOption.NamePart} NamePart + */ + NamePart.fromObject = function fromObject(object) { + if ( + object instanceof + $root.google.protobuf.UninterpretedOption.NamePart + ) + return object + var message = new $root.google.protobuf.UninterpretedOption.NamePart() + if (object.namePart != null) + message.namePart = String(object.namePart) + if (object.isExtension != null) + message.isExtension = Boolean(object.isExtension) + return message + } + + /** + * Creates a plain object from a NamePart message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {google.protobuf.UninterpretedOption.NamePart} message NamePart + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + NamePart.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.namePart = '' + object.isExtension = false + } + if ( + message.namePart != null && + message.hasOwnProperty('namePart') + ) + object.namePart = message.namePart + if ( + message.isExtension != null && + message.hasOwnProperty('isExtension') + ) + object.isExtension = message.isExtension + return object + } + + /** + * Converts this NamePart to JSON. + * @function toJSON + * @memberof google.protobuf.UninterpretedOption.NamePart + * @instance + * @returns {Object.} JSON object + */ + NamePart.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return NamePart + })() + + return UninterpretedOption + })() + + protobuf.SourceCodeInfo = (function () { + /** + * Properties of a SourceCodeInfo. + * @memberof google.protobuf + * @interface ISourceCodeInfo + * @property {Array.|null} [location] SourceCodeInfo location + */ + + /** + * Constructs a new SourceCodeInfo. + * @memberof google.protobuf + * @classdesc Represents a SourceCodeInfo. + * @implements ISourceCodeInfo + * @constructor + * @param {google.protobuf.ISourceCodeInfo=} [properties] Properties to set + */ + function SourceCodeInfo(properties) { + this.location = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * SourceCodeInfo location. + * @member {Array.} location + * @memberof google.protobuf.SourceCodeInfo + * @instance + */ + SourceCodeInfo.prototype.location = $util.emptyArray + + /** + * Creates a new SourceCodeInfo instance using the specified properties. + * @function create + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {google.protobuf.ISourceCodeInfo=} [properties] Properties to set + * @returns {google.protobuf.SourceCodeInfo} SourceCodeInfo instance + */ + SourceCodeInfo.create = function create(properties) { + return new SourceCodeInfo(properties) + } + + /** + * Encodes the specified SourceCodeInfo message. Does not implicitly {@link google.protobuf.SourceCodeInfo.verify|verify} messages. + * @function encode + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {google.protobuf.ISourceCodeInfo} message SourceCodeInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SourceCodeInfo.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.location != null && message.location.length) + for (var i = 0; i < message.location.length; ++i) + $root.google.protobuf.SourceCodeInfo.Location.encode( + message.location[i], + writer.uint32(/* id 1, wireType 2 =*/ 10).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified SourceCodeInfo message, length delimited. Does not implicitly {@link google.protobuf.SourceCodeInfo.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {google.protobuf.ISourceCodeInfo} message SourceCodeInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SourceCodeInfo.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a SourceCodeInfo message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.SourceCodeInfo} SourceCodeInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SourceCodeInfo.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.SourceCodeInfo() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + if (!(message.location && message.location.length)) + message.location = [] + message.location.push( + $root.google.protobuf.SourceCodeInfo.Location.decode( + reader, + reader.uint32() + ) + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a SourceCodeInfo message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.SourceCodeInfo} SourceCodeInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SourceCodeInfo.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a SourceCodeInfo message. + * @function verify + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SourceCodeInfo.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.location != null && + message.hasOwnProperty('location') + ) { + if (!Array.isArray(message.location)) + return 'location: array expected' + for (var i = 0; i < message.location.length; ++i) { + var error = $root.google.protobuf.SourceCodeInfo.Location.verify( + message.location[i] + ) + if (error) return 'location.' + error + } + } + return null + } + + /** + * Creates a SourceCodeInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.SourceCodeInfo} SourceCodeInfo + */ + SourceCodeInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.SourceCodeInfo) + return object + var message = new $root.google.protobuf.SourceCodeInfo() + if (object.location) { + if (!Array.isArray(object.location)) + throw TypeError( + '.google.protobuf.SourceCodeInfo.location: array expected' + ) + message.location = [] + for (var i = 0; i < object.location.length; ++i) { + if (typeof object.location[i] !== 'object') + throw TypeError( + '.google.protobuf.SourceCodeInfo.location: object expected' + ) + message.location[ + i + ] = $root.google.protobuf.SourceCodeInfo.Location.fromObject( + object.location[i] + ) + } + } + return message + } + + /** + * Creates a plain object from a SourceCodeInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {google.protobuf.SourceCodeInfo} message SourceCodeInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SourceCodeInfo.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) object.location = [] + if (message.location && message.location.length) { + object.location = [] + for (var j = 0; j < message.location.length; ++j) + object.location[ + j + ] = $root.google.protobuf.SourceCodeInfo.Location.toObject( + message.location[j], + options + ) + } + return object + } + + /** + * Converts this SourceCodeInfo to JSON. + * @function toJSON + * @memberof google.protobuf.SourceCodeInfo + * @instance + * @returns {Object.} JSON object + */ + SourceCodeInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + SourceCodeInfo.Location = (function () { + /** + * Properties of a Location. + * @memberof google.protobuf.SourceCodeInfo + * @interface ILocation + * @property {Array.|null} [path] Location path + * @property {Array.|null} [span] Location span + * @property {string|null} [leadingComments] Location leadingComments + * @property {string|null} [trailingComments] Location trailingComments + * @property {Array.|null} [leadingDetachedComments] Location leadingDetachedComments + */ + + /** + * Constructs a new Location. + * @memberof google.protobuf.SourceCodeInfo + * @classdesc Represents a Location. + * @implements ILocation + * @constructor + * @param {google.protobuf.SourceCodeInfo.ILocation=} [properties] Properties to set + */ + function Location(properties) { + this.path = [] + this.span = [] + this.leadingDetachedComments = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * Location path. + * @member {Array.} path + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.path = $util.emptyArray + + /** + * Location span. + * @member {Array.} span + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.span = $util.emptyArray + + /** + * Location leadingComments. + * @member {string} leadingComments + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.leadingComments = '' + + /** + * Location trailingComments. + * @member {string} trailingComments + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.trailingComments = '' + + /** + * Location leadingDetachedComments. + * @member {Array.} leadingDetachedComments + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.leadingDetachedComments = $util.emptyArray + + /** + * Creates a new Location instance using the specified properties. + * @function create + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {google.protobuf.SourceCodeInfo.ILocation=} [properties] Properties to set + * @returns {google.protobuf.SourceCodeInfo.Location} Location instance + */ + Location.create = function create(properties) { + return new Location(properties) + } + + /** + * Encodes the specified Location message. Does not implicitly {@link google.protobuf.SourceCodeInfo.Location.verify|verify} messages. + * @function encode + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {google.protobuf.SourceCodeInfo.ILocation} message Location message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Location.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.path != null && message.path.length) { + writer.uint32(/* id 1, wireType 2 =*/ 10).fork() + for (var i = 0; i < message.path.length; ++i) + writer.int32(message.path[i]) + writer.ldelim() + } + if (message.span != null && message.span.length) { + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + for (var i = 0; i < message.span.length; ++i) + writer.int32(message.span[i]) + writer.ldelim() + } + if ( + message.leadingComments != null && + message.hasOwnProperty('leadingComments') + ) + writer + .uint32(/* id 3, wireType 2 =*/ 26) + .string(message.leadingComments) + if ( + message.trailingComments != null && + message.hasOwnProperty('trailingComments') + ) + writer + .uint32(/* id 4, wireType 2 =*/ 34) + .string(message.trailingComments) + if ( + message.leadingDetachedComments != null && + message.leadingDetachedComments.length + ) + for ( + var i = 0; + i < message.leadingDetachedComments.length; + ++i + ) + writer + .uint32(/* id 6, wireType 2 =*/ 50) + .string(message.leadingDetachedComments[i]) + return writer + } + + /** + * Encodes the specified Location message, length delimited. Does not implicitly {@link google.protobuf.SourceCodeInfo.Location.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {google.protobuf.SourceCodeInfo.ILocation} message Location message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Location.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a Location message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.SourceCodeInfo.Location} Location + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Location.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.SourceCodeInfo.Location() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + if (!(message.path && message.path.length)) + message.path = [] + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos + while (reader.pos < end2) + message.path.push(reader.int32()) + } else message.path.push(reader.int32()) + break + case 2: + if (!(message.span && message.span.length)) + message.span = [] + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos + while (reader.pos < end2) + message.span.push(reader.int32()) + } else message.span.push(reader.int32()) + break + case 3: + message.leadingComments = reader.string() + break + case 4: + message.trailingComments = reader.string() + break + case 6: + if ( + !( + message.leadingDetachedComments && + message.leadingDetachedComments.length + ) + ) + message.leadingDetachedComments = [] + message.leadingDetachedComments.push(reader.string()) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a Location message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.SourceCodeInfo.Location} Location + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Location.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a Location message. + * @function verify + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Location.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.path != null && message.hasOwnProperty('path')) { + if (!Array.isArray(message.path)) + return 'path: array expected' + for (var i = 0; i < message.path.length; ++i) + if (!$util.isInteger(message.path[i])) + return 'path: integer[] expected' + } + if (message.span != null && message.hasOwnProperty('span')) { + if (!Array.isArray(message.span)) + return 'span: array expected' + for (var i = 0; i < message.span.length; ++i) + if (!$util.isInteger(message.span[i])) + return 'span: integer[] expected' + } + if ( + message.leadingComments != null && + message.hasOwnProperty('leadingComments') + ) + if (!$util.isString(message.leadingComments)) + return 'leadingComments: string expected' + if ( + message.trailingComments != null && + message.hasOwnProperty('trailingComments') + ) + if (!$util.isString(message.trailingComments)) + return 'trailingComments: string expected' + if ( + message.leadingDetachedComments != null && + message.hasOwnProperty('leadingDetachedComments') + ) { + if (!Array.isArray(message.leadingDetachedComments)) + return 'leadingDetachedComments: array expected' + for ( + var i = 0; + i < message.leadingDetachedComments.length; + ++i + ) + if (!$util.isString(message.leadingDetachedComments[i])) + return 'leadingDetachedComments: string[] expected' + } + return null + } + + /** + * Creates a Location message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.SourceCodeInfo.Location} Location + */ + Location.fromObject = function fromObject(object) { + if ( + object instanceof + $root.google.protobuf.SourceCodeInfo.Location + ) + return object + var message = new $root.google.protobuf.SourceCodeInfo.Location() + if (object.path) { + if (!Array.isArray(object.path)) + throw TypeError( + '.google.protobuf.SourceCodeInfo.Location.path: array expected' + ) + message.path = [] + for (var i = 0; i < object.path.length; ++i) + message.path[i] = object.path[i] | 0 + } + if (object.span) { + if (!Array.isArray(object.span)) + throw TypeError( + '.google.protobuf.SourceCodeInfo.Location.span: array expected' + ) + message.span = [] + for (var i = 0; i < object.span.length; ++i) + message.span[i] = object.span[i] | 0 + } + if (object.leadingComments != null) + message.leadingComments = String(object.leadingComments) + if (object.trailingComments != null) + message.trailingComments = String(object.trailingComments) + if (object.leadingDetachedComments) { + if (!Array.isArray(object.leadingDetachedComments)) + throw TypeError( + '.google.protobuf.SourceCodeInfo.Location.leadingDetachedComments: array expected' + ) + message.leadingDetachedComments = [] + for ( + var i = 0; + i < object.leadingDetachedComments.length; + ++i + ) + message.leadingDetachedComments[i] = String( + object.leadingDetachedComments[i] + ) + } + return message + } + + /** + * Creates a plain object from a Location message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {google.protobuf.SourceCodeInfo.Location} message Location + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Location.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) { + object.path = [] + object.span = [] + object.leadingDetachedComments = [] + } + if (options.defaults) { + object.leadingComments = '' + object.trailingComments = '' + } + if (message.path && message.path.length) { + object.path = [] + for (var j = 0; j < message.path.length; ++j) + object.path[j] = message.path[j] + } + if (message.span && message.span.length) { + object.span = [] + for (var j = 0; j < message.span.length; ++j) + object.span[j] = message.span[j] + } + if ( + message.leadingComments != null && + message.hasOwnProperty('leadingComments') + ) + object.leadingComments = message.leadingComments + if ( + message.trailingComments != null && + message.hasOwnProperty('trailingComments') + ) + object.trailingComments = message.trailingComments + if ( + message.leadingDetachedComments && + message.leadingDetachedComments.length + ) { + object.leadingDetachedComments = [] + for ( + var j = 0; + j < message.leadingDetachedComments.length; + ++j + ) + object.leadingDetachedComments[j] = + message.leadingDetachedComments[j] + } + return object + } + + /** + * Converts this Location to JSON. + * @function toJSON + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + * @returns {Object.} JSON object + */ + Location.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return Location + })() + + return SourceCodeInfo + })() + + protobuf.GeneratedCodeInfo = (function () { + /** + * Properties of a GeneratedCodeInfo. + * @memberof google.protobuf + * @interface IGeneratedCodeInfo + * @property {Array.|null} [annotation] GeneratedCodeInfo annotation + */ + + /** + * Constructs a new GeneratedCodeInfo. + * @memberof google.protobuf + * @classdesc Represents a GeneratedCodeInfo. + * @implements IGeneratedCodeInfo + * @constructor + * @param {google.protobuf.IGeneratedCodeInfo=} [properties] Properties to set + */ + function GeneratedCodeInfo(properties) { + this.annotation = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * GeneratedCodeInfo annotation. + * @member {Array.} annotation + * @memberof google.protobuf.GeneratedCodeInfo + * @instance + */ + GeneratedCodeInfo.prototype.annotation = $util.emptyArray + + /** + * Creates a new GeneratedCodeInfo instance using the specified properties. + * @function create + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {google.protobuf.IGeneratedCodeInfo=} [properties] Properties to set + * @returns {google.protobuf.GeneratedCodeInfo} GeneratedCodeInfo instance + */ + GeneratedCodeInfo.create = function create(properties) { + return new GeneratedCodeInfo(properties) + } + + /** + * Encodes the specified GeneratedCodeInfo message. Does not implicitly {@link google.protobuf.GeneratedCodeInfo.verify|verify} messages. + * @function encode + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {google.protobuf.IGeneratedCodeInfo} message GeneratedCodeInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GeneratedCodeInfo.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.annotation != null && message.annotation.length) + for (var i = 0; i < message.annotation.length; ++i) + $root.google.protobuf.GeneratedCodeInfo.Annotation.encode( + message.annotation[i], + writer.uint32(/* id 1, wireType 2 =*/ 10).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified GeneratedCodeInfo message, length delimited. Does not implicitly {@link google.protobuf.GeneratedCodeInfo.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {google.protobuf.IGeneratedCodeInfo} message GeneratedCodeInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GeneratedCodeInfo.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a GeneratedCodeInfo message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.GeneratedCodeInfo} GeneratedCodeInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GeneratedCodeInfo.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.GeneratedCodeInfo() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + if (!(message.annotation && message.annotation.length)) + message.annotation = [] + message.annotation.push( + $root.google.protobuf.GeneratedCodeInfo.Annotation.decode( + reader, + reader.uint32() + ) + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a GeneratedCodeInfo message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.GeneratedCodeInfo} GeneratedCodeInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GeneratedCodeInfo.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a GeneratedCodeInfo message. + * @function verify + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GeneratedCodeInfo.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.annotation != null && + message.hasOwnProperty('annotation') + ) { + if (!Array.isArray(message.annotation)) + return 'annotation: array expected' + for (var i = 0; i < message.annotation.length; ++i) { + var error = $root.google.protobuf.GeneratedCodeInfo.Annotation.verify( + message.annotation[i] + ) + if (error) return 'annotation.' + error + } + } + return null + } + + /** + * Creates a GeneratedCodeInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.GeneratedCodeInfo} GeneratedCodeInfo + */ + GeneratedCodeInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.GeneratedCodeInfo) + return object + var message = new $root.google.protobuf.GeneratedCodeInfo() + if (object.annotation) { + if (!Array.isArray(object.annotation)) + throw TypeError( + '.google.protobuf.GeneratedCodeInfo.annotation: array expected' + ) + message.annotation = [] + for (var i = 0; i < object.annotation.length; ++i) { + if (typeof object.annotation[i] !== 'object') + throw TypeError( + '.google.protobuf.GeneratedCodeInfo.annotation: object expected' + ) + message.annotation[ + i + ] = $root.google.protobuf.GeneratedCodeInfo.Annotation.fromObject( + object.annotation[i] + ) + } + } + return message + } + + /** + * Creates a plain object from a GeneratedCodeInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {google.protobuf.GeneratedCodeInfo} message GeneratedCodeInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GeneratedCodeInfo.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) object.annotation = [] + if (message.annotation && message.annotation.length) { + object.annotation = [] + for (var j = 0; j < message.annotation.length; ++j) + object.annotation[ + j + ] = $root.google.protobuf.GeneratedCodeInfo.Annotation.toObject( + message.annotation[j], + options + ) + } + return object + } + + /** + * Converts this GeneratedCodeInfo to JSON. + * @function toJSON + * @memberof google.protobuf.GeneratedCodeInfo + * @instance + * @returns {Object.} JSON object + */ + GeneratedCodeInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + GeneratedCodeInfo.Annotation = (function () { + /** + * Properties of an Annotation. + * @memberof google.protobuf.GeneratedCodeInfo + * @interface IAnnotation + * @property {Array.|null} [path] Annotation path + * @property {string|null} [sourceFile] Annotation sourceFile + * @property {number|null} [begin] Annotation begin + * @property {number|null} [end] Annotation end + */ + + /** + * Constructs a new Annotation. + * @memberof google.protobuf.GeneratedCodeInfo + * @classdesc Represents an Annotation. + * @implements IAnnotation + * @constructor + * @param {google.protobuf.GeneratedCodeInfo.IAnnotation=} [properties] Properties to set + */ + function Annotation(properties) { + this.path = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * Annotation path. + * @member {Array.} path + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + */ + Annotation.prototype.path = $util.emptyArray + + /** + * Annotation sourceFile. + * @member {string} sourceFile + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + */ + Annotation.prototype.sourceFile = '' + + /** + * Annotation begin. + * @member {number} begin + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + */ + Annotation.prototype.begin = 0 + + /** + * Annotation end. + * @member {number} end + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + */ + Annotation.prototype.end = 0 + + /** + * Creates a new Annotation instance using the specified properties. + * @function create + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {google.protobuf.GeneratedCodeInfo.IAnnotation=} [properties] Properties to set + * @returns {google.protobuf.GeneratedCodeInfo.Annotation} Annotation instance + */ + Annotation.create = function create(properties) { + return new Annotation(properties) + } + + /** + * Encodes the specified Annotation message. Does not implicitly {@link google.protobuf.GeneratedCodeInfo.Annotation.verify|verify} messages. + * @function encode + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {google.protobuf.GeneratedCodeInfo.IAnnotation} message Annotation message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Annotation.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.path != null && message.path.length) { + writer.uint32(/* id 1, wireType 2 =*/ 10).fork() + for (var i = 0; i < message.path.length; ++i) + writer.int32(message.path[i]) + writer.ldelim() + } + if ( + message.sourceFile != null && + message.hasOwnProperty('sourceFile') + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.sourceFile) + if (message.begin != null && message.hasOwnProperty('begin')) + writer + .uint32(/* id 3, wireType 0 =*/ 24) + .int32(message.begin) + if (message.end != null && message.hasOwnProperty('end')) + writer.uint32(/* id 4, wireType 0 =*/ 32).int32(message.end) + return writer + } + + /** + * Encodes the specified Annotation message, length delimited. Does not implicitly {@link google.protobuf.GeneratedCodeInfo.Annotation.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {google.protobuf.GeneratedCodeInfo.IAnnotation} message Annotation message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Annotation.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an Annotation message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.GeneratedCodeInfo.Annotation} Annotation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Annotation.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.GeneratedCodeInfo.Annotation() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + if (!(message.path && message.path.length)) + message.path = [] + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos + while (reader.pos < end2) + message.path.push(reader.int32()) + } else message.path.push(reader.int32()) + break + case 2: + message.sourceFile = reader.string() + break + case 3: + message.begin = reader.int32() + break + case 4: + message.end = reader.int32() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an Annotation message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.GeneratedCodeInfo.Annotation} Annotation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Annotation.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an Annotation message. + * @function verify + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Annotation.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.path != null && message.hasOwnProperty('path')) { + if (!Array.isArray(message.path)) + return 'path: array expected' + for (var i = 0; i < message.path.length; ++i) + if (!$util.isInteger(message.path[i])) + return 'path: integer[] expected' + } + if ( + message.sourceFile != null && + message.hasOwnProperty('sourceFile') + ) + if (!$util.isString(message.sourceFile)) + return 'sourceFile: string expected' + if (message.begin != null && message.hasOwnProperty('begin')) + if (!$util.isInteger(message.begin)) + return 'begin: integer expected' + if (message.end != null && message.hasOwnProperty('end')) + if (!$util.isInteger(message.end)) + return 'end: integer expected' + return null + } + + /** + * Creates an Annotation message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.GeneratedCodeInfo.Annotation} Annotation + */ + Annotation.fromObject = function fromObject(object) { + if ( + object instanceof + $root.google.protobuf.GeneratedCodeInfo.Annotation + ) + return object + var message = new $root.google.protobuf.GeneratedCodeInfo.Annotation() + if (object.path) { + if (!Array.isArray(object.path)) + throw TypeError( + '.google.protobuf.GeneratedCodeInfo.Annotation.path: array expected' + ) + message.path = [] + for (var i = 0; i < object.path.length; ++i) + message.path[i] = object.path[i] | 0 + } + if (object.sourceFile != null) + message.sourceFile = String(object.sourceFile) + if (object.begin != null) message.begin = object.begin | 0 + if (object.end != null) message.end = object.end | 0 + return message + } + + /** + * Creates a plain object from an Annotation message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {google.protobuf.GeneratedCodeInfo.Annotation} message Annotation + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Annotation.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) object.path = [] + if (options.defaults) { + object.sourceFile = '' + object.begin = 0 + object.end = 0 + } + if (message.path && message.path.length) { + object.path = [] + for (var j = 0; j < message.path.length; ++j) + object.path[j] = message.path[j] + } + if ( + message.sourceFile != null && + message.hasOwnProperty('sourceFile') + ) + object.sourceFile = message.sourceFile + if (message.begin != null && message.hasOwnProperty('begin')) + object.begin = message.begin + if (message.end != null && message.hasOwnProperty('end')) + object.end = message.end + return object + } + + /** + * Converts this Annotation to JSON. + * @function toJSON + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + * @returns {Object.} JSON object + */ + Annotation.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return Annotation + })() + + return GeneratedCodeInfo + })() + + return protobuf + })() + + google.type = (function () { + /** + * Namespace type. + * @memberof google + * @namespace + */ + var type = {} + + type.Expr = (function () { + /** + * Properties of an Expr. + * @memberof google.type + * @interface IExpr + * @property {string|null} [expression] Expr expression + * @property {string|null} [title] Expr title + * @property {string|null} [description] Expr description + * @property {string|null} [location] Expr location + */ + + /** + * Constructs a new Expr. + * @memberof google.type + * @classdesc Represents an Expr. + * @implements IExpr + * @constructor + * @param {google.type.IExpr=} [properties] Properties to set + */ + function Expr(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * Expr expression. + * @member {string} expression + * @memberof google.type.Expr + * @instance + */ + Expr.prototype.expression = '' + + /** + * Expr title. + * @member {string} title + * @memberof google.type.Expr + * @instance + */ + Expr.prototype.title = '' + + /** + * Expr description. + * @member {string} description + * @memberof google.type.Expr + * @instance + */ + Expr.prototype.description = '' + + /** + * Expr location. + * @member {string} location + * @memberof google.type.Expr + * @instance + */ + Expr.prototype.location = '' + + /** + * Creates a new Expr instance using the specified properties. + * @function create + * @memberof google.type.Expr + * @static + * @param {google.type.IExpr=} [properties] Properties to set + * @returns {google.type.Expr} Expr instance + */ + Expr.create = function create(properties) { + return new Expr(properties) + } + + /** + * Encodes the specified Expr message. Does not implicitly {@link google.type.Expr.verify|verify} messages. + * @function encode + * @memberof google.type.Expr + * @static + * @param {google.type.IExpr} message Expr message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Expr.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.expression != null && + message.hasOwnProperty('expression') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.expression) + if (message.title != null && message.hasOwnProperty('title')) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.title) + if ( + message.description != null && + message.hasOwnProperty('description') + ) + writer + .uint32(/* id 3, wireType 2 =*/ 26) + .string(message.description) + if ( + message.location != null && + message.hasOwnProperty('location') + ) + writer + .uint32(/* id 4, wireType 2 =*/ 34) + .string(message.location) + return writer + } + + /** + * Encodes the specified Expr message, length delimited. Does not implicitly {@link google.type.Expr.verify|verify} messages. + * @function encodeDelimited + * @memberof google.type.Expr + * @static + * @param {google.type.IExpr} message Expr message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Expr.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an Expr message from the specified reader or buffer. + * @function decode + * @memberof google.type.Expr + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.type.Expr} Expr + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Expr.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.type.Expr() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.expression = reader.string() + break + case 2: + message.title = reader.string() + break + case 3: + message.description = reader.string() + break + case 4: + message.location = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an Expr message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.type.Expr + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.type.Expr} Expr + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Expr.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an Expr message. + * @function verify + * @memberof google.type.Expr + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Expr.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.expression != null && + message.hasOwnProperty('expression') + ) + if (!$util.isString(message.expression)) + return 'expression: string expected' + if (message.title != null && message.hasOwnProperty('title')) + if (!$util.isString(message.title)) + return 'title: string expected' + if ( + message.description != null && + message.hasOwnProperty('description') + ) + if (!$util.isString(message.description)) + return 'description: string expected' + if ( + message.location != null && + message.hasOwnProperty('location') + ) + if (!$util.isString(message.location)) + return 'location: string expected' + return null + } + + /** + * Creates an Expr message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.type.Expr + * @static + * @param {Object.} object Plain object + * @returns {google.type.Expr} Expr + */ + Expr.fromObject = function fromObject(object) { + if (object instanceof $root.google.type.Expr) return object + var message = new $root.google.type.Expr() + if (object.expression != null) + message.expression = String(object.expression) + if (object.title != null) message.title = String(object.title) + if (object.description != null) + message.description = String(object.description) + if (object.location != null) + message.location = String(object.location) + return message + } + + /** + * Creates a plain object from an Expr message. Also converts values to other types if specified. + * @function toObject + * @memberof google.type.Expr + * @static + * @param {google.type.Expr} message Expr + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Expr.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.expression = '' + object.title = '' + object.description = '' + object.location = '' + } + if ( + message.expression != null && + message.hasOwnProperty('expression') + ) + object.expression = message.expression + if (message.title != null && message.hasOwnProperty('title')) + object.title = message.title + if ( + message.description != null && + message.hasOwnProperty('description') + ) + object.description = message.description + if ( + message.location != null && + message.hasOwnProperty('location') + ) + object.location = message.location + return object + } + + /** + * Converts this Expr to JSON. + * @function toJSON + * @memberof google.type.Expr + * @instance + * @returns {Object.} JSON object + */ + Expr.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return Expr + })() + + return type + })() + + return google + })() + + return $root + }) + + /***/ + }, + + /***/ 59081: /***/ function ( + module, + __unused_webpack_exports, + __webpack_require__ + ) { + /* module decorator */ module = __webpack_require__.nmd(module) + /** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + /*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/ + ;(function (global, factory) { + /* global define, require, module */ + + /* AMD */ if (typeof define === 'function' && define.amd) + define(['protobufjs/minimal'], factory) + /* CommonJS */ else if (true && module && module.exports) + module.exports = factory(__webpack_require__(96916)) + })(this, function ($protobuf) { + 'use strict' + + // Common aliases + var $Reader = $protobuf.Reader, + $Writer = $protobuf.Writer, + $util = $protobuf.util + + // Exported root namespace + var $root = + $protobuf.roots.operations_protos || + ($protobuf.roots.operations_protos = {}) + + $root.google = (function () { + /** + * Namespace google. + * @exports google + * @namespace + */ + var google = {} + + google.longrunning = (function () { + /** + * Namespace longrunning. + * @memberof google + * @namespace + */ + var longrunning = {} + + longrunning.Operations = (function () { + /** + * Constructs a new Operations service. + * @memberof google.longrunning + * @classdesc Represents an Operations + * @extends $protobuf.rpc.Service + * @constructor + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + */ + function Operations( + rpcImpl, + requestDelimited, + responseDelimited + ) { + $protobuf.rpc.Service.call( + this, + rpcImpl, + requestDelimited, + responseDelimited + ) + } + + ;(Operations.prototype = Object.create( + $protobuf.rpc.Service.prototype + )).constructor = Operations + + /** + * Creates new Operations service using the specified rpc implementation. + * @function create + * @memberof google.longrunning.Operations + * @static + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + * @returns {Operations} RPC service. Useful where requests and/or responses are streamed. + */ + Operations.create = function create( + rpcImpl, + requestDelimited, + responseDelimited + ) { + return new this(rpcImpl, requestDelimited, responseDelimited) + } + + /** + * Callback as used by {@link google.longrunning.Operations#listOperations}. + * @memberof google.longrunning.Operations + * @typedef ListOperationsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.ListOperationsResponse} [response] ListOperationsResponse + */ + + /** + * Calls ListOperations. + * @function listOperations + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IListOperationsRequest} request ListOperationsRequest message or plain object + * @param {google.longrunning.Operations.ListOperationsCallback} callback Node-style callback called with the error, if any, and ListOperationsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty( + (Operations.prototype.listOperations = function listOperations( + request, + callback + ) { + return this.rpcCall( + listOperations, + $root.google.longrunning.ListOperationsRequest, + $root.google.longrunning.ListOperationsResponse, + request, + callback + ) + }), + 'name', + { value: 'ListOperations' } + ) + + /** + * Calls ListOperations. + * @function listOperations + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IListOperationsRequest} request ListOperationsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.longrunning.Operations#getOperation}. + * @memberof google.longrunning.Operations + * @typedef GetOperationCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls GetOperation. + * @function getOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IGetOperationRequest} request GetOperationRequest message or plain object + * @param {google.longrunning.Operations.GetOperationCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty( + (Operations.prototype.getOperation = function getOperation( + request, + callback + ) { + return this.rpcCall( + getOperation, + $root.google.longrunning.GetOperationRequest, + $root.google.longrunning.Operation, + request, + callback + ) + }), + 'name', + { value: 'GetOperation' } + ) + + /** + * Calls GetOperation. + * @function getOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IGetOperationRequest} request GetOperationRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.longrunning.Operations#deleteOperation}. + * @memberof google.longrunning.Operations + * @typedef DeleteOperationCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls DeleteOperation. + * @function deleteOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IDeleteOperationRequest} request DeleteOperationRequest message or plain object + * @param {google.longrunning.Operations.DeleteOperationCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty( + (Operations.prototype.deleteOperation = function deleteOperation( + request, + callback + ) { + return this.rpcCall( + deleteOperation, + $root.google.longrunning.DeleteOperationRequest, + $root.google.protobuf.Empty, + request, + callback + ) + }), + 'name', + { value: 'DeleteOperation' } + ) + + /** + * Calls DeleteOperation. + * @function deleteOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IDeleteOperationRequest} request DeleteOperationRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.longrunning.Operations#cancelOperation}. + * @memberof google.longrunning.Operations + * @typedef CancelOperationCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls CancelOperation. + * @function cancelOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.ICancelOperationRequest} request CancelOperationRequest message or plain object + * @param {google.longrunning.Operations.CancelOperationCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty( + (Operations.prototype.cancelOperation = function cancelOperation( + request, + callback + ) { + return this.rpcCall( + cancelOperation, + $root.google.longrunning.CancelOperationRequest, + $root.google.protobuf.Empty, + request, + callback + ) + }), + 'name', + { value: 'CancelOperation' } + ) + + /** + * Calls CancelOperation. + * @function cancelOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.ICancelOperationRequest} request CancelOperationRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.longrunning.Operations#waitOperation}. + * @memberof google.longrunning.Operations + * @typedef WaitOperationCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls WaitOperation. + * @function waitOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IWaitOperationRequest} request WaitOperationRequest message or plain object + * @param {google.longrunning.Operations.WaitOperationCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty( + (Operations.prototype.waitOperation = function waitOperation( + request, + callback + ) { + return this.rpcCall( + waitOperation, + $root.google.longrunning.WaitOperationRequest, + $root.google.longrunning.Operation, + request, + callback + ) + }), + 'name', + { value: 'WaitOperation' } + ) + + /** + * Calls WaitOperation. + * @function waitOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IWaitOperationRequest} request WaitOperationRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return Operations + })() + + longrunning.Operation = (function () { + /** + * Properties of an Operation. + * @memberof google.longrunning + * @interface IOperation + * @property {string|null} [name] Operation name + * @property {google.protobuf.IAny|null} [metadata] Operation metadata + * @property {boolean|null} [done] Operation done + * @property {google.rpc.IStatus|null} [error] Operation error + * @property {google.protobuf.IAny|null} [response] Operation response + */ + + /** + * Constructs a new Operation. + * @memberof google.longrunning + * @classdesc Represents an Operation. + * @implements IOperation + * @constructor + * @param {google.longrunning.IOperation=} [properties] Properties to set + */ + function Operation(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * Operation name. + * @member {string} name + * @memberof google.longrunning.Operation + * @instance + */ + Operation.prototype.name = '' + + /** + * Operation metadata. + * @member {google.protobuf.IAny|null|undefined} metadata + * @memberof google.longrunning.Operation + * @instance + */ + Operation.prototype.metadata = null + + /** + * Operation done. + * @member {boolean} done + * @memberof google.longrunning.Operation + * @instance + */ + Operation.prototype.done = false + + /** + * Operation error. + * @member {google.rpc.IStatus|null|undefined} error + * @memberof google.longrunning.Operation + * @instance + */ + Operation.prototype.error = null + + /** + * Operation response. + * @member {google.protobuf.IAny|null|undefined} response + * @memberof google.longrunning.Operation + * @instance + */ + Operation.prototype.response = null + + // OneOf field names bound to virtual getters and setters + var $oneOfFields + + /** + * Operation result. + * @member {"error"|"response"|undefined} result + * @memberof google.longrunning.Operation + * @instance + */ + Object.defineProperty(Operation.prototype, 'result', { + get: $util.oneOfGetter(($oneOfFields = ['error', 'response'])), + set: $util.oneOfSetter($oneOfFields) + }) + + /** + * Creates a new Operation instance using the specified properties. + * @function create + * @memberof google.longrunning.Operation + * @static + * @param {google.longrunning.IOperation=} [properties] Properties to set + * @returns {google.longrunning.Operation} Operation instance + */ + Operation.create = function create(properties) { + return new Operation(properties) + } + + /** + * Encodes the specified Operation message. Does not implicitly {@link google.longrunning.Operation.verify|verify} messages. + * @function encode + * @memberof google.longrunning.Operation + * @static + * @param {google.longrunning.IOperation} message Operation message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Operation.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.name != null && message.hasOwnProperty('name')) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.name) + if ( + message.metadata != null && + message.hasOwnProperty('metadata') + ) + $root.google.protobuf.Any.encode( + message.metadata, + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + ).ldelim() + if (message.done != null && message.hasOwnProperty('done')) + writer.uint32(/* id 3, wireType 0 =*/ 24).bool(message.done) + if (message.error != null && message.hasOwnProperty('error')) + $root.google.rpc.Status.encode( + message.error, + writer.uint32(/* id 4, wireType 2 =*/ 34).fork() + ).ldelim() + if ( + message.response != null && + message.hasOwnProperty('response') + ) + $root.google.protobuf.Any.encode( + message.response, + writer.uint32(/* id 5, wireType 2 =*/ 42).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified Operation message, length delimited. Does not implicitly {@link google.longrunning.Operation.verify|verify} messages. + * @function encodeDelimited + * @memberof google.longrunning.Operation + * @static + * @param {google.longrunning.IOperation} message Operation message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Operation.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an Operation message from the specified reader or buffer. + * @function decode + * @memberof google.longrunning.Operation + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.longrunning.Operation} Operation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Operation.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.longrunning.Operation() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + case 2: + message.metadata = $root.google.protobuf.Any.decode( + reader, + reader.uint32() + ) + break + case 3: + message.done = reader.bool() + break + case 4: + message.error = $root.google.rpc.Status.decode( + reader, + reader.uint32() + ) + break + case 5: + message.response = $root.google.protobuf.Any.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an Operation message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.longrunning.Operation + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.longrunning.Operation} Operation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Operation.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an Operation message. + * @function verify + * @memberof google.longrunning.Operation + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Operation.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + var properties = {} + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + if ( + message.metadata != null && + message.hasOwnProperty('metadata') + ) { + var error = $root.google.protobuf.Any.verify(message.metadata) + if (error) return 'metadata.' + error + } + if (message.done != null && message.hasOwnProperty('done')) + if (typeof message.done !== 'boolean') + return 'done: boolean expected' + if (message.error != null && message.hasOwnProperty('error')) { + properties.result = 1 + { + var error = $root.google.rpc.Status.verify(message.error) + if (error) return 'error.' + error + } + } + if ( + message.response != null && + message.hasOwnProperty('response') + ) { + if (properties.result === 1) return 'result: multiple values' + properties.result = 1 + { + var error = $root.google.protobuf.Any.verify( + message.response + ) + if (error) return 'response.' + error + } + } + return null + } + + /** + * Creates an Operation message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.Operation + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.Operation} Operation + */ + Operation.fromObject = function fromObject(object) { + if (object instanceof $root.google.longrunning.Operation) + return object + var message = new $root.google.longrunning.Operation() + if (object.name != null) message.name = String(object.name) + if (object.metadata != null) { + if (typeof object.metadata !== 'object') + throw TypeError( + '.google.longrunning.Operation.metadata: object expected' + ) + message.metadata = $root.google.protobuf.Any.fromObject( + object.metadata + ) + } + if (object.done != null) message.done = Boolean(object.done) + if (object.error != null) { + if (typeof object.error !== 'object') + throw TypeError( + '.google.longrunning.Operation.error: object expected' + ) + message.error = $root.google.rpc.Status.fromObject( + object.error + ) + } + if (object.response != null) { + if (typeof object.response !== 'object') + throw TypeError( + '.google.longrunning.Operation.response: object expected' + ) + message.response = $root.google.protobuf.Any.fromObject( + object.response + ) + } + return message + } + + /** + * Creates a plain object from an Operation message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.Operation + * @static + * @param {google.longrunning.Operation} message Operation + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Operation.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.name = '' + object.metadata = null + object.done = false + } + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + if ( + message.metadata != null && + message.hasOwnProperty('metadata') + ) + object.metadata = $root.google.protobuf.Any.toObject( + message.metadata, + options + ) + if (message.done != null && message.hasOwnProperty('done')) + object.done = message.done + if (message.error != null && message.hasOwnProperty('error')) { + object.error = $root.google.rpc.Status.toObject( + message.error, + options + ) + if (options.oneofs) object.result = 'error' + } + if ( + message.response != null && + message.hasOwnProperty('response') + ) { + object.response = $root.google.protobuf.Any.toObject( + message.response, + options + ) + if (options.oneofs) object.result = 'response' + } + return object + } + + /** + * Converts this Operation to JSON. + * @function toJSON + * @memberof google.longrunning.Operation + * @instance + * @returns {Object.} JSON object + */ + Operation.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return Operation + })() + + longrunning.GetOperationRequest = (function () { + /** + * Properties of a GetOperationRequest. + * @memberof google.longrunning + * @interface IGetOperationRequest + * @property {string|null} [name] GetOperationRequest name + */ + + /** + * Constructs a new GetOperationRequest. + * @memberof google.longrunning + * @classdesc Represents a GetOperationRequest. + * @implements IGetOperationRequest + * @constructor + * @param {google.longrunning.IGetOperationRequest=} [properties] Properties to set + */ + function GetOperationRequest(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * GetOperationRequest name. + * @member {string} name + * @memberof google.longrunning.GetOperationRequest + * @instance + */ + GetOperationRequest.prototype.name = '' + + /** + * Creates a new GetOperationRequest instance using the specified properties. + * @function create + * @memberof google.longrunning.GetOperationRequest + * @static + * @param {google.longrunning.IGetOperationRequest=} [properties] Properties to set + * @returns {google.longrunning.GetOperationRequest} GetOperationRequest instance + */ + GetOperationRequest.create = function create(properties) { + return new GetOperationRequest(properties) + } + + /** + * Encodes the specified GetOperationRequest message. Does not implicitly {@link google.longrunning.GetOperationRequest.verify|verify} messages. + * @function encode + * @memberof google.longrunning.GetOperationRequest + * @static + * @param {google.longrunning.IGetOperationRequest} message GetOperationRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetOperationRequest.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.name != null && message.hasOwnProperty('name')) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.name) + return writer + } + + /** + * Encodes the specified GetOperationRequest message, length delimited. Does not implicitly {@link google.longrunning.GetOperationRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.longrunning.GetOperationRequest + * @static + * @param {google.longrunning.IGetOperationRequest} message GetOperationRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetOperationRequest.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a GetOperationRequest message from the specified reader or buffer. + * @function decode + * @memberof google.longrunning.GetOperationRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.longrunning.GetOperationRequest} GetOperationRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetOperationRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.longrunning.GetOperationRequest() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a GetOperationRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.longrunning.GetOperationRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.longrunning.GetOperationRequest} GetOperationRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetOperationRequest.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a GetOperationRequest message. + * @function verify + * @memberof google.longrunning.GetOperationRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetOperationRequest.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + return null + } + + /** + * Creates a GetOperationRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.GetOperationRequest + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.GetOperationRequest} GetOperationRequest + */ + GetOperationRequest.fromObject = function fromObject(object) { + if ( + object instanceof $root.google.longrunning.GetOperationRequest + ) + return object + var message = new $root.google.longrunning.GetOperationRequest() + if (object.name != null) message.name = String(object.name) + return message + } + + /** + * Creates a plain object from a GetOperationRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.GetOperationRequest + * @static + * @param {google.longrunning.GetOperationRequest} message GetOperationRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetOperationRequest.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) object.name = '' + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + return object + } + + /** + * Converts this GetOperationRequest to JSON. + * @function toJSON + * @memberof google.longrunning.GetOperationRequest + * @instance + * @returns {Object.} JSON object + */ + GetOperationRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return GetOperationRequest + })() + + longrunning.ListOperationsRequest = (function () { + /** + * Properties of a ListOperationsRequest. + * @memberof google.longrunning + * @interface IListOperationsRequest + * @property {string|null} [name] ListOperationsRequest name + * @property {string|null} [filter] ListOperationsRequest filter + * @property {number|null} [pageSize] ListOperationsRequest pageSize + * @property {string|null} [pageToken] ListOperationsRequest pageToken + */ + + /** + * Constructs a new ListOperationsRequest. + * @memberof google.longrunning + * @classdesc Represents a ListOperationsRequest. + * @implements IListOperationsRequest + * @constructor + * @param {google.longrunning.IListOperationsRequest=} [properties] Properties to set + */ + function ListOperationsRequest(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * ListOperationsRequest name. + * @member {string} name + * @memberof google.longrunning.ListOperationsRequest + * @instance + */ + ListOperationsRequest.prototype.name = '' + + /** + * ListOperationsRequest filter. + * @member {string} filter + * @memberof google.longrunning.ListOperationsRequest + * @instance + */ + ListOperationsRequest.prototype.filter = '' + + /** + * ListOperationsRequest pageSize. + * @member {number} pageSize + * @memberof google.longrunning.ListOperationsRequest + * @instance + */ + ListOperationsRequest.prototype.pageSize = 0 + + /** + * ListOperationsRequest pageToken. + * @member {string} pageToken + * @memberof google.longrunning.ListOperationsRequest + * @instance + */ + ListOperationsRequest.prototype.pageToken = '' + + /** + * Creates a new ListOperationsRequest instance using the specified properties. + * @function create + * @memberof google.longrunning.ListOperationsRequest + * @static + * @param {google.longrunning.IListOperationsRequest=} [properties] Properties to set + * @returns {google.longrunning.ListOperationsRequest} ListOperationsRequest instance + */ + ListOperationsRequest.create = function create(properties) { + return new ListOperationsRequest(properties) + } + + /** + * Encodes the specified ListOperationsRequest message. Does not implicitly {@link google.longrunning.ListOperationsRequest.verify|verify} messages. + * @function encode + * @memberof google.longrunning.ListOperationsRequest + * @static + * @param {google.longrunning.IListOperationsRequest} message ListOperationsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListOperationsRequest.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.filter != null && message.hasOwnProperty('filter')) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.filter) + if ( + message.pageSize != null && + message.hasOwnProperty('pageSize') + ) + writer + .uint32(/* id 2, wireType 0 =*/ 16) + .int32(message.pageSize) + if ( + message.pageToken != null && + message.hasOwnProperty('pageToken') + ) + writer + .uint32(/* id 3, wireType 2 =*/ 26) + .string(message.pageToken) + if (message.name != null && message.hasOwnProperty('name')) + writer.uint32(/* id 4, wireType 2 =*/ 34).string(message.name) + return writer + } + + /** + * Encodes the specified ListOperationsRequest message, length delimited. Does not implicitly {@link google.longrunning.ListOperationsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.longrunning.ListOperationsRequest + * @static + * @param {google.longrunning.IListOperationsRequest} message ListOperationsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListOperationsRequest.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a ListOperationsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.longrunning.ListOperationsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.longrunning.ListOperationsRequest} ListOperationsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListOperationsRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.longrunning.ListOperationsRequest() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 4: + message.name = reader.string() + break + case 1: + message.filter = reader.string() + break + case 2: + message.pageSize = reader.int32() + break + case 3: + message.pageToken = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a ListOperationsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.longrunning.ListOperationsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.longrunning.ListOperationsRequest} ListOperationsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListOperationsRequest.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a ListOperationsRequest message. + * @function verify + * @memberof google.longrunning.ListOperationsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListOperationsRequest.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + if (message.filter != null && message.hasOwnProperty('filter')) + if (!$util.isString(message.filter)) + return 'filter: string expected' + if ( + message.pageSize != null && + message.hasOwnProperty('pageSize') + ) + if (!$util.isInteger(message.pageSize)) + return 'pageSize: integer expected' + if ( + message.pageToken != null && + message.hasOwnProperty('pageToken') + ) + if (!$util.isString(message.pageToken)) + return 'pageToken: string expected' + return null + } + + /** + * Creates a ListOperationsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.ListOperationsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.ListOperationsRequest} ListOperationsRequest + */ + ListOperationsRequest.fromObject = function fromObject(object) { + if ( + object instanceof + $root.google.longrunning.ListOperationsRequest + ) + return object + var message = new $root.google.longrunning.ListOperationsRequest() + if (object.name != null) message.name = String(object.name) + if (object.filter != null) + message.filter = String(object.filter) + if (object.pageSize != null) + message.pageSize = object.pageSize | 0 + if (object.pageToken != null) + message.pageToken = String(object.pageToken) + return message + } + + /** + * Creates a plain object from a ListOperationsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.ListOperationsRequest + * @static + * @param {google.longrunning.ListOperationsRequest} message ListOperationsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListOperationsRequest.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.filter = '' + object.pageSize = 0 + object.pageToken = '' + object.name = '' + } + if (message.filter != null && message.hasOwnProperty('filter')) + object.filter = message.filter + if ( + message.pageSize != null && + message.hasOwnProperty('pageSize') + ) + object.pageSize = message.pageSize + if ( + message.pageToken != null && + message.hasOwnProperty('pageToken') + ) + object.pageToken = message.pageToken + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + return object + } + + /** + * Converts this ListOperationsRequest to JSON. + * @function toJSON + * @memberof google.longrunning.ListOperationsRequest + * @instance + * @returns {Object.} JSON object + */ + ListOperationsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return ListOperationsRequest + })() + + longrunning.ListOperationsResponse = (function () { + /** + * Properties of a ListOperationsResponse. + * @memberof google.longrunning + * @interface IListOperationsResponse + * @property {Array.|null} [operations] ListOperationsResponse operations + * @property {string|null} [nextPageToken] ListOperationsResponse nextPageToken + */ + + /** + * Constructs a new ListOperationsResponse. + * @memberof google.longrunning + * @classdesc Represents a ListOperationsResponse. + * @implements IListOperationsResponse + * @constructor + * @param {google.longrunning.IListOperationsResponse=} [properties] Properties to set + */ + function ListOperationsResponse(properties) { + this.operations = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * ListOperationsResponse operations. + * @member {Array.} operations + * @memberof google.longrunning.ListOperationsResponse + * @instance + */ + ListOperationsResponse.prototype.operations = $util.emptyArray + + /** + * ListOperationsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.longrunning.ListOperationsResponse + * @instance + */ + ListOperationsResponse.prototype.nextPageToken = '' + + /** + * Creates a new ListOperationsResponse instance using the specified properties. + * @function create + * @memberof google.longrunning.ListOperationsResponse + * @static + * @param {google.longrunning.IListOperationsResponse=} [properties] Properties to set + * @returns {google.longrunning.ListOperationsResponse} ListOperationsResponse instance + */ + ListOperationsResponse.create = function create(properties) { + return new ListOperationsResponse(properties) + } + + /** + * Encodes the specified ListOperationsResponse message. Does not implicitly {@link google.longrunning.ListOperationsResponse.verify|verify} messages. + * @function encode + * @memberof google.longrunning.ListOperationsResponse + * @static + * @param {google.longrunning.IListOperationsResponse} message ListOperationsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListOperationsResponse.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.operations != null && message.operations.length) + for (var i = 0; i < message.operations.length; ++i) + $root.google.longrunning.Operation.encode( + message.operations[i], + writer.uint32(/* id 1, wireType 2 =*/ 10).fork() + ).ldelim() + if ( + message.nextPageToken != null && + message.hasOwnProperty('nextPageToken') + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.nextPageToken) + return writer + } + + /** + * Encodes the specified ListOperationsResponse message, length delimited. Does not implicitly {@link google.longrunning.ListOperationsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.longrunning.ListOperationsResponse + * @static + * @param {google.longrunning.IListOperationsResponse} message ListOperationsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListOperationsResponse.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a ListOperationsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.longrunning.ListOperationsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.longrunning.ListOperationsResponse} ListOperationsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListOperationsResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.longrunning.ListOperationsResponse() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + if (!(message.operations && message.operations.length)) + message.operations = [] + message.operations.push( + $root.google.longrunning.Operation.decode( + reader, + reader.uint32() + ) + ) + break + case 2: + message.nextPageToken = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a ListOperationsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.longrunning.ListOperationsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.longrunning.ListOperationsResponse} ListOperationsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListOperationsResponse.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a ListOperationsResponse message. + * @function verify + * @memberof google.longrunning.ListOperationsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListOperationsResponse.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.operations != null && + message.hasOwnProperty('operations') + ) { + if (!Array.isArray(message.operations)) + return 'operations: array expected' + for (var i = 0; i < message.operations.length; ++i) { + var error = $root.google.longrunning.Operation.verify( + message.operations[i] + ) + if (error) return 'operations.' + error + } + } + if ( + message.nextPageToken != null && + message.hasOwnProperty('nextPageToken') + ) + if (!$util.isString(message.nextPageToken)) + return 'nextPageToken: string expected' + return null + } + + /** + * Creates a ListOperationsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.ListOperationsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.ListOperationsResponse} ListOperationsResponse + */ + ListOperationsResponse.fromObject = function fromObject(object) { + if ( + object instanceof + $root.google.longrunning.ListOperationsResponse + ) + return object + var message = new $root.google.longrunning.ListOperationsResponse() + if (object.operations) { + if (!Array.isArray(object.operations)) + throw TypeError( + '.google.longrunning.ListOperationsResponse.operations: array expected' + ) + message.operations = [] + for (var i = 0; i < object.operations.length; ++i) { + if (typeof object.operations[i] !== 'object') + throw TypeError( + '.google.longrunning.ListOperationsResponse.operations: object expected' + ) + message.operations[ + i + ] = $root.google.longrunning.Operation.fromObject( + object.operations[i] + ) + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken) + return message + } + + /** + * Creates a plain object from a ListOperationsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.ListOperationsResponse + * @static + * @param {google.longrunning.ListOperationsResponse} message ListOperationsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListOperationsResponse.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) object.operations = [] + if (options.defaults) object.nextPageToken = '' + if (message.operations && message.operations.length) { + object.operations = [] + for (var j = 0; j < message.operations.length; ++j) + object.operations[ + j + ] = $root.google.longrunning.Operation.toObject( + message.operations[j], + options + ) + } + if ( + message.nextPageToken != null && + message.hasOwnProperty('nextPageToken') + ) + object.nextPageToken = message.nextPageToken + return object + } + + /** + * Converts this ListOperationsResponse to JSON. + * @function toJSON + * @memberof google.longrunning.ListOperationsResponse + * @instance + * @returns {Object.} JSON object + */ + ListOperationsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return ListOperationsResponse + })() + + longrunning.CancelOperationRequest = (function () { + /** + * Properties of a CancelOperationRequest. + * @memberof google.longrunning + * @interface ICancelOperationRequest + * @property {string|null} [name] CancelOperationRequest name + */ + + /** + * Constructs a new CancelOperationRequest. + * @memberof google.longrunning + * @classdesc Represents a CancelOperationRequest. + * @implements ICancelOperationRequest + * @constructor + * @param {google.longrunning.ICancelOperationRequest=} [properties] Properties to set + */ + function CancelOperationRequest(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * CancelOperationRequest name. + * @member {string} name + * @memberof google.longrunning.CancelOperationRequest + * @instance + */ + CancelOperationRequest.prototype.name = '' + + /** + * Creates a new CancelOperationRequest instance using the specified properties. + * @function create + * @memberof google.longrunning.CancelOperationRequest + * @static + * @param {google.longrunning.ICancelOperationRequest=} [properties] Properties to set + * @returns {google.longrunning.CancelOperationRequest} CancelOperationRequest instance + */ + CancelOperationRequest.create = function create(properties) { + return new CancelOperationRequest(properties) + } + + /** + * Encodes the specified CancelOperationRequest message. Does not implicitly {@link google.longrunning.CancelOperationRequest.verify|verify} messages. + * @function encode + * @memberof google.longrunning.CancelOperationRequest + * @static + * @param {google.longrunning.ICancelOperationRequest} message CancelOperationRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CancelOperationRequest.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.name != null && message.hasOwnProperty('name')) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.name) + return writer + } + + /** + * Encodes the specified CancelOperationRequest message, length delimited. Does not implicitly {@link google.longrunning.CancelOperationRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.longrunning.CancelOperationRequest + * @static + * @param {google.longrunning.ICancelOperationRequest} message CancelOperationRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CancelOperationRequest.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a CancelOperationRequest message from the specified reader or buffer. + * @function decode + * @memberof google.longrunning.CancelOperationRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.longrunning.CancelOperationRequest} CancelOperationRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CancelOperationRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.longrunning.CancelOperationRequest() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a CancelOperationRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.longrunning.CancelOperationRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.longrunning.CancelOperationRequest} CancelOperationRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CancelOperationRequest.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a CancelOperationRequest message. + * @function verify + * @memberof google.longrunning.CancelOperationRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CancelOperationRequest.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + return null + } + + /** + * Creates a CancelOperationRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.CancelOperationRequest + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.CancelOperationRequest} CancelOperationRequest + */ + CancelOperationRequest.fromObject = function fromObject(object) { + if ( + object instanceof + $root.google.longrunning.CancelOperationRequest + ) + return object + var message = new $root.google.longrunning.CancelOperationRequest() + if (object.name != null) message.name = String(object.name) + return message + } + + /** + * Creates a plain object from a CancelOperationRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.CancelOperationRequest + * @static + * @param {google.longrunning.CancelOperationRequest} message CancelOperationRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CancelOperationRequest.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) object.name = '' + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + return object + } + + /** + * Converts this CancelOperationRequest to JSON. + * @function toJSON + * @memberof google.longrunning.CancelOperationRequest + * @instance + * @returns {Object.} JSON object + */ + CancelOperationRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return CancelOperationRequest + })() + + longrunning.DeleteOperationRequest = (function () { + /** + * Properties of a DeleteOperationRequest. + * @memberof google.longrunning + * @interface IDeleteOperationRequest + * @property {string|null} [name] DeleteOperationRequest name + */ + + /** + * Constructs a new DeleteOperationRequest. + * @memberof google.longrunning + * @classdesc Represents a DeleteOperationRequest. + * @implements IDeleteOperationRequest + * @constructor + * @param {google.longrunning.IDeleteOperationRequest=} [properties] Properties to set + */ + function DeleteOperationRequest(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * DeleteOperationRequest name. + * @member {string} name + * @memberof google.longrunning.DeleteOperationRequest + * @instance + */ + DeleteOperationRequest.prototype.name = '' + + /** + * Creates a new DeleteOperationRequest instance using the specified properties. + * @function create + * @memberof google.longrunning.DeleteOperationRequest + * @static + * @param {google.longrunning.IDeleteOperationRequest=} [properties] Properties to set + * @returns {google.longrunning.DeleteOperationRequest} DeleteOperationRequest instance + */ + DeleteOperationRequest.create = function create(properties) { + return new DeleteOperationRequest(properties) + } + + /** + * Encodes the specified DeleteOperationRequest message. Does not implicitly {@link google.longrunning.DeleteOperationRequest.verify|verify} messages. + * @function encode + * @memberof google.longrunning.DeleteOperationRequest + * @static + * @param {google.longrunning.IDeleteOperationRequest} message DeleteOperationRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteOperationRequest.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.name != null && message.hasOwnProperty('name')) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.name) + return writer + } + + /** + * Encodes the specified DeleteOperationRequest message, length delimited. Does not implicitly {@link google.longrunning.DeleteOperationRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.longrunning.DeleteOperationRequest + * @static + * @param {google.longrunning.IDeleteOperationRequest} message DeleteOperationRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteOperationRequest.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a DeleteOperationRequest message from the specified reader or buffer. + * @function decode + * @memberof google.longrunning.DeleteOperationRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.longrunning.DeleteOperationRequest} DeleteOperationRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteOperationRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.longrunning.DeleteOperationRequest() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a DeleteOperationRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.longrunning.DeleteOperationRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.longrunning.DeleteOperationRequest} DeleteOperationRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteOperationRequest.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a DeleteOperationRequest message. + * @function verify + * @memberof google.longrunning.DeleteOperationRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DeleteOperationRequest.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + return null + } + + /** + * Creates a DeleteOperationRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.DeleteOperationRequest + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.DeleteOperationRequest} DeleteOperationRequest + */ + DeleteOperationRequest.fromObject = function fromObject(object) { + if ( + object instanceof + $root.google.longrunning.DeleteOperationRequest + ) + return object + var message = new $root.google.longrunning.DeleteOperationRequest() + if (object.name != null) message.name = String(object.name) + return message + } + + /** + * Creates a plain object from a DeleteOperationRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.DeleteOperationRequest + * @static + * @param {google.longrunning.DeleteOperationRequest} message DeleteOperationRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeleteOperationRequest.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) object.name = '' + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + return object + } + + /** + * Converts this DeleteOperationRequest to JSON. + * @function toJSON + * @memberof google.longrunning.DeleteOperationRequest + * @instance + * @returns {Object.} JSON object + */ + DeleteOperationRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return DeleteOperationRequest + })() + + longrunning.WaitOperationRequest = (function () { + /** + * Properties of a WaitOperationRequest. + * @memberof google.longrunning + * @interface IWaitOperationRequest + * @property {string|null} [name] WaitOperationRequest name + * @property {google.protobuf.IDuration|null} [timeout] WaitOperationRequest timeout + */ + + /** + * Constructs a new WaitOperationRequest. + * @memberof google.longrunning + * @classdesc Represents a WaitOperationRequest. + * @implements IWaitOperationRequest + * @constructor + * @param {google.longrunning.IWaitOperationRequest=} [properties] Properties to set + */ + function WaitOperationRequest(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * WaitOperationRequest name. + * @member {string} name + * @memberof google.longrunning.WaitOperationRequest + * @instance + */ + WaitOperationRequest.prototype.name = '' + + /** + * WaitOperationRequest timeout. + * @member {google.protobuf.IDuration|null|undefined} timeout + * @memberof google.longrunning.WaitOperationRequest + * @instance + */ + WaitOperationRequest.prototype.timeout = null + + /** + * Creates a new WaitOperationRequest instance using the specified properties. + * @function create + * @memberof google.longrunning.WaitOperationRequest + * @static + * @param {google.longrunning.IWaitOperationRequest=} [properties] Properties to set + * @returns {google.longrunning.WaitOperationRequest} WaitOperationRequest instance + */ + WaitOperationRequest.create = function create(properties) { + return new WaitOperationRequest(properties) + } + + /** + * Encodes the specified WaitOperationRequest message. Does not implicitly {@link google.longrunning.WaitOperationRequest.verify|verify} messages. + * @function encode + * @memberof google.longrunning.WaitOperationRequest + * @static + * @param {google.longrunning.IWaitOperationRequest} message WaitOperationRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WaitOperationRequest.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.name != null && message.hasOwnProperty('name')) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.name) + if ( + message.timeout != null && + message.hasOwnProperty('timeout') + ) + $root.google.protobuf.Duration.encode( + message.timeout, + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified WaitOperationRequest message, length delimited. Does not implicitly {@link google.longrunning.WaitOperationRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.longrunning.WaitOperationRequest + * @static + * @param {google.longrunning.IWaitOperationRequest} message WaitOperationRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WaitOperationRequest.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a WaitOperationRequest message from the specified reader or buffer. + * @function decode + * @memberof google.longrunning.WaitOperationRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.longrunning.WaitOperationRequest} WaitOperationRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WaitOperationRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.longrunning.WaitOperationRequest() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + case 2: + message.timeout = $root.google.protobuf.Duration.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a WaitOperationRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.longrunning.WaitOperationRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.longrunning.WaitOperationRequest} WaitOperationRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WaitOperationRequest.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a WaitOperationRequest message. + * @function verify + * @memberof google.longrunning.WaitOperationRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + WaitOperationRequest.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + if ( + message.timeout != null && + message.hasOwnProperty('timeout') + ) { + var error = $root.google.protobuf.Duration.verify( + message.timeout + ) + if (error) return 'timeout.' + error + } + return null + } + + /** + * Creates a WaitOperationRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.WaitOperationRequest + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.WaitOperationRequest} WaitOperationRequest + */ + WaitOperationRequest.fromObject = function fromObject(object) { + if ( + object instanceof + $root.google.longrunning.WaitOperationRequest + ) + return object + var message = new $root.google.longrunning.WaitOperationRequest() + if (object.name != null) message.name = String(object.name) + if (object.timeout != null) { + if (typeof object.timeout !== 'object') + throw TypeError( + '.google.longrunning.WaitOperationRequest.timeout: object expected' + ) + message.timeout = $root.google.protobuf.Duration.fromObject( + object.timeout + ) + } + return message + } + + /** + * Creates a plain object from a WaitOperationRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.WaitOperationRequest + * @static + * @param {google.longrunning.WaitOperationRequest} message WaitOperationRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + WaitOperationRequest.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.name = '' + object.timeout = null + } + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + if ( + message.timeout != null && + message.hasOwnProperty('timeout') + ) + object.timeout = $root.google.protobuf.Duration.toObject( + message.timeout, + options + ) + return object + } + + /** + * Converts this WaitOperationRequest to JSON. + * @function toJSON + * @memberof google.longrunning.WaitOperationRequest + * @instance + * @returns {Object.} JSON object + */ + WaitOperationRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return WaitOperationRequest + })() + + longrunning.OperationInfo = (function () { + /** + * Properties of an OperationInfo. + * @memberof google.longrunning + * @interface IOperationInfo + * @property {string|null} [responseType] OperationInfo responseType + * @property {string|null} [metadataType] OperationInfo metadataType + */ + + /** + * Constructs a new OperationInfo. + * @memberof google.longrunning + * @classdesc Represents an OperationInfo. + * @implements IOperationInfo + * @constructor + * @param {google.longrunning.IOperationInfo=} [properties] Properties to set + */ + function OperationInfo(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * OperationInfo responseType. + * @member {string} responseType + * @memberof google.longrunning.OperationInfo + * @instance + */ + OperationInfo.prototype.responseType = '' + + /** + * OperationInfo metadataType. + * @member {string} metadataType + * @memberof google.longrunning.OperationInfo + * @instance + */ + OperationInfo.prototype.metadataType = '' + + /** + * Creates a new OperationInfo instance using the specified properties. + * @function create + * @memberof google.longrunning.OperationInfo + * @static + * @param {google.longrunning.IOperationInfo=} [properties] Properties to set + * @returns {google.longrunning.OperationInfo} OperationInfo instance + */ + OperationInfo.create = function create(properties) { + return new OperationInfo(properties) + } + + /** + * Encodes the specified OperationInfo message. Does not implicitly {@link google.longrunning.OperationInfo.verify|verify} messages. + * @function encode + * @memberof google.longrunning.OperationInfo + * @static + * @param {google.longrunning.IOperationInfo} message OperationInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OperationInfo.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.responseType != null && + message.hasOwnProperty('responseType') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.responseType) + if ( + message.metadataType != null && + message.hasOwnProperty('metadataType') + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.metadataType) + return writer + } + + /** + * Encodes the specified OperationInfo message, length delimited. Does not implicitly {@link google.longrunning.OperationInfo.verify|verify} messages. + * @function encodeDelimited + * @memberof google.longrunning.OperationInfo + * @static + * @param {google.longrunning.IOperationInfo} message OperationInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OperationInfo.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an OperationInfo message from the specified reader or buffer. + * @function decode + * @memberof google.longrunning.OperationInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.longrunning.OperationInfo} OperationInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OperationInfo.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.longrunning.OperationInfo() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.responseType = reader.string() + break + case 2: + message.metadataType = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an OperationInfo message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.longrunning.OperationInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.longrunning.OperationInfo} OperationInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OperationInfo.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an OperationInfo message. + * @function verify + * @memberof google.longrunning.OperationInfo + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + OperationInfo.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.responseType != null && + message.hasOwnProperty('responseType') + ) + if (!$util.isString(message.responseType)) + return 'responseType: string expected' + if ( + message.metadataType != null && + message.hasOwnProperty('metadataType') + ) + if (!$util.isString(message.metadataType)) + return 'metadataType: string expected' + return null + } + + /** + * Creates an OperationInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.OperationInfo + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.OperationInfo} OperationInfo + */ + OperationInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.longrunning.OperationInfo) + return object + var message = new $root.google.longrunning.OperationInfo() + if (object.responseType != null) + message.responseType = String(object.responseType) + if (object.metadataType != null) + message.metadataType = String(object.metadataType) + return message + } + + /** + * Creates a plain object from an OperationInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.OperationInfo + * @static + * @param {google.longrunning.OperationInfo} message OperationInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + OperationInfo.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.responseType = '' + object.metadataType = '' + } + if ( + message.responseType != null && + message.hasOwnProperty('responseType') + ) + object.responseType = message.responseType + if ( + message.metadataType != null && + message.hasOwnProperty('metadataType') + ) + object.metadataType = message.metadataType + return object + } + + /** + * Converts this OperationInfo to JSON. + * @function toJSON + * @memberof google.longrunning.OperationInfo + * @instance + * @returns {Object.} JSON object + */ + OperationInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return OperationInfo + })() + + return longrunning + })() + + google.api = (function () { + /** + * Namespace api. + * @memberof google + * @namespace + */ + var api = {} + + api.Http = (function () { + /** + * Properties of a Http. + * @memberof google.api + * @interface IHttp + * @property {Array.|null} [rules] Http rules + * @property {boolean|null} [fullyDecodeReservedExpansion] Http fullyDecodeReservedExpansion + */ + + /** + * Constructs a new Http. + * @memberof google.api + * @classdesc Represents a Http. + * @implements IHttp + * @constructor + * @param {google.api.IHttp=} [properties] Properties to set + */ + function Http(properties) { + this.rules = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * Http rules. + * @member {Array.} rules + * @memberof google.api.Http + * @instance + */ + Http.prototype.rules = $util.emptyArray + + /** + * Http fullyDecodeReservedExpansion. + * @member {boolean} fullyDecodeReservedExpansion + * @memberof google.api.Http + * @instance + */ + Http.prototype.fullyDecodeReservedExpansion = false + + /** + * Creates a new Http instance using the specified properties. + * @function create + * @memberof google.api.Http + * @static + * @param {google.api.IHttp=} [properties] Properties to set + * @returns {google.api.Http} Http instance + */ + Http.create = function create(properties) { + return new Http(properties) + } + + /** + * Encodes the specified Http message. Does not implicitly {@link google.api.Http.verify|verify} messages. + * @function encode + * @memberof google.api.Http + * @static + * @param {google.api.IHttp} message Http message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Http.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.rules != null && message.rules.length) + for (var i = 0; i < message.rules.length; ++i) + $root.google.api.HttpRule.encode( + message.rules[i], + writer.uint32(/* id 1, wireType 2 =*/ 10).fork() + ).ldelim() + if ( + message.fullyDecodeReservedExpansion != null && + message.hasOwnProperty('fullyDecodeReservedExpansion') + ) + writer + .uint32(/* id 2, wireType 0 =*/ 16) + .bool(message.fullyDecodeReservedExpansion) + return writer + } + + /** + * Encodes the specified Http message, length delimited. Does not implicitly {@link google.api.Http.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.Http + * @static + * @param {google.api.IHttp} message Http message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Http.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a Http message from the specified reader or buffer. + * @function decode + * @memberof google.api.Http + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.Http} Http + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Http.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.api.Http() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + if (!(message.rules && message.rules.length)) + message.rules = [] + message.rules.push( + $root.google.api.HttpRule.decode( + reader, + reader.uint32() + ) + ) + break + case 2: + message.fullyDecodeReservedExpansion = reader.bool() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a Http message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.Http + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.Http} Http + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Http.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a Http message. + * @function verify + * @memberof google.api.Http + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Http.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.rules != null && message.hasOwnProperty('rules')) { + if (!Array.isArray(message.rules)) + return 'rules: array expected' + for (var i = 0; i < message.rules.length; ++i) { + var error = $root.google.api.HttpRule.verify( + message.rules[i] + ) + if (error) return 'rules.' + error + } + } + if ( + message.fullyDecodeReservedExpansion != null && + message.hasOwnProperty('fullyDecodeReservedExpansion') + ) + if (typeof message.fullyDecodeReservedExpansion !== 'boolean') + return 'fullyDecodeReservedExpansion: boolean expected' + return null + } + + /** + * Creates a Http message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.Http + * @static + * @param {Object.} object Plain object + * @returns {google.api.Http} Http + */ + Http.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.Http) return object + var message = new $root.google.api.Http() + if (object.rules) { + if (!Array.isArray(object.rules)) + throw TypeError('.google.api.Http.rules: array expected') + message.rules = [] + for (var i = 0; i < object.rules.length; ++i) { + if (typeof object.rules[i] !== 'object') + throw TypeError('.google.api.Http.rules: object expected') + message.rules[i] = $root.google.api.HttpRule.fromObject( + object.rules[i] + ) + } + } + if (object.fullyDecodeReservedExpansion != null) + message.fullyDecodeReservedExpansion = Boolean( + object.fullyDecodeReservedExpansion + ) + return message + } + + /** + * Creates a plain object from a Http message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.Http + * @static + * @param {google.api.Http} message Http + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Http.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) object.rules = [] + if (options.defaults) + object.fullyDecodeReservedExpansion = false + if (message.rules && message.rules.length) { + object.rules = [] + for (var j = 0; j < message.rules.length; ++j) + object.rules[j] = $root.google.api.HttpRule.toObject( + message.rules[j], + options + ) + } + if ( + message.fullyDecodeReservedExpansion != null && + message.hasOwnProperty('fullyDecodeReservedExpansion') + ) + object.fullyDecodeReservedExpansion = + message.fullyDecodeReservedExpansion + return object + } + + /** + * Converts this Http to JSON. + * @function toJSON + * @memberof google.api.Http + * @instance + * @returns {Object.} JSON object + */ + Http.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return Http + })() + + api.HttpRule = (function () { + /** + * Properties of a HttpRule. + * @memberof google.api + * @interface IHttpRule + * @property {string|null} [selector] HttpRule selector + * @property {string|null} [get] HttpRule get + * @property {string|null} [put] HttpRule put + * @property {string|null} [post] HttpRule post + * @property {string|null} ["delete"] HttpRule delete + * @property {string|null} [patch] HttpRule patch + * @property {google.api.ICustomHttpPattern|null} [custom] HttpRule custom + * @property {string|null} [body] HttpRule body + * @property {string|null} [responseBody] HttpRule responseBody + * @property {Array.|null} [additionalBindings] HttpRule additionalBindings + */ + + /** + * Constructs a new HttpRule. + * @memberof google.api + * @classdesc Represents a HttpRule. + * @implements IHttpRule + * @constructor + * @param {google.api.IHttpRule=} [properties] Properties to set + */ + function HttpRule(properties) { + this.additionalBindings = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * HttpRule selector. + * @member {string} selector + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.selector = '' + + /** + * HttpRule get. + * @member {string} get + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.get = '' + + /** + * HttpRule put. + * @member {string} put + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.put = '' + + /** + * HttpRule post. + * @member {string} post + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.post = '' + + /** + * HttpRule delete. + * @member {string} delete + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype['delete'] = '' + + /** + * HttpRule patch. + * @member {string} patch + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.patch = '' + + /** + * HttpRule custom. + * @member {google.api.ICustomHttpPattern|null|undefined} custom + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.custom = null + + /** + * HttpRule body. + * @member {string} body + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.body = '' + + /** + * HttpRule responseBody. + * @member {string} responseBody + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.responseBody = '' + + /** + * HttpRule additionalBindings. + * @member {Array.} additionalBindings + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.additionalBindings = $util.emptyArray + + // OneOf field names bound to virtual getters and setters + var $oneOfFields + + /** + * HttpRule pattern. + * @member {"get"|"put"|"post"|"delete"|"patch"|"custom"|undefined} pattern + * @memberof google.api.HttpRule + * @instance + */ + Object.defineProperty(HttpRule.prototype, 'pattern', { + get: $util.oneOfGetter( + ($oneOfFields = [ + 'get', + 'put', + 'post', + 'delete', + 'patch', + 'custom' + ]) + ), + set: $util.oneOfSetter($oneOfFields) + }) + + /** + * Creates a new HttpRule instance using the specified properties. + * @function create + * @memberof google.api.HttpRule + * @static + * @param {google.api.IHttpRule=} [properties] Properties to set + * @returns {google.api.HttpRule} HttpRule instance + */ + HttpRule.create = function create(properties) { + return new HttpRule(properties) + } + + /** + * Encodes the specified HttpRule message. Does not implicitly {@link google.api.HttpRule.verify|verify} messages. + * @function encode + * @memberof google.api.HttpRule + * @static + * @param {google.api.IHttpRule} message HttpRule message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + HttpRule.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.selector != null && + message.hasOwnProperty('selector') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.selector) + if (message.get != null && message.hasOwnProperty('get')) + writer.uint32(/* id 2, wireType 2 =*/ 18).string(message.get) + if (message.put != null && message.hasOwnProperty('put')) + writer.uint32(/* id 3, wireType 2 =*/ 26).string(message.put) + if (message.post != null && message.hasOwnProperty('post')) + writer.uint32(/* id 4, wireType 2 =*/ 34).string(message.post) + if ( + message['delete'] != null && + message.hasOwnProperty('delete') + ) + writer + .uint32(/* id 5, wireType 2 =*/ 42) + .string(message['delete']) + if (message.patch != null && message.hasOwnProperty('patch')) + writer + .uint32(/* id 6, wireType 2 =*/ 50) + .string(message.patch) + if (message.body != null && message.hasOwnProperty('body')) + writer.uint32(/* id 7, wireType 2 =*/ 58).string(message.body) + if (message.custom != null && message.hasOwnProperty('custom')) + $root.google.api.CustomHttpPattern.encode( + message.custom, + writer.uint32(/* id 8, wireType 2 =*/ 66).fork() + ).ldelim() + if ( + message.additionalBindings != null && + message.additionalBindings.length + ) + for (var i = 0; i < message.additionalBindings.length; ++i) + $root.google.api.HttpRule.encode( + message.additionalBindings[i], + writer.uint32(/* id 11, wireType 2 =*/ 90).fork() + ).ldelim() + if ( + message.responseBody != null && + message.hasOwnProperty('responseBody') + ) + writer + .uint32(/* id 12, wireType 2 =*/ 98) + .string(message.responseBody) + return writer + } + + /** + * Encodes the specified HttpRule message, length delimited. Does not implicitly {@link google.api.HttpRule.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.HttpRule + * @static + * @param {google.api.IHttpRule} message HttpRule message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + HttpRule.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a HttpRule message from the specified reader or buffer. + * @function decode + * @memberof google.api.HttpRule + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.HttpRule} HttpRule + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + HttpRule.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.api.HttpRule() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.selector = reader.string() + break + case 2: + message.get = reader.string() + break + case 3: + message.put = reader.string() + break + case 4: + message.post = reader.string() + break + case 5: + message['delete'] = reader.string() + break + case 6: + message.patch = reader.string() + break + case 8: + message.custom = $root.google.api.CustomHttpPattern.decode( + reader, + reader.uint32() + ) + break + case 7: + message.body = reader.string() + break + case 12: + message.responseBody = reader.string() + break + case 11: + if ( + !( + message.additionalBindings && + message.additionalBindings.length + ) + ) + message.additionalBindings = [] + message.additionalBindings.push( + $root.google.api.HttpRule.decode( + reader, + reader.uint32() + ) + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a HttpRule message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.HttpRule + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.HttpRule} HttpRule + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + HttpRule.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a HttpRule message. + * @function verify + * @memberof google.api.HttpRule + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + HttpRule.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + var properties = {} + if ( + message.selector != null && + message.hasOwnProperty('selector') + ) + if (!$util.isString(message.selector)) + return 'selector: string expected' + if (message.get != null && message.hasOwnProperty('get')) { + properties.pattern = 1 + if (!$util.isString(message.get)) + return 'get: string expected' + } + if (message.put != null && message.hasOwnProperty('put')) { + if (properties.pattern === 1) + return 'pattern: multiple values' + properties.pattern = 1 + if (!$util.isString(message.put)) + return 'put: string expected' + } + if (message.post != null && message.hasOwnProperty('post')) { + if (properties.pattern === 1) + return 'pattern: multiple values' + properties.pattern = 1 + if (!$util.isString(message.post)) + return 'post: string expected' + } + if ( + message['delete'] != null && + message.hasOwnProperty('delete') + ) { + if (properties.pattern === 1) + return 'pattern: multiple values' + properties.pattern = 1 + if (!$util.isString(message['delete'])) + return 'delete: string expected' + } + if (message.patch != null && message.hasOwnProperty('patch')) { + if (properties.pattern === 1) + return 'pattern: multiple values' + properties.pattern = 1 + if (!$util.isString(message.patch)) + return 'patch: string expected' + } + if ( + message.custom != null && + message.hasOwnProperty('custom') + ) { + if (properties.pattern === 1) + return 'pattern: multiple values' + properties.pattern = 1 + { + var error = $root.google.api.CustomHttpPattern.verify( + message.custom + ) + if (error) return 'custom.' + error + } + } + if (message.body != null && message.hasOwnProperty('body')) + if (!$util.isString(message.body)) + return 'body: string expected' + if ( + message.responseBody != null && + message.hasOwnProperty('responseBody') + ) + if (!$util.isString(message.responseBody)) + return 'responseBody: string expected' + if ( + message.additionalBindings != null && + message.hasOwnProperty('additionalBindings') + ) { + if (!Array.isArray(message.additionalBindings)) + return 'additionalBindings: array expected' + for (var i = 0; i < message.additionalBindings.length; ++i) { + var error = $root.google.api.HttpRule.verify( + message.additionalBindings[i] + ) + if (error) return 'additionalBindings.' + error + } + } + return null + } + + /** + * Creates a HttpRule message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.HttpRule + * @static + * @param {Object.} object Plain object + * @returns {google.api.HttpRule} HttpRule + */ + HttpRule.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.HttpRule) return object + var message = new $root.google.api.HttpRule() + if (object.selector != null) + message.selector = String(object.selector) + if (object.get != null) message.get = String(object.get) + if (object.put != null) message.put = String(object.put) + if (object.post != null) message.post = String(object.post) + if (object['delete'] != null) + message['delete'] = String(object['delete']) + if (object.patch != null) message.patch = String(object.patch) + if (object.custom != null) { + if (typeof object.custom !== 'object') + throw TypeError( + '.google.api.HttpRule.custom: object expected' + ) + message.custom = $root.google.api.CustomHttpPattern.fromObject( + object.custom + ) + } + if (object.body != null) message.body = String(object.body) + if (object.responseBody != null) + message.responseBody = String(object.responseBody) + if (object.additionalBindings) { + if (!Array.isArray(object.additionalBindings)) + throw TypeError( + '.google.api.HttpRule.additionalBindings: array expected' + ) + message.additionalBindings = [] + for (var i = 0; i < object.additionalBindings.length; ++i) { + if (typeof object.additionalBindings[i] !== 'object') + throw TypeError( + '.google.api.HttpRule.additionalBindings: object expected' + ) + message.additionalBindings[ + i + ] = $root.google.api.HttpRule.fromObject( + object.additionalBindings[i] + ) + } + } + return message + } + + /** + * Creates a plain object from a HttpRule message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.HttpRule + * @static + * @param {google.api.HttpRule} message HttpRule + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + HttpRule.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) + object.additionalBindings = [] + if (options.defaults) { + object.selector = '' + object.body = '' + object.responseBody = '' + } + if ( + message.selector != null && + message.hasOwnProperty('selector') + ) + object.selector = message.selector + if (message.get != null && message.hasOwnProperty('get')) { + object.get = message.get + if (options.oneofs) object.pattern = 'get' + } + if (message.put != null && message.hasOwnProperty('put')) { + object.put = message.put + if (options.oneofs) object.pattern = 'put' + } + if (message.post != null && message.hasOwnProperty('post')) { + object.post = message.post + if (options.oneofs) object.pattern = 'post' + } + if ( + message['delete'] != null && + message.hasOwnProperty('delete') + ) { + object['delete'] = message['delete'] + if (options.oneofs) object.pattern = 'delete' + } + if (message.patch != null && message.hasOwnProperty('patch')) { + object.patch = message.patch + if (options.oneofs) object.pattern = 'patch' + } + if (message.body != null && message.hasOwnProperty('body')) + object.body = message.body + if ( + message.custom != null && + message.hasOwnProperty('custom') + ) { + object.custom = $root.google.api.CustomHttpPattern.toObject( + message.custom, + options + ) + if (options.oneofs) object.pattern = 'custom' + } + if ( + message.additionalBindings && + message.additionalBindings.length + ) { + object.additionalBindings = [] + for (var j = 0; j < message.additionalBindings.length; ++j) + object.additionalBindings[ + j + ] = $root.google.api.HttpRule.toObject( + message.additionalBindings[j], + options + ) + } + if ( + message.responseBody != null && + message.hasOwnProperty('responseBody') + ) + object.responseBody = message.responseBody + return object + } + + /** + * Converts this HttpRule to JSON. + * @function toJSON + * @memberof google.api.HttpRule + * @instance + * @returns {Object.} JSON object + */ + HttpRule.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return HttpRule + })() + + api.CustomHttpPattern = (function () { + /** + * Properties of a CustomHttpPattern. + * @memberof google.api + * @interface ICustomHttpPattern + * @property {string|null} [kind] CustomHttpPattern kind + * @property {string|null} [path] CustomHttpPattern path + */ + + /** + * Constructs a new CustomHttpPattern. + * @memberof google.api + * @classdesc Represents a CustomHttpPattern. + * @implements ICustomHttpPattern + * @constructor + * @param {google.api.ICustomHttpPattern=} [properties] Properties to set + */ + function CustomHttpPattern(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * CustomHttpPattern kind. + * @member {string} kind + * @memberof google.api.CustomHttpPattern + * @instance + */ + CustomHttpPattern.prototype.kind = '' + + /** + * CustomHttpPattern path. + * @member {string} path + * @memberof google.api.CustomHttpPattern + * @instance + */ + CustomHttpPattern.prototype.path = '' + + /** + * Creates a new CustomHttpPattern instance using the specified properties. + * @function create + * @memberof google.api.CustomHttpPattern + * @static + * @param {google.api.ICustomHttpPattern=} [properties] Properties to set + * @returns {google.api.CustomHttpPattern} CustomHttpPattern instance + */ + CustomHttpPattern.create = function create(properties) { + return new CustomHttpPattern(properties) + } + + /** + * Encodes the specified CustomHttpPattern message. Does not implicitly {@link google.api.CustomHttpPattern.verify|verify} messages. + * @function encode + * @memberof google.api.CustomHttpPattern + * @static + * @param {google.api.ICustomHttpPattern} message CustomHttpPattern message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CustomHttpPattern.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.kind != null && message.hasOwnProperty('kind')) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.kind) + if (message.path != null && message.hasOwnProperty('path')) + writer.uint32(/* id 2, wireType 2 =*/ 18).string(message.path) + return writer + } + + /** + * Encodes the specified CustomHttpPattern message, length delimited. Does not implicitly {@link google.api.CustomHttpPattern.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.CustomHttpPattern + * @static + * @param {google.api.ICustomHttpPattern} message CustomHttpPattern message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CustomHttpPattern.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a CustomHttpPattern message from the specified reader or buffer. + * @function decode + * @memberof google.api.CustomHttpPattern + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.CustomHttpPattern} CustomHttpPattern + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CustomHttpPattern.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.api.CustomHttpPattern() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.kind = reader.string() + break + case 2: + message.path = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a CustomHttpPattern message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.CustomHttpPattern + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.CustomHttpPattern} CustomHttpPattern + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CustomHttpPattern.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a CustomHttpPattern message. + * @function verify + * @memberof google.api.CustomHttpPattern + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CustomHttpPattern.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.kind != null && message.hasOwnProperty('kind')) + if (!$util.isString(message.kind)) + return 'kind: string expected' + if (message.path != null && message.hasOwnProperty('path')) + if (!$util.isString(message.path)) + return 'path: string expected' + return null + } + + /** + * Creates a CustomHttpPattern message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.CustomHttpPattern + * @static + * @param {Object.} object Plain object + * @returns {google.api.CustomHttpPattern} CustomHttpPattern + */ + CustomHttpPattern.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.CustomHttpPattern) + return object + var message = new $root.google.api.CustomHttpPattern() + if (object.kind != null) message.kind = String(object.kind) + if (object.path != null) message.path = String(object.path) + return message + } + + /** + * Creates a plain object from a CustomHttpPattern message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.CustomHttpPattern + * @static + * @param {google.api.CustomHttpPattern} message CustomHttpPattern + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CustomHttpPattern.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.kind = '' + object.path = '' + } + if (message.kind != null && message.hasOwnProperty('kind')) + object.kind = message.kind + if (message.path != null && message.hasOwnProperty('path')) + object.path = message.path + return object + } + + /** + * Converts this CustomHttpPattern to JSON. + * @function toJSON + * @memberof google.api.CustomHttpPattern + * @instance + * @returns {Object.} JSON object + */ + CustomHttpPattern.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return CustomHttpPattern + })() + + return api + })() + + google.protobuf = (function () { + /** + * Namespace protobuf. + * @memberof google + * @namespace + */ + var protobuf = {} + + protobuf.FileDescriptorSet = (function () { + /** + * Properties of a FileDescriptorSet. + * @memberof google.protobuf + * @interface IFileDescriptorSet + * @property {Array.|null} [file] FileDescriptorSet file + */ + + /** + * Constructs a new FileDescriptorSet. + * @memberof google.protobuf + * @classdesc Represents a FileDescriptorSet. + * @implements IFileDescriptorSet + * @constructor + * @param {google.protobuf.IFileDescriptorSet=} [properties] Properties to set + */ + function FileDescriptorSet(properties) { + this.file = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * FileDescriptorSet file. + * @member {Array.} file + * @memberof google.protobuf.FileDescriptorSet + * @instance + */ + FileDescriptorSet.prototype.file = $util.emptyArray + + /** + * Creates a new FileDescriptorSet instance using the specified properties. + * @function create + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {google.protobuf.IFileDescriptorSet=} [properties] Properties to set + * @returns {google.protobuf.FileDescriptorSet} FileDescriptorSet instance + */ + FileDescriptorSet.create = function create(properties) { + return new FileDescriptorSet(properties) + } + + /** + * Encodes the specified FileDescriptorSet message. Does not implicitly {@link google.protobuf.FileDescriptorSet.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {google.protobuf.IFileDescriptorSet} message FileDescriptorSet message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FileDescriptorSet.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.file != null && message.file.length) + for (var i = 0; i < message.file.length; ++i) + $root.google.protobuf.FileDescriptorProto.encode( + message.file[i], + writer.uint32(/* id 1, wireType 2 =*/ 10).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified FileDescriptorSet message, length delimited. Does not implicitly {@link google.protobuf.FileDescriptorSet.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {google.protobuf.IFileDescriptorSet} message FileDescriptorSet message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FileDescriptorSet.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a FileDescriptorSet message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FileDescriptorSet} FileDescriptorSet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FileDescriptorSet.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.FileDescriptorSet() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + if (!(message.file && message.file.length)) + message.file = [] + message.file.push( + $root.google.protobuf.FileDescriptorProto.decode( + reader, + reader.uint32() + ) + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a FileDescriptorSet message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FileDescriptorSet} FileDescriptorSet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FileDescriptorSet.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a FileDescriptorSet message. + * @function verify + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FileDescriptorSet.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.file != null && message.hasOwnProperty('file')) { + if (!Array.isArray(message.file)) + return 'file: array expected' + for (var i = 0; i < message.file.length; ++i) { + var error = $root.google.protobuf.FileDescriptorProto.verify( + message.file[i] + ) + if (error) return 'file.' + error + } + } + return null + } + + /** + * Creates a FileDescriptorSet message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FileDescriptorSet} FileDescriptorSet + */ + FileDescriptorSet.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FileDescriptorSet) + return object + var message = new $root.google.protobuf.FileDescriptorSet() + if (object.file) { + if (!Array.isArray(object.file)) + throw TypeError( + '.google.protobuf.FileDescriptorSet.file: array expected' + ) + message.file = [] + for (var i = 0; i < object.file.length; ++i) { + if (typeof object.file[i] !== 'object') + throw TypeError( + '.google.protobuf.FileDescriptorSet.file: object expected' + ) + message.file[ + i + ] = $root.google.protobuf.FileDescriptorProto.fromObject( + object.file[i] + ) + } + } + return message + } + + /** + * Creates a plain object from a FileDescriptorSet message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {google.protobuf.FileDescriptorSet} message FileDescriptorSet + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FileDescriptorSet.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) object.file = [] + if (message.file && message.file.length) { + object.file = [] + for (var j = 0; j < message.file.length; ++j) + object.file[ + j + ] = $root.google.protobuf.FileDescriptorProto.toObject( + message.file[j], + options + ) + } + return object + } + + /** + * Converts this FileDescriptorSet to JSON. + * @function toJSON + * @memberof google.protobuf.FileDescriptorSet + * @instance + * @returns {Object.} JSON object + */ + FileDescriptorSet.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return FileDescriptorSet + })() + + protobuf.FileDescriptorProto = (function () { + /** + * Properties of a FileDescriptorProto. + * @memberof google.protobuf + * @interface IFileDescriptorProto + * @property {string|null} [name] FileDescriptorProto name + * @property {string|null} ["package"] FileDescriptorProto package + * @property {Array.|null} [dependency] FileDescriptorProto dependency + * @property {Array.|null} [publicDependency] FileDescriptorProto publicDependency + * @property {Array.|null} [weakDependency] FileDescriptorProto weakDependency + * @property {Array.|null} [messageType] FileDescriptorProto messageType + * @property {Array.|null} [enumType] FileDescriptorProto enumType + * @property {Array.|null} [service] FileDescriptorProto service + * @property {Array.|null} [extension] FileDescriptorProto extension + * @property {google.protobuf.IFileOptions|null} [options] FileDescriptorProto options + * @property {google.protobuf.ISourceCodeInfo|null} [sourceCodeInfo] FileDescriptorProto sourceCodeInfo + * @property {string|null} [syntax] FileDescriptorProto syntax + */ + + /** + * Constructs a new FileDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a FileDescriptorProto. + * @implements IFileDescriptorProto + * @constructor + * @param {google.protobuf.IFileDescriptorProto=} [properties] Properties to set + */ + function FileDescriptorProto(properties) { + this.dependency = [] + this.publicDependency = [] + this.weakDependency = [] + this.messageType = [] + this.enumType = [] + this.service = [] + this.extension = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * FileDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.name = '' + + /** + * FileDescriptorProto package. + * @member {string} package + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype['package'] = '' + + /** + * FileDescriptorProto dependency. + * @member {Array.} dependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.dependency = $util.emptyArray + + /** + * FileDescriptorProto publicDependency. + * @member {Array.} publicDependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.publicDependency = $util.emptyArray + + /** + * FileDescriptorProto weakDependency. + * @member {Array.} weakDependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.weakDependency = $util.emptyArray + + /** + * FileDescriptorProto messageType. + * @member {Array.} messageType + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.messageType = $util.emptyArray + + /** + * FileDescriptorProto enumType. + * @member {Array.} enumType + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.enumType = $util.emptyArray + + /** + * FileDescriptorProto service. + * @member {Array.} service + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.service = $util.emptyArray + + /** + * FileDescriptorProto extension. + * @member {Array.} extension + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.extension = $util.emptyArray + + /** + * FileDescriptorProto options. + * @member {google.protobuf.IFileOptions|null|undefined} options + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.options = null + + /** + * FileDescriptorProto sourceCodeInfo. + * @member {google.protobuf.ISourceCodeInfo|null|undefined} sourceCodeInfo + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.sourceCodeInfo = null + + /** + * FileDescriptorProto syntax. + * @member {string} syntax + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.syntax = '' + + /** + * Creates a new FileDescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {google.protobuf.IFileDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.FileDescriptorProto} FileDescriptorProto instance + */ + FileDescriptorProto.create = function create(properties) { + return new FileDescriptorProto(properties) + } + + /** + * Encodes the specified FileDescriptorProto message. Does not implicitly {@link google.protobuf.FileDescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {google.protobuf.IFileDescriptorProto} message FileDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FileDescriptorProto.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.name != null && message.hasOwnProperty('name')) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.name) + if ( + message['package'] != null && + message.hasOwnProperty('package') + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message['package']) + if (message.dependency != null && message.dependency.length) + for (var i = 0; i < message.dependency.length; ++i) + writer + .uint32(/* id 3, wireType 2 =*/ 26) + .string(message.dependency[i]) + if (message.messageType != null && message.messageType.length) + for (var i = 0; i < message.messageType.length; ++i) + $root.google.protobuf.DescriptorProto.encode( + message.messageType[i], + writer.uint32(/* id 4, wireType 2 =*/ 34).fork() + ).ldelim() + if (message.enumType != null && message.enumType.length) + for (var i = 0; i < message.enumType.length; ++i) + $root.google.protobuf.EnumDescriptorProto.encode( + message.enumType[i], + writer.uint32(/* id 5, wireType 2 =*/ 42).fork() + ).ldelim() + if (message.service != null && message.service.length) + for (var i = 0; i < message.service.length; ++i) + $root.google.protobuf.ServiceDescriptorProto.encode( + message.service[i], + writer.uint32(/* id 6, wireType 2 =*/ 50).fork() + ).ldelim() + if (message.extension != null && message.extension.length) + for (var i = 0; i < message.extension.length; ++i) + $root.google.protobuf.FieldDescriptorProto.encode( + message.extension[i], + writer.uint32(/* id 7, wireType 2 =*/ 58).fork() + ).ldelim() + if ( + message.options != null && + message.hasOwnProperty('options') + ) + $root.google.protobuf.FileOptions.encode( + message.options, + writer.uint32(/* id 8, wireType 2 =*/ 66).fork() + ).ldelim() + if ( + message.sourceCodeInfo != null && + message.hasOwnProperty('sourceCodeInfo') + ) + $root.google.protobuf.SourceCodeInfo.encode( + message.sourceCodeInfo, + writer.uint32(/* id 9, wireType 2 =*/ 74).fork() + ).ldelim() + if ( + message.publicDependency != null && + message.publicDependency.length + ) + for (var i = 0; i < message.publicDependency.length; ++i) + writer + .uint32(/* id 10, wireType 0 =*/ 80) + .int32(message.publicDependency[i]) + if ( + message.weakDependency != null && + message.weakDependency.length + ) + for (var i = 0; i < message.weakDependency.length; ++i) + writer + .uint32(/* id 11, wireType 0 =*/ 88) + .int32(message.weakDependency[i]) + if (message.syntax != null && message.hasOwnProperty('syntax')) + writer + .uint32(/* id 12, wireType 2 =*/ 98) + .string(message.syntax) + return writer + } + + /** + * Encodes the specified FileDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.FileDescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {google.protobuf.IFileDescriptorProto} message FileDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FileDescriptorProto.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a FileDescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FileDescriptorProto} FileDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FileDescriptorProto.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.FileDescriptorProto() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + case 2: + message['package'] = reader.string() + break + case 3: + if (!(message.dependency && message.dependency.length)) + message.dependency = [] + message.dependency.push(reader.string()) + break + case 10: + if ( + !( + message.publicDependency && + message.publicDependency.length + ) + ) + message.publicDependency = [] + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos + while (reader.pos < end2) + message.publicDependency.push(reader.int32()) + } else message.publicDependency.push(reader.int32()) + break + case 11: + if ( + !( + message.weakDependency && + message.weakDependency.length + ) + ) + message.weakDependency = [] + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos + while (reader.pos < end2) + message.weakDependency.push(reader.int32()) + } else message.weakDependency.push(reader.int32()) + break + case 4: + if (!(message.messageType && message.messageType.length)) + message.messageType = [] + message.messageType.push( + $root.google.protobuf.DescriptorProto.decode( + reader, + reader.uint32() + ) + ) + break + case 5: + if (!(message.enumType && message.enumType.length)) + message.enumType = [] + message.enumType.push( + $root.google.protobuf.EnumDescriptorProto.decode( + reader, + reader.uint32() + ) + ) + break + case 6: + if (!(message.service && message.service.length)) + message.service = [] + message.service.push( + $root.google.protobuf.ServiceDescriptorProto.decode( + reader, + reader.uint32() + ) + ) + break + case 7: + if (!(message.extension && message.extension.length)) + message.extension = [] + message.extension.push( + $root.google.protobuf.FieldDescriptorProto.decode( + reader, + reader.uint32() + ) + ) + break + case 8: + message.options = $root.google.protobuf.FileOptions.decode( + reader, + reader.uint32() + ) + break + case 9: + message.sourceCodeInfo = $root.google.protobuf.SourceCodeInfo.decode( + reader, + reader.uint32() + ) + break + case 12: + message.syntax = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a FileDescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FileDescriptorProto} FileDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FileDescriptorProto.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a FileDescriptorProto message. + * @function verify + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FileDescriptorProto.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + if ( + message['package'] != null && + message.hasOwnProperty('package') + ) + if (!$util.isString(message['package'])) + return 'package: string expected' + if ( + message.dependency != null && + message.hasOwnProperty('dependency') + ) { + if (!Array.isArray(message.dependency)) + return 'dependency: array expected' + for (var i = 0; i < message.dependency.length; ++i) + if (!$util.isString(message.dependency[i])) + return 'dependency: string[] expected' + } + if ( + message.publicDependency != null && + message.hasOwnProperty('publicDependency') + ) { + if (!Array.isArray(message.publicDependency)) + return 'publicDependency: array expected' + for (var i = 0; i < message.publicDependency.length; ++i) + if (!$util.isInteger(message.publicDependency[i])) + return 'publicDependency: integer[] expected' + } + if ( + message.weakDependency != null && + message.hasOwnProperty('weakDependency') + ) { + if (!Array.isArray(message.weakDependency)) + return 'weakDependency: array expected' + for (var i = 0; i < message.weakDependency.length; ++i) + if (!$util.isInteger(message.weakDependency[i])) + return 'weakDependency: integer[] expected' + } + if ( + message.messageType != null && + message.hasOwnProperty('messageType') + ) { + if (!Array.isArray(message.messageType)) + return 'messageType: array expected' + for (var i = 0; i < message.messageType.length; ++i) { + var error = $root.google.protobuf.DescriptorProto.verify( + message.messageType[i] + ) + if (error) return 'messageType.' + error + } + } + if ( + message.enumType != null && + message.hasOwnProperty('enumType') + ) { + if (!Array.isArray(message.enumType)) + return 'enumType: array expected' + for (var i = 0; i < message.enumType.length; ++i) { + var error = $root.google.protobuf.EnumDescriptorProto.verify( + message.enumType[i] + ) + if (error) return 'enumType.' + error + } + } + if ( + message.service != null && + message.hasOwnProperty('service') + ) { + if (!Array.isArray(message.service)) + return 'service: array expected' + for (var i = 0; i < message.service.length; ++i) { + var error = $root.google.protobuf.ServiceDescriptorProto.verify( + message.service[i] + ) + if (error) return 'service.' + error + } + } + if ( + message.extension != null && + message.hasOwnProperty('extension') + ) { + if (!Array.isArray(message.extension)) + return 'extension: array expected' + for (var i = 0; i < message.extension.length; ++i) { + var error = $root.google.protobuf.FieldDescriptorProto.verify( + message.extension[i] + ) + if (error) return 'extension.' + error + } + } + if ( + message.options != null && + message.hasOwnProperty('options') + ) { + var error = $root.google.protobuf.FileOptions.verify( + message.options + ) + if (error) return 'options.' + error + } + if ( + message.sourceCodeInfo != null && + message.hasOwnProperty('sourceCodeInfo') + ) { + var error = $root.google.protobuf.SourceCodeInfo.verify( + message.sourceCodeInfo + ) + if (error) return 'sourceCodeInfo.' + error + } + if (message.syntax != null && message.hasOwnProperty('syntax')) + if (!$util.isString(message.syntax)) + return 'syntax: string expected' + return null + } + + /** + * Creates a FileDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FileDescriptorProto} FileDescriptorProto + */ + FileDescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FileDescriptorProto) + return object + var message = new $root.google.protobuf.FileDescriptorProto() + if (object.name != null) message.name = String(object.name) + if (object['package'] != null) + message['package'] = String(object['package']) + if (object.dependency) { + if (!Array.isArray(object.dependency)) + throw TypeError( + '.google.protobuf.FileDescriptorProto.dependency: array expected' + ) + message.dependency = [] + for (var i = 0; i < object.dependency.length; ++i) + message.dependency[i] = String(object.dependency[i]) + } + if (object.publicDependency) { + if (!Array.isArray(object.publicDependency)) + throw TypeError( + '.google.protobuf.FileDescriptorProto.publicDependency: array expected' + ) + message.publicDependency = [] + for (var i = 0; i < object.publicDependency.length; ++i) + message.publicDependency[i] = object.publicDependency[i] | 0 + } + if (object.weakDependency) { + if (!Array.isArray(object.weakDependency)) + throw TypeError( + '.google.protobuf.FileDescriptorProto.weakDependency: array expected' + ) + message.weakDependency = [] + for (var i = 0; i < object.weakDependency.length; ++i) + message.weakDependency[i] = object.weakDependency[i] | 0 + } + if (object.messageType) { + if (!Array.isArray(object.messageType)) + throw TypeError( + '.google.protobuf.FileDescriptorProto.messageType: array expected' + ) + message.messageType = [] + for (var i = 0; i < object.messageType.length; ++i) { + if (typeof object.messageType[i] !== 'object') + throw TypeError( + '.google.protobuf.FileDescriptorProto.messageType: object expected' + ) + message.messageType[ + i + ] = $root.google.protobuf.DescriptorProto.fromObject( + object.messageType[i] + ) + } + } + if (object.enumType) { + if (!Array.isArray(object.enumType)) + throw TypeError( + '.google.protobuf.FileDescriptorProto.enumType: array expected' + ) + message.enumType = [] + for (var i = 0; i < object.enumType.length; ++i) { + if (typeof object.enumType[i] !== 'object') + throw TypeError( + '.google.protobuf.FileDescriptorProto.enumType: object expected' + ) + message.enumType[ + i + ] = $root.google.protobuf.EnumDescriptorProto.fromObject( + object.enumType[i] + ) + } + } + if (object.service) { + if (!Array.isArray(object.service)) + throw TypeError( + '.google.protobuf.FileDescriptorProto.service: array expected' + ) + message.service = [] + for (var i = 0; i < object.service.length; ++i) { + if (typeof object.service[i] !== 'object') + throw TypeError( + '.google.protobuf.FileDescriptorProto.service: object expected' + ) + message.service[ + i + ] = $root.google.protobuf.ServiceDescriptorProto.fromObject( + object.service[i] + ) + } + } + if (object.extension) { + if (!Array.isArray(object.extension)) + throw TypeError( + '.google.protobuf.FileDescriptorProto.extension: array expected' + ) + message.extension = [] + for (var i = 0; i < object.extension.length; ++i) { + if (typeof object.extension[i] !== 'object') + throw TypeError( + '.google.protobuf.FileDescriptorProto.extension: object expected' + ) + message.extension[ + i + ] = $root.google.protobuf.FieldDescriptorProto.fromObject( + object.extension[i] + ) + } + } + if (object.options != null) { + if (typeof object.options !== 'object') + throw TypeError( + '.google.protobuf.FileDescriptorProto.options: object expected' + ) + message.options = $root.google.protobuf.FileOptions.fromObject( + object.options + ) + } + if (object.sourceCodeInfo != null) { + if (typeof object.sourceCodeInfo !== 'object') + throw TypeError( + '.google.protobuf.FileDescriptorProto.sourceCodeInfo: object expected' + ) + message.sourceCodeInfo = $root.google.protobuf.SourceCodeInfo.fromObject( + object.sourceCodeInfo + ) + } + if (object.syntax != null) + message.syntax = String(object.syntax) + return message + } + + /** + * Creates a plain object from a FileDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {google.protobuf.FileDescriptorProto} message FileDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FileDescriptorProto.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) { + object.dependency = [] + object.messageType = [] + object.enumType = [] + object.service = [] + object.extension = [] + object.publicDependency = [] + object.weakDependency = [] + } + if (options.defaults) { + object.name = '' + object['package'] = '' + object.options = null + object.sourceCodeInfo = null + object.syntax = '' + } + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + if ( + message['package'] != null && + message.hasOwnProperty('package') + ) + object['package'] = message['package'] + if (message.dependency && message.dependency.length) { + object.dependency = [] + for (var j = 0; j < message.dependency.length; ++j) + object.dependency[j] = message.dependency[j] + } + if (message.messageType && message.messageType.length) { + object.messageType = [] + for (var j = 0; j < message.messageType.length; ++j) + object.messageType[ + j + ] = $root.google.protobuf.DescriptorProto.toObject( + message.messageType[j], + options + ) + } + if (message.enumType && message.enumType.length) { + object.enumType = [] + for (var j = 0; j < message.enumType.length; ++j) + object.enumType[ + j + ] = $root.google.protobuf.EnumDescriptorProto.toObject( + message.enumType[j], + options + ) + } + if (message.service && message.service.length) { + object.service = [] + for (var j = 0; j < message.service.length; ++j) + object.service[ + j + ] = $root.google.protobuf.ServiceDescriptorProto.toObject( + message.service[j], + options + ) + } + if (message.extension && message.extension.length) { + object.extension = [] + for (var j = 0; j < message.extension.length; ++j) + object.extension[ + j + ] = $root.google.protobuf.FieldDescriptorProto.toObject( + message.extension[j], + options + ) + } + if ( + message.options != null && + message.hasOwnProperty('options') + ) + object.options = $root.google.protobuf.FileOptions.toObject( + message.options, + options + ) + if ( + message.sourceCodeInfo != null && + message.hasOwnProperty('sourceCodeInfo') + ) + object.sourceCodeInfo = $root.google.protobuf.SourceCodeInfo.toObject( + message.sourceCodeInfo, + options + ) + if ( + message.publicDependency && + message.publicDependency.length + ) { + object.publicDependency = [] + for (var j = 0; j < message.publicDependency.length; ++j) + object.publicDependency[j] = message.publicDependency[j] + } + if (message.weakDependency && message.weakDependency.length) { + object.weakDependency = [] + for (var j = 0; j < message.weakDependency.length; ++j) + object.weakDependency[j] = message.weakDependency[j] + } + if (message.syntax != null && message.hasOwnProperty('syntax')) + object.syntax = message.syntax + return object + } + + /** + * Converts this FileDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.FileDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + FileDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return FileDescriptorProto + })() + + protobuf.DescriptorProto = (function () { + /** + * Properties of a DescriptorProto. + * @memberof google.protobuf + * @interface IDescriptorProto + * @property {string|null} [name] DescriptorProto name + * @property {Array.|null} [field] DescriptorProto field + * @property {Array.|null} [extension] DescriptorProto extension + * @property {Array.|null} [nestedType] DescriptorProto nestedType + * @property {Array.|null} [enumType] DescriptorProto enumType + * @property {Array.|null} [extensionRange] DescriptorProto extensionRange + * @property {Array.|null} [oneofDecl] DescriptorProto oneofDecl + * @property {google.protobuf.IMessageOptions|null} [options] DescriptorProto options + * @property {Array.|null} [reservedRange] DescriptorProto reservedRange + * @property {Array.|null} [reservedName] DescriptorProto reservedName + */ + + /** + * Constructs a new DescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a DescriptorProto. + * @implements IDescriptorProto + * @constructor + * @param {google.protobuf.IDescriptorProto=} [properties] Properties to set + */ + function DescriptorProto(properties) { + this.field = [] + this.extension = [] + this.nestedType = [] + this.enumType = [] + this.extensionRange = [] + this.oneofDecl = [] + this.reservedRange = [] + this.reservedName = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * DescriptorProto name. + * @member {string} name + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.name = '' + + /** + * DescriptorProto field. + * @member {Array.} field + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.field = $util.emptyArray + + /** + * DescriptorProto extension. + * @member {Array.} extension + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.extension = $util.emptyArray + + /** + * DescriptorProto nestedType. + * @member {Array.} nestedType + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.nestedType = $util.emptyArray + + /** + * DescriptorProto enumType. + * @member {Array.} enumType + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.enumType = $util.emptyArray + + /** + * DescriptorProto extensionRange. + * @member {Array.} extensionRange + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.extensionRange = $util.emptyArray + + /** + * DescriptorProto oneofDecl. + * @member {Array.} oneofDecl + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.oneofDecl = $util.emptyArray + + /** + * DescriptorProto options. + * @member {google.protobuf.IMessageOptions|null|undefined} options + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.options = null + + /** + * DescriptorProto reservedRange. + * @member {Array.} reservedRange + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.reservedRange = $util.emptyArray + + /** + * DescriptorProto reservedName. + * @member {Array.} reservedName + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.reservedName = $util.emptyArray + + /** + * Creates a new DescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.DescriptorProto + * @static + * @param {google.protobuf.IDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.DescriptorProto} DescriptorProto instance + */ + DescriptorProto.create = function create(properties) { + return new DescriptorProto(properties) + } + + /** + * Encodes the specified DescriptorProto message. Does not implicitly {@link google.protobuf.DescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.DescriptorProto + * @static + * @param {google.protobuf.IDescriptorProto} message DescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DescriptorProto.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.name != null && message.hasOwnProperty('name')) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.name) + if (message.field != null && message.field.length) + for (var i = 0; i < message.field.length; ++i) + $root.google.protobuf.FieldDescriptorProto.encode( + message.field[i], + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + ).ldelim() + if (message.nestedType != null && message.nestedType.length) + for (var i = 0; i < message.nestedType.length; ++i) + $root.google.protobuf.DescriptorProto.encode( + message.nestedType[i], + writer.uint32(/* id 3, wireType 2 =*/ 26).fork() + ).ldelim() + if (message.enumType != null && message.enumType.length) + for (var i = 0; i < message.enumType.length; ++i) + $root.google.protobuf.EnumDescriptorProto.encode( + message.enumType[i], + writer.uint32(/* id 4, wireType 2 =*/ 34).fork() + ).ldelim() + if ( + message.extensionRange != null && + message.extensionRange.length + ) + for (var i = 0; i < message.extensionRange.length; ++i) + $root.google.protobuf.DescriptorProto.ExtensionRange.encode( + message.extensionRange[i], + writer.uint32(/* id 5, wireType 2 =*/ 42).fork() + ).ldelim() + if (message.extension != null && message.extension.length) + for (var i = 0; i < message.extension.length; ++i) + $root.google.protobuf.FieldDescriptorProto.encode( + message.extension[i], + writer.uint32(/* id 6, wireType 2 =*/ 50).fork() + ).ldelim() + if ( + message.options != null && + message.hasOwnProperty('options') + ) + $root.google.protobuf.MessageOptions.encode( + message.options, + writer.uint32(/* id 7, wireType 2 =*/ 58).fork() + ).ldelim() + if (message.oneofDecl != null && message.oneofDecl.length) + for (var i = 0; i < message.oneofDecl.length; ++i) + $root.google.protobuf.OneofDescriptorProto.encode( + message.oneofDecl[i], + writer.uint32(/* id 8, wireType 2 =*/ 66).fork() + ).ldelim() + if ( + message.reservedRange != null && + message.reservedRange.length + ) + for (var i = 0; i < message.reservedRange.length; ++i) + $root.google.protobuf.DescriptorProto.ReservedRange.encode( + message.reservedRange[i], + writer.uint32(/* id 9, wireType 2 =*/ 74).fork() + ).ldelim() + if (message.reservedName != null && message.reservedName.length) + for (var i = 0; i < message.reservedName.length; ++i) + writer + .uint32(/* id 10, wireType 2 =*/ 82) + .string(message.reservedName[i]) + return writer + } + + /** + * Encodes the specified DescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.DescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.DescriptorProto + * @static + * @param {google.protobuf.IDescriptorProto} message DescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DescriptorProto.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a DescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.DescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.DescriptorProto} DescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DescriptorProto.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.DescriptorProto() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + case 2: + if (!(message.field && message.field.length)) + message.field = [] + message.field.push( + $root.google.protobuf.FieldDescriptorProto.decode( + reader, + reader.uint32() + ) + ) + break + case 6: + if (!(message.extension && message.extension.length)) + message.extension = [] + message.extension.push( + $root.google.protobuf.FieldDescriptorProto.decode( + reader, + reader.uint32() + ) + ) + break + case 3: + if (!(message.nestedType && message.nestedType.length)) + message.nestedType = [] + message.nestedType.push( + $root.google.protobuf.DescriptorProto.decode( + reader, + reader.uint32() + ) + ) + break + case 4: + if (!(message.enumType && message.enumType.length)) + message.enumType = [] + message.enumType.push( + $root.google.protobuf.EnumDescriptorProto.decode( + reader, + reader.uint32() + ) + ) + break + case 5: + if ( + !( + message.extensionRange && + message.extensionRange.length + ) + ) + message.extensionRange = [] + message.extensionRange.push( + $root.google.protobuf.DescriptorProto.ExtensionRange.decode( + reader, + reader.uint32() + ) + ) + break + case 8: + if (!(message.oneofDecl && message.oneofDecl.length)) + message.oneofDecl = [] + message.oneofDecl.push( + $root.google.protobuf.OneofDescriptorProto.decode( + reader, + reader.uint32() + ) + ) + break + case 7: + message.options = $root.google.protobuf.MessageOptions.decode( + reader, + reader.uint32() + ) + break + case 9: + if ( + !(message.reservedRange && message.reservedRange.length) + ) + message.reservedRange = [] + message.reservedRange.push( + $root.google.protobuf.DescriptorProto.ReservedRange.decode( + reader, + reader.uint32() + ) + ) + break + case 10: + if ( + !(message.reservedName && message.reservedName.length) + ) + message.reservedName = [] + message.reservedName.push(reader.string()) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a DescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.DescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.DescriptorProto} DescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DescriptorProto.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a DescriptorProto message. + * @function verify + * @memberof google.protobuf.DescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DescriptorProto.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + if (message.field != null && message.hasOwnProperty('field')) { + if (!Array.isArray(message.field)) + return 'field: array expected' + for (var i = 0; i < message.field.length; ++i) { + var error = $root.google.protobuf.FieldDescriptorProto.verify( + message.field[i] + ) + if (error) return 'field.' + error + } + } + if ( + message.extension != null && + message.hasOwnProperty('extension') + ) { + if (!Array.isArray(message.extension)) + return 'extension: array expected' + for (var i = 0; i < message.extension.length; ++i) { + var error = $root.google.protobuf.FieldDescriptorProto.verify( + message.extension[i] + ) + if (error) return 'extension.' + error + } + } + if ( + message.nestedType != null && + message.hasOwnProperty('nestedType') + ) { + if (!Array.isArray(message.nestedType)) + return 'nestedType: array expected' + for (var i = 0; i < message.nestedType.length; ++i) { + var error = $root.google.protobuf.DescriptorProto.verify( + message.nestedType[i] + ) + if (error) return 'nestedType.' + error + } + } + if ( + message.enumType != null && + message.hasOwnProperty('enumType') + ) { + if (!Array.isArray(message.enumType)) + return 'enumType: array expected' + for (var i = 0; i < message.enumType.length; ++i) { + var error = $root.google.protobuf.EnumDescriptorProto.verify( + message.enumType[i] + ) + if (error) return 'enumType.' + error + } + } + if ( + message.extensionRange != null && + message.hasOwnProperty('extensionRange') + ) { + if (!Array.isArray(message.extensionRange)) + return 'extensionRange: array expected' + for (var i = 0; i < message.extensionRange.length; ++i) { + var error = $root.google.protobuf.DescriptorProto.ExtensionRange.verify( + message.extensionRange[i] + ) + if (error) return 'extensionRange.' + error + } + } + if ( + message.oneofDecl != null && + message.hasOwnProperty('oneofDecl') + ) { + if (!Array.isArray(message.oneofDecl)) + return 'oneofDecl: array expected' + for (var i = 0; i < message.oneofDecl.length; ++i) { + var error = $root.google.protobuf.OneofDescriptorProto.verify( + message.oneofDecl[i] + ) + if (error) return 'oneofDecl.' + error + } + } + if ( + message.options != null && + message.hasOwnProperty('options') + ) { + var error = $root.google.protobuf.MessageOptions.verify( + message.options + ) + if (error) return 'options.' + error + } + if ( + message.reservedRange != null && + message.hasOwnProperty('reservedRange') + ) { + if (!Array.isArray(message.reservedRange)) + return 'reservedRange: array expected' + for (var i = 0; i < message.reservedRange.length; ++i) { + var error = $root.google.protobuf.DescriptorProto.ReservedRange.verify( + message.reservedRange[i] + ) + if (error) return 'reservedRange.' + error + } + } + if ( + message.reservedName != null && + message.hasOwnProperty('reservedName') + ) { + if (!Array.isArray(message.reservedName)) + return 'reservedName: array expected' + for (var i = 0; i < message.reservedName.length; ++i) + if (!$util.isString(message.reservedName[i])) + return 'reservedName: string[] expected' + } + return null + } + + /** + * Creates a DescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.DescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.DescriptorProto} DescriptorProto + */ + DescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.DescriptorProto) + return object + var message = new $root.google.protobuf.DescriptorProto() + if (object.name != null) message.name = String(object.name) + if (object.field) { + if (!Array.isArray(object.field)) + throw TypeError( + '.google.protobuf.DescriptorProto.field: array expected' + ) + message.field = [] + for (var i = 0; i < object.field.length; ++i) { + if (typeof object.field[i] !== 'object') + throw TypeError( + '.google.protobuf.DescriptorProto.field: object expected' + ) + message.field[ + i + ] = $root.google.protobuf.FieldDescriptorProto.fromObject( + object.field[i] + ) + } + } + if (object.extension) { + if (!Array.isArray(object.extension)) + throw TypeError( + '.google.protobuf.DescriptorProto.extension: array expected' + ) + message.extension = [] + for (var i = 0; i < object.extension.length; ++i) { + if (typeof object.extension[i] !== 'object') + throw TypeError( + '.google.protobuf.DescriptorProto.extension: object expected' + ) + message.extension[ + i + ] = $root.google.protobuf.FieldDescriptorProto.fromObject( + object.extension[i] + ) + } + } + if (object.nestedType) { + if (!Array.isArray(object.nestedType)) + throw TypeError( + '.google.protobuf.DescriptorProto.nestedType: array expected' + ) + message.nestedType = [] + for (var i = 0; i < object.nestedType.length; ++i) { + if (typeof object.nestedType[i] !== 'object') + throw TypeError( + '.google.protobuf.DescriptorProto.nestedType: object expected' + ) + message.nestedType[ + i + ] = $root.google.protobuf.DescriptorProto.fromObject( + object.nestedType[i] + ) + } + } + if (object.enumType) { + if (!Array.isArray(object.enumType)) + throw TypeError( + '.google.protobuf.DescriptorProto.enumType: array expected' + ) + message.enumType = [] + for (var i = 0; i < object.enumType.length; ++i) { + if (typeof object.enumType[i] !== 'object') + throw TypeError( + '.google.protobuf.DescriptorProto.enumType: object expected' + ) + message.enumType[ + i + ] = $root.google.protobuf.EnumDescriptorProto.fromObject( + object.enumType[i] + ) + } + } + if (object.extensionRange) { + if (!Array.isArray(object.extensionRange)) + throw TypeError( + '.google.protobuf.DescriptorProto.extensionRange: array expected' + ) + message.extensionRange = [] + for (var i = 0; i < object.extensionRange.length; ++i) { + if (typeof object.extensionRange[i] !== 'object') + throw TypeError( + '.google.protobuf.DescriptorProto.extensionRange: object expected' + ) + message.extensionRange[ + i + ] = $root.google.protobuf.DescriptorProto.ExtensionRange.fromObject( + object.extensionRange[i] + ) + } + } + if (object.oneofDecl) { + if (!Array.isArray(object.oneofDecl)) + throw TypeError( + '.google.protobuf.DescriptorProto.oneofDecl: array expected' + ) + message.oneofDecl = [] + for (var i = 0; i < object.oneofDecl.length; ++i) { + if (typeof object.oneofDecl[i] !== 'object') + throw TypeError( + '.google.protobuf.DescriptorProto.oneofDecl: object expected' + ) + message.oneofDecl[ + i + ] = $root.google.protobuf.OneofDescriptorProto.fromObject( + object.oneofDecl[i] + ) + } + } + if (object.options != null) { + if (typeof object.options !== 'object') + throw TypeError( + '.google.protobuf.DescriptorProto.options: object expected' + ) + message.options = $root.google.protobuf.MessageOptions.fromObject( + object.options + ) + } + if (object.reservedRange) { + if (!Array.isArray(object.reservedRange)) + throw TypeError( + '.google.protobuf.DescriptorProto.reservedRange: array expected' + ) + message.reservedRange = [] + for (var i = 0; i < object.reservedRange.length; ++i) { + if (typeof object.reservedRange[i] !== 'object') + throw TypeError( + '.google.protobuf.DescriptorProto.reservedRange: object expected' + ) + message.reservedRange[ + i + ] = $root.google.protobuf.DescriptorProto.ReservedRange.fromObject( + object.reservedRange[i] + ) + } + } + if (object.reservedName) { + if (!Array.isArray(object.reservedName)) + throw TypeError( + '.google.protobuf.DescriptorProto.reservedName: array expected' + ) + message.reservedName = [] + for (var i = 0; i < object.reservedName.length; ++i) + message.reservedName[i] = String(object.reservedName[i]) + } + return message + } + + /** + * Creates a plain object from a DescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.DescriptorProto + * @static + * @param {google.protobuf.DescriptorProto} message DescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DescriptorProto.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) { + object.field = [] + object.nestedType = [] + object.enumType = [] + object.extensionRange = [] + object.extension = [] + object.oneofDecl = [] + object.reservedRange = [] + object.reservedName = [] + } + if (options.defaults) { + object.name = '' + object.options = null + } + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + if (message.field && message.field.length) { + object.field = [] + for (var j = 0; j < message.field.length; ++j) + object.field[ + j + ] = $root.google.protobuf.FieldDescriptorProto.toObject( + message.field[j], + options + ) + } + if (message.nestedType && message.nestedType.length) { + object.nestedType = [] + for (var j = 0; j < message.nestedType.length; ++j) + object.nestedType[ + j + ] = $root.google.protobuf.DescriptorProto.toObject( + message.nestedType[j], + options + ) + } + if (message.enumType && message.enumType.length) { + object.enumType = [] + for (var j = 0; j < message.enumType.length; ++j) + object.enumType[ + j + ] = $root.google.protobuf.EnumDescriptorProto.toObject( + message.enumType[j], + options + ) + } + if (message.extensionRange && message.extensionRange.length) { + object.extensionRange = [] + for (var j = 0; j < message.extensionRange.length; ++j) + object.extensionRange[ + j + ] = $root.google.protobuf.DescriptorProto.ExtensionRange.toObject( + message.extensionRange[j], + options + ) + } + if (message.extension && message.extension.length) { + object.extension = [] + for (var j = 0; j < message.extension.length; ++j) + object.extension[ + j + ] = $root.google.protobuf.FieldDescriptorProto.toObject( + message.extension[j], + options + ) + } + if ( + message.options != null && + message.hasOwnProperty('options') + ) + object.options = $root.google.protobuf.MessageOptions.toObject( + message.options, + options + ) + if (message.oneofDecl && message.oneofDecl.length) { + object.oneofDecl = [] + for (var j = 0; j < message.oneofDecl.length; ++j) + object.oneofDecl[ + j + ] = $root.google.protobuf.OneofDescriptorProto.toObject( + message.oneofDecl[j], + options + ) + } + if (message.reservedRange && message.reservedRange.length) { + object.reservedRange = [] + for (var j = 0; j < message.reservedRange.length; ++j) + object.reservedRange[ + j + ] = $root.google.protobuf.DescriptorProto.ReservedRange.toObject( + message.reservedRange[j], + options + ) + } + if (message.reservedName && message.reservedName.length) { + object.reservedName = [] + for (var j = 0; j < message.reservedName.length; ++j) + object.reservedName[j] = message.reservedName[j] + } + return object + } + + /** + * Converts this DescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.DescriptorProto + * @instance + * @returns {Object.} JSON object + */ + DescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + DescriptorProto.ExtensionRange = (function () { + /** + * Properties of an ExtensionRange. + * @memberof google.protobuf.DescriptorProto + * @interface IExtensionRange + * @property {number|null} [start] ExtensionRange start + * @property {number|null} [end] ExtensionRange end + * @property {google.protobuf.IExtensionRangeOptions|null} [options] ExtensionRange options + */ + + /** + * Constructs a new ExtensionRange. + * @memberof google.protobuf.DescriptorProto + * @classdesc Represents an ExtensionRange. + * @implements IExtensionRange + * @constructor + * @param {google.protobuf.DescriptorProto.IExtensionRange=} [properties] Properties to set + */ + function ExtensionRange(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * ExtensionRange start. + * @member {number} start + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @instance + */ + ExtensionRange.prototype.start = 0 + + /** + * ExtensionRange end. + * @member {number} end + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @instance + */ + ExtensionRange.prototype.end = 0 + + /** + * ExtensionRange options. + * @member {google.protobuf.IExtensionRangeOptions|null|undefined} options + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @instance + */ + ExtensionRange.prototype.options = null + + /** + * Creates a new ExtensionRange instance using the specified properties. + * @function create + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {google.protobuf.DescriptorProto.IExtensionRange=} [properties] Properties to set + * @returns {google.protobuf.DescriptorProto.ExtensionRange} ExtensionRange instance + */ + ExtensionRange.create = function create(properties) { + return new ExtensionRange(properties) + } + + /** + * Encodes the specified ExtensionRange message. Does not implicitly {@link google.protobuf.DescriptorProto.ExtensionRange.verify|verify} messages. + * @function encode + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {google.protobuf.DescriptorProto.IExtensionRange} message ExtensionRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExtensionRange.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.start != null && message.hasOwnProperty('start')) + writer + .uint32(/* id 1, wireType 0 =*/ 8) + .int32(message.start) + if (message.end != null && message.hasOwnProperty('end')) + writer.uint32(/* id 2, wireType 0 =*/ 16).int32(message.end) + if ( + message.options != null && + message.hasOwnProperty('options') + ) + $root.google.protobuf.ExtensionRangeOptions.encode( + message.options, + writer.uint32(/* id 3, wireType 2 =*/ 26).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified ExtensionRange message, length delimited. Does not implicitly {@link google.protobuf.DescriptorProto.ExtensionRange.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {google.protobuf.DescriptorProto.IExtensionRange} message ExtensionRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExtensionRange.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an ExtensionRange message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.DescriptorProto.ExtensionRange} ExtensionRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExtensionRange.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.DescriptorProto.ExtensionRange() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.start = reader.int32() + break + case 2: + message.end = reader.int32() + break + case 3: + message.options = $root.google.protobuf.ExtensionRangeOptions.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an ExtensionRange message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.DescriptorProto.ExtensionRange} ExtensionRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExtensionRange.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an ExtensionRange message. + * @function verify + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExtensionRange.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.start != null && message.hasOwnProperty('start')) + if (!$util.isInteger(message.start)) + return 'start: integer expected' + if (message.end != null && message.hasOwnProperty('end')) + if (!$util.isInteger(message.end)) + return 'end: integer expected' + if ( + message.options != null && + message.hasOwnProperty('options') + ) { + var error = $root.google.protobuf.ExtensionRangeOptions.verify( + message.options + ) + if (error) return 'options.' + error + } + return null + } + + /** + * Creates an ExtensionRange message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.DescriptorProto.ExtensionRange} ExtensionRange + */ + ExtensionRange.fromObject = function fromObject(object) { + if ( + object instanceof + $root.google.protobuf.DescriptorProto.ExtensionRange + ) + return object + var message = new $root.google.protobuf.DescriptorProto.ExtensionRange() + if (object.start != null) message.start = object.start | 0 + if (object.end != null) message.end = object.end | 0 + if (object.options != null) { + if (typeof object.options !== 'object') + throw TypeError( + '.google.protobuf.DescriptorProto.ExtensionRange.options: object expected' + ) + message.options = $root.google.protobuf.ExtensionRangeOptions.fromObject( + object.options + ) + } + return message + } + + /** + * Creates a plain object from an ExtensionRange message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {google.protobuf.DescriptorProto.ExtensionRange} message ExtensionRange + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExtensionRange.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.start = 0 + object.end = 0 + object.options = null + } + if (message.start != null && message.hasOwnProperty('start')) + object.start = message.start + if (message.end != null && message.hasOwnProperty('end')) + object.end = message.end + if ( + message.options != null && + message.hasOwnProperty('options') + ) + object.options = $root.google.protobuf.ExtensionRangeOptions.toObject( + message.options, + options + ) + return object + } + + /** + * Converts this ExtensionRange to JSON. + * @function toJSON + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @instance + * @returns {Object.} JSON object + */ + ExtensionRange.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return ExtensionRange + })() + + DescriptorProto.ReservedRange = (function () { + /** + * Properties of a ReservedRange. + * @memberof google.protobuf.DescriptorProto + * @interface IReservedRange + * @property {number|null} [start] ReservedRange start + * @property {number|null} [end] ReservedRange end + */ + + /** + * Constructs a new ReservedRange. + * @memberof google.protobuf.DescriptorProto + * @classdesc Represents a ReservedRange. + * @implements IReservedRange + * @constructor + * @param {google.protobuf.DescriptorProto.IReservedRange=} [properties] Properties to set + */ + function ReservedRange(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * ReservedRange start. + * @member {number} start + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @instance + */ + ReservedRange.prototype.start = 0 + + /** + * ReservedRange end. + * @member {number} end + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @instance + */ + ReservedRange.prototype.end = 0 + + /** + * Creates a new ReservedRange instance using the specified properties. + * @function create + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {google.protobuf.DescriptorProto.IReservedRange=} [properties] Properties to set + * @returns {google.protobuf.DescriptorProto.ReservedRange} ReservedRange instance + */ + ReservedRange.create = function create(properties) { + return new ReservedRange(properties) + } + + /** + * Encodes the specified ReservedRange message. Does not implicitly {@link google.protobuf.DescriptorProto.ReservedRange.verify|verify} messages. + * @function encode + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {google.protobuf.DescriptorProto.IReservedRange} message ReservedRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReservedRange.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.start != null && message.hasOwnProperty('start')) + writer + .uint32(/* id 1, wireType 0 =*/ 8) + .int32(message.start) + if (message.end != null && message.hasOwnProperty('end')) + writer.uint32(/* id 2, wireType 0 =*/ 16).int32(message.end) + return writer + } + + /** + * Encodes the specified ReservedRange message, length delimited. Does not implicitly {@link google.protobuf.DescriptorProto.ReservedRange.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {google.protobuf.DescriptorProto.IReservedRange} message ReservedRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReservedRange.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a ReservedRange message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.DescriptorProto.ReservedRange} ReservedRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReservedRange.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.DescriptorProto.ReservedRange() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.start = reader.int32() + break + case 2: + message.end = reader.int32() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a ReservedRange message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.DescriptorProto.ReservedRange} ReservedRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReservedRange.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a ReservedRange message. + * @function verify + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ReservedRange.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.start != null && message.hasOwnProperty('start')) + if (!$util.isInteger(message.start)) + return 'start: integer expected' + if (message.end != null && message.hasOwnProperty('end')) + if (!$util.isInteger(message.end)) + return 'end: integer expected' + return null + } + + /** + * Creates a ReservedRange message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.DescriptorProto.ReservedRange} ReservedRange + */ + ReservedRange.fromObject = function fromObject(object) { + if ( + object instanceof + $root.google.protobuf.DescriptorProto.ReservedRange + ) + return object + var message = new $root.google.protobuf.DescriptorProto.ReservedRange() + if (object.start != null) message.start = object.start | 0 + if (object.end != null) message.end = object.end | 0 + return message + } + + /** + * Creates a plain object from a ReservedRange message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {google.protobuf.DescriptorProto.ReservedRange} message ReservedRange + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ReservedRange.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.start = 0 + object.end = 0 + } + if (message.start != null && message.hasOwnProperty('start')) + object.start = message.start + if (message.end != null && message.hasOwnProperty('end')) + object.end = message.end + return object + } + + /** + * Converts this ReservedRange to JSON. + * @function toJSON + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @instance + * @returns {Object.} JSON object + */ + ReservedRange.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return ReservedRange + })() + + return DescriptorProto + })() + + protobuf.ExtensionRangeOptions = (function () { + /** + * Properties of an ExtensionRangeOptions. + * @memberof google.protobuf + * @interface IExtensionRangeOptions + * @property {Array.|null} [uninterpretedOption] ExtensionRangeOptions uninterpretedOption + */ + + /** + * Constructs a new ExtensionRangeOptions. + * @memberof google.protobuf + * @classdesc Represents an ExtensionRangeOptions. + * @implements IExtensionRangeOptions + * @constructor + * @param {google.protobuf.IExtensionRangeOptions=} [properties] Properties to set + */ + function ExtensionRangeOptions(properties) { + this.uninterpretedOption = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * ExtensionRangeOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.ExtensionRangeOptions + * @instance + */ + ExtensionRangeOptions.prototype.uninterpretedOption = + $util.emptyArray + + /** + * Creates a new ExtensionRangeOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.ExtensionRangeOptions + * @static + * @param {google.protobuf.IExtensionRangeOptions=} [properties] Properties to set + * @returns {google.protobuf.ExtensionRangeOptions} ExtensionRangeOptions instance + */ + ExtensionRangeOptions.create = function create(properties) { + return new ExtensionRangeOptions(properties) + } + + /** + * Encodes the specified ExtensionRangeOptions message. Does not implicitly {@link google.protobuf.ExtensionRangeOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.ExtensionRangeOptions + * @static + * @param {google.protobuf.IExtensionRangeOptions} message ExtensionRangeOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExtensionRangeOptions.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.uninterpretedOption != null && + message.uninterpretedOption.length + ) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode( + message.uninterpretedOption[i], + writer.uint32(/* id 999, wireType 2 =*/ 7994).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified ExtensionRangeOptions message, length delimited. Does not implicitly {@link google.protobuf.ExtensionRangeOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.ExtensionRangeOptions + * @static + * @param {google.protobuf.IExtensionRangeOptions} message ExtensionRangeOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExtensionRangeOptions.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an ExtensionRangeOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.ExtensionRangeOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.ExtensionRangeOptions} ExtensionRangeOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExtensionRangeOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.ExtensionRangeOptions() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 999: + if ( + !( + message.uninterpretedOption && + message.uninterpretedOption.length + ) + ) + message.uninterpretedOption = [] + message.uninterpretedOption.push( + $root.google.protobuf.UninterpretedOption.decode( + reader, + reader.uint32() + ) + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an ExtensionRangeOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.ExtensionRangeOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.ExtensionRangeOptions} ExtensionRangeOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExtensionRangeOptions.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an ExtensionRangeOptions message. + * @function verify + * @memberof google.protobuf.ExtensionRangeOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExtensionRangeOptions.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.uninterpretedOption != null && + message.hasOwnProperty('uninterpretedOption') + ) { + if (!Array.isArray(message.uninterpretedOption)) + return 'uninterpretedOption: array expected' + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify( + message.uninterpretedOption[i] + ) + if (error) return 'uninterpretedOption.' + error + } + } + return null + } + + /** + * Creates an ExtensionRangeOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.ExtensionRangeOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.ExtensionRangeOptions} ExtensionRangeOptions + */ + ExtensionRangeOptions.fromObject = function fromObject(object) { + if ( + object instanceof $root.google.protobuf.ExtensionRangeOptions + ) + return object + var message = new $root.google.protobuf.ExtensionRangeOptions() + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError( + '.google.protobuf.ExtensionRangeOptions.uninterpretedOption: array expected' + ) + message.uninterpretedOption = [] + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== 'object') + throw TypeError( + '.google.protobuf.ExtensionRangeOptions.uninterpretedOption: object expected' + ) + message.uninterpretedOption[ + i + ] = $root.google.protobuf.UninterpretedOption.fromObject( + object.uninterpretedOption[i] + ) + } + } + return message + } + + /** + * Creates a plain object from an ExtensionRangeOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.ExtensionRangeOptions + * @static + * @param {google.protobuf.ExtensionRangeOptions} message ExtensionRangeOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExtensionRangeOptions.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) + object.uninterpretedOption = [] + if ( + message.uninterpretedOption && + message.uninterpretedOption.length + ) { + object.uninterpretedOption = [] + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[ + j + ] = $root.google.protobuf.UninterpretedOption.toObject( + message.uninterpretedOption[j], + options + ) + } + return object + } + + /** + * Converts this ExtensionRangeOptions to JSON. + * @function toJSON + * @memberof google.protobuf.ExtensionRangeOptions + * @instance + * @returns {Object.} JSON object + */ + ExtensionRangeOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return ExtensionRangeOptions + })() + + protobuf.FieldDescriptorProto = (function () { + /** + * Properties of a FieldDescriptorProto. + * @memberof google.protobuf + * @interface IFieldDescriptorProto + * @property {string|null} [name] FieldDescriptorProto name + * @property {number|null} [number] FieldDescriptorProto number + * @property {google.protobuf.FieldDescriptorProto.Label|null} [label] FieldDescriptorProto label + * @property {google.protobuf.FieldDescriptorProto.Type|null} [type] FieldDescriptorProto type + * @property {string|null} [typeName] FieldDescriptorProto typeName + * @property {string|null} [extendee] FieldDescriptorProto extendee + * @property {string|null} [defaultValue] FieldDescriptorProto defaultValue + * @property {number|null} [oneofIndex] FieldDescriptorProto oneofIndex + * @property {string|null} [jsonName] FieldDescriptorProto jsonName + * @property {google.protobuf.IFieldOptions|null} [options] FieldDescriptorProto options + */ + + /** + * Constructs a new FieldDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a FieldDescriptorProto. + * @implements IFieldDescriptorProto + * @constructor + * @param {google.protobuf.IFieldDescriptorProto=} [properties] Properties to set + */ + function FieldDescriptorProto(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * FieldDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.name = '' + + /** + * FieldDescriptorProto number. + * @member {number} number + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.number = 0 + + /** + * FieldDescriptorProto label. + * @member {google.protobuf.FieldDescriptorProto.Label} label + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.label = 1 + + /** + * FieldDescriptorProto type. + * @member {google.protobuf.FieldDescriptorProto.Type} type + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.type = 1 + + /** + * FieldDescriptorProto typeName. + * @member {string} typeName + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.typeName = '' + + /** + * FieldDescriptorProto extendee. + * @member {string} extendee + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.extendee = '' + + /** + * FieldDescriptorProto defaultValue. + * @member {string} defaultValue + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.defaultValue = '' + + /** + * FieldDescriptorProto oneofIndex. + * @member {number} oneofIndex + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.oneofIndex = 0 + + /** + * FieldDescriptorProto jsonName. + * @member {string} jsonName + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.jsonName = '' + + /** + * FieldDescriptorProto options. + * @member {google.protobuf.IFieldOptions|null|undefined} options + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.options = null + + /** + * Creates a new FieldDescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {google.protobuf.IFieldDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.FieldDescriptorProto} FieldDescriptorProto instance + */ + FieldDescriptorProto.create = function create(properties) { + return new FieldDescriptorProto(properties) + } + + /** + * Encodes the specified FieldDescriptorProto message. Does not implicitly {@link google.protobuf.FieldDescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {google.protobuf.IFieldDescriptorProto} message FieldDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FieldDescriptorProto.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.name != null && message.hasOwnProperty('name')) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.name) + if ( + message.extendee != null && + message.hasOwnProperty('extendee') + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.extendee) + if (message.number != null && message.hasOwnProperty('number')) + writer + .uint32(/* id 3, wireType 0 =*/ 24) + .int32(message.number) + if (message.label != null && message.hasOwnProperty('label')) + writer.uint32(/* id 4, wireType 0 =*/ 32).int32(message.label) + if (message.type != null && message.hasOwnProperty('type')) + writer.uint32(/* id 5, wireType 0 =*/ 40).int32(message.type) + if ( + message.typeName != null && + message.hasOwnProperty('typeName') + ) + writer + .uint32(/* id 6, wireType 2 =*/ 50) + .string(message.typeName) + if ( + message.defaultValue != null && + message.hasOwnProperty('defaultValue') + ) + writer + .uint32(/* id 7, wireType 2 =*/ 58) + .string(message.defaultValue) + if ( + message.options != null && + message.hasOwnProperty('options') + ) + $root.google.protobuf.FieldOptions.encode( + message.options, + writer.uint32(/* id 8, wireType 2 =*/ 66).fork() + ).ldelim() + if ( + message.oneofIndex != null && + message.hasOwnProperty('oneofIndex') + ) + writer + .uint32(/* id 9, wireType 0 =*/ 72) + .int32(message.oneofIndex) + if ( + message.jsonName != null && + message.hasOwnProperty('jsonName') + ) + writer + .uint32(/* id 10, wireType 2 =*/ 82) + .string(message.jsonName) + return writer + } + + /** + * Encodes the specified FieldDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.FieldDescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {google.protobuf.IFieldDescriptorProto} message FieldDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FieldDescriptorProto.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a FieldDescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FieldDescriptorProto} FieldDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FieldDescriptorProto.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.FieldDescriptorProto() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + case 3: + message.number = reader.int32() + break + case 4: + message.label = reader.int32() + break + case 5: + message.type = reader.int32() + break + case 6: + message.typeName = reader.string() + break + case 2: + message.extendee = reader.string() + break + case 7: + message.defaultValue = reader.string() + break + case 9: + message.oneofIndex = reader.int32() + break + case 10: + message.jsonName = reader.string() + break + case 8: + message.options = $root.google.protobuf.FieldOptions.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a FieldDescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FieldDescriptorProto} FieldDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FieldDescriptorProto.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a FieldDescriptorProto message. + * @function verify + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FieldDescriptorProto.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + if (message.number != null && message.hasOwnProperty('number')) + if (!$util.isInteger(message.number)) + return 'number: integer expected' + if (message.label != null && message.hasOwnProperty('label')) + switch (message.label) { + default: + return 'label: enum value expected' + case 1: + case 2: + case 3: + break + } + if (message.type != null && message.hasOwnProperty('type')) + switch (message.type) { + default: + return 'type: enum value expected' + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + case 15: + case 16: + case 17: + case 18: + break + } + if ( + message.typeName != null && + message.hasOwnProperty('typeName') + ) + if (!$util.isString(message.typeName)) + return 'typeName: string expected' + if ( + message.extendee != null && + message.hasOwnProperty('extendee') + ) + if (!$util.isString(message.extendee)) + return 'extendee: string expected' + if ( + message.defaultValue != null && + message.hasOwnProperty('defaultValue') + ) + if (!$util.isString(message.defaultValue)) + return 'defaultValue: string expected' + if ( + message.oneofIndex != null && + message.hasOwnProperty('oneofIndex') + ) + if (!$util.isInteger(message.oneofIndex)) + return 'oneofIndex: integer expected' + if ( + message.jsonName != null && + message.hasOwnProperty('jsonName') + ) + if (!$util.isString(message.jsonName)) + return 'jsonName: string expected' + if ( + message.options != null && + message.hasOwnProperty('options') + ) { + var error = $root.google.protobuf.FieldOptions.verify( + message.options + ) + if (error) return 'options.' + error + } + return null + } + + /** + * Creates a FieldDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FieldDescriptorProto} FieldDescriptorProto + */ + FieldDescriptorProto.fromObject = function fromObject(object) { + if ( + object instanceof $root.google.protobuf.FieldDescriptorProto + ) + return object + var message = new $root.google.protobuf.FieldDescriptorProto() + if (object.name != null) message.name = String(object.name) + if (object.number != null) message.number = object.number | 0 + switch (object.label) { + case 'LABEL_OPTIONAL': + case 1: + message.label = 1 + break + case 'LABEL_REQUIRED': + case 2: + message.label = 2 + break + case 'LABEL_REPEATED': + case 3: + message.label = 3 + break + } + switch (object.type) { + case 'TYPE_DOUBLE': + case 1: + message.type = 1 + break + case 'TYPE_FLOAT': + case 2: + message.type = 2 + break + case 'TYPE_INT64': + case 3: + message.type = 3 + break + case 'TYPE_UINT64': + case 4: + message.type = 4 + break + case 'TYPE_INT32': + case 5: + message.type = 5 + break + case 'TYPE_FIXED64': + case 6: + message.type = 6 + break + case 'TYPE_FIXED32': + case 7: + message.type = 7 + break + case 'TYPE_BOOL': + case 8: + message.type = 8 + break + case 'TYPE_STRING': + case 9: + message.type = 9 + break + case 'TYPE_GROUP': + case 10: + message.type = 10 + break + case 'TYPE_MESSAGE': + case 11: + message.type = 11 + break + case 'TYPE_BYTES': + case 12: + message.type = 12 + break + case 'TYPE_UINT32': + case 13: + message.type = 13 + break + case 'TYPE_ENUM': + case 14: + message.type = 14 + break + case 'TYPE_SFIXED32': + case 15: + message.type = 15 + break + case 'TYPE_SFIXED64': + case 16: + message.type = 16 + break + case 'TYPE_SINT32': + case 17: + message.type = 17 + break + case 'TYPE_SINT64': + case 18: + message.type = 18 + break + } + if (object.typeName != null) + message.typeName = String(object.typeName) + if (object.extendee != null) + message.extendee = String(object.extendee) + if (object.defaultValue != null) + message.defaultValue = String(object.defaultValue) + if (object.oneofIndex != null) + message.oneofIndex = object.oneofIndex | 0 + if (object.jsonName != null) + message.jsonName = String(object.jsonName) + if (object.options != null) { + if (typeof object.options !== 'object') + throw TypeError( + '.google.protobuf.FieldDescriptorProto.options: object expected' + ) + message.options = $root.google.protobuf.FieldOptions.fromObject( + object.options + ) + } + return message + } + + /** + * Creates a plain object from a FieldDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {google.protobuf.FieldDescriptorProto} message FieldDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FieldDescriptorProto.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.name = '' + object.extendee = '' + object.number = 0 + object.label = options.enums === String ? 'LABEL_OPTIONAL' : 1 + object.type = options.enums === String ? 'TYPE_DOUBLE' : 1 + object.typeName = '' + object.defaultValue = '' + object.options = null + object.oneofIndex = 0 + object.jsonName = '' + } + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + if ( + message.extendee != null && + message.hasOwnProperty('extendee') + ) + object.extendee = message.extendee + if (message.number != null && message.hasOwnProperty('number')) + object.number = message.number + if (message.label != null && message.hasOwnProperty('label')) + object.label = + options.enums === String + ? $root.google.protobuf.FieldDescriptorProto.Label[ + message.label + ] + : message.label + if (message.type != null && message.hasOwnProperty('type')) + object.type = + options.enums === String + ? $root.google.protobuf.FieldDescriptorProto.Type[ + message.type + ] + : message.type + if ( + message.typeName != null && + message.hasOwnProperty('typeName') + ) + object.typeName = message.typeName + if ( + message.defaultValue != null && + message.hasOwnProperty('defaultValue') + ) + object.defaultValue = message.defaultValue + if ( + message.options != null && + message.hasOwnProperty('options') + ) + object.options = $root.google.protobuf.FieldOptions.toObject( + message.options, + options + ) + if ( + message.oneofIndex != null && + message.hasOwnProperty('oneofIndex') + ) + object.oneofIndex = message.oneofIndex + if ( + message.jsonName != null && + message.hasOwnProperty('jsonName') + ) + object.jsonName = message.jsonName + return object + } + + /** + * Converts this FieldDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.FieldDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + FieldDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + /** + * Type enum. + * @name google.protobuf.FieldDescriptorProto.Type + * @enum {string} + * @property {number} TYPE_DOUBLE=1 TYPE_DOUBLE value + * @property {number} TYPE_FLOAT=2 TYPE_FLOAT value + * @property {number} TYPE_INT64=3 TYPE_INT64 value + * @property {number} TYPE_UINT64=4 TYPE_UINT64 value + * @property {number} TYPE_INT32=5 TYPE_INT32 value + * @property {number} TYPE_FIXED64=6 TYPE_FIXED64 value + * @property {number} TYPE_FIXED32=7 TYPE_FIXED32 value + * @property {number} TYPE_BOOL=8 TYPE_BOOL value + * @property {number} TYPE_STRING=9 TYPE_STRING value + * @property {number} TYPE_GROUP=10 TYPE_GROUP value + * @property {number} TYPE_MESSAGE=11 TYPE_MESSAGE value + * @property {number} TYPE_BYTES=12 TYPE_BYTES value + * @property {number} TYPE_UINT32=13 TYPE_UINT32 value + * @property {number} TYPE_ENUM=14 TYPE_ENUM value + * @property {number} TYPE_SFIXED32=15 TYPE_SFIXED32 value + * @property {number} TYPE_SFIXED64=16 TYPE_SFIXED64 value + * @property {number} TYPE_SINT32=17 TYPE_SINT32 value + * @property {number} TYPE_SINT64=18 TYPE_SINT64 value + */ + FieldDescriptorProto.Type = (function () { + var valuesById = {}, + values = Object.create(valuesById) + values[(valuesById[1] = 'TYPE_DOUBLE')] = 1 + values[(valuesById[2] = 'TYPE_FLOAT')] = 2 + values[(valuesById[3] = 'TYPE_INT64')] = 3 + values[(valuesById[4] = 'TYPE_UINT64')] = 4 + values[(valuesById[5] = 'TYPE_INT32')] = 5 + values[(valuesById[6] = 'TYPE_FIXED64')] = 6 + values[(valuesById[7] = 'TYPE_FIXED32')] = 7 + values[(valuesById[8] = 'TYPE_BOOL')] = 8 + values[(valuesById[9] = 'TYPE_STRING')] = 9 + values[(valuesById[10] = 'TYPE_GROUP')] = 10 + values[(valuesById[11] = 'TYPE_MESSAGE')] = 11 + values[(valuesById[12] = 'TYPE_BYTES')] = 12 + values[(valuesById[13] = 'TYPE_UINT32')] = 13 + values[(valuesById[14] = 'TYPE_ENUM')] = 14 + values[(valuesById[15] = 'TYPE_SFIXED32')] = 15 + values[(valuesById[16] = 'TYPE_SFIXED64')] = 16 + values[(valuesById[17] = 'TYPE_SINT32')] = 17 + values[(valuesById[18] = 'TYPE_SINT64')] = 18 + return values + })() + + /** + * Label enum. + * @name google.protobuf.FieldDescriptorProto.Label + * @enum {string} + * @property {number} LABEL_OPTIONAL=1 LABEL_OPTIONAL value + * @property {number} LABEL_REQUIRED=2 LABEL_REQUIRED value + * @property {number} LABEL_REPEATED=3 LABEL_REPEATED value + */ + FieldDescriptorProto.Label = (function () { + var valuesById = {}, + values = Object.create(valuesById) + values[(valuesById[1] = 'LABEL_OPTIONAL')] = 1 + values[(valuesById[2] = 'LABEL_REQUIRED')] = 2 + values[(valuesById[3] = 'LABEL_REPEATED')] = 3 + return values + })() + + return FieldDescriptorProto + })() + + protobuf.OneofDescriptorProto = (function () { + /** + * Properties of an OneofDescriptorProto. + * @memberof google.protobuf + * @interface IOneofDescriptorProto + * @property {string|null} [name] OneofDescriptorProto name + * @property {google.protobuf.IOneofOptions|null} [options] OneofDescriptorProto options + */ + + /** + * Constructs a new OneofDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents an OneofDescriptorProto. + * @implements IOneofDescriptorProto + * @constructor + * @param {google.protobuf.IOneofDescriptorProto=} [properties] Properties to set + */ + function OneofDescriptorProto(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * OneofDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.OneofDescriptorProto + * @instance + */ + OneofDescriptorProto.prototype.name = '' + + /** + * OneofDescriptorProto options. + * @member {google.protobuf.IOneofOptions|null|undefined} options + * @memberof google.protobuf.OneofDescriptorProto + * @instance + */ + OneofDescriptorProto.prototype.options = null + + /** + * Creates a new OneofDescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {google.protobuf.IOneofDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.OneofDescriptorProto} OneofDescriptorProto instance + */ + OneofDescriptorProto.create = function create(properties) { + return new OneofDescriptorProto(properties) + } + + /** + * Encodes the specified OneofDescriptorProto message. Does not implicitly {@link google.protobuf.OneofDescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {google.protobuf.IOneofDescriptorProto} message OneofDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OneofDescriptorProto.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.name != null && message.hasOwnProperty('name')) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.name) + if ( + message.options != null && + message.hasOwnProperty('options') + ) + $root.google.protobuf.OneofOptions.encode( + message.options, + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified OneofDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.OneofDescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {google.protobuf.IOneofDescriptorProto} message OneofDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OneofDescriptorProto.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an OneofDescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.OneofDescriptorProto} OneofDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OneofDescriptorProto.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.OneofDescriptorProto() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + case 2: + message.options = $root.google.protobuf.OneofOptions.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an OneofDescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.OneofDescriptorProto} OneofDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OneofDescriptorProto.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an OneofDescriptorProto message. + * @function verify + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + OneofDescriptorProto.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + if ( + message.options != null && + message.hasOwnProperty('options') + ) { + var error = $root.google.protobuf.OneofOptions.verify( + message.options + ) + if (error) return 'options.' + error + } + return null + } + + /** + * Creates an OneofDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.OneofDescriptorProto} OneofDescriptorProto + */ + OneofDescriptorProto.fromObject = function fromObject(object) { + if ( + object instanceof $root.google.protobuf.OneofDescriptorProto + ) + return object + var message = new $root.google.protobuf.OneofDescriptorProto() + if (object.name != null) message.name = String(object.name) + if (object.options != null) { + if (typeof object.options !== 'object') + throw TypeError( + '.google.protobuf.OneofDescriptorProto.options: object expected' + ) + message.options = $root.google.protobuf.OneofOptions.fromObject( + object.options + ) + } + return message + } + + /** + * Creates a plain object from an OneofDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {google.protobuf.OneofDescriptorProto} message OneofDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + OneofDescriptorProto.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.name = '' + object.options = null + } + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + if ( + message.options != null && + message.hasOwnProperty('options') + ) + object.options = $root.google.protobuf.OneofOptions.toObject( + message.options, + options + ) + return object + } + + /** + * Converts this OneofDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.OneofDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + OneofDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return OneofDescriptorProto + })() + + protobuf.EnumDescriptorProto = (function () { + /** + * Properties of an EnumDescriptorProto. + * @memberof google.protobuf + * @interface IEnumDescriptorProto + * @property {string|null} [name] EnumDescriptorProto name + * @property {Array.|null} [value] EnumDescriptorProto value + * @property {google.protobuf.IEnumOptions|null} [options] EnumDescriptorProto options + * @property {Array.|null} [reservedRange] EnumDescriptorProto reservedRange + * @property {Array.|null} [reservedName] EnumDescriptorProto reservedName + */ + + /** + * Constructs a new EnumDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents an EnumDescriptorProto. + * @implements IEnumDescriptorProto + * @constructor + * @param {google.protobuf.IEnumDescriptorProto=} [properties] Properties to set + */ + function EnumDescriptorProto(properties) { + this.value = [] + this.reservedRange = [] + this.reservedName = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * EnumDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.name = '' + + /** + * EnumDescriptorProto value. + * @member {Array.} value + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.value = $util.emptyArray + + /** + * EnumDescriptorProto options. + * @member {google.protobuf.IEnumOptions|null|undefined} options + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.options = null + + /** + * EnumDescriptorProto reservedRange. + * @member {Array.} reservedRange + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.reservedRange = $util.emptyArray + + /** + * EnumDescriptorProto reservedName. + * @member {Array.} reservedName + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.reservedName = $util.emptyArray + + /** + * Creates a new EnumDescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {google.protobuf.IEnumDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.EnumDescriptorProto} EnumDescriptorProto instance + */ + EnumDescriptorProto.create = function create(properties) { + return new EnumDescriptorProto(properties) + } + + /** + * Encodes the specified EnumDescriptorProto message. Does not implicitly {@link google.protobuf.EnumDescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {google.protobuf.IEnumDescriptorProto} message EnumDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumDescriptorProto.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.name != null && message.hasOwnProperty('name')) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.name) + if (message.value != null && message.value.length) + for (var i = 0; i < message.value.length; ++i) + $root.google.protobuf.EnumValueDescriptorProto.encode( + message.value[i], + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + ).ldelim() + if ( + message.options != null && + message.hasOwnProperty('options') + ) + $root.google.protobuf.EnumOptions.encode( + message.options, + writer.uint32(/* id 3, wireType 2 =*/ 26).fork() + ).ldelim() + if ( + message.reservedRange != null && + message.reservedRange.length + ) + for (var i = 0; i < message.reservedRange.length; ++i) + $root.google.protobuf.EnumDescriptorProto.EnumReservedRange.encode( + message.reservedRange[i], + writer.uint32(/* id 4, wireType 2 =*/ 34).fork() + ).ldelim() + if (message.reservedName != null && message.reservedName.length) + for (var i = 0; i < message.reservedName.length; ++i) + writer + .uint32(/* id 5, wireType 2 =*/ 42) + .string(message.reservedName[i]) + return writer + } + + /** + * Encodes the specified EnumDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.EnumDescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {google.protobuf.IEnumDescriptorProto} message EnumDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumDescriptorProto.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an EnumDescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.EnumDescriptorProto} EnumDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumDescriptorProto.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.EnumDescriptorProto() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + case 2: + if (!(message.value && message.value.length)) + message.value = [] + message.value.push( + $root.google.protobuf.EnumValueDescriptorProto.decode( + reader, + reader.uint32() + ) + ) + break + case 3: + message.options = $root.google.protobuf.EnumOptions.decode( + reader, + reader.uint32() + ) + break + case 4: + if ( + !(message.reservedRange && message.reservedRange.length) + ) + message.reservedRange = [] + message.reservedRange.push( + $root.google.protobuf.EnumDescriptorProto.EnumReservedRange.decode( + reader, + reader.uint32() + ) + ) + break + case 5: + if ( + !(message.reservedName && message.reservedName.length) + ) + message.reservedName = [] + message.reservedName.push(reader.string()) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an EnumDescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.EnumDescriptorProto} EnumDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumDescriptorProto.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an EnumDescriptorProto message. + * @function verify + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + EnumDescriptorProto.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + if (message.value != null && message.hasOwnProperty('value')) { + if (!Array.isArray(message.value)) + return 'value: array expected' + for (var i = 0; i < message.value.length; ++i) { + var error = $root.google.protobuf.EnumValueDescriptorProto.verify( + message.value[i] + ) + if (error) return 'value.' + error + } + } + if ( + message.options != null && + message.hasOwnProperty('options') + ) { + var error = $root.google.protobuf.EnumOptions.verify( + message.options + ) + if (error) return 'options.' + error + } + if ( + message.reservedRange != null && + message.hasOwnProperty('reservedRange') + ) { + if (!Array.isArray(message.reservedRange)) + return 'reservedRange: array expected' + for (var i = 0; i < message.reservedRange.length; ++i) { + var error = $root.google.protobuf.EnumDescriptorProto.EnumReservedRange.verify( + message.reservedRange[i] + ) + if (error) return 'reservedRange.' + error + } + } + if ( + message.reservedName != null && + message.hasOwnProperty('reservedName') + ) { + if (!Array.isArray(message.reservedName)) + return 'reservedName: array expected' + for (var i = 0; i < message.reservedName.length; ++i) + if (!$util.isString(message.reservedName[i])) + return 'reservedName: string[] expected' + } + return null + } + + /** + * Creates an EnumDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.EnumDescriptorProto} EnumDescriptorProto + */ + EnumDescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.EnumDescriptorProto) + return object + var message = new $root.google.protobuf.EnumDescriptorProto() + if (object.name != null) message.name = String(object.name) + if (object.value) { + if (!Array.isArray(object.value)) + throw TypeError( + '.google.protobuf.EnumDescriptorProto.value: array expected' + ) + message.value = [] + for (var i = 0; i < object.value.length; ++i) { + if (typeof object.value[i] !== 'object') + throw TypeError( + '.google.protobuf.EnumDescriptorProto.value: object expected' + ) + message.value[ + i + ] = $root.google.protobuf.EnumValueDescriptorProto.fromObject( + object.value[i] + ) + } + } + if (object.options != null) { + if (typeof object.options !== 'object') + throw TypeError( + '.google.protobuf.EnumDescriptorProto.options: object expected' + ) + message.options = $root.google.protobuf.EnumOptions.fromObject( + object.options + ) + } + if (object.reservedRange) { + if (!Array.isArray(object.reservedRange)) + throw TypeError( + '.google.protobuf.EnumDescriptorProto.reservedRange: array expected' + ) + message.reservedRange = [] + for (var i = 0; i < object.reservedRange.length; ++i) { + if (typeof object.reservedRange[i] !== 'object') + throw TypeError( + '.google.protobuf.EnumDescriptorProto.reservedRange: object expected' + ) + message.reservedRange[ + i + ] = $root.google.protobuf.EnumDescriptorProto.EnumReservedRange.fromObject( + object.reservedRange[i] + ) + } + } + if (object.reservedName) { + if (!Array.isArray(object.reservedName)) + throw TypeError( + '.google.protobuf.EnumDescriptorProto.reservedName: array expected' + ) + message.reservedName = [] + for (var i = 0; i < object.reservedName.length; ++i) + message.reservedName[i] = String(object.reservedName[i]) + } + return message + } + + /** + * Creates a plain object from an EnumDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {google.protobuf.EnumDescriptorProto} message EnumDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EnumDescriptorProto.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) { + object.value = [] + object.reservedRange = [] + object.reservedName = [] + } + if (options.defaults) { + object.name = '' + object.options = null + } + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + if (message.value && message.value.length) { + object.value = [] + for (var j = 0; j < message.value.length; ++j) + object.value[ + j + ] = $root.google.protobuf.EnumValueDescriptorProto.toObject( + message.value[j], + options + ) + } + if ( + message.options != null && + message.hasOwnProperty('options') + ) + object.options = $root.google.protobuf.EnumOptions.toObject( + message.options, + options + ) + if (message.reservedRange && message.reservedRange.length) { + object.reservedRange = [] + for (var j = 0; j < message.reservedRange.length; ++j) + object.reservedRange[ + j + ] = $root.google.protobuf.EnumDescriptorProto.EnumReservedRange.toObject( + message.reservedRange[j], + options + ) + } + if (message.reservedName && message.reservedName.length) { + object.reservedName = [] + for (var j = 0; j < message.reservedName.length; ++j) + object.reservedName[j] = message.reservedName[j] + } + return object + } + + /** + * Converts this EnumDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.EnumDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + EnumDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + EnumDescriptorProto.EnumReservedRange = (function () { + /** + * Properties of an EnumReservedRange. + * @memberof google.protobuf.EnumDescriptorProto + * @interface IEnumReservedRange + * @property {number|null} [start] EnumReservedRange start + * @property {number|null} [end] EnumReservedRange end + */ + + /** + * Constructs a new EnumReservedRange. + * @memberof google.protobuf.EnumDescriptorProto + * @classdesc Represents an EnumReservedRange. + * @implements IEnumReservedRange + * @constructor + * @param {google.protobuf.EnumDescriptorProto.IEnumReservedRange=} [properties] Properties to set + */ + function EnumReservedRange(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * EnumReservedRange start. + * @member {number} start + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @instance + */ + EnumReservedRange.prototype.start = 0 + + /** + * EnumReservedRange end. + * @member {number} end + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @instance + */ + EnumReservedRange.prototype.end = 0 + + /** + * Creates a new EnumReservedRange instance using the specified properties. + * @function create + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @static + * @param {google.protobuf.EnumDescriptorProto.IEnumReservedRange=} [properties] Properties to set + * @returns {google.protobuf.EnumDescriptorProto.EnumReservedRange} EnumReservedRange instance + */ + EnumReservedRange.create = function create(properties) { + return new EnumReservedRange(properties) + } + + /** + * Encodes the specified EnumReservedRange message. Does not implicitly {@link google.protobuf.EnumDescriptorProto.EnumReservedRange.verify|verify} messages. + * @function encode + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @static + * @param {google.protobuf.EnumDescriptorProto.IEnumReservedRange} message EnumReservedRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumReservedRange.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.start != null && message.hasOwnProperty('start')) + writer + .uint32(/* id 1, wireType 0 =*/ 8) + .int32(message.start) + if (message.end != null && message.hasOwnProperty('end')) + writer.uint32(/* id 2, wireType 0 =*/ 16).int32(message.end) + return writer + } + + /** + * Encodes the specified EnumReservedRange message, length delimited. Does not implicitly {@link google.protobuf.EnumDescriptorProto.EnumReservedRange.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @static + * @param {google.protobuf.EnumDescriptorProto.IEnumReservedRange} message EnumReservedRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumReservedRange.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an EnumReservedRange message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.EnumDescriptorProto.EnumReservedRange} EnumReservedRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumReservedRange.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.EnumDescriptorProto.EnumReservedRange() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.start = reader.int32() + break + case 2: + message.end = reader.int32() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an EnumReservedRange message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.EnumDescriptorProto.EnumReservedRange} EnumReservedRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumReservedRange.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an EnumReservedRange message. + * @function verify + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + EnumReservedRange.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.start != null && message.hasOwnProperty('start')) + if (!$util.isInteger(message.start)) + return 'start: integer expected' + if (message.end != null && message.hasOwnProperty('end')) + if (!$util.isInteger(message.end)) + return 'end: integer expected' + return null + } + + /** + * Creates an EnumReservedRange message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.EnumDescriptorProto.EnumReservedRange} EnumReservedRange + */ + EnumReservedRange.fromObject = function fromObject(object) { + if ( + object instanceof + $root.google.protobuf.EnumDescriptorProto.EnumReservedRange + ) + return object + var message = new $root.google.protobuf.EnumDescriptorProto.EnumReservedRange() + if (object.start != null) message.start = object.start | 0 + if (object.end != null) message.end = object.end | 0 + return message + } + + /** + * Creates a plain object from an EnumReservedRange message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @static + * @param {google.protobuf.EnumDescriptorProto.EnumReservedRange} message EnumReservedRange + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EnumReservedRange.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.start = 0 + object.end = 0 + } + if (message.start != null && message.hasOwnProperty('start')) + object.start = message.start + if (message.end != null && message.hasOwnProperty('end')) + object.end = message.end + return object + } + + /** + * Converts this EnumReservedRange to JSON. + * @function toJSON + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @instance + * @returns {Object.} JSON object + */ + EnumReservedRange.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return EnumReservedRange + })() + + return EnumDescriptorProto + })() + + protobuf.EnumValueDescriptorProto = (function () { + /** + * Properties of an EnumValueDescriptorProto. + * @memberof google.protobuf + * @interface IEnumValueDescriptorProto + * @property {string|null} [name] EnumValueDescriptorProto name + * @property {number|null} [number] EnumValueDescriptorProto number + * @property {google.protobuf.IEnumValueOptions|null} [options] EnumValueDescriptorProto options + */ + + /** + * Constructs a new EnumValueDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents an EnumValueDescriptorProto. + * @implements IEnumValueDescriptorProto + * @constructor + * @param {google.protobuf.IEnumValueDescriptorProto=} [properties] Properties to set + */ + function EnumValueDescriptorProto(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * EnumValueDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.EnumValueDescriptorProto + * @instance + */ + EnumValueDescriptorProto.prototype.name = '' + + /** + * EnumValueDescriptorProto number. + * @member {number} number + * @memberof google.protobuf.EnumValueDescriptorProto + * @instance + */ + EnumValueDescriptorProto.prototype.number = 0 + + /** + * EnumValueDescriptorProto options. + * @member {google.protobuf.IEnumValueOptions|null|undefined} options + * @memberof google.protobuf.EnumValueDescriptorProto + * @instance + */ + EnumValueDescriptorProto.prototype.options = null + + /** + * Creates a new EnumValueDescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {google.protobuf.IEnumValueDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.EnumValueDescriptorProto} EnumValueDescriptorProto instance + */ + EnumValueDescriptorProto.create = function create(properties) { + return new EnumValueDescriptorProto(properties) + } + + /** + * Encodes the specified EnumValueDescriptorProto message. Does not implicitly {@link google.protobuf.EnumValueDescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {google.protobuf.IEnumValueDescriptorProto} message EnumValueDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumValueDescriptorProto.encode = function encode( + message, + writer + ) { + if (!writer) writer = $Writer.create() + if (message.name != null && message.hasOwnProperty('name')) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.name) + if (message.number != null && message.hasOwnProperty('number')) + writer + .uint32(/* id 2, wireType 0 =*/ 16) + .int32(message.number) + if ( + message.options != null && + message.hasOwnProperty('options') + ) + $root.google.protobuf.EnumValueOptions.encode( + message.options, + writer.uint32(/* id 3, wireType 2 =*/ 26).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified EnumValueDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.EnumValueDescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {google.protobuf.IEnumValueDescriptorProto} message EnumValueDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumValueDescriptorProto.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an EnumValueDescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.EnumValueDescriptorProto} EnumValueDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumValueDescriptorProto.decode = function decode( + reader, + length + ) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.EnumValueDescriptorProto() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + case 2: + message.number = reader.int32() + break + case 3: + message.options = $root.google.protobuf.EnumValueOptions.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an EnumValueDescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.EnumValueDescriptorProto} EnumValueDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumValueDescriptorProto.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an EnumValueDescriptorProto message. + * @function verify + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + EnumValueDescriptorProto.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + if (message.number != null && message.hasOwnProperty('number')) + if (!$util.isInteger(message.number)) + return 'number: integer expected' + if ( + message.options != null && + message.hasOwnProperty('options') + ) { + var error = $root.google.protobuf.EnumValueOptions.verify( + message.options + ) + if (error) return 'options.' + error + } + return null + } + + /** + * Creates an EnumValueDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.EnumValueDescriptorProto} EnumValueDescriptorProto + */ + EnumValueDescriptorProto.fromObject = function fromObject( + object + ) { + if ( + object instanceof + $root.google.protobuf.EnumValueDescriptorProto + ) + return object + var message = new $root.google.protobuf.EnumValueDescriptorProto() + if (object.name != null) message.name = String(object.name) + if (object.number != null) message.number = object.number | 0 + if (object.options != null) { + if (typeof object.options !== 'object') + throw TypeError( + '.google.protobuf.EnumValueDescriptorProto.options: object expected' + ) + message.options = $root.google.protobuf.EnumValueOptions.fromObject( + object.options + ) + } + return message + } + + /** + * Creates a plain object from an EnumValueDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {google.protobuf.EnumValueDescriptorProto} message EnumValueDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EnumValueDescriptorProto.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.name = '' + object.number = 0 + object.options = null + } + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + if (message.number != null && message.hasOwnProperty('number')) + object.number = message.number + if ( + message.options != null && + message.hasOwnProperty('options') + ) + object.options = $root.google.protobuf.EnumValueOptions.toObject( + message.options, + options + ) + return object + } + + /** + * Converts this EnumValueDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.EnumValueDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + EnumValueDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return EnumValueDescriptorProto + })() + + protobuf.ServiceDescriptorProto = (function () { + /** + * Properties of a ServiceDescriptorProto. + * @memberof google.protobuf + * @interface IServiceDescriptorProto + * @property {string|null} [name] ServiceDescriptorProto name + * @property {Array.|null} [method] ServiceDescriptorProto method + * @property {google.protobuf.IServiceOptions|null} [options] ServiceDescriptorProto options + */ + + /** + * Constructs a new ServiceDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a ServiceDescriptorProto. + * @implements IServiceDescriptorProto + * @constructor + * @param {google.protobuf.IServiceDescriptorProto=} [properties] Properties to set + */ + function ServiceDescriptorProto(properties) { + this.method = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * ServiceDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.ServiceDescriptorProto + * @instance + */ + ServiceDescriptorProto.prototype.name = '' + + /** + * ServiceDescriptorProto method. + * @member {Array.} method + * @memberof google.protobuf.ServiceDescriptorProto + * @instance + */ + ServiceDescriptorProto.prototype.method = $util.emptyArray + + /** + * ServiceDescriptorProto options. + * @member {google.protobuf.IServiceOptions|null|undefined} options + * @memberof google.protobuf.ServiceDescriptorProto + * @instance + */ + ServiceDescriptorProto.prototype.options = null + + /** + * Creates a new ServiceDescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {google.protobuf.IServiceDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.ServiceDescriptorProto} ServiceDescriptorProto instance + */ + ServiceDescriptorProto.create = function create(properties) { + return new ServiceDescriptorProto(properties) + } + + /** + * Encodes the specified ServiceDescriptorProto message. Does not implicitly {@link google.protobuf.ServiceDescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {google.protobuf.IServiceDescriptorProto} message ServiceDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ServiceDescriptorProto.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.name != null && message.hasOwnProperty('name')) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.name) + if (message.method != null && message.method.length) + for (var i = 0; i < message.method.length; ++i) + $root.google.protobuf.MethodDescriptorProto.encode( + message.method[i], + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + ).ldelim() + if ( + message.options != null && + message.hasOwnProperty('options') + ) + $root.google.protobuf.ServiceOptions.encode( + message.options, + writer.uint32(/* id 3, wireType 2 =*/ 26).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified ServiceDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.ServiceDescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {google.protobuf.IServiceDescriptorProto} message ServiceDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ServiceDescriptorProto.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a ServiceDescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.ServiceDescriptorProto} ServiceDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ServiceDescriptorProto.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.ServiceDescriptorProto() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + case 2: + if (!(message.method && message.method.length)) + message.method = [] + message.method.push( + $root.google.protobuf.MethodDescriptorProto.decode( + reader, + reader.uint32() + ) + ) + break + case 3: + message.options = $root.google.protobuf.ServiceOptions.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a ServiceDescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.ServiceDescriptorProto} ServiceDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ServiceDescriptorProto.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a ServiceDescriptorProto message. + * @function verify + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ServiceDescriptorProto.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + if ( + message.method != null && + message.hasOwnProperty('method') + ) { + if (!Array.isArray(message.method)) + return 'method: array expected' + for (var i = 0; i < message.method.length; ++i) { + var error = $root.google.protobuf.MethodDescriptorProto.verify( + message.method[i] + ) + if (error) return 'method.' + error + } + } + if ( + message.options != null && + message.hasOwnProperty('options') + ) { + var error = $root.google.protobuf.ServiceOptions.verify( + message.options + ) + if (error) return 'options.' + error + } + return null + } + + /** + * Creates a ServiceDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.ServiceDescriptorProto} ServiceDescriptorProto + */ + ServiceDescriptorProto.fromObject = function fromObject(object) { + if ( + object instanceof $root.google.protobuf.ServiceDescriptorProto + ) + return object + var message = new $root.google.protobuf.ServiceDescriptorProto() + if (object.name != null) message.name = String(object.name) + if (object.method) { + if (!Array.isArray(object.method)) + throw TypeError( + '.google.protobuf.ServiceDescriptorProto.method: array expected' + ) + message.method = [] + for (var i = 0; i < object.method.length; ++i) { + if (typeof object.method[i] !== 'object') + throw TypeError( + '.google.protobuf.ServiceDescriptorProto.method: object expected' + ) + message.method[ + i + ] = $root.google.protobuf.MethodDescriptorProto.fromObject( + object.method[i] + ) + } + } + if (object.options != null) { + if (typeof object.options !== 'object') + throw TypeError( + '.google.protobuf.ServiceDescriptorProto.options: object expected' + ) + message.options = $root.google.protobuf.ServiceOptions.fromObject( + object.options + ) + } + return message + } + + /** + * Creates a plain object from a ServiceDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {google.protobuf.ServiceDescriptorProto} message ServiceDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ServiceDescriptorProto.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) object.method = [] + if (options.defaults) { + object.name = '' + object.options = null + } + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + if (message.method && message.method.length) { + object.method = [] + for (var j = 0; j < message.method.length; ++j) + object.method[ + j + ] = $root.google.protobuf.MethodDescriptorProto.toObject( + message.method[j], + options + ) + } + if ( + message.options != null && + message.hasOwnProperty('options') + ) + object.options = $root.google.protobuf.ServiceOptions.toObject( + message.options, + options + ) + return object + } + + /** + * Converts this ServiceDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.ServiceDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + ServiceDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return ServiceDescriptorProto + })() + + protobuf.MethodDescriptorProto = (function () { + /** + * Properties of a MethodDescriptorProto. + * @memberof google.protobuf + * @interface IMethodDescriptorProto + * @property {string|null} [name] MethodDescriptorProto name + * @property {string|null} [inputType] MethodDescriptorProto inputType + * @property {string|null} [outputType] MethodDescriptorProto outputType + * @property {google.protobuf.IMethodOptions|null} [options] MethodDescriptorProto options + * @property {boolean|null} [clientStreaming] MethodDescriptorProto clientStreaming + * @property {boolean|null} [serverStreaming] MethodDescriptorProto serverStreaming + */ + + /** + * Constructs a new MethodDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a MethodDescriptorProto. + * @implements IMethodDescriptorProto + * @constructor + * @param {google.protobuf.IMethodDescriptorProto=} [properties] Properties to set + */ + function MethodDescriptorProto(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * MethodDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.name = '' + + /** + * MethodDescriptorProto inputType. + * @member {string} inputType + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.inputType = '' + + /** + * MethodDescriptorProto outputType. + * @member {string} outputType + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.outputType = '' + + /** + * MethodDescriptorProto options. + * @member {google.protobuf.IMethodOptions|null|undefined} options + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.options = null + + /** + * MethodDescriptorProto clientStreaming. + * @member {boolean} clientStreaming + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.clientStreaming = false + + /** + * MethodDescriptorProto serverStreaming. + * @member {boolean} serverStreaming + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.serverStreaming = false + + /** + * Creates a new MethodDescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {google.protobuf.IMethodDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.MethodDescriptorProto} MethodDescriptorProto instance + */ + MethodDescriptorProto.create = function create(properties) { + return new MethodDescriptorProto(properties) + } + + /** + * Encodes the specified MethodDescriptorProto message. Does not implicitly {@link google.protobuf.MethodDescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {google.protobuf.IMethodDescriptorProto} message MethodDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MethodDescriptorProto.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.name != null && message.hasOwnProperty('name')) + writer.uint32(/* id 1, wireType 2 =*/ 10).string(message.name) + if ( + message.inputType != null && + message.hasOwnProperty('inputType') + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.inputType) + if ( + message.outputType != null && + message.hasOwnProperty('outputType') + ) + writer + .uint32(/* id 3, wireType 2 =*/ 26) + .string(message.outputType) + if ( + message.options != null && + message.hasOwnProperty('options') + ) + $root.google.protobuf.MethodOptions.encode( + message.options, + writer.uint32(/* id 4, wireType 2 =*/ 34).fork() + ).ldelim() + if ( + message.clientStreaming != null && + message.hasOwnProperty('clientStreaming') + ) + writer + .uint32(/* id 5, wireType 0 =*/ 40) + .bool(message.clientStreaming) + if ( + message.serverStreaming != null && + message.hasOwnProperty('serverStreaming') + ) + writer + .uint32(/* id 6, wireType 0 =*/ 48) + .bool(message.serverStreaming) + return writer + } + + /** + * Encodes the specified MethodDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.MethodDescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {google.protobuf.IMethodDescriptorProto} message MethodDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MethodDescriptorProto.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a MethodDescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.MethodDescriptorProto} MethodDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MethodDescriptorProto.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.MethodDescriptorProto() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.name = reader.string() + break + case 2: + message.inputType = reader.string() + break + case 3: + message.outputType = reader.string() + break + case 4: + message.options = $root.google.protobuf.MethodOptions.decode( + reader, + reader.uint32() + ) + break + case 5: + message.clientStreaming = reader.bool() + break + case 6: + message.serverStreaming = reader.bool() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a MethodDescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.MethodDescriptorProto} MethodDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MethodDescriptorProto.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a MethodDescriptorProto message. + * @function verify + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + MethodDescriptorProto.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) + if (!$util.isString(message.name)) + return 'name: string expected' + if ( + message.inputType != null && + message.hasOwnProperty('inputType') + ) + if (!$util.isString(message.inputType)) + return 'inputType: string expected' + if ( + message.outputType != null && + message.hasOwnProperty('outputType') + ) + if (!$util.isString(message.outputType)) + return 'outputType: string expected' + if ( + message.options != null && + message.hasOwnProperty('options') + ) { + var error = $root.google.protobuf.MethodOptions.verify( + message.options + ) + if (error) return 'options.' + error + } + if ( + message.clientStreaming != null && + message.hasOwnProperty('clientStreaming') + ) + if (typeof message.clientStreaming !== 'boolean') + return 'clientStreaming: boolean expected' + if ( + message.serverStreaming != null && + message.hasOwnProperty('serverStreaming') + ) + if (typeof message.serverStreaming !== 'boolean') + return 'serverStreaming: boolean expected' + return null + } + + /** + * Creates a MethodDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.MethodDescriptorProto} MethodDescriptorProto + */ + MethodDescriptorProto.fromObject = function fromObject(object) { + if ( + object instanceof $root.google.protobuf.MethodDescriptorProto + ) + return object + var message = new $root.google.protobuf.MethodDescriptorProto() + if (object.name != null) message.name = String(object.name) + if (object.inputType != null) + message.inputType = String(object.inputType) + if (object.outputType != null) + message.outputType = String(object.outputType) + if (object.options != null) { + if (typeof object.options !== 'object') + throw TypeError( + '.google.protobuf.MethodDescriptorProto.options: object expected' + ) + message.options = $root.google.protobuf.MethodOptions.fromObject( + object.options + ) + } + if (object.clientStreaming != null) + message.clientStreaming = Boolean(object.clientStreaming) + if (object.serverStreaming != null) + message.serverStreaming = Boolean(object.serverStreaming) + return message + } + + /** + * Creates a plain object from a MethodDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {google.protobuf.MethodDescriptorProto} message MethodDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MethodDescriptorProto.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.name = '' + object.inputType = '' + object.outputType = '' + object.options = null + object.clientStreaming = false + object.serverStreaming = false + } + if (message.name != null && message.hasOwnProperty('name')) + object.name = message.name + if ( + message.inputType != null && + message.hasOwnProperty('inputType') + ) + object.inputType = message.inputType + if ( + message.outputType != null && + message.hasOwnProperty('outputType') + ) + object.outputType = message.outputType + if ( + message.options != null && + message.hasOwnProperty('options') + ) + object.options = $root.google.protobuf.MethodOptions.toObject( + message.options, + options + ) + if ( + message.clientStreaming != null && + message.hasOwnProperty('clientStreaming') + ) + object.clientStreaming = message.clientStreaming + if ( + message.serverStreaming != null && + message.hasOwnProperty('serverStreaming') + ) + object.serverStreaming = message.serverStreaming + return object + } + + /** + * Converts this MethodDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.MethodDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + MethodDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return MethodDescriptorProto + })() + + protobuf.FileOptions = (function () { + /** + * Properties of a FileOptions. + * @memberof google.protobuf + * @interface IFileOptions + * @property {string|null} [javaPackage] FileOptions javaPackage + * @property {string|null} [javaOuterClassname] FileOptions javaOuterClassname + * @property {boolean|null} [javaMultipleFiles] FileOptions javaMultipleFiles + * @property {boolean|null} [javaGenerateEqualsAndHash] FileOptions javaGenerateEqualsAndHash + * @property {boolean|null} [javaStringCheckUtf8] FileOptions javaStringCheckUtf8 + * @property {google.protobuf.FileOptions.OptimizeMode|null} [optimizeFor] FileOptions optimizeFor + * @property {string|null} [goPackage] FileOptions goPackage + * @property {boolean|null} [ccGenericServices] FileOptions ccGenericServices + * @property {boolean|null} [javaGenericServices] FileOptions javaGenericServices + * @property {boolean|null} [pyGenericServices] FileOptions pyGenericServices + * @property {boolean|null} [phpGenericServices] FileOptions phpGenericServices + * @property {boolean|null} [deprecated] FileOptions deprecated + * @property {boolean|null} [ccEnableArenas] FileOptions ccEnableArenas + * @property {string|null} [objcClassPrefix] FileOptions objcClassPrefix + * @property {string|null} [csharpNamespace] FileOptions csharpNamespace + * @property {string|null} [swiftPrefix] FileOptions swiftPrefix + * @property {string|null} [phpClassPrefix] FileOptions phpClassPrefix + * @property {string|null} [phpNamespace] FileOptions phpNamespace + * @property {string|null} [phpMetadataNamespace] FileOptions phpMetadataNamespace + * @property {string|null} [rubyPackage] FileOptions rubyPackage + * @property {Array.|null} [uninterpretedOption] FileOptions uninterpretedOption + */ + + /** + * Constructs a new FileOptions. + * @memberof google.protobuf + * @classdesc Represents a FileOptions. + * @implements IFileOptions + * @constructor + * @param {google.protobuf.IFileOptions=} [properties] Properties to set + */ + function FileOptions(properties) { + this.uninterpretedOption = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * FileOptions javaPackage. + * @member {string} javaPackage + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaPackage = '' + + /** + * FileOptions javaOuterClassname. + * @member {string} javaOuterClassname + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaOuterClassname = '' + + /** + * FileOptions javaMultipleFiles. + * @member {boolean} javaMultipleFiles + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaMultipleFiles = false + + /** + * FileOptions javaGenerateEqualsAndHash. + * @member {boolean} javaGenerateEqualsAndHash + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaGenerateEqualsAndHash = false + + /** + * FileOptions javaStringCheckUtf8. + * @member {boolean} javaStringCheckUtf8 + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaStringCheckUtf8 = false + + /** + * FileOptions optimizeFor. + * @member {google.protobuf.FileOptions.OptimizeMode} optimizeFor + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.optimizeFor = 1 + + /** + * FileOptions goPackage. + * @member {string} goPackage + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.goPackage = '' + + /** + * FileOptions ccGenericServices. + * @member {boolean} ccGenericServices + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.ccGenericServices = false + + /** + * FileOptions javaGenericServices. + * @member {boolean} javaGenericServices + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaGenericServices = false + + /** + * FileOptions pyGenericServices. + * @member {boolean} pyGenericServices + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.pyGenericServices = false + + /** + * FileOptions phpGenericServices. + * @member {boolean} phpGenericServices + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.phpGenericServices = false + + /** + * FileOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.deprecated = false + + /** + * FileOptions ccEnableArenas. + * @member {boolean} ccEnableArenas + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.ccEnableArenas = false + + /** + * FileOptions objcClassPrefix. + * @member {string} objcClassPrefix + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.objcClassPrefix = '' + + /** + * FileOptions csharpNamespace. + * @member {string} csharpNamespace + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.csharpNamespace = '' + + /** + * FileOptions swiftPrefix. + * @member {string} swiftPrefix + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.swiftPrefix = '' + + /** + * FileOptions phpClassPrefix. + * @member {string} phpClassPrefix + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.phpClassPrefix = '' + + /** + * FileOptions phpNamespace. + * @member {string} phpNamespace + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.phpNamespace = '' + + /** + * FileOptions phpMetadataNamespace. + * @member {string} phpMetadataNamespace + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.phpMetadataNamespace = '' + + /** + * FileOptions rubyPackage. + * @member {string} rubyPackage + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.rubyPackage = '' + + /** + * FileOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.uninterpretedOption = $util.emptyArray + + /** + * Creates a new FileOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.FileOptions + * @static + * @param {google.protobuf.IFileOptions=} [properties] Properties to set + * @returns {google.protobuf.FileOptions} FileOptions instance + */ + FileOptions.create = function create(properties) { + return new FileOptions(properties) + } + + /** + * Encodes the specified FileOptions message. Does not implicitly {@link google.protobuf.FileOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FileOptions + * @static + * @param {google.protobuf.IFileOptions} message FileOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FileOptions.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.javaPackage != null && + message.hasOwnProperty('javaPackage') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.javaPackage) + if ( + message.javaOuterClassname != null && + message.hasOwnProperty('javaOuterClassname') + ) + writer + .uint32(/* id 8, wireType 2 =*/ 66) + .string(message.javaOuterClassname) + if ( + message.optimizeFor != null && + message.hasOwnProperty('optimizeFor') + ) + writer + .uint32(/* id 9, wireType 0 =*/ 72) + .int32(message.optimizeFor) + if ( + message.javaMultipleFiles != null && + message.hasOwnProperty('javaMultipleFiles') + ) + writer + .uint32(/* id 10, wireType 0 =*/ 80) + .bool(message.javaMultipleFiles) + if ( + message.goPackage != null && + message.hasOwnProperty('goPackage') + ) + writer + .uint32(/* id 11, wireType 2 =*/ 90) + .string(message.goPackage) + if ( + message.ccGenericServices != null && + message.hasOwnProperty('ccGenericServices') + ) + writer + .uint32(/* id 16, wireType 0 =*/ 128) + .bool(message.ccGenericServices) + if ( + message.javaGenericServices != null && + message.hasOwnProperty('javaGenericServices') + ) + writer + .uint32(/* id 17, wireType 0 =*/ 136) + .bool(message.javaGenericServices) + if ( + message.pyGenericServices != null && + message.hasOwnProperty('pyGenericServices') + ) + writer + .uint32(/* id 18, wireType 0 =*/ 144) + .bool(message.pyGenericServices) + if ( + message.javaGenerateEqualsAndHash != null && + message.hasOwnProperty('javaGenerateEqualsAndHash') + ) + writer + .uint32(/* id 20, wireType 0 =*/ 160) + .bool(message.javaGenerateEqualsAndHash) + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + writer + .uint32(/* id 23, wireType 0 =*/ 184) + .bool(message.deprecated) + if ( + message.javaStringCheckUtf8 != null && + message.hasOwnProperty('javaStringCheckUtf8') + ) + writer + .uint32(/* id 27, wireType 0 =*/ 216) + .bool(message.javaStringCheckUtf8) + if ( + message.ccEnableArenas != null && + message.hasOwnProperty('ccEnableArenas') + ) + writer + .uint32(/* id 31, wireType 0 =*/ 248) + .bool(message.ccEnableArenas) + if ( + message.objcClassPrefix != null && + message.hasOwnProperty('objcClassPrefix') + ) + writer + .uint32(/* id 36, wireType 2 =*/ 290) + .string(message.objcClassPrefix) + if ( + message.csharpNamespace != null && + message.hasOwnProperty('csharpNamespace') + ) + writer + .uint32(/* id 37, wireType 2 =*/ 298) + .string(message.csharpNamespace) + if ( + message.swiftPrefix != null && + message.hasOwnProperty('swiftPrefix') + ) + writer + .uint32(/* id 39, wireType 2 =*/ 314) + .string(message.swiftPrefix) + if ( + message.phpClassPrefix != null && + message.hasOwnProperty('phpClassPrefix') + ) + writer + .uint32(/* id 40, wireType 2 =*/ 322) + .string(message.phpClassPrefix) + if ( + message.phpNamespace != null && + message.hasOwnProperty('phpNamespace') + ) + writer + .uint32(/* id 41, wireType 2 =*/ 330) + .string(message.phpNamespace) + if ( + message.phpGenericServices != null && + message.hasOwnProperty('phpGenericServices') + ) + writer + .uint32(/* id 42, wireType 0 =*/ 336) + .bool(message.phpGenericServices) + if ( + message.phpMetadataNamespace != null && + message.hasOwnProperty('phpMetadataNamespace') + ) + writer + .uint32(/* id 44, wireType 2 =*/ 354) + .string(message.phpMetadataNamespace) + if ( + message.rubyPackage != null && + message.hasOwnProperty('rubyPackage') + ) + writer + .uint32(/* id 45, wireType 2 =*/ 362) + .string(message.rubyPackage) + if ( + message.uninterpretedOption != null && + message.uninterpretedOption.length + ) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode( + message.uninterpretedOption[i], + writer.uint32(/* id 999, wireType 2 =*/ 7994).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified FileOptions message, length delimited. Does not implicitly {@link google.protobuf.FileOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FileOptions + * @static + * @param {google.protobuf.IFileOptions} message FileOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FileOptions.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a FileOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FileOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FileOptions} FileOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FileOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.FileOptions() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.javaPackage = reader.string() + break + case 8: + message.javaOuterClassname = reader.string() + break + case 10: + message.javaMultipleFiles = reader.bool() + break + case 20: + message.javaGenerateEqualsAndHash = reader.bool() + break + case 27: + message.javaStringCheckUtf8 = reader.bool() + break + case 9: + message.optimizeFor = reader.int32() + break + case 11: + message.goPackage = reader.string() + break + case 16: + message.ccGenericServices = reader.bool() + break + case 17: + message.javaGenericServices = reader.bool() + break + case 18: + message.pyGenericServices = reader.bool() + break + case 42: + message.phpGenericServices = reader.bool() + break + case 23: + message.deprecated = reader.bool() + break + case 31: + message.ccEnableArenas = reader.bool() + break + case 36: + message.objcClassPrefix = reader.string() + break + case 37: + message.csharpNamespace = reader.string() + break + case 39: + message.swiftPrefix = reader.string() + break + case 40: + message.phpClassPrefix = reader.string() + break + case 41: + message.phpNamespace = reader.string() + break + case 44: + message.phpMetadataNamespace = reader.string() + break + case 45: + message.rubyPackage = reader.string() + break + case 999: + if ( + !( + message.uninterpretedOption && + message.uninterpretedOption.length + ) + ) + message.uninterpretedOption = [] + message.uninterpretedOption.push( + $root.google.protobuf.UninterpretedOption.decode( + reader, + reader.uint32() + ) + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a FileOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FileOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FileOptions} FileOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FileOptions.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a FileOptions message. + * @function verify + * @memberof google.protobuf.FileOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FileOptions.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.javaPackage != null && + message.hasOwnProperty('javaPackage') + ) + if (!$util.isString(message.javaPackage)) + return 'javaPackage: string expected' + if ( + message.javaOuterClassname != null && + message.hasOwnProperty('javaOuterClassname') + ) + if (!$util.isString(message.javaOuterClassname)) + return 'javaOuterClassname: string expected' + if ( + message.javaMultipleFiles != null && + message.hasOwnProperty('javaMultipleFiles') + ) + if (typeof message.javaMultipleFiles !== 'boolean') + return 'javaMultipleFiles: boolean expected' + if ( + message.javaGenerateEqualsAndHash != null && + message.hasOwnProperty('javaGenerateEqualsAndHash') + ) + if (typeof message.javaGenerateEqualsAndHash !== 'boolean') + return 'javaGenerateEqualsAndHash: boolean expected' + if ( + message.javaStringCheckUtf8 != null && + message.hasOwnProperty('javaStringCheckUtf8') + ) + if (typeof message.javaStringCheckUtf8 !== 'boolean') + return 'javaStringCheckUtf8: boolean expected' + if ( + message.optimizeFor != null && + message.hasOwnProperty('optimizeFor') + ) + switch (message.optimizeFor) { + default: + return 'optimizeFor: enum value expected' + case 1: + case 2: + case 3: + break + } + if ( + message.goPackage != null && + message.hasOwnProperty('goPackage') + ) + if (!$util.isString(message.goPackage)) + return 'goPackage: string expected' + if ( + message.ccGenericServices != null && + message.hasOwnProperty('ccGenericServices') + ) + if (typeof message.ccGenericServices !== 'boolean') + return 'ccGenericServices: boolean expected' + if ( + message.javaGenericServices != null && + message.hasOwnProperty('javaGenericServices') + ) + if (typeof message.javaGenericServices !== 'boolean') + return 'javaGenericServices: boolean expected' + if ( + message.pyGenericServices != null && + message.hasOwnProperty('pyGenericServices') + ) + if (typeof message.pyGenericServices !== 'boolean') + return 'pyGenericServices: boolean expected' + if ( + message.phpGenericServices != null && + message.hasOwnProperty('phpGenericServices') + ) + if (typeof message.phpGenericServices !== 'boolean') + return 'phpGenericServices: boolean expected' + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + if (typeof message.deprecated !== 'boolean') + return 'deprecated: boolean expected' + if ( + message.ccEnableArenas != null && + message.hasOwnProperty('ccEnableArenas') + ) + if (typeof message.ccEnableArenas !== 'boolean') + return 'ccEnableArenas: boolean expected' + if ( + message.objcClassPrefix != null && + message.hasOwnProperty('objcClassPrefix') + ) + if (!$util.isString(message.objcClassPrefix)) + return 'objcClassPrefix: string expected' + if ( + message.csharpNamespace != null && + message.hasOwnProperty('csharpNamespace') + ) + if (!$util.isString(message.csharpNamespace)) + return 'csharpNamespace: string expected' + if ( + message.swiftPrefix != null && + message.hasOwnProperty('swiftPrefix') + ) + if (!$util.isString(message.swiftPrefix)) + return 'swiftPrefix: string expected' + if ( + message.phpClassPrefix != null && + message.hasOwnProperty('phpClassPrefix') + ) + if (!$util.isString(message.phpClassPrefix)) + return 'phpClassPrefix: string expected' + if ( + message.phpNamespace != null && + message.hasOwnProperty('phpNamespace') + ) + if (!$util.isString(message.phpNamespace)) + return 'phpNamespace: string expected' + if ( + message.phpMetadataNamespace != null && + message.hasOwnProperty('phpMetadataNamespace') + ) + if (!$util.isString(message.phpMetadataNamespace)) + return 'phpMetadataNamespace: string expected' + if ( + message.rubyPackage != null && + message.hasOwnProperty('rubyPackage') + ) + if (!$util.isString(message.rubyPackage)) + return 'rubyPackage: string expected' + if ( + message.uninterpretedOption != null && + message.hasOwnProperty('uninterpretedOption') + ) { + if (!Array.isArray(message.uninterpretedOption)) + return 'uninterpretedOption: array expected' + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify( + message.uninterpretedOption[i] + ) + if (error) return 'uninterpretedOption.' + error + } + } + return null + } + + /** + * Creates a FileOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FileOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FileOptions} FileOptions + */ + FileOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FileOptions) + return object + var message = new $root.google.protobuf.FileOptions() + if (object.javaPackage != null) + message.javaPackage = String(object.javaPackage) + if (object.javaOuterClassname != null) + message.javaOuterClassname = String(object.javaOuterClassname) + if (object.javaMultipleFiles != null) + message.javaMultipleFiles = Boolean(object.javaMultipleFiles) + if (object.javaGenerateEqualsAndHash != null) + message.javaGenerateEqualsAndHash = Boolean( + object.javaGenerateEqualsAndHash + ) + if (object.javaStringCheckUtf8 != null) + message.javaStringCheckUtf8 = Boolean( + object.javaStringCheckUtf8 + ) + switch (object.optimizeFor) { + case 'SPEED': + case 1: + message.optimizeFor = 1 + break + case 'CODE_SIZE': + case 2: + message.optimizeFor = 2 + break + case 'LITE_RUNTIME': + case 3: + message.optimizeFor = 3 + break + } + if (object.goPackage != null) + message.goPackage = String(object.goPackage) + if (object.ccGenericServices != null) + message.ccGenericServices = Boolean(object.ccGenericServices) + if (object.javaGenericServices != null) + message.javaGenericServices = Boolean( + object.javaGenericServices + ) + if (object.pyGenericServices != null) + message.pyGenericServices = Boolean(object.pyGenericServices) + if (object.phpGenericServices != null) + message.phpGenericServices = Boolean( + object.phpGenericServices + ) + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated) + if (object.ccEnableArenas != null) + message.ccEnableArenas = Boolean(object.ccEnableArenas) + if (object.objcClassPrefix != null) + message.objcClassPrefix = String(object.objcClassPrefix) + if (object.csharpNamespace != null) + message.csharpNamespace = String(object.csharpNamespace) + if (object.swiftPrefix != null) + message.swiftPrefix = String(object.swiftPrefix) + if (object.phpClassPrefix != null) + message.phpClassPrefix = String(object.phpClassPrefix) + if (object.phpNamespace != null) + message.phpNamespace = String(object.phpNamespace) + if (object.phpMetadataNamespace != null) + message.phpMetadataNamespace = String( + object.phpMetadataNamespace + ) + if (object.rubyPackage != null) + message.rubyPackage = String(object.rubyPackage) + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError( + '.google.protobuf.FileOptions.uninterpretedOption: array expected' + ) + message.uninterpretedOption = [] + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== 'object') + throw TypeError( + '.google.protobuf.FileOptions.uninterpretedOption: object expected' + ) + message.uninterpretedOption[ + i + ] = $root.google.protobuf.UninterpretedOption.fromObject( + object.uninterpretedOption[i] + ) + } + } + return message + } + + /** + * Creates a plain object from a FileOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FileOptions + * @static + * @param {google.protobuf.FileOptions} message FileOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FileOptions.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) + object.uninterpretedOption = [] + if (options.defaults) { + object.javaPackage = '' + object.javaOuterClassname = '' + object.optimizeFor = options.enums === String ? 'SPEED' : 1 + object.javaMultipleFiles = false + object.goPackage = '' + object.ccGenericServices = false + object.javaGenericServices = false + object.pyGenericServices = false + object.javaGenerateEqualsAndHash = false + object.deprecated = false + object.javaStringCheckUtf8 = false + object.ccEnableArenas = false + object.objcClassPrefix = '' + object.csharpNamespace = '' + object.swiftPrefix = '' + object.phpClassPrefix = '' + object.phpNamespace = '' + object.phpGenericServices = false + object.phpMetadataNamespace = '' + object.rubyPackage = '' + } + if ( + message.javaPackage != null && + message.hasOwnProperty('javaPackage') + ) + object.javaPackage = message.javaPackage + if ( + message.javaOuterClassname != null && + message.hasOwnProperty('javaOuterClassname') + ) + object.javaOuterClassname = message.javaOuterClassname + if ( + message.optimizeFor != null && + message.hasOwnProperty('optimizeFor') + ) + object.optimizeFor = + options.enums === String + ? $root.google.protobuf.FileOptions.OptimizeMode[ + message.optimizeFor + ] + : message.optimizeFor + if ( + message.javaMultipleFiles != null && + message.hasOwnProperty('javaMultipleFiles') + ) + object.javaMultipleFiles = message.javaMultipleFiles + if ( + message.goPackage != null && + message.hasOwnProperty('goPackage') + ) + object.goPackage = message.goPackage + if ( + message.ccGenericServices != null && + message.hasOwnProperty('ccGenericServices') + ) + object.ccGenericServices = message.ccGenericServices + if ( + message.javaGenericServices != null && + message.hasOwnProperty('javaGenericServices') + ) + object.javaGenericServices = message.javaGenericServices + if ( + message.pyGenericServices != null && + message.hasOwnProperty('pyGenericServices') + ) + object.pyGenericServices = message.pyGenericServices + if ( + message.javaGenerateEqualsAndHash != null && + message.hasOwnProperty('javaGenerateEqualsAndHash') + ) + object.javaGenerateEqualsAndHash = + message.javaGenerateEqualsAndHash + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + object.deprecated = message.deprecated + if ( + message.javaStringCheckUtf8 != null && + message.hasOwnProperty('javaStringCheckUtf8') + ) + object.javaStringCheckUtf8 = message.javaStringCheckUtf8 + if ( + message.ccEnableArenas != null && + message.hasOwnProperty('ccEnableArenas') + ) + object.ccEnableArenas = message.ccEnableArenas + if ( + message.objcClassPrefix != null && + message.hasOwnProperty('objcClassPrefix') + ) + object.objcClassPrefix = message.objcClassPrefix + if ( + message.csharpNamespace != null && + message.hasOwnProperty('csharpNamespace') + ) + object.csharpNamespace = message.csharpNamespace + if ( + message.swiftPrefix != null && + message.hasOwnProperty('swiftPrefix') + ) + object.swiftPrefix = message.swiftPrefix + if ( + message.phpClassPrefix != null && + message.hasOwnProperty('phpClassPrefix') + ) + object.phpClassPrefix = message.phpClassPrefix + if ( + message.phpNamespace != null && + message.hasOwnProperty('phpNamespace') + ) + object.phpNamespace = message.phpNamespace + if ( + message.phpGenericServices != null && + message.hasOwnProperty('phpGenericServices') + ) + object.phpGenericServices = message.phpGenericServices + if ( + message.phpMetadataNamespace != null && + message.hasOwnProperty('phpMetadataNamespace') + ) + object.phpMetadataNamespace = message.phpMetadataNamespace + if ( + message.rubyPackage != null && + message.hasOwnProperty('rubyPackage') + ) + object.rubyPackage = message.rubyPackage + if ( + message.uninterpretedOption && + message.uninterpretedOption.length + ) { + object.uninterpretedOption = [] + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[ + j + ] = $root.google.protobuf.UninterpretedOption.toObject( + message.uninterpretedOption[j], + options + ) + } + return object + } + + /** + * Converts this FileOptions to JSON. + * @function toJSON + * @memberof google.protobuf.FileOptions + * @instance + * @returns {Object.} JSON object + */ + FileOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + /** + * OptimizeMode enum. + * @name google.protobuf.FileOptions.OptimizeMode + * @enum {string} + * @property {number} SPEED=1 SPEED value + * @property {number} CODE_SIZE=2 CODE_SIZE value + * @property {number} LITE_RUNTIME=3 LITE_RUNTIME value + */ + FileOptions.OptimizeMode = (function () { + var valuesById = {}, + values = Object.create(valuesById) + values[(valuesById[1] = 'SPEED')] = 1 + values[(valuesById[2] = 'CODE_SIZE')] = 2 + values[(valuesById[3] = 'LITE_RUNTIME')] = 3 + return values + })() + + return FileOptions + })() + + protobuf.MessageOptions = (function () { + /** + * Properties of a MessageOptions. + * @memberof google.protobuf + * @interface IMessageOptions + * @property {boolean|null} [messageSetWireFormat] MessageOptions messageSetWireFormat + * @property {boolean|null} [noStandardDescriptorAccessor] MessageOptions noStandardDescriptorAccessor + * @property {boolean|null} [deprecated] MessageOptions deprecated + * @property {boolean|null} [mapEntry] MessageOptions mapEntry + * @property {Array.|null} [uninterpretedOption] MessageOptions uninterpretedOption + */ + + /** + * Constructs a new MessageOptions. + * @memberof google.protobuf + * @classdesc Represents a MessageOptions. + * @implements IMessageOptions + * @constructor + * @param {google.protobuf.IMessageOptions=} [properties] Properties to set + */ + function MessageOptions(properties) { + this.uninterpretedOption = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * MessageOptions messageSetWireFormat. + * @member {boolean} messageSetWireFormat + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.messageSetWireFormat = false + + /** + * MessageOptions noStandardDescriptorAccessor. + * @member {boolean} noStandardDescriptorAccessor + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.noStandardDescriptorAccessor = false + + /** + * MessageOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.deprecated = false + + /** + * MessageOptions mapEntry. + * @member {boolean} mapEntry + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.mapEntry = false + + /** + * MessageOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.uninterpretedOption = $util.emptyArray + + /** + * Creates a new MessageOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.MessageOptions + * @static + * @param {google.protobuf.IMessageOptions=} [properties] Properties to set + * @returns {google.protobuf.MessageOptions} MessageOptions instance + */ + MessageOptions.create = function create(properties) { + return new MessageOptions(properties) + } + + /** + * Encodes the specified MessageOptions message. Does not implicitly {@link google.protobuf.MessageOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.MessageOptions + * @static + * @param {google.protobuf.IMessageOptions} message MessageOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MessageOptions.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.messageSetWireFormat != null && + message.hasOwnProperty('messageSetWireFormat') + ) + writer + .uint32(/* id 1, wireType 0 =*/ 8) + .bool(message.messageSetWireFormat) + if ( + message.noStandardDescriptorAccessor != null && + message.hasOwnProperty('noStandardDescriptorAccessor') + ) + writer + .uint32(/* id 2, wireType 0 =*/ 16) + .bool(message.noStandardDescriptorAccessor) + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + writer + .uint32(/* id 3, wireType 0 =*/ 24) + .bool(message.deprecated) + if ( + message.mapEntry != null && + message.hasOwnProperty('mapEntry') + ) + writer + .uint32(/* id 7, wireType 0 =*/ 56) + .bool(message.mapEntry) + if ( + message.uninterpretedOption != null && + message.uninterpretedOption.length + ) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode( + message.uninterpretedOption[i], + writer.uint32(/* id 999, wireType 2 =*/ 7994).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified MessageOptions message, length delimited. Does not implicitly {@link google.protobuf.MessageOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.MessageOptions + * @static + * @param {google.protobuf.IMessageOptions} message MessageOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MessageOptions.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a MessageOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.MessageOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.MessageOptions} MessageOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MessageOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.MessageOptions() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.messageSetWireFormat = reader.bool() + break + case 2: + message.noStandardDescriptorAccessor = reader.bool() + break + case 3: + message.deprecated = reader.bool() + break + case 7: + message.mapEntry = reader.bool() + break + case 999: + if ( + !( + message.uninterpretedOption && + message.uninterpretedOption.length + ) + ) + message.uninterpretedOption = [] + message.uninterpretedOption.push( + $root.google.protobuf.UninterpretedOption.decode( + reader, + reader.uint32() + ) + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a MessageOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.MessageOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.MessageOptions} MessageOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MessageOptions.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a MessageOptions message. + * @function verify + * @memberof google.protobuf.MessageOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + MessageOptions.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.messageSetWireFormat != null && + message.hasOwnProperty('messageSetWireFormat') + ) + if (typeof message.messageSetWireFormat !== 'boolean') + return 'messageSetWireFormat: boolean expected' + if ( + message.noStandardDescriptorAccessor != null && + message.hasOwnProperty('noStandardDescriptorAccessor') + ) + if (typeof message.noStandardDescriptorAccessor !== 'boolean') + return 'noStandardDescriptorAccessor: boolean expected' + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + if (typeof message.deprecated !== 'boolean') + return 'deprecated: boolean expected' + if ( + message.mapEntry != null && + message.hasOwnProperty('mapEntry') + ) + if (typeof message.mapEntry !== 'boolean') + return 'mapEntry: boolean expected' + if ( + message.uninterpretedOption != null && + message.hasOwnProperty('uninterpretedOption') + ) { + if (!Array.isArray(message.uninterpretedOption)) + return 'uninterpretedOption: array expected' + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify( + message.uninterpretedOption[i] + ) + if (error) return 'uninterpretedOption.' + error + } + } + return null + } + + /** + * Creates a MessageOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.MessageOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.MessageOptions} MessageOptions + */ + MessageOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.MessageOptions) + return object + var message = new $root.google.protobuf.MessageOptions() + if (object.messageSetWireFormat != null) + message.messageSetWireFormat = Boolean( + object.messageSetWireFormat + ) + if (object.noStandardDescriptorAccessor != null) + message.noStandardDescriptorAccessor = Boolean( + object.noStandardDescriptorAccessor + ) + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated) + if (object.mapEntry != null) + message.mapEntry = Boolean(object.mapEntry) + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError( + '.google.protobuf.MessageOptions.uninterpretedOption: array expected' + ) + message.uninterpretedOption = [] + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== 'object') + throw TypeError( + '.google.protobuf.MessageOptions.uninterpretedOption: object expected' + ) + message.uninterpretedOption[ + i + ] = $root.google.protobuf.UninterpretedOption.fromObject( + object.uninterpretedOption[i] + ) + } + } + return message + } + + /** + * Creates a plain object from a MessageOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.MessageOptions + * @static + * @param {google.protobuf.MessageOptions} message MessageOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MessageOptions.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) + object.uninterpretedOption = [] + if (options.defaults) { + object.messageSetWireFormat = false + object.noStandardDescriptorAccessor = false + object.deprecated = false + object.mapEntry = false + } + if ( + message.messageSetWireFormat != null && + message.hasOwnProperty('messageSetWireFormat') + ) + object.messageSetWireFormat = message.messageSetWireFormat + if ( + message.noStandardDescriptorAccessor != null && + message.hasOwnProperty('noStandardDescriptorAccessor') + ) + object.noStandardDescriptorAccessor = + message.noStandardDescriptorAccessor + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + object.deprecated = message.deprecated + if ( + message.mapEntry != null && + message.hasOwnProperty('mapEntry') + ) + object.mapEntry = message.mapEntry + if ( + message.uninterpretedOption && + message.uninterpretedOption.length + ) { + object.uninterpretedOption = [] + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[ + j + ] = $root.google.protobuf.UninterpretedOption.toObject( + message.uninterpretedOption[j], + options + ) + } + return object + } + + /** + * Converts this MessageOptions to JSON. + * @function toJSON + * @memberof google.protobuf.MessageOptions + * @instance + * @returns {Object.} JSON object + */ + MessageOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return MessageOptions + })() + + protobuf.FieldOptions = (function () { + /** + * Properties of a FieldOptions. + * @memberof google.protobuf + * @interface IFieldOptions + * @property {google.protobuf.FieldOptions.CType|null} [ctype] FieldOptions ctype + * @property {boolean|null} [packed] FieldOptions packed + * @property {google.protobuf.FieldOptions.JSType|null} [jstype] FieldOptions jstype + * @property {boolean|null} [lazy] FieldOptions lazy + * @property {boolean|null} [deprecated] FieldOptions deprecated + * @property {boolean|null} [weak] FieldOptions weak + * @property {Array.|null} [uninterpretedOption] FieldOptions uninterpretedOption + */ + + /** + * Constructs a new FieldOptions. + * @memberof google.protobuf + * @classdesc Represents a FieldOptions. + * @implements IFieldOptions + * @constructor + * @param {google.protobuf.IFieldOptions=} [properties] Properties to set + */ + function FieldOptions(properties) { + this.uninterpretedOption = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * FieldOptions ctype. + * @member {google.protobuf.FieldOptions.CType} ctype + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.ctype = 0 + + /** + * FieldOptions packed. + * @member {boolean} packed + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.packed = false + + /** + * FieldOptions jstype. + * @member {google.protobuf.FieldOptions.JSType} jstype + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.jstype = 0 + + /** + * FieldOptions lazy. + * @member {boolean} lazy + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.lazy = false + + /** + * FieldOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.deprecated = false + + /** + * FieldOptions weak. + * @member {boolean} weak + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.weak = false + + /** + * FieldOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.uninterpretedOption = $util.emptyArray + + /** + * Creates a new FieldOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.FieldOptions + * @static + * @param {google.protobuf.IFieldOptions=} [properties] Properties to set + * @returns {google.protobuf.FieldOptions} FieldOptions instance + */ + FieldOptions.create = function create(properties) { + return new FieldOptions(properties) + } + + /** + * Encodes the specified FieldOptions message. Does not implicitly {@link google.protobuf.FieldOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FieldOptions + * @static + * @param {google.protobuf.IFieldOptions} message FieldOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FieldOptions.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.ctype != null && message.hasOwnProperty('ctype')) + writer.uint32(/* id 1, wireType 0 =*/ 8).int32(message.ctype) + if (message.packed != null && message.hasOwnProperty('packed')) + writer.uint32(/* id 2, wireType 0 =*/ 16).bool(message.packed) + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + writer + .uint32(/* id 3, wireType 0 =*/ 24) + .bool(message.deprecated) + if (message.lazy != null && message.hasOwnProperty('lazy')) + writer.uint32(/* id 5, wireType 0 =*/ 40).bool(message.lazy) + if (message.jstype != null && message.hasOwnProperty('jstype')) + writer + .uint32(/* id 6, wireType 0 =*/ 48) + .int32(message.jstype) + if (message.weak != null && message.hasOwnProperty('weak')) + writer.uint32(/* id 10, wireType 0 =*/ 80).bool(message.weak) + if ( + message.uninterpretedOption != null && + message.uninterpretedOption.length + ) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode( + message.uninterpretedOption[i], + writer.uint32(/* id 999, wireType 2 =*/ 7994).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified FieldOptions message, length delimited. Does not implicitly {@link google.protobuf.FieldOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FieldOptions + * @static + * @param {google.protobuf.IFieldOptions} message FieldOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FieldOptions.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a FieldOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FieldOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FieldOptions} FieldOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FieldOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.FieldOptions() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.ctype = reader.int32() + break + case 2: + message.packed = reader.bool() + break + case 6: + message.jstype = reader.int32() + break + case 5: + message.lazy = reader.bool() + break + case 3: + message.deprecated = reader.bool() + break + case 10: + message.weak = reader.bool() + break + case 999: + if ( + !( + message.uninterpretedOption && + message.uninterpretedOption.length + ) + ) + message.uninterpretedOption = [] + message.uninterpretedOption.push( + $root.google.protobuf.UninterpretedOption.decode( + reader, + reader.uint32() + ) + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a FieldOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FieldOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FieldOptions} FieldOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FieldOptions.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a FieldOptions message. + * @function verify + * @memberof google.protobuf.FieldOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FieldOptions.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.ctype != null && message.hasOwnProperty('ctype')) + switch (message.ctype) { + default: + return 'ctype: enum value expected' + case 0: + case 1: + case 2: + break + } + if (message.packed != null && message.hasOwnProperty('packed')) + if (typeof message.packed !== 'boolean') + return 'packed: boolean expected' + if (message.jstype != null && message.hasOwnProperty('jstype')) + switch (message.jstype) { + default: + return 'jstype: enum value expected' + case 0: + case 1: + case 2: + break + } + if (message.lazy != null && message.hasOwnProperty('lazy')) + if (typeof message.lazy !== 'boolean') + return 'lazy: boolean expected' + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + if (typeof message.deprecated !== 'boolean') + return 'deprecated: boolean expected' + if (message.weak != null && message.hasOwnProperty('weak')) + if (typeof message.weak !== 'boolean') + return 'weak: boolean expected' + if ( + message.uninterpretedOption != null && + message.hasOwnProperty('uninterpretedOption') + ) { + if (!Array.isArray(message.uninterpretedOption)) + return 'uninterpretedOption: array expected' + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify( + message.uninterpretedOption[i] + ) + if (error) return 'uninterpretedOption.' + error + } + } + return null + } + + /** + * Creates a FieldOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FieldOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FieldOptions} FieldOptions + */ + FieldOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FieldOptions) + return object + var message = new $root.google.protobuf.FieldOptions() + switch (object.ctype) { + case 'STRING': + case 0: + message.ctype = 0 + break + case 'CORD': + case 1: + message.ctype = 1 + break + case 'STRING_PIECE': + case 2: + message.ctype = 2 + break + } + if (object.packed != null) + message.packed = Boolean(object.packed) + switch (object.jstype) { + case 'JS_NORMAL': + case 0: + message.jstype = 0 + break + case 'JS_STRING': + case 1: + message.jstype = 1 + break + case 'JS_NUMBER': + case 2: + message.jstype = 2 + break + } + if (object.lazy != null) message.lazy = Boolean(object.lazy) + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated) + if (object.weak != null) message.weak = Boolean(object.weak) + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError( + '.google.protobuf.FieldOptions.uninterpretedOption: array expected' + ) + message.uninterpretedOption = [] + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== 'object') + throw TypeError( + '.google.protobuf.FieldOptions.uninterpretedOption: object expected' + ) + message.uninterpretedOption[ + i + ] = $root.google.protobuf.UninterpretedOption.fromObject( + object.uninterpretedOption[i] + ) + } + } + return message + } + + /** + * Creates a plain object from a FieldOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FieldOptions + * @static + * @param {google.protobuf.FieldOptions} message FieldOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FieldOptions.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) + object.uninterpretedOption = [] + if (options.defaults) { + object.ctype = options.enums === String ? 'STRING' : 0 + object.packed = false + object.deprecated = false + object.lazy = false + object.jstype = options.enums === String ? 'JS_NORMAL' : 0 + object.weak = false + } + if (message.ctype != null && message.hasOwnProperty('ctype')) + object.ctype = + options.enums === String + ? $root.google.protobuf.FieldOptions.CType[message.ctype] + : message.ctype + if (message.packed != null && message.hasOwnProperty('packed')) + object.packed = message.packed + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + object.deprecated = message.deprecated + if (message.lazy != null && message.hasOwnProperty('lazy')) + object.lazy = message.lazy + if (message.jstype != null && message.hasOwnProperty('jstype')) + object.jstype = + options.enums === String + ? $root.google.protobuf.FieldOptions.JSType[ + message.jstype + ] + : message.jstype + if (message.weak != null && message.hasOwnProperty('weak')) + object.weak = message.weak + if ( + message.uninterpretedOption && + message.uninterpretedOption.length + ) { + object.uninterpretedOption = [] + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[ + j + ] = $root.google.protobuf.UninterpretedOption.toObject( + message.uninterpretedOption[j], + options + ) + } + return object + } + + /** + * Converts this FieldOptions to JSON. + * @function toJSON + * @memberof google.protobuf.FieldOptions + * @instance + * @returns {Object.} JSON object + */ + FieldOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + /** + * CType enum. + * @name google.protobuf.FieldOptions.CType + * @enum {string} + * @property {number} STRING=0 STRING value + * @property {number} CORD=1 CORD value + * @property {number} STRING_PIECE=2 STRING_PIECE value + */ + FieldOptions.CType = (function () { + var valuesById = {}, + values = Object.create(valuesById) + values[(valuesById[0] = 'STRING')] = 0 + values[(valuesById[1] = 'CORD')] = 1 + values[(valuesById[2] = 'STRING_PIECE')] = 2 + return values + })() + + /** + * JSType enum. + * @name google.protobuf.FieldOptions.JSType + * @enum {string} + * @property {number} JS_NORMAL=0 JS_NORMAL value + * @property {number} JS_STRING=1 JS_STRING value + * @property {number} JS_NUMBER=2 JS_NUMBER value + */ + FieldOptions.JSType = (function () { + var valuesById = {}, + values = Object.create(valuesById) + values[(valuesById[0] = 'JS_NORMAL')] = 0 + values[(valuesById[1] = 'JS_STRING')] = 1 + values[(valuesById[2] = 'JS_NUMBER')] = 2 + return values + })() + + return FieldOptions + })() + + protobuf.OneofOptions = (function () { + /** + * Properties of an OneofOptions. + * @memberof google.protobuf + * @interface IOneofOptions + * @property {Array.|null} [uninterpretedOption] OneofOptions uninterpretedOption + */ + + /** + * Constructs a new OneofOptions. + * @memberof google.protobuf + * @classdesc Represents an OneofOptions. + * @implements IOneofOptions + * @constructor + * @param {google.protobuf.IOneofOptions=} [properties] Properties to set + */ + function OneofOptions(properties) { + this.uninterpretedOption = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * OneofOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.OneofOptions + * @instance + */ + OneofOptions.prototype.uninterpretedOption = $util.emptyArray + + /** + * Creates a new OneofOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.OneofOptions + * @static + * @param {google.protobuf.IOneofOptions=} [properties] Properties to set + * @returns {google.protobuf.OneofOptions} OneofOptions instance + */ + OneofOptions.create = function create(properties) { + return new OneofOptions(properties) + } + + /** + * Encodes the specified OneofOptions message. Does not implicitly {@link google.protobuf.OneofOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.OneofOptions + * @static + * @param {google.protobuf.IOneofOptions} message OneofOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OneofOptions.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.uninterpretedOption != null && + message.uninterpretedOption.length + ) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode( + message.uninterpretedOption[i], + writer.uint32(/* id 999, wireType 2 =*/ 7994).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified OneofOptions message, length delimited. Does not implicitly {@link google.protobuf.OneofOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.OneofOptions + * @static + * @param {google.protobuf.IOneofOptions} message OneofOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OneofOptions.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an OneofOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.OneofOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.OneofOptions} OneofOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OneofOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.OneofOptions() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 999: + if ( + !( + message.uninterpretedOption && + message.uninterpretedOption.length + ) + ) + message.uninterpretedOption = [] + message.uninterpretedOption.push( + $root.google.protobuf.UninterpretedOption.decode( + reader, + reader.uint32() + ) + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an OneofOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.OneofOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.OneofOptions} OneofOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OneofOptions.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an OneofOptions message. + * @function verify + * @memberof google.protobuf.OneofOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + OneofOptions.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.uninterpretedOption != null && + message.hasOwnProperty('uninterpretedOption') + ) { + if (!Array.isArray(message.uninterpretedOption)) + return 'uninterpretedOption: array expected' + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify( + message.uninterpretedOption[i] + ) + if (error) return 'uninterpretedOption.' + error + } + } + return null + } + + /** + * Creates an OneofOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.OneofOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.OneofOptions} OneofOptions + */ + OneofOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.OneofOptions) + return object + var message = new $root.google.protobuf.OneofOptions() + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError( + '.google.protobuf.OneofOptions.uninterpretedOption: array expected' + ) + message.uninterpretedOption = [] + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== 'object') + throw TypeError( + '.google.protobuf.OneofOptions.uninterpretedOption: object expected' + ) + message.uninterpretedOption[ + i + ] = $root.google.protobuf.UninterpretedOption.fromObject( + object.uninterpretedOption[i] + ) + } + } + return message + } + + /** + * Creates a plain object from an OneofOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.OneofOptions + * @static + * @param {google.protobuf.OneofOptions} message OneofOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + OneofOptions.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) + object.uninterpretedOption = [] + if ( + message.uninterpretedOption && + message.uninterpretedOption.length + ) { + object.uninterpretedOption = [] + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[ + j + ] = $root.google.protobuf.UninterpretedOption.toObject( + message.uninterpretedOption[j], + options + ) + } + return object + } + + /** + * Converts this OneofOptions to JSON. + * @function toJSON + * @memberof google.protobuf.OneofOptions + * @instance + * @returns {Object.} JSON object + */ + OneofOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return OneofOptions + })() + + protobuf.EnumOptions = (function () { + /** + * Properties of an EnumOptions. + * @memberof google.protobuf + * @interface IEnumOptions + * @property {boolean|null} [allowAlias] EnumOptions allowAlias + * @property {boolean|null} [deprecated] EnumOptions deprecated + * @property {Array.|null} [uninterpretedOption] EnumOptions uninterpretedOption + */ + + /** + * Constructs a new EnumOptions. + * @memberof google.protobuf + * @classdesc Represents an EnumOptions. + * @implements IEnumOptions + * @constructor + * @param {google.protobuf.IEnumOptions=} [properties] Properties to set + */ + function EnumOptions(properties) { + this.uninterpretedOption = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * EnumOptions allowAlias. + * @member {boolean} allowAlias + * @memberof google.protobuf.EnumOptions + * @instance + */ + EnumOptions.prototype.allowAlias = false + + /** + * EnumOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.EnumOptions + * @instance + */ + EnumOptions.prototype.deprecated = false + + /** + * EnumOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.EnumOptions + * @instance + */ + EnumOptions.prototype.uninterpretedOption = $util.emptyArray + + /** + * Creates a new EnumOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.EnumOptions + * @static + * @param {google.protobuf.IEnumOptions=} [properties] Properties to set + * @returns {google.protobuf.EnumOptions} EnumOptions instance + */ + EnumOptions.create = function create(properties) { + return new EnumOptions(properties) + } + + /** + * Encodes the specified EnumOptions message. Does not implicitly {@link google.protobuf.EnumOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.EnumOptions + * @static + * @param {google.protobuf.IEnumOptions} message EnumOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumOptions.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.allowAlias != null && + message.hasOwnProperty('allowAlias') + ) + writer + .uint32(/* id 2, wireType 0 =*/ 16) + .bool(message.allowAlias) + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + writer + .uint32(/* id 3, wireType 0 =*/ 24) + .bool(message.deprecated) + if ( + message.uninterpretedOption != null && + message.uninterpretedOption.length + ) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode( + message.uninterpretedOption[i], + writer.uint32(/* id 999, wireType 2 =*/ 7994).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified EnumOptions message, length delimited. Does not implicitly {@link google.protobuf.EnumOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.EnumOptions + * @static + * @param {google.protobuf.IEnumOptions} message EnumOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumOptions.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an EnumOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.EnumOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.EnumOptions} EnumOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.EnumOptions() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 2: + message.allowAlias = reader.bool() + break + case 3: + message.deprecated = reader.bool() + break + case 999: + if ( + !( + message.uninterpretedOption && + message.uninterpretedOption.length + ) + ) + message.uninterpretedOption = [] + message.uninterpretedOption.push( + $root.google.protobuf.UninterpretedOption.decode( + reader, + reader.uint32() + ) + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an EnumOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.EnumOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.EnumOptions} EnumOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumOptions.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an EnumOptions message. + * @function verify + * @memberof google.protobuf.EnumOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + EnumOptions.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.allowAlias != null && + message.hasOwnProperty('allowAlias') + ) + if (typeof message.allowAlias !== 'boolean') + return 'allowAlias: boolean expected' + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + if (typeof message.deprecated !== 'boolean') + return 'deprecated: boolean expected' + if ( + message.uninterpretedOption != null && + message.hasOwnProperty('uninterpretedOption') + ) { + if (!Array.isArray(message.uninterpretedOption)) + return 'uninterpretedOption: array expected' + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify( + message.uninterpretedOption[i] + ) + if (error) return 'uninterpretedOption.' + error + } + } + return null + } + + /** + * Creates an EnumOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.EnumOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.EnumOptions} EnumOptions + */ + EnumOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.EnumOptions) + return object + var message = new $root.google.protobuf.EnumOptions() + if (object.allowAlias != null) + message.allowAlias = Boolean(object.allowAlias) + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated) + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError( + '.google.protobuf.EnumOptions.uninterpretedOption: array expected' + ) + message.uninterpretedOption = [] + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== 'object') + throw TypeError( + '.google.protobuf.EnumOptions.uninterpretedOption: object expected' + ) + message.uninterpretedOption[ + i + ] = $root.google.protobuf.UninterpretedOption.fromObject( + object.uninterpretedOption[i] + ) + } + } + return message + } + + /** + * Creates a plain object from an EnumOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.EnumOptions + * @static + * @param {google.protobuf.EnumOptions} message EnumOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EnumOptions.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) + object.uninterpretedOption = [] + if (options.defaults) { + object.allowAlias = false + object.deprecated = false + } + if ( + message.allowAlias != null && + message.hasOwnProperty('allowAlias') + ) + object.allowAlias = message.allowAlias + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + object.deprecated = message.deprecated + if ( + message.uninterpretedOption && + message.uninterpretedOption.length + ) { + object.uninterpretedOption = [] + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[ + j + ] = $root.google.protobuf.UninterpretedOption.toObject( + message.uninterpretedOption[j], + options + ) + } + return object + } + + /** + * Converts this EnumOptions to JSON. + * @function toJSON + * @memberof google.protobuf.EnumOptions + * @instance + * @returns {Object.} JSON object + */ + EnumOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return EnumOptions + })() + + protobuf.EnumValueOptions = (function () { + /** + * Properties of an EnumValueOptions. + * @memberof google.protobuf + * @interface IEnumValueOptions + * @property {boolean|null} [deprecated] EnumValueOptions deprecated + * @property {Array.|null} [uninterpretedOption] EnumValueOptions uninterpretedOption + */ + + /** + * Constructs a new EnumValueOptions. + * @memberof google.protobuf + * @classdesc Represents an EnumValueOptions. + * @implements IEnumValueOptions + * @constructor + * @param {google.protobuf.IEnumValueOptions=} [properties] Properties to set + */ + function EnumValueOptions(properties) { + this.uninterpretedOption = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * EnumValueOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.EnumValueOptions + * @instance + */ + EnumValueOptions.prototype.deprecated = false + + /** + * EnumValueOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.EnumValueOptions + * @instance + */ + EnumValueOptions.prototype.uninterpretedOption = $util.emptyArray + + /** + * Creates a new EnumValueOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {google.protobuf.IEnumValueOptions=} [properties] Properties to set + * @returns {google.protobuf.EnumValueOptions} EnumValueOptions instance + */ + EnumValueOptions.create = function create(properties) { + return new EnumValueOptions(properties) + } + + /** + * Encodes the specified EnumValueOptions message. Does not implicitly {@link google.protobuf.EnumValueOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {google.protobuf.IEnumValueOptions} message EnumValueOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumValueOptions.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + writer + .uint32(/* id 1, wireType 0 =*/ 8) + .bool(message.deprecated) + if ( + message.uninterpretedOption != null && + message.uninterpretedOption.length + ) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode( + message.uninterpretedOption[i], + writer.uint32(/* id 999, wireType 2 =*/ 7994).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified EnumValueOptions message, length delimited. Does not implicitly {@link google.protobuf.EnumValueOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {google.protobuf.IEnumValueOptions} message EnumValueOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumValueOptions.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an EnumValueOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.EnumValueOptions} EnumValueOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumValueOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.EnumValueOptions() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.deprecated = reader.bool() + break + case 999: + if ( + !( + message.uninterpretedOption && + message.uninterpretedOption.length + ) + ) + message.uninterpretedOption = [] + message.uninterpretedOption.push( + $root.google.protobuf.UninterpretedOption.decode( + reader, + reader.uint32() + ) + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an EnumValueOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.EnumValueOptions} EnumValueOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumValueOptions.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an EnumValueOptions message. + * @function verify + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + EnumValueOptions.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + if (typeof message.deprecated !== 'boolean') + return 'deprecated: boolean expected' + if ( + message.uninterpretedOption != null && + message.hasOwnProperty('uninterpretedOption') + ) { + if (!Array.isArray(message.uninterpretedOption)) + return 'uninterpretedOption: array expected' + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify( + message.uninterpretedOption[i] + ) + if (error) return 'uninterpretedOption.' + error + } + } + return null + } + + /** + * Creates an EnumValueOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.EnumValueOptions} EnumValueOptions + */ + EnumValueOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.EnumValueOptions) + return object + var message = new $root.google.protobuf.EnumValueOptions() + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated) + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError( + '.google.protobuf.EnumValueOptions.uninterpretedOption: array expected' + ) + message.uninterpretedOption = [] + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== 'object') + throw TypeError( + '.google.protobuf.EnumValueOptions.uninterpretedOption: object expected' + ) + message.uninterpretedOption[ + i + ] = $root.google.protobuf.UninterpretedOption.fromObject( + object.uninterpretedOption[i] + ) + } + } + return message + } + + /** + * Creates a plain object from an EnumValueOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {google.protobuf.EnumValueOptions} message EnumValueOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EnumValueOptions.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) + object.uninterpretedOption = [] + if (options.defaults) object.deprecated = false + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + object.deprecated = message.deprecated + if ( + message.uninterpretedOption && + message.uninterpretedOption.length + ) { + object.uninterpretedOption = [] + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[ + j + ] = $root.google.protobuf.UninterpretedOption.toObject( + message.uninterpretedOption[j], + options + ) + } + return object + } + + /** + * Converts this EnumValueOptions to JSON. + * @function toJSON + * @memberof google.protobuf.EnumValueOptions + * @instance + * @returns {Object.} JSON object + */ + EnumValueOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return EnumValueOptions + })() + + protobuf.ServiceOptions = (function () { + /** + * Properties of a ServiceOptions. + * @memberof google.protobuf + * @interface IServiceOptions + * @property {boolean|null} [deprecated] ServiceOptions deprecated + * @property {Array.|null} [uninterpretedOption] ServiceOptions uninterpretedOption + */ + + /** + * Constructs a new ServiceOptions. + * @memberof google.protobuf + * @classdesc Represents a ServiceOptions. + * @implements IServiceOptions + * @constructor + * @param {google.protobuf.IServiceOptions=} [properties] Properties to set + */ + function ServiceOptions(properties) { + this.uninterpretedOption = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * ServiceOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.ServiceOptions + * @instance + */ + ServiceOptions.prototype.deprecated = false + + /** + * ServiceOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.ServiceOptions + * @instance + */ + ServiceOptions.prototype.uninterpretedOption = $util.emptyArray + + /** + * Creates a new ServiceOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.ServiceOptions + * @static + * @param {google.protobuf.IServiceOptions=} [properties] Properties to set + * @returns {google.protobuf.ServiceOptions} ServiceOptions instance + */ + ServiceOptions.create = function create(properties) { + return new ServiceOptions(properties) + } + + /** + * Encodes the specified ServiceOptions message. Does not implicitly {@link google.protobuf.ServiceOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.ServiceOptions + * @static + * @param {google.protobuf.IServiceOptions} message ServiceOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ServiceOptions.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + writer + .uint32(/* id 33, wireType 0 =*/ 264) + .bool(message.deprecated) + if ( + message.uninterpretedOption != null && + message.uninterpretedOption.length + ) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode( + message.uninterpretedOption[i], + writer.uint32(/* id 999, wireType 2 =*/ 7994).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified ServiceOptions message, length delimited. Does not implicitly {@link google.protobuf.ServiceOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.ServiceOptions + * @static + * @param {google.protobuf.IServiceOptions} message ServiceOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ServiceOptions.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a ServiceOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.ServiceOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.ServiceOptions} ServiceOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ServiceOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.ServiceOptions() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool() + break + case 999: + if ( + !( + message.uninterpretedOption && + message.uninterpretedOption.length + ) + ) + message.uninterpretedOption = [] + message.uninterpretedOption.push( + $root.google.protobuf.UninterpretedOption.decode( + reader, + reader.uint32() + ) + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a ServiceOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.ServiceOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.ServiceOptions} ServiceOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ServiceOptions.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a ServiceOptions message. + * @function verify + * @memberof google.protobuf.ServiceOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ServiceOptions.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + if (typeof message.deprecated !== 'boolean') + return 'deprecated: boolean expected' + if ( + message.uninterpretedOption != null && + message.hasOwnProperty('uninterpretedOption') + ) { + if (!Array.isArray(message.uninterpretedOption)) + return 'uninterpretedOption: array expected' + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify( + message.uninterpretedOption[i] + ) + if (error) return 'uninterpretedOption.' + error + } + } + return null + } + + /** + * Creates a ServiceOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.ServiceOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.ServiceOptions} ServiceOptions + */ + ServiceOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.ServiceOptions) + return object + var message = new $root.google.protobuf.ServiceOptions() + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated) + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError( + '.google.protobuf.ServiceOptions.uninterpretedOption: array expected' + ) + message.uninterpretedOption = [] + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== 'object') + throw TypeError( + '.google.protobuf.ServiceOptions.uninterpretedOption: object expected' + ) + message.uninterpretedOption[ + i + ] = $root.google.protobuf.UninterpretedOption.fromObject( + object.uninterpretedOption[i] + ) + } + } + return message + } + + /** + * Creates a plain object from a ServiceOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.ServiceOptions + * @static + * @param {google.protobuf.ServiceOptions} message ServiceOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ServiceOptions.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) + object.uninterpretedOption = [] + if (options.defaults) object.deprecated = false + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + object.deprecated = message.deprecated + if ( + message.uninterpretedOption && + message.uninterpretedOption.length + ) { + object.uninterpretedOption = [] + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[ + j + ] = $root.google.protobuf.UninterpretedOption.toObject( + message.uninterpretedOption[j], + options + ) + } + return object + } + + /** + * Converts this ServiceOptions to JSON. + * @function toJSON + * @memberof google.protobuf.ServiceOptions + * @instance + * @returns {Object.} JSON object + */ + ServiceOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return ServiceOptions + })() + + protobuf.MethodOptions = (function () { + /** + * Properties of a MethodOptions. + * @memberof google.protobuf + * @interface IMethodOptions + * @property {boolean|null} [deprecated] MethodOptions deprecated + * @property {google.protobuf.MethodOptions.IdempotencyLevel|null} [idempotencyLevel] MethodOptions idempotencyLevel + * @property {Array.|null} [uninterpretedOption] MethodOptions uninterpretedOption + * @property {google.longrunning.IOperationInfo|null} [".google.longrunning.operationInfo"] MethodOptions .google.longrunning.operationInfo + * @property {google.api.IHttpRule|null} [".google.api.http"] MethodOptions .google.api.http + */ + + /** + * Constructs a new MethodOptions. + * @memberof google.protobuf + * @classdesc Represents a MethodOptions. + * @implements IMethodOptions + * @constructor + * @param {google.protobuf.IMethodOptions=} [properties] Properties to set + */ + function MethodOptions(properties) { + this.uninterpretedOption = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * MethodOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype.deprecated = false + + /** + * MethodOptions idempotencyLevel. + * @member {google.protobuf.MethodOptions.IdempotencyLevel} idempotencyLevel + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype.idempotencyLevel = 0 + + /** + * MethodOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype.uninterpretedOption = $util.emptyArray + + /** + * MethodOptions .google.longrunning.operationInfo. + * @member {google.longrunning.IOperationInfo|null|undefined} .google.longrunning.operationInfo + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype[ + '.google.longrunning.operationInfo' + ] = null + + /** + * MethodOptions .google.api.http. + * @member {google.api.IHttpRule|null|undefined} .google.api.http + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype['.google.api.http'] = null + + /** + * Creates a new MethodOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.MethodOptions + * @static + * @param {google.protobuf.IMethodOptions=} [properties] Properties to set + * @returns {google.protobuf.MethodOptions} MethodOptions instance + */ + MethodOptions.create = function create(properties) { + return new MethodOptions(properties) + } + + /** + * Encodes the specified MethodOptions message. Does not implicitly {@link google.protobuf.MethodOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.MethodOptions + * @static + * @param {google.protobuf.IMethodOptions} message MethodOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MethodOptions.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + writer + .uint32(/* id 33, wireType 0 =*/ 264) + .bool(message.deprecated) + if ( + message.idempotencyLevel != null && + message.hasOwnProperty('idempotencyLevel') + ) + writer + .uint32(/* id 34, wireType 0 =*/ 272) + .int32(message.idempotencyLevel) + if ( + message.uninterpretedOption != null && + message.uninterpretedOption.length + ) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode( + message.uninterpretedOption[i], + writer.uint32(/* id 999, wireType 2 =*/ 7994).fork() + ).ldelim() + if ( + message['.google.longrunning.operationInfo'] != null && + message.hasOwnProperty('.google.longrunning.operationInfo') + ) + $root.google.longrunning.OperationInfo.encode( + message['.google.longrunning.operationInfo'], + writer.uint32(/* id 1049, wireType 2 =*/ 8394).fork() + ).ldelim() + if ( + message['.google.api.http'] != null && + message.hasOwnProperty('.google.api.http') + ) + $root.google.api.HttpRule.encode( + message['.google.api.http'], + writer + .uint32(/* id 72295728, wireType 2 =*/ 578365826) + .fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified MethodOptions message, length delimited. Does not implicitly {@link google.protobuf.MethodOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.MethodOptions + * @static + * @param {google.protobuf.IMethodOptions} message MethodOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MethodOptions.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a MethodOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.MethodOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.MethodOptions} MethodOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MethodOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.MethodOptions() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool() + break + case 34: + message.idempotencyLevel = reader.int32() + break + case 999: + if ( + !( + message.uninterpretedOption && + message.uninterpretedOption.length + ) + ) + message.uninterpretedOption = [] + message.uninterpretedOption.push( + $root.google.protobuf.UninterpretedOption.decode( + reader, + reader.uint32() + ) + ) + break + case 1049: + message[ + '.google.longrunning.operationInfo' + ] = $root.google.longrunning.OperationInfo.decode( + reader, + reader.uint32() + ) + break + case 72295728: + message[ + '.google.api.http' + ] = $root.google.api.HttpRule.decode( + reader, + reader.uint32() + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a MethodOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.MethodOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.MethodOptions} MethodOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MethodOptions.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a MethodOptions message. + * @function verify + * @memberof google.protobuf.MethodOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + MethodOptions.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + if (typeof message.deprecated !== 'boolean') + return 'deprecated: boolean expected' + if ( + message.idempotencyLevel != null && + message.hasOwnProperty('idempotencyLevel') + ) + switch (message.idempotencyLevel) { + default: + return 'idempotencyLevel: enum value expected' + case 0: + case 1: + case 2: + break + } + if ( + message.uninterpretedOption != null && + message.hasOwnProperty('uninterpretedOption') + ) { + if (!Array.isArray(message.uninterpretedOption)) + return 'uninterpretedOption: array expected' + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify( + message.uninterpretedOption[i] + ) + if (error) return 'uninterpretedOption.' + error + } + } + if ( + message['.google.longrunning.operationInfo'] != null && + message.hasOwnProperty('.google.longrunning.operationInfo') + ) { + var error = $root.google.longrunning.OperationInfo.verify( + message['.google.longrunning.operationInfo'] + ) + if (error) return '.google.longrunning.operationInfo.' + error + } + if ( + message['.google.api.http'] != null && + message.hasOwnProperty('.google.api.http') + ) { + var error = $root.google.api.HttpRule.verify( + message['.google.api.http'] + ) + if (error) return '.google.api.http.' + error + } + return null + } + + /** + * Creates a MethodOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.MethodOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.MethodOptions} MethodOptions + */ + MethodOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.MethodOptions) + return object + var message = new $root.google.protobuf.MethodOptions() + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated) + switch (object.idempotencyLevel) { + case 'IDEMPOTENCY_UNKNOWN': + case 0: + message.idempotencyLevel = 0 + break + case 'NO_SIDE_EFFECTS': + case 1: + message.idempotencyLevel = 1 + break + case 'IDEMPOTENT': + case 2: + message.idempotencyLevel = 2 + break + } + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError( + '.google.protobuf.MethodOptions.uninterpretedOption: array expected' + ) + message.uninterpretedOption = [] + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== 'object') + throw TypeError( + '.google.protobuf.MethodOptions.uninterpretedOption: object expected' + ) + message.uninterpretedOption[ + i + ] = $root.google.protobuf.UninterpretedOption.fromObject( + object.uninterpretedOption[i] + ) + } + } + if (object['.google.longrunning.operationInfo'] != null) { + if ( + typeof object['.google.longrunning.operationInfo'] !== + 'object' + ) + throw TypeError( + '.google.protobuf.MethodOptions..google.longrunning.operationInfo: object expected' + ) + message[ + '.google.longrunning.operationInfo' + ] = $root.google.longrunning.OperationInfo.fromObject( + object['.google.longrunning.operationInfo'] + ) + } + if (object['.google.api.http'] != null) { + if (typeof object['.google.api.http'] !== 'object') + throw TypeError( + '.google.protobuf.MethodOptions..google.api.http: object expected' + ) + message[ + '.google.api.http' + ] = $root.google.api.HttpRule.fromObject( + object['.google.api.http'] + ) + } + return message + } + + /** + * Creates a plain object from a MethodOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.MethodOptions + * @static + * @param {google.protobuf.MethodOptions} message MethodOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MethodOptions.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) + object.uninterpretedOption = [] + if (options.defaults) { + object.deprecated = false + object.idempotencyLevel = + options.enums === String ? 'IDEMPOTENCY_UNKNOWN' : 0 + object['.google.longrunning.operationInfo'] = null + object['.google.api.http'] = null + } + if ( + message.deprecated != null && + message.hasOwnProperty('deprecated') + ) + object.deprecated = message.deprecated + if ( + message.idempotencyLevel != null && + message.hasOwnProperty('idempotencyLevel') + ) + object.idempotencyLevel = + options.enums === String + ? $root.google.protobuf.MethodOptions.IdempotencyLevel[ + message.idempotencyLevel + ] + : message.idempotencyLevel + if ( + message.uninterpretedOption && + message.uninterpretedOption.length + ) { + object.uninterpretedOption = [] + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[ + j + ] = $root.google.protobuf.UninterpretedOption.toObject( + message.uninterpretedOption[j], + options + ) + } + if ( + message['.google.longrunning.operationInfo'] != null && + message.hasOwnProperty('.google.longrunning.operationInfo') + ) + object[ + '.google.longrunning.operationInfo' + ] = $root.google.longrunning.OperationInfo.toObject( + message['.google.longrunning.operationInfo'], + options + ) + if ( + message['.google.api.http'] != null && + message.hasOwnProperty('.google.api.http') + ) + object[ + '.google.api.http' + ] = $root.google.api.HttpRule.toObject( + message['.google.api.http'], + options + ) + return object + } + + /** + * Converts this MethodOptions to JSON. + * @function toJSON + * @memberof google.protobuf.MethodOptions + * @instance + * @returns {Object.} JSON object + */ + MethodOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + /** + * IdempotencyLevel enum. + * @name google.protobuf.MethodOptions.IdempotencyLevel + * @enum {string} + * @property {number} IDEMPOTENCY_UNKNOWN=0 IDEMPOTENCY_UNKNOWN value + * @property {number} NO_SIDE_EFFECTS=1 NO_SIDE_EFFECTS value + * @property {number} IDEMPOTENT=2 IDEMPOTENT value + */ + MethodOptions.IdempotencyLevel = (function () { + var valuesById = {}, + values = Object.create(valuesById) + values[(valuesById[0] = 'IDEMPOTENCY_UNKNOWN')] = 0 + values[(valuesById[1] = 'NO_SIDE_EFFECTS')] = 1 + values[(valuesById[2] = 'IDEMPOTENT')] = 2 + return values + })() + + return MethodOptions + })() + + protobuf.UninterpretedOption = (function () { + /** + * Properties of an UninterpretedOption. + * @memberof google.protobuf + * @interface IUninterpretedOption + * @property {Array.|null} [name] UninterpretedOption name + * @property {string|null} [identifierValue] UninterpretedOption identifierValue + * @property {number|Long|null} [positiveIntValue] UninterpretedOption positiveIntValue + * @property {number|Long|null} [negativeIntValue] UninterpretedOption negativeIntValue + * @property {number|null} [doubleValue] UninterpretedOption doubleValue + * @property {Uint8Array|null} [stringValue] UninterpretedOption stringValue + * @property {string|null} [aggregateValue] UninterpretedOption aggregateValue + */ + + /** + * Constructs a new UninterpretedOption. + * @memberof google.protobuf + * @classdesc Represents an UninterpretedOption. + * @implements IUninterpretedOption + * @constructor + * @param {google.protobuf.IUninterpretedOption=} [properties] Properties to set + */ + function UninterpretedOption(properties) { + this.name = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * UninterpretedOption name. + * @member {Array.} name + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.name = $util.emptyArray + + /** + * UninterpretedOption identifierValue. + * @member {string} identifierValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.identifierValue = '' + + /** + * UninterpretedOption positiveIntValue. + * @member {number|Long} positiveIntValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.positiveIntValue = $util.Long + ? $util.Long.fromBits(0, 0, true) + : 0 + + /** + * UninterpretedOption negativeIntValue. + * @member {number|Long} negativeIntValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.negativeIntValue = $util.Long + ? $util.Long.fromBits(0, 0, false) + : 0 + + /** + * UninterpretedOption doubleValue. + * @member {number} doubleValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.doubleValue = 0 + + /** + * UninterpretedOption stringValue. + * @member {Uint8Array} stringValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.stringValue = $util.newBuffer([]) + + /** + * UninterpretedOption aggregateValue. + * @member {string} aggregateValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.aggregateValue = '' + + /** + * Creates a new UninterpretedOption instance using the specified properties. + * @function create + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {google.protobuf.IUninterpretedOption=} [properties] Properties to set + * @returns {google.protobuf.UninterpretedOption} UninterpretedOption instance + */ + UninterpretedOption.create = function create(properties) { + return new UninterpretedOption(properties) + } + + /** + * Encodes the specified UninterpretedOption message. Does not implicitly {@link google.protobuf.UninterpretedOption.verify|verify} messages. + * @function encode + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {google.protobuf.IUninterpretedOption} message UninterpretedOption message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UninterpretedOption.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.name != null && message.name.length) + for (var i = 0; i < message.name.length; ++i) + $root.google.protobuf.UninterpretedOption.NamePart.encode( + message.name[i], + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + ).ldelim() + if ( + message.identifierValue != null && + message.hasOwnProperty('identifierValue') + ) + writer + .uint32(/* id 3, wireType 2 =*/ 26) + .string(message.identifierValue) + if ( + message.positiveIntValue != null && + message.hasOwnProperty('positiveIntValue') + ) + writer + .uint32(/* id 4, wireType 0 =*/ 32) + .uint64(message.positiveIntValue) + if ( + message.negativeIntValue != null && + message.hasOwnProperty('negativeIntValue') + ) + writer + .uint32(/* id 5, wireType 0 =*/ 40) + .int64(message.negativeIntValue) + if ( + message.doubleValue != null && + message.hasOwnProperty('doubleValue') + ) + writer + .uint32(/* id 6, wireType 1 =*/ 49) + .double(message.doubleValue) + if ( + message.stringValue != null && + message.hasOwnProperty('stringValue') + ) + writer + .uint32(/* id 7, wireType 2 =*/ 58) + .bytes(message.stringValue) + if ( + message.aggregateValue != null && + message.hasOwnProperty('aggregateValue') + ) + writer + .uint32(/* id 8, wireType 2 =*/ 66) + .string(message.aggregateValue) + return writer + } + + /** + * Encodes the specified UninterpretedOption message, length delimited. Does not implicitly {@link google.protobuf.UninterpretedOption.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {google.protobuf.IUninterpretedOption} message UninterpretedOption message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UninterpretedOption.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an UninterpretedOption message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.UninterpretedOption} UninterpretedOption + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UninterpretedOption.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.UninterpretedOption() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 2: + if (!(message.name && message.name.length)) + message.name = [] + message.name.push( + $root.google.protobuf.UninterpretedOption.NamePart.decode( + reader, + reader.uint32() + ) + ) + break + case 3: + message.identifierValue = reader.string() + break + case 4: + message.positiveIntValue = reader.uint64() + break + case 5: + message.negativeIntValue = reader.int64() + break + case 6: + message.doubleValue = reader.double() + break + case 7: + message.stringValue = reader.bytes() + break + case 8: + message.aggregateValue = reader.string() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an UninterpretedOption message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.UninterpretedOption} UninterpretedOption + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UninterpretedOption.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an UninterpretedOption message. + * @function verify + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UninterpretedOption.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.name != null && message.hasOwnProperty('name')) { + if (!Array.isArray(message.name)) + return 'name: array expected' + for (var i = 0; i < message.name.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.NamePart.verify( + message.name[i] + ) + if (error) return 'name.' + error + } + } + if ( + message.identifierValue != null && + message.hasOwnProperty('identifierValue') + ) + if (!$util.isString(message.identifierValue)) + return 'identifierValue: string expected' + if ( + message.positiveIntValue != null && + message.hasOwnProperty('positiveIntValue') + ) + if ( + !$util.isInteger(message.positiveIntValue) && + !( + message.positiveIntValue && + $util.isInteger(message.positiveIntValue.low) && + $util.isInteger(message.positiveIntValue.high) + ) + ) + return 'positiveIntValue: integer|Long expected' + if ( + message.negativeIntValue != null && + message.hasOwnProperty('negativeIntValue') + ) + if ( + !$util.isInteger(message.negativeIntValue) && + !( + message.negativeIntValue && + $util.isInteger(message.negativeIntValue.low) && + $util.isInteger(message.negativeIntValue.high) + ) + ) + return 'negativeIntValue: integer|Long expected' + if ( + message.doubleValue != null && + message.hasOwnProperty('doubleValue') + ) + if (typeof message.doubleValue !== 'number') + return 'doubleValue: number expected' + if ( + message.stringValue != null && + message.hasOwnProperty('stringValue') + ) + if ( + !( + (message.stringValue && + typeof message.stringValue.length === 'number') || + $util.isString(message.stringValue) + ) + ) + return 'stringValue: buffer expected' + if ( + message.aggregateValue != null && + message.hasOwnProperty('aggregateValue') + ) + if (!$util.isString(message.aggregateValue)) + return 'aggregateValue: string expected' + return null + } + + /** + * Creates an UninterpretedOption message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.UninterpretedOption} UninterpretedOption + */ + UninterpretedOption.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.UninterpretedOption) + return object + var message = new $root.google.protobuf.UninterpretedOption() + if (object.name) { + if (!Array.isArray(object.name)) + throw TypeError( + '.google.protobuf.UninterpretedOption.name: array expected' + ) + message.name = [] + for (var i = 0; i < object.name.length; ++i) { + if (typeof object.name[i] !== 'object') + throw TypeError( + '.google.protobuf.UninterpretedOption.name: object expected' + ) + message.name[ + i + ] = $root.google.protobuf.UninterpretedOption.NamePart.fromObject( + object.name[i] + ) + } + } + if (object.identifierValue != null) + message.identifierValue = String(object.identifierValue) + if (object.positiveIntValue != null) + if ($util.Long) + (message.positiveIntValue = $util.Long.fromValue( + object.positiveIntValue + )).unsigned = true + else if (typeof object.positiveIntValue === 'string') + message.positiveIntValue = parseInt( + object.positiveIntValue, + 10 + ) + else if (typeof object.positiveIntValue === 'number') + message.positiveIntValue = object.positiveIntValue + else if (typeof object.positiveIntValue === 'object') + message.positiveIntValue = new $util.LongBits( + object.positiveIntValue.low >>> 0, + object.positiveIntValue.high >>> 0 + ).toNumber(true) + if (object.negativeIntValue != null) + if ($util.Long) + (message.negativeIntValue = $util.Long.fromValue( + object.negativeIntValue + )).unsigned = false + else if (typeof object.negativeIntValue === 'string') + message.negativeIntValue = parseInt( + object.negativeIntValue, + 10 + ) + else if (typeof object.negativeIntValue === 'number') + message.negativeIntValue = object.negativeIntValue + else if (typeof object.negativeIntValue === 'object') + message.negativeIntValue = new $util.LongBits( + object.negativeIntValue.low >>> 0, + object.negativeIntValue.high >>> 0 + ).toNumber() + if (object.doubleValue != null) + message.doubleValue = Number(object.doubleValue) + if (object.stringValue != null) + if (typeof object.stringValue === 'string') + $util.base64.decode( + object.stringValue, + (message.stringValue = $util.newBuffer( + $util.base64.length(object.stringValue) + )), + 0 + ) + else if (object.stringValue.length) + message.stringValue = object.stringValue + if (object.aggregateValue != null) + message.aggregateValue = String(object.aggregateValue) + return message + } + + /** + * Creates a plain object from an UninterpretedOption message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {google.protobuf.UninterpretedOption} message UninterpretedOption + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UninterpretedOption.toObject = function toObject( + message, + options + ) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) object.name = [] + if (options.defaults) { + object.identifierValue = '' + if ($util.Long) { + var long = new $util.Long(0, 0, true) + object.positiveIntValue = + options.longs === String + ? long.toString() + : options.longs === Number + ? long.toNumber() + : long + } else + object.positiveIntValue = options.longs === String ? '0' : 0 + if ($util.Long) { + var long = new $util.Long(0, 0, false) + object.negativeIntValue = + options.longs === String + ? long.toString() + : options.longs === Number + ? long.toNumber() + : long + } else + object.negativeIntValue = options.longs === String ? '0' : 0 + object.doubleValue = 0 + if (options.bytes === String) object.stringValue = '' + else { + object.stringValue = [] + if (options.bytes !== Array) + object.stringValue = $util.newBuffer(object.stringValue) + } + object.aggregateValue = '' + } + if (message.name && message.name.length) { + object.name = [] + for (var j = 0; j < message.name.length; ++j) + object.name[ + j + ] = $root.google.protobuf.UninterpretedOption.NamePart.toObject( + message.name[j], + options + ) + } + if ( + message.identifierValue != null && + message.hasOwnProperty('identifierValue') + ) + object.identifierValue = message.identifierValue + if ( + message.positiveIntValue != null && + message.hasOwnProperty('positiveIntValue') + ) + if (typeof message.positiveIntValue === 'number') + object.positiveIntValue = + options.longs === String + ? String(message.positiveIntValue) + : message.positiveIntValue + else + object.positiveIntValue = + options.longs === String + ? $util.Long.prototype.toString.call( + message.positiveIntValue + ) + : options.longs === Number + ? new $util.LongBits( + message.positiveIntValue.low >>> 0, + message.positiveIntValue.high >>> 0 + ).toNumber(true) + : message.positiveIntValue + if ( + message.negativeIntValue != null && + message.hasOwnProperty('negativeIntValue') + ) + if (typeof message.negativeIntValue === 'number') + object.negativeIntValue = + options.longs === String + ? String(message.negativeIntValue) + : message.negativeIntValue + else + object.negativeIntValue = + options.longs === String + ? $util.Long.prototype.toString.call( + message.negativeIntValue + ) + : options.longs === Number + ? new $util.LongBits( + message.negativeIntValue.low >>> 0, + message.negativeIntValue.high >>> 0 + ).toNumber() + : message.negativeIntValue + if ( + message.doubleValue != null && + message.hasOwnProperty('doubleValue') + ) + object.doubleValue = + options.json && !isFinite(message.doubleValue) + ? String(message.doubleValue) + : message.doubleValue + if ( + message.stringValue != null && + message.hasOwnProperty('stringValue') + ) + object.stringValue = + options.bytes === String + ? $util.base64.encode( + message.stringValue, + 0, + message.stringValue.length + ) + : options.bytes === Array + ? Array.prototype.slice.call(message.stringValue) + : message.stringValue + if ( + message.aggregateValue != null && + message.hasOwnProperty('aggregateValue') + ) + object.aggregateValue = message.aggregateValue + return object + } + + /** + * Converts this UninterpretedOption to JSON. + * @function toJSON + * @memberof google.protobuf.UninterpretedOption + * @instance + * @returns {Object.} JSON object + */ + UninterpretedOption.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + UninterpretedOption.NamePart = (function () { + /** + * Properties of a NamePart. + * @memberof google.protobuf.UninterpretedOption + * @interface INamePart + * @property {string} namePart NamePart namePart + * @property {boolean} isExtension NamePart isExtension + */ + + /** + * Constructs a new NamePart. + * @memberof google.protobuf.UninterpretedOption + * @classdesc Represents a NamePart. + * @implements INamePart + * @constructor + * @param {google.protobuf.UninterpretedOption.INamePart=} [properties] Properties to set + */ + function NamePart(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * NamePart namePart. + * @member {string} namePart + * @memberof google.protobuf.UninterpretedOption.NamePart + * @instance + */ + NamePart.prototype.namePart = '' + + /** + * NamePart isExtension. + * @member {boolean} isExtension + * @memberof google.protobuf.UninterpretedOption.NamePart + * @instance + */ + NamePart.prototype.isExtension = false + + /** + * Creates a new NamePart instance using the specified properties. + * @function create + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {google.protobuf.UninterpretedOption.INamePart=} [properties] Properties to set + * @returns {google.protobuf.UninterpretedOption.NamePart} NamePart instance + */ + NamePart.create = function create(properties) { + return new NamePart(properties) + } + + /** + * Encodes the specified NamePart message. Does not implicitly {@link google.protobuf.UninterpretedOption.NamePart.verify|verify} messages. + * @function encode + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {google.protobuf.UninterpretedOption.INamePart} message NamePart message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + NamePart.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.namePart) + writer + .uint32(/* id 2, wireType 0 =*/ 16) + .bool(message.isExtension) + return writer + } + + /** + * Encodes the specified NamePart message, length delimited. Does not implicitly {@link google.protobuf.UninterpretedOption.NamePart.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {google.protobuf.UninterpretedOption.INamePart} message NamePart message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + NamePart.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a NamePart message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.UninterpretedOption.NamePart} NamePart + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + NamePart.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.UninterpretedOption.NamePart() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.namePart = reader.string() + break + case 2: + message.isExtension = reader.bool() + break + default: + reader.skipType(tag & 7) + break + } + } + if (!message.hasOwnProperty('namePart')) + throw $util.ProtocolError("missing required 'namePart'", { + instance: message + }) + if (!message.hasOwnProperty('isExtension')) + throw $util.ProtocolError( + "missing required 'isExtension'", + { instance: message } + ) + return message + } + + /** + * Decodes a NamePart message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.UninterpretedOption.NamePart} NamePart + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + NamePart.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a NamePart message. + * @function verify + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + NamePart.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (!$util.isString(message.namePart)) + return 'namePart: string expected' + if (typeof message.isExtension !== 'boolean') + return 'isExtension: boolean expected' + return null + } + + /** + * Creates a NamePart message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.UninterpretedOption.NamePart} NamePart + */ + NamePart.fromObject = function fromObject(object) { + if ( + object instanceof + $root.google.protobuf.UninterpretedOption.NamePart + ) + return object + var message = new $root.google.protobuf.UninterpretedOption.NamePart() + if (object.namePart != null) + message.namePart = String(object.namePart) + if (object.isExtension != null) + message.isExtension = Boolean(object.isExtension) + return message + } + + /** + * Creates a plain object from a NamePart message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {google.protobuf.UninterpretedOption.NamePart} message NamePart + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + NamePart.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.namePart = '' + object.isExtension = false + } + if ( + message.namePart != null && + message.hasOwnProperty('namePart') + ) + object.namePart = message.namePart + if ( + message.isExtension != null && + message.hasOwnProperty('isExtension') + ) + object.isExtension = message.isExtension + return object + } + + /** + * Converts this NamePart to JSON. + * @function toJSON + * @memberof google.protobuf.UninterpretedOption.NamePart + * @instance + * @returns {Object.} JSON object + */ + NamePart.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return NamePart + })() + + return UninterpretedOption + })() + + protobuf.SourceCodeInfo = (function () { + /** + * Properties of a SourceCodeInfo. + * @memberof google.protobuf + * @interface ISourceCodeInfo + * @property {Array.|null} [location] SourceCodeInfo location + */ + + /** + * Constructs a new SourceCodeInfo. + * @memberof google.protobuf + * @classdesc Represents a SourceCodeInfo. + * @implements ISourceCodeInfo + * @constructor + * @param {google.protobuf.ISourceCodeInfo=} [properties] Properties to set + */ + function SourceCodeInfo(properties) { + this.location = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * SourceCodeInfo location. + * @member {Array.} location + * @memberof google.protobuf.SourceCodeInfo + * @instance + */ + SourceCodeInfo.prototype.location = $util.emptyArray + + /** + * Creates a new SourceCodeInfo instance using the specified properties. + * @function create + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {google.protobuf.ISourceCodeInfo=} [properties] Properties to set + * @returns {google.protobuf.SourceCodeInfo} SourceCodeInfo instance + */ + SourceCodeInfo.create = function create(properties) { + return new SourceCodeInfo(properties) + } + + /** + * Encodes the specified SourceCodeInfo message. Does not implicitly {@link google.protobuf.SourceCodeInfo.verify|verify} messages. + * @function encode + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {google.protobuf.ISourceCodeInfo} message SourceCodeInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SourceCodeInfo.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.location != null && message.location.length) + for (var i = 0; i < message.location.length; ++i) + $root.google.protobuf.SourceCodeInfo.Location.encode( + message.location[i], + writer.uint32(/* id 1, wireType 2 =*/ 10).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified SourceCodeInfo message, length delimited. Does not implicitly {@link google.protobuf.SourceCodeInfo.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {google.protobuf.ISourceCodeInfo} message SourceCodeInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SourceCodeInfo.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a SourceCodeInfo message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.SourceCodeInfo} SourceCodeInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SourceCodeInfo.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.SourceCodeInfo() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + if (!(message.location && message.location.length)) + message.location = [] + message.location.push( + $root.google.protobuf.SourceCodeInfo.Location.decode( + reader, + reader.uint32() + ) + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a SourceCodeInfo message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.SourceCodeInfo} SourceCodeInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SourceCodeInfo.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a SourceCodeInfo message. + * @function verify + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SourceCodeInfo.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.location != null && + message.hasOwnProperty('location') + ) { + if (!Array.isArray(message.location)) + return 'location: array expected' + for (var i = 0; i < message.location.length; ++i) { + var error = $root.google.protobuf.SourceCodeInfo.Location.verify( + message.location[i] + ) + if (error) return 'location.' + error + } + } + return null + } + + /** + * Creates a SourceCodeInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.SourceCodeInfo} SourceCodeInfo + */ + SourceCodeInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.SourceCodeInfo) + return object + var message = new $root.google.protobuf.SourceCodeInfo() + if (object.location) { + if (!Array.isArray(object.location)) + throw TypeError( + '.google.protobuf.SourceCodeInfo.location: array expected' + ) + message.location = [] + for (var i = 0; i < object.location.length; ++i) { + if (typeof object.location[i] !== 'object') + throw TypeError( + '.google.protobuf.SourceCodeInfo.location: object expected' + ) + message.location[ + i + ] = $root.google.protobuf.SourceCodeInfo.Location.fromObject( + object.location[i] + ) + } + } + return message + } + + /** + * Creates a plain object from a SourceCodeInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {google.protobuf.SourceCodeInfo} message SourceCodeInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SourceCodeInfo.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) object.location = [] + if (message.location && message.location.length) { + object.location = [] + for (var j = 0; j < message.location.length; ++j) + object.location[ + j + ] = $root.google.protobuf.SourceCodeInfo.Location.toObject( + message.location[j], + options + ) + } + return object + } + + /** + * Converts this SourceCodeInfo to JSON. + * @function toJSON + * @memberof google.protobuf.SourceCodeInfo + * @instance + * @returns {Object.} JSON object + */ + SourceCodeInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + SourceCodeInfo.Location = (function () { + /** + * Properties of a Location. + * @memberof google.protobuf.SourceCodeInfo + * @interface ILocation + * @property {Array.|null} [path] Location path + * @property {Array.|null} [span] Location span + * @property {string|null} [leadingComments] Location leadingComments + * @property {string|null} [trailingComments] Location trailingComments + * @property {Array.|null} [leadingDetachedComments] Location leadingDetachedComments + */ + + /** + * Constructs a new Location. + * @memberof google.protobuf.SourceCodeInfo + * @classdesc Represents a Location. + * @implements ILocation + * @constructor + * @param {google.protobuf.SourceCodeInfo.ILocation=} [properties] Properties to set + */ + function Location(properties) { + this.path = [] + this.span = [] + this.leadingDetachedComments = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * Location path. + * @member {Array.} path + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.path = $util.emptyArray + + /** + * Location span. + * @member {Array.} span + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.span = $util.emptyArray + + /** + * Location leadingComments. + * @member {string} leadingComments + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.leadingComments = '' + + /** + * Location trailingComments. + * @member {string} trailingComments + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.trailingComments = '' + + /** + * Location leadingDetachedComments. + * @member {Array.} leadingDetachedComments + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.leadingDetachedComments = $util.emptyArray + + /** + * Creates a new Location instance using the specified properties. + * @function create + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {google.protobuf.SourceCodeInfo.ILocation=} [properties] Properties to set + * @returns {google.protobuf.SourceCodeInfo.Location} Location instance + */ + Location.create = function create(properties) { + return new Location(properties) + } + + /** + * Encodes the specified Location message. Does not implicitly {@link google.protobuf.SourceCodeInfo.Location.verify|verify} messages. + * @function encode + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {google.protobuf.SourceCodeInfo.ILocation} message Location message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Location.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.path != null && message.path.length) { + writer.uint32(/* id 1, wireType 2 =*/ 10).fork() + for (var i = 0; i < message.path.length; ++i) + writer.int32(message.path[i]) + writer.ldelim() + } + if (message.span != null && message.span.length) { + writer.uint32(/* id 2, wireType 2 =*/ 18).fork() + for (var i = 0; i < message.span.length; ++i) + writer.int32(message.span[i]) + writer.ldelim() + } + if ( + message.leadingComments != null && + message.hasOwnProperty('leadingComments') + ) + writer + .uint32(/* id 3, wireType 2 =*/ 26) + .string(message.leadingComments) + if ( + message.trailingComments != null && + message.hasOwnProperty('trailingComments') + ) + writer + .uint32(/* id 4, wireType 2 =*/ 34) + .string(message.trailingComments) + if ( + message.leadingDetachedComments != null && + message.leadingDetachedComments.length + ) + for ( + var i = 0; + i < message.leadingDetachedComments.length; + ++i + ) + writer + .uint32(/* id 6, wireType 2 =*/ 50) + .string(message.leadingDetachedComments[i]) + return writer + } + + /** + * Encodes the specified Location message, length delimited. Does not implicitly {@link google.protobuf.SourceCodeInfo.Location.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {google.protobuf.SourceCodeInfo.ILocation} message Location message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Location.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a Location message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.SourceCodeInfo.Location} Location + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Location.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.SourceCodeInfo.Location() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + if (!(message.path && message.path.length)) + message.path = [] + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos + while (reader.pos < end2) + message.path.push(reader.int32()) + } else message.path.push(reader.int32()) + break + case 2: + if (!(message.span && message.span.length)) + message.span = [] + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos + while (reader.pos < end2) + message.span.push(reader.int32()) + } else message.span.push(reader.int32()) + break + case 3: + message.leadingComments = reader.string() + break + case 4: + message.trailingComments = reader.string() + break + case 6: + if ( + !( + message.leadingDetachedComments && + message.leadingDetachedComments.length + ) + ) + message.leadingDetachedComments = [] + message.leadingDetachedComments.push(reader.string()) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a Location message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.SourceCodeInfo.Location} Location + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Location.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a Location message. + * @function verify + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Location.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.path != null && message.hasOwnProperty('path')) { + if (!Array.isArray(message.path)) + return 'path: array expected' + for (var i = 0; i < message.path.length; ++i) + if (!$util.isInteger(message.path[i])) + return 'path: integer[] expected' + } + if (message.span != null && message.hasOwnProperty('span')) { + if (!Array.isArray(message.span)) + return 'span: array expected' + for (var i = 0; i < message.span.length; ++i) + if (!$util.isInteger(message.span[i])) + return 'span: integer[] expected' + } + if ( + message.leadingComments != null && + message.hasOwnProperty('leadingComments') + ) + if (!$util.isString(message.leadingComments)) + return 'leadingComments: string expected' + if ( + message.trailingComments != null && + message.hasOwnProperty('trailingComments') + ) + if (!$util.isString(message.trailingComments)) + return 'trailingComments: string expected' + if ( + message.leadingDetachedComments != null && + message.hasOwnProperty('leadingDetachedComments') + ) { + if (!Array.isArray(message.leadingDetachedComments)) + return 'leadingDetachedComments: array expected' + for ( + var i = 0; + i < message.leadingDetachedComments.length; + ++i + ) + if (!$util.isString(message.leadingDetachedComments[i])) + return 'leadingDetachedComments: string[] expected' + } + return null + } + + /** + * Creates a Location message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.SourceCodeInfo.Location} Location + */ + Location.fromObject = function fromObject(object) { + if ( + object instanceof + $root.google.protobuf.SourceCodeInfo.Location + ) + return object + var message = new $root.google.protobuf.SourceCodeInfo.Location() + if (object.path) { + if (!Array.isArray(object.path)) + throw TypeError( + '.google.protobuf.SourceCodeInfo.Location.path: array expected' + ) + message.path = [] + for (var i = 0; i < object.path.length; ++i) + message.path[i] = object.path[i] | 0 + } + if (object.span) { + if (!Array.isArray(object.span)) + throw TypeError( + '.google.protobuf.SourceCodeInfo.Location.span: array expected' + ) + message.span = [] + for (var i = 0; i < object.span.length; ++i) + message.span[i] = object.span[i] | 0 + } + if (object.leadingComments != null) + message.leadingComments = String(object.leadingComments) + if (object.trailingComments != null) + message.trailingComments = String(object.trailingComments) + if (object.leadingDetachedComments) { + if (!Array.isArray(object.leadingDetachedComments)) + throw TypeError( + '.google.protobuf.SourceCodeInfo.Location.leadingDetachedComments: array expected' + ) + message.leadingDetachedComments = [] + for ( + var i = 0; + i < object.leadingDetachedComments.length; + ++i + ) + message.leadingDetachedComments[i] = String( + object.leadingDetachedComments[i] + ) + } + return message + } + + /** + * Creates a plain object from a Location message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {google.protobuf.SourceCodeInfo.Location} message Location + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Location.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) { + object.path = [] + object.span = [] + object.leadingDetachedComments = [] + } + if (options.defaults) { + object.leadingComments = '' + object.trailingComments = '' + } + if (message.path && message.path.length) { + object.path = [] + for (var j = 0; j < message.path.length; ++j) + object.path[j] = message.path[j] + } + if (message.span && message.span.length) { + object.span = [] + for (var j = 0; j < message.span.length; ++j) + object.span[j] = message.span[j] + } + if ( + message.leadingComments != null && + message.hasOwnProperty('leadingComments') + ) + object.leadingComments = message.leadingComments + if ( + message.trailingComments != null && + message.hasOwnProperty('trailingComments') + ) + object.trailingComments = message.trailingComments + if ( + message.leadingDetachedComments && + message.leadingDetachedComments.length + ) { + object.leadingDetachedComments = [] + for ( + var j = 0; + j < message.leadingDetachedComments.length; + ++j + ) + object.leadingDetachedComments[j] = + message.leadingDetachedComments[j] + } + return object + } + + /** + * Converts this Location to JSON. + * @function toJSON + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + * @returns {Object.} JSON object + */ + Location.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return Location + })() + + return SourceCodeInfo + })() + + protobuf.GeneratedCodeInfo = (function () { + /** + * Properties of a GeneratedCodeInfo. + * @memberof google.protobuf + * @interface IGeneratedCodeInfo + * @property {Array.|null} [annotation] GeneratedCodeInfo annotation + */ + + /** + * Constructs a new GeneratedCodeInfo. + * @memberof google.protobuf + * @classdesc Represents a GeneratedCodeInfo. + * @implements IGeneratedCodeInfo + * @constructor + * @param {google.protobuf.IGeneratedCodeInfo=} [properties] Properties to set + */ + function GeneratedCodeInfo(properties) { + this.annotation = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * GeneratedCodeInfo annotation. + * @member {Array.} annotation + * @memberof google.protobuf.GeneratedCodeInfo + * @instance + */ + GeneratedCodeInfo.prototype.annotation = $util.emptyArray + + /** + * Creates a new GeneratedCodeInfo instance using the specified properties. + * @function create + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {google.protobuf.IGeneratedCodeInfo=} [properties] Properties to set + * @returns {google.protobuf.GeneratedCodeInfo} GeneratedCodeInfo instance + */ + GeneratedCodeInfo.create = function create(properties) { + return new GeneratedCodeInfo(properties) + } + + /** + * Encodes the specified GeneratedCodeInfo message. Does not implicitly {@link google.protobuf.GeneratedCodeInfo.verify|verify} messages. + * @function encode + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {google.protobuf.IGeneratedCodeInfo} message GeneratedCodeInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GeneratedCodeInfo.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.annotation != null && message.annotation.length) + for (var i = 0; i < message.annotation.length; ++i) + $root.google.protobuf.GeneratedCodeInfo.Annotation.encode( + message.annotation[i], + writer.uint32(/* id 1, wireType 2 =*/ 10).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified GeneratedCodeInfo message, length delimited. Does not implicitly {@link google.protobuf.GeneratedCodeInfo.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {google.protobuf.IGeneratedCodeInfo} message GeneratedCodeInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GeneratedCodeInfo.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a GeneratedCodeInfo message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.GeneratedCodeInfo} GeneratedCodeInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GeneratedCodeInfo.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.GeneratedCodeInfo() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + if (!(message.annotation && message.annotation.length)) + message.annotation = [] + message.annotation.push( + $root.google.protobuf.GeneratedCodeInfo.Annotation.decode( + reader, + reader.uint32() + ) + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a GeneratedCodeInfo message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.GeneratedCodeInfo} GeneratedCodeInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GeneratedCodeInfo.decodeDelimited = function decodeDelimited( + reader + ) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a GeneratedCodeInfo message. + * @function verify + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GeneratedCodeInfo.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.annotation != null && + message.hasOwnProperty('annotation') + ) { + if (!Array.isArray(message.annotation)) + return 'annotation: array expected' + for (var i = 0; i < message.annotation.length; ++i) { + var error = $root.google.protobuf.GeneratedCodeInfo.Annotation.verify( + message.annotation[i] + ) + if (error) return 'annotation.' + error + } + } + return null + } + + /** + * Creates a GeneratedCodeInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.GeneratedCodeInfo} GeneratedCodeInfo + */ + GeneratedCodeInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.GeneratedCodeInfo) + return object + var message = new $root.google.protobuf.GeneratedCodeInfo() + if (object.annotation) { + if (!Array.isArray(object.annotation)) + throw TypeError( + '.google.protobuf.GeneratedCodeInfo.annotation: array expected' + ) + message.annotation = [] + for (var i = 0; i < object.annotation.length; ++i) { + if (typeof object.annotation[i] !== 'object') + throw TypeError( + '.google.protobuf.GeneratedCodeInfo.annotation: object expected' + ) + message.annotation[ + i + ] = $root.google.protobuf.GeneratedCodeInfo.Annotation.fromObject( + object.annotation[i] + ) + } + } + return message + } + + /** + * Creates a plain object from a GeneratedCodeInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {google.protobuf.GeneratedCodeInfo} message GeneratedCodeInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GeneratedCodeInfo.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) object.annotation = [] + if (message.annotation && message.annotation.length) { + object.annotation = [] + for (var j = 0; j < message.annotation.length; ++j) + object.annotation[ + j + ] = $root.google.protobuf.GeneratedCodeInfo.Annotation.toObject( + message.annotation[j], + options + ) + } + return object + } + + /** + * Converts this GeneratedCodeInfo to JSON. + * @function toJSON + * @memberof google.protobuf.GeneratedCodeInfo + * @instance + * @returns {Object.} JSON object + */ + GeneratedCodeInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + GeneratedCodeInfo.Annotation = (function () { + /** + * Properties of an Annotation. + * @memberof google.protobuf.GeneratedCodeInfo + * @interface IAnnotation + * @property {Array.|null} [path] Annotation path + * @property {string|null} [sourceFile] Annotation sourceFile + * @property {number|null} [begin] Annotation begin + * @property {number|null} [end] Annotation end + */ + + /** + * Constructs a new Annotation. + * @memberof google.protobuf.GeneratedCodeInfo + * @classdesc Represents an Annotation. + * @implements IAnnotation + * @constructor + * @param {google.protobuf.GeneratedCodeInfo.IAnnotation=} [properties] Properties to set + */ + function Annotation(properties) { + this.path = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * Annotation path. + * @member {Array.} path + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + */ + Annotation.prototype.path = $util.emptyArray + + /** + * Annotation sourceFile. + * @member {string} sourceFile + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + */ + Annotation.prototype.sourceFile = '' + + /** + * Annotation begin. + * @member {number} begin + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + */ + Annotation.prototype.begin = 0 + + /** + * Annotation end. + * @member {number} end + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + */ + Annotation.prototype.end = 0 + + /** + * Creates a new Annotation instance using the specified properties. + * @function create + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {google.protobuf.GeneratedCodeInfo.IAnnotation=} [properties] Properties to set + * @returns {google.protobuf.GeneratedCodeInfo.Annotation} Annotation instance + */ + Annotation.create = function create(properties) { + return new Annotation(properties) + } + + /** + * Encodes the specified Annotation message. Does not implicitly {@link google.protobuf.GeneratedCodeInfo.Annotation.verify|verify} messages. + * @function encode + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {google.protobuf.GeneratedCodeInfo.IAnnotation} message Annotation message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Annotation.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.path != null && message.path.length) { + writer.uint32(/* id 1, wireType 2 =*/ 10).fork() + for (var i = 0; i < message.path.length; ++i) + writer.int32(message.path[i]) + writer.ldelim() + } + if ( + message.sourceFile != null && + message.hasOwnProperty('sourceFile') + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.sourceFile) + if (message.begin != null && message.hasOwnProperty('begin')) + writer + .uint32(/* id 3, wireType 0 =*/ 24) + .int32(message.begin) + if (message.end != null && message.hasOwnProperty('end')) + writer.uint32(/* id 4, wireType 0 =*/ 32).int32(message.end) + return writer + } + + /** + * Encodes the specified Annotation message, length delimited. Does not implicitly {@link google.protobuf.GeneratedCodeInfo.Annotation.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {google.protobuf.GeneratedCodeInfo.IAnnotation} message Annotation message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Annotation.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an Annotation message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.GeneratedCodeInfo.Annotation} Annotation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Annotation.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.GeneratedCodeInfo.Annotation() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + if (!(message.path && message.path.length)) + message.path = [] + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos + while (reader.pos < end2) + message.path.push(reader.int32()) + } else message.path.push(reader.int32()) + break + case 2: + message.sourceFile = reader.string() + break + case 3: + message.begin = reader.int32() + break + case 4: + message.end = reader.int32() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an Annotation message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.GeneratedCodeInfo.Annotation} Annotation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Annotation.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an Annotation message. + * @function verify + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Annotation.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.path != null && message.hasOwnProperty('path')) { + if (!Array.isArray(message.path)) + return 'path: array expected' + for (var i = 0; i < message.path.length; ++i) + if (!$util.isInteger(message.path[i])) + return 'path: integer[] expected' + } + if ( + message.sourceFile != null && + message.hasOwnProperty('sourceFile') + ) + if (!$util.isString(message.sourceFile)) + return 'sourceFile: string expected' + if (message.begin != null && message.hasOwnProperty('begin')) + if (!$util.isInteger(message.begin)) + return 'begin: integer expected' + if (message.end != null && message.hasOwnProperty('end')) + if (!$util.isInteger(message.end)) + return 'end: integer expected' + return null + } + + /** + * Creates an Annotation message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.GeneratedCodeInfo.Annotation} Annotation + */ + Annotation.fromObject = function fromObject(object) { + if ( + object instanceof + $root.google.protobuf.GeneratedCodeInfo.Annotation + ) + return object + var message = new $root.google.protobuf.GeneratedCodeInfo.Annotation() + if (object.path) { + if (!Array.isArray(object.path)) + throw TypeError( + '.google.protobuf.GeneratedCodeInfo.Annotation.path: array expected' + ) + message.path = [] + for (var i = 0; i < object.path.length; ++i) + message.path[i] = object.path[i] | 0 + } + if (object.sourceFile != null) + message.sourceFile = String(object.sourceFile) + if (object.begin != null) message.begin = object.begin | 0 + if (object.end != null) message.end = object.end | 0 + return message + } + + /** + * Creates a plain object from an Annotation message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {google.protobuf.GeneratedCodeInfo.Annotation} message Annotation + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Annotation.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) object.path = [] + if (options.defaults) { + object.sourceFile = '' + object.begin = 0 + object.end = 0 + } + if (message.path && message.path.length) { + object.path = [] + for (var j = 0; j < message.path.length; ++j) + object.path[j] = message.path[j] + } + if ( + message.sourceFile != null && + message.hasOwnProperty('sourceFile') + ) + object.sourceFile = message.sourceFile + if (message.begin != null && message.hasOwnProperty('begin')) + object.begin = message.begin + if (message.end != null && message.hasOwnProperty('end')) + object.end = message.end + return object + } + + /** + * Converts this Annotation to JSON. + * @function toJSON + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + * @returns {Object.} JSON object + */ + Annotation.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return Annotation + })() + + return GeneratedCodeInfo + })() + + protobuf.Any = (function () { + /** + * Properties of an Any. + * @memberof google.protobuf + * @interface IAny + * @property {string|null} [type_url] Any type_url + * @property {Uint8Array|null} [value] Any value + */ + + /** + * Constructs a new Any. + * @memberof google.protobuf + * @classdesc Represents an Any. + * @implements IAny + * @constructor + * @param {google.protobuf.IAny=} [properties] Properties to set + */ + function Any(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * Any type_url. + * @member {string} type_url + * @memberof google.protobuf.Any + * @instance + */ + Any.prototype.type_url = '' + + /** + * Any value. + * @member {Uint8Array} value + * @memberof google.protobuf.Any + * @instance + */ + Any.prototype.value = $util.newBuffer([]) + + /** + * Creates a new Any instance using the specified properties. + * @function create + * @memberof google.protobuf.Any + * @static + * @param {google.protobuf.IAny=} [properties] Properties to set + * @returns {google.protobuf.Any} Any instance + */ + Any.create = function create(properties) { + return new Any(properties) + } + + /** + * Encodes the specified Any message. Does not implicitly {@link google.protobuf.Any.verify|verify} messages. + * @function encode + * @memberof google.protobuf.Any + * @static + * @param {google.protobuf.IAny} message Any message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Any.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.type_url != null && + message.hasOwnProperty('type_url') + ) + writer + .uint32(/* id 1, wireType 2 =*/ 10) + .string(message.type_url) + if (message.value != null && message.hasOwnProperty('value')) + writer.uint32(/* id 2, wireType 2 =*/ 18).bytes(message.value) + return writer + } + + /** + * Encodes the specified Any message, length delimited. Does not implicitly {@link google.protobuf.Any.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.Any + * @static + * @param {google.protobuf.IAny} message Any message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Any.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an Any message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.Any + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.Any} Any + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Any.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.Any() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.type_url = reader.string() + break + case 2: + message.value = reader.bytes() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an Any message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.Any + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.Any} Any + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Any.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an Any message. + * @function verify + * @memberof google.protobuf.Any + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Any.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.type_url != null && + message.hasOwnProperty('type_url') + ) + if (!$util.isString(message.type_url)) + return 'type_url: string expected' + if (message.value != null && message.hasOwnProperty('value')) + if ( + !( + (message.value && + typeof message.value.length === 'number') || + $util.isString(message.value) + ) + ) + return 'value: buffer expected' + return null + } + + /** + * Creates an Any message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Any + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Any} Any + */ + Any.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Any) return object + var message = new $root.google.protobuf.Any() + if (object.type_url != null) + message.type_url = String(object.type_url) + if (object.value != null) + if (typeof object.value === 'string') + $util.base64.decode( + object.value, + (message.value = $util.newBuffer( + $util.base64.length(object.value) + )), + 0 + ) + else if (object.value.length) message.value = object.value + return message + } + + /** + * Creates a plain object from an Any message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Any + * @static + * @param {google.protobuf.Any} message Any + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Any.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.defaults) { + object.type_url = '' + if (options.bytes === String) object.value = '' + else { + object.value = [] + if (options.bytes !== Array) + object.value = $util.newBuffer(object.value) + } + } + if ( + message.type_url != null && + message.hasOwnProperty('type_url') + ) + object.type_url = message.type_url + if (message.value != null && message.hasOwnProperty('value')) + object.value = + options.bytes === String + ? $util.base64.encode( + message.value, + 0, + message.value.length + ) + : options.bytes === Array + ? Array.prototype.slice.call(message.value) + : message.value + return object + } + + /** + * Converts this Any to JSON. + * @function toJSON + * @memberof google.protobuf.Any + * @instance + * @returns {Object.} JSON object + */ + Any.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return Any + })() + + protobuf.Duration = (function () { + /** + * Properties of a Duration. + * @memberof google.protobuf + * @interface IDuration + * @property {number|Long|null} [seconds] Duration seconds + * @property {number|null} [nanos] Duration nanos + */ + + /** + * Constructs a new Duration. + * @memberof google.protobuf + * @classdesc Represents a Duration. + * @implements IDuration + * @constructor + * @param {google.protobuf.IDuration=} [properties] Properties to set + */ + function Duration(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * Duration seconds. + * @member {number|Long} seconds + * @memberof google.protobuf.Duration + * @instance + */ + Duration.prototype.seconds = $util.Long + ? $util.Long.fromBits(0, 0, false) + : 0 + + /** + * Duration nanos. + * @member {number} nanos + * @memberof google.protobuf.Duration + * @instance + */ + Duration.prototype.nanos = 0 + + /** + * Creates a new Duration instance using the specified properties. + * @function create + * @memberof google.protobuf.Duration + * @static + * @param {google.protobuf.IDuration=} [properties] Properties to set + * @returns {google.protobuf.Duration} Duration instance + */ + Duration.create = function create(properties) { + return new Duration(properties) + } + + /** + * Encodes the specified Duration message. Does not implicitly {@link google.protobuf.Duration.verify|verify} messages. + * @function encode + * @memberof google.protobuf.Duration + * @static + * @param {google.protobuf.IDuration} message Duration message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Duration.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if ( + message.seconds != null && + message.hasOwnProperty('seconds') + ) + writer + .uint32(/* id 1, wireType 0 =*/ 8) + .int64(message.seconds) + if (message.nanos != null && message.hasOwnProperty('nanos')) + writer.uint32(/* id 2, wireType 0 =*/ 16).int32(message.nanos) + return writer + } + + /** + * Encodes the specified Duration message, length delimited. Does not implicitly {@link google.protobuf.Duration.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.Duration + * @static + * @param {google.protobuf.IDuration} message Duration message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Duration.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a Duration message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.Duration + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.Duration} Duration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Duration.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.Duration() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.seconds = reader.int64() + break + case 2: + message.nanos = reader.int32() + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a Duration message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.Duration + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.Duration} Duration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Duration.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a Duration message. + * @function verify + * @memberof google.protobuf.Duration + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Duration.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if ( + message.seconds != null && + message.hasOwnProperty('seconds') + ) + if ( + !$util.isInteger(message.seconds) && + !( + message.seconds && + $util.isInteger(message.seconds.low) && + $util.isInteger(message.seconds.high) + ) + ) + return 'seconds: integer|Long expected' + if (message.nanos != null && message.hasOwnProperty('nanos')) + if (!$util.isInteger(message.nanos)) + return 'nanos: integer expected' + return null + } + + /** + * Creates a Duration message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Duration + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Duration} Duration + */ + Duration.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Duration) + return object + var message = new $root.google.protobuf.Duration() + if (object.seconds != null) + if ($util.Long) + (message.seconds = $util.Long.fromValue( + object.seconds + )).unsigned = false + else if (typeof object.seconds === 'string') + message.seconds = parseInt(object.seconds, 10) + else if (typeof object.seconds === 'number') + message.seconds = object.seconds + else if (typeof object.seconds === 'object') + message.seconds = new $util.LongBits( + object.seconds.low >>> 0, + object.seconds.high >>> 0 + ).toNumber() + if (object.nanos != null) message.nanos = object.nanos | 0 + return message + } + + /** + * Creates a plain object from a Duration message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Duration + * @static + * @param {google.protobuf.Duration} message Duration + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Duration.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.defaults) { + if ($util.Long) { + var long = new $util.Long(0, 0, false) + object.seconds = + options.longs === String + ? long.toString() + : options.longs === Number + ? long.toNumber() + : long + } else object.seconds = options.longs === String ? '0' : 0 + object.nanos = 0 + } + if ( + message.seconds != null && + message.hasOwnProperty('seconds') + ) + if (typeof message.seconds === 'number') + object.seconds = + options.longs === String + ? String(message.seconds) + : message.seconds + else + object.seconds = + options.longs === String + ? $util.Long.prototype.toString.call(message.seconds) + : options.longs === Number + ? new $util.LongBits( + message.seconds.low >>> 0, + message.seconds.high >>> 0 + ).toNumber() + : message.seconds + if (message.nanos != null && message.hasOwnProperty('nanos')) + object.nanos = message.nanos + return object + } + + /** + * Converts this Duration to JSON. + * @function toJSON + * @memberof google.protobuf.Duration + * @instance + * @returns {Object.} JSON object + */ + Duration.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return Duration + })() + + protobuf.Empty = (function () { + /** + * Properties of an Empty. + * @memberof google.protobuf + * @interface IEmpty + */ + + /** + * Constructs a new Empty. + * @memberof google.protobuf + * @classdesc Represents an Empty. + * @implements IEmpty + * @constructor + * @param {google.protobuf.IEmpty=} [properties] Properties to set + */ + function Empty(properties) { + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * Creates a new Empty instance using the specified properties. + * @function create + * @memberof google.protobuf.Empty + * @static + * @param {google.protobuf.IEmpty=} [properties] Properties to set + * @returns {google.protobuf.Empty} Empty instance + */ + Empty.create = function create(properties) { + return new Empty(properties) + } + + /** + * Encodes the specified Empty message. Does not implicitly {@link google.protobuf.Empty.verify|verify} messages. + * @function encode + * @memberof google.protobuf.Empty + * @static + * @param {google.protobuf.IEmpty} message Empty message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Empty.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + return writer + } + + /** + * Encodes the specified Empty message, length delimited. Does not implicitly {@link google.protobuf.Empty.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.Empty + * @static + * @param {google.protobuf.IEmpty} message Empty message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Empty.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes an Empty message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.Empty + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.Empty} Empty + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Empty.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.protobuf.Empty() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes an Empty message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.Empty + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.Empty} Empty + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Empty.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies an Empty message. + * @function verify + * @memberof google.protobuf.Empty + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Empty.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + return null + } + + /** + * Creates an Empty message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Empty + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Empty} Empty + */ + Empty.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Empty) return object + return new $root.google.protobuf.Empty() + } + + /** + * Creates a plain object from an Empty message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Empty + * @static + * @param {google.protobuf.Empty} message Empty + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Empty.toObject = function toObject() { + return {} + } + + /** + * Converts this Empty to JSON. + * @function toJSON + * @memberof google.protobuf.Empty + * @instance + * @returns {Object.} JSON object + */ + Empty.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return Empty + })() + + return protobuf + })() + + google.rpc = (function () { + /** + * Namespace rpc. + * @memberof google + * @namespace + */ + var rpc = {} + + rpc.Status = (function () { + /** + * Properties of a Status. + * @memberof google.rpc + * @interface IStatus + * @property {number|null} [code] Status code + * @property {string|null} [message] Status message + * @property {Array.|null} [details] Status details + */ + + /** + * Constructs a new Status. + * @memberof google.rpc + * @classdesc Represents a Status. + * @implements IStatus + * @constructor + * @param {google.rpc.IStatus=} [properties] Properties to set + */ + function Status(properties) { + this.details = [] + if (properties) + for ( + var keys = Object.keys(properties), i = 0; + i < keys.length; + ++i + ) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]] + } + + /** + * Status code. + * @member {number} code + * @memberof google.rpc.Status + * @instance + */ + Status.prototype.code = 0 + + /** + * Status message. + * @member {string} message + * @memberof google.rpc.Status + * @instance + */ + Status.prototype.message = '' + + /** + * Status details. + * @member {Array.} details + * @memberof google.rpc.Status + * @instance + */ + Status.prototype.details = $util.emptyArray + + /** + * Creates a new Status instance using the specified properties. + * @function create + * @memberof google.rpc.Status + * @static + * @param {google.rpc.IStatus=} [properties] Properties to set + * @returns {google.rpc.Status} Status instance + */ + Status.create = function create(properties) { + return new Status(properties) + } + + /** + * Encodes the specified Status message. Does not implicitly {@link google.rpc.Status.verify|verify} messages. + * @function encode + * @memberof google.rpc.Status + * @static + * @param {google.rpc.IStatus} message Status message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Status.encode = function encode(message, writer) { + if (!writer) writer = $Writer.create() + if (message.code != null && message.hasOwnProperty('code')) + writer.uint32(/* id 1, wireType 0 =*/ 8).int32(message.code) + if ( + message.message != null && + message.hasOwnProperty('message') + ) + writer + .uint32(/* id 2, wireType 2 =*/ 18) + .string(message.message) + if (message.details != null && message.details.length) + for (var i = 0; i < message.details.length; ++i) + $root.google.protobuf.Any.encode( + message.details[i], + writer.uint32(/* id 3, wireType 2 =*/ 26).fork() + ).ldelim() + return writer + } + + /** + * Encodes the specified Status message, length delimited. Does not implicitly {@link google.rpc.Status.verify|verify} messages. + * @function encodeDelimited + * @memberof google.rpc.Status + * @static + * @param {google.rpc.IStatus} message Status message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Status.encodeDelimited = function encodeDelimited( + message, + writer + ) { + return this.encode(message, writer).ldelim() + } + + /** + * Decodes a Status message from the specified reader or buffer. + * @function decode + * @memberof google.rpc.Status + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.rpc.Status} Status + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Status.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader) + var end = + length === undefined ? reader.len : reader.pos + length, + message = new $root.google.rpc.Status() + while (reader.pos < end) { + var tag = reader.uint32() + switch (tag >>> 3) { + case 1: + message.code = reader.int32() + break + case 2: + message.message = reader.string() + break + case 3: + if (!(message.details && message.details.length)) + message.details = [] + message.details.push( + $root.google.protobuf.Any.decode( + reader, + reader.uint32() + ) + ) + break + default: + reader.skipType(tag & 7) + break + } + } + return message + } + + /** + * Decodes a Status message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.rpc.Status + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.rpc.Status} Status + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Status.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) reader = new $Reader(reader) + return this.decode(reader, reader.uint32()) + } + + /** + * Verifies a Status message. + * @function verify + * @memberof google.rpc.Status + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Status.verify = function verify(message) { + if (typeof message !== 'object' || message === null) + return 'object expected' + if (message.code != null && message.hasOwnProperty('code')) + if (!$util.isInteger(message.code)) + return 'code: integer expected' + if ( + message.message != null && + message.hasOwnProperty('message') + ) + if (!$util.isString(message.message)) + return 'message: string expected' + if ( + message.details != null && + message.hasOwnProperty('details') + ) { + if (!Array.isArray(message.details)) + return 'details: array expected' + for (var i = 0; i < message.details.length; ++i) { + var error = $root.google.protobuf.Any.verify( + message.details[i] + ) + if (error) return 'details.' + error + } + } + return null + } + + /** + * Creates a Status message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.rpc.Status + * @static + * @param {Object.} object Plain object + * @returns {google.rpc.Status} Status + */ + Status.fromObject = function fromObject(object) { + if (object instanceof $root.google.rpc.Status) return object + var message = new $root.google.rpc.Status() + if (object.code != null) message.code = object.code | 0 + if (object.message != null) + message.message = String(object.message) + if (object.details) { + if (!Array.isArray(object.details)) + throw TypeError( + '.google.rpc.Status.details: array expected' + ) + message.details = [] + for (var i = 0; i < object.details.length; ++i) { + if (typeof object.details[i] !== 'object') + throw TypeError( + '.google.rpc.Status.details: object expected' + ) + message.details[i] = $root.google.protobuf.Any.fromObject( + object.details[i] + ) + } + } + return message + } + + /** + * Creates a plain object from a Status message. Also converts values to other types if specified. + * @function toObject + * @memberof google.rpc.Status + * @static + * @param {google.rpc.Status} message Status + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Status.toObject = function toObject(message, options) { + if (!options) options = {} + var object = {} + if (options.arrays || options.defaults) object.details = [] + if (options.defaults) { + object.code = 0 + object.message = '' + } + if (message.code != null && message.hasOwnProperty('code')) + object.code = message.code + if ( + message.message != null && + message.hasOwnProperty('message') + ) + object.message = message.message + if (message.details && message.details.length) { + object.details = [] + for (var j = 0; j < message.details.length; ++j) + object.details[j] = $root.google.protobuf.Any.toObject( + message.details[j], + options + ) + } + return object + } + + /** + * Converts this Status to JSON. + * @function toJSON + * @memberof google.rpc.Status + * @instance + * @returns {Object.} JSON object + */ + Status.prototype.toJSON = function toJSON() { + return this.constructor.toObject( + this, + $protobuf.util.toJSONOptions + ) + } + + return Status + })() + + return rpc + })() + + return google + })() + + return $root + }) + + /***/ + }, + + /***/ 55398: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.createAPICaller = void 0 + const normalApiCaller_1 = __webpack_require__(56513) + function createAPICaller(settings, descriptor) { + if (!descriptor) { + return new normalApiCaller_1.NormalApiCaller() + } + return descriptor.getApiCaller(settings) + } + exports.createAPICaller = createAPICaller + //# sourceMappingURL=apiCaller.js.map + + /***/ + }, + + /***/ 41283: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.BundleApiCaller = void 0 + const call_1 = __webpack_require__(53047) + const googleError_1 = __webpack_require__(6634) + /** + * An implementation of APICaller for bundled calls. + * Uses BundleExecutor to do bundling. + */ + class BundleApiCaller { + constructor(bundler) { + this.bundler = bundler + } + init(callback) { + if (callback) { + return new call_1.OngoingCall(callback) + } + return new call_1.OngoingCallPromise() + } + wrap(func) { + return func + } + call(apiCall, argument, settings, status) { + if (!settings.isBundling) { + throw new googleError_1.GoogleError( + 'Bundling enabled with no isBundling!' + ) + } + status.call((argument, callback) => { + this.bundler.schedule(apiCall, argument, callback) + return status + }, argument) + } + fail(canceller, err) { + canceller.callback(err) + } + result(canceller) { + return canceller.promise + } + } + exports.BundleApiCaller = BundleApiCaller + //# sourceMappingURL=bundleApiCaller.js.map + + /***/ + }, + + /***/ 94847: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.BundleDescriptor = void 0 + const normalApiCaller_1 = __webpack_require__(56513) + const bundleApiCaller_1 = __webpack_require__(41283) + const bundleExecutor_1 = __webpack_require__(59491) + /** + * Capitalizes the first character of the given string. + */ + function capitalize(str) { + if (str.length === 0) { + return str + } + return str[0].toUpperCase() + str.slice(1) + } + /** + * Converts a given string from snake_case (normally used in proto definitions) to + * camelCase (used by protobuf.js) + */ + function toCamelCase(str) { + // split on spaces, non-alphanumeric, or capital letters + const splitted = str + .split(/(?=[A-Z])|[\s\W_]+/) + .filter(w => w.length > 0) + .map(word => word.toLowerCase()) + if (splitted.length === 0) { + return str + } + return [splitted[0], ...splitted.slice(1).map(capitalize)].join('') + } + /** + * A descriptor for calls that can be bundled into one call. + */ + class BundleDescriptor { + /** + * Describes the structure of bundled call. + * + * requestDiscriminatorFields may include '.' as a separator, which is used to + * indicate object traversal. This allows fields in nested objects to be used + * to determine what request to bundle. + * + * @property {String} bundledField + * @property {String} requestDiscriminatorFields + * @property {String} subresponseField + * @property {Function} byteLengthFunction + * + * @param {String} bundledField - the repeated field in the request message + * that will have its elements aggregated by bundling. + * @param {String} requestDiscriminatorFields - a list of fields in the + * target request message class that are used to detemrine which request + * messages should be bundled together. + * @param {String} subresponseField - an optional field, when present it + * indicates the field in the response message that should be used to + * demultiplex the response into multiple response messages. + * @param {Function} byteLengthFunction - a function to obtain the byte + * length to be consumed for the bundled field messages. Because Node.JS + * protobuf.js/gRPC uses builtin Objects for the user-visible data and + * internally they are encoded/decoded in protobuf manner, this function + * is actually necessary to calculate the byte length. + * @constructor + */ + constructor( + bundledField, + requestDiscriminatorFields, + subresponseField, + byteLengthFunction + ) { + if (!byteLengthFunction && typeof subresponseField === 'function') { + byteLengthFunction = subresponseField + subresponseField = null + } + this.bundledField = bundledField + this.requestDiscriminatorFields = requestDiscriminatorFields.map( + toCamelCase + ) + this.subresponseField = subresponseField + this.byteLengthFunction = byteLengthFunction + } + getApiCaller(settings) { + if (settings.isBundling === false) { + return new normalApiCaller_1.NormalApiCaller() + } + return new bundleApiCaller_1.BundleApiCaller( + new bundleExecutor_1.BundleExecutor(settings.bundleOptions, this) + ) + } + } + exports.BundleDescriptor = BundleDescriptor + //# sourceMappingURL=bundleDescriptor.js.map + + /***/ + }, + + /***/ 59491: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.BundleExecutor = void 0 + const status_1 = __webpack_require__(53501) + const googleError_1 = __webpack_require__(6634) + const warnings_1 = __webpack_require__(16328) + const bundlingUtils_1 = __webpack_require__(16255) + const task_1 = __webpack_require__(43302) + function noop() {} + /** + * BundleExecutor stores several timers for each bundle (calls are bundled based + * on the options passed, each bundle has unique ID that is calculated based on + * field values). Each timer fires and sends a call after certain amount of + * time, and if a new request comes to the same bundle, the timer can be + * restarted. + */ + class BundleExecutor { + /** + * Organizes requests for an api service that requires to bundle them. + * + * @param {BundleOptions} bundleOptions - configures strategy this instance + * uses when executing bundled functions. + * @param {BundleDescriptor} bundleDescriptor - the description of the bundling. + * @constructor + */ + constructor(bundleOptions, bundleDescriptor) { + this._options = bundleOptions + this._descriptor = bundleDescriptor + this._tasks = {} + this._timers = {} + this._invocations = {} + this._invocationId = 0 + } + /** + * Schedule a method call. + * + * @param {function} apiCall - the function for an API call. + * @param {Object} request - the request object to be bundled with others. + * @param {APICallback} callback - the callback to be called when the method finished. + * @return {function()} - the function to cancel the scheduled invocation. + */ + schedule(apiCall, request, callback) { + const bundleId = bundlingUtils_1.computeBundleId( + request, + this._descriptor.requestDiscriminatorFields + ) + callback = callback || noop + if (bundleId === undefined) { + warnings_1.warn( + 'bundling_schedule_bundleid_undefined', + 'The request does not have enough information for request bundling. ' + + `Invoking immediately. Request: ${JSON.stringify(request)} ` + + `discriminator fields: ${this._descriptor.requestDiscriminatorFields}` + ) + return apiCall(request, callback) + } + if (request[this._descriptor.bundledField] === undefined) { + warnings_1.warn( + 'bundling_no_bundled_field', + `Request does not contain field ${this._descriptor.bundledField} that must present for bundling. ` + + `Invoking immediately. Request: ${JSON.stringify(request)}` + ) + return apiCall(request, callback) + } + if (!(bundleId in this._tasks)) { + this._tasks[bundleId] = new task_1.Task( + apiCall, + request, + this._descriptor.bundledField, + this._descriptor.subresponseField + ) + } + let task = this._tasks[bundleId] + callback.id = String(this._invocationId++) + this._invocations[callback.id] = bundleId + const bundledField = request[this._descriptor.bundledField] + const elementCount = bundledField.length + let requestBytes = 0 + // eslint-disable-next-line @typescript-eslint/no-this-alias + const self = this + bundledField.forEach(obj => { + requestBytes += this._descriptor.byteLengthFunction(obj) + }) + const countLimit = this._options.elementCountLimit || 0 + const byteLimit = this._options.requestByteLimit || 0 + if ( + (countLimit > 0 && elementCount > countLimit) || + (byteLimit > 0 && requestBytes >= byteLimit) + ) { + let message + if (countLimit > 0 && elementCount > countLimit) { + message = + 'The number of elements ' + + elementCount + + ' exceeds the limit ' + + this._options.elementCountLimit + } else { + message = + 'The required bytes ' + + requestBytes + + ' exceeds the limit ' + + this._options.requestByteLimit + } + const error = new googleError_1.GoogleError(message) + error.code = status_1.Status.INVALID_ARGUMENT + callback(error) + return { + cancel: noop + } + } + const existingCount = task.getElementCount() + const existingBytes = task.getRequestByteSize() + if ( + (countLimit > 0 && elementCount + existingCount >= countLimit) || + (byteLimit > 0 && requestBytes + existingBytes >= byteLimit) + ) { + this._runNow(bundleId) + this._tasks[bundleId] = new task_1.Task( + apiCall, + request, + this._descriptor.bundledField, + this._descriptor.subresponseField + ) + task = this._tasks[bundleId] + } + task.extend(bundledField, requestBytes, callback) + const ret = { + cancel() { + self._cancel(callback.id) + } + } + const countThreshold = this._options.elementCountThreshold || 0 + const sizeThreshold = this._options.requestByteThreshold || 0 + if ( + (countThreshold > 0 && task.getElementCount() >= countThreshold) || + (sizeThreshold > 0 && task.getRequestByteSize() >= sizeThreshold) + ) { + this._runNow(bundleId) + return ret + } + if (!(bundleId in this._timers) && this._options.delayThreshold > 0) { + this._timers[bundleId] = setTimeout(() => { + delete this._timers[bundleId] + this._runNow(bundleId) + }, this._options.delayThreshold) + } + return ret + } + /** + * Clears scheduled timeout if it exists. + * + * @param {String} bundleId - the id for the task whose timeout needs to be + * cleared. + * @private + */ + _maybeClearTimeout(bundleId) { + if (bundleId in this._timers) { + const timerId = this._timers[bundleId] + delete this._timers[bundleId] + clearTimeout(timerId) + } + } + /** + * Cancels an event. + * + * @param {String} id - The id for the event in the task. + * @private + */ + _cancel(id) { + if (!(id in this._invocations)) { + return + } + const bundleId = this._invocations[id] + if (!(bundleId in this._tasks)) { + return + } + const task = this._tasks[bundleId] + delete this._invocations[id] + if (task.cancel(id)) { + this._maybeClearTimeout(bundleId) + delete this._tasks[bundleId] + } + } + /** + * Invokes a task. + * + * @param {String} bundleId - The id for the task. + * @private + */ + _runNow(bundleId) { + if (!(bundleId in this._tasks)) { + warnings_1.warn( + 'bundle_runnow_bundleid_unknown', + `No such bundleid: ${bundleId}` + ) + return + } + this._maybeClearTimeout(bundleId) + const task = this._tasks[bundleId] + delete this._tasks[bundleId] + task.run().forEach(id => { + delete this._invocations[id] + }) + } + } + exports.BundleExecutor = BundleExecutor + //# sourceMappingURL=bundleExecutor.js.map + + /***/ + }, + + /***/ 16255: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + /** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.computeBundleId = void 0 + /** + * Compute the identifier of the `obj`. The objects of the same ID + * will be bundled together. + * + * @param {RequestType} obj - The request object. + * @param {String[]} discriminatorFields - The array of field names. + * A field name may include '.' as a separator, which is used to + * indicate object traversal. + * @return {String|undefined} - the identifier string, or undefined if any + * discriminator fields do not exist. + */ + function computeBundleId(obj, discriminatorFields) { + const ids = [] + let hasIds = false + for (const field of discriminatorFields) { + const id = at(obj, field) + if (id === undefined) { + ids.push(null) + } else { + hasIds = true + ids.push(id) + } + } + if (!hasIds) { + return undefined + } + return JSON.stringify(ids) + } + exports.computeBundleId = computeBundleId + /** + * Given an object field path that may contain dots, dig into the obj and find + * the value at the given path. + * @example + * const obj = { + * a: { + * b: 5 + * } + * } + * const id = at(obj, 'a.b'); + * // id = 5 + * @param field Path to the property with `.` notation + * @param obj The object to traverse + * @returns the value at the given path + */ + function at(obj, field) { + const pathParts = field.split('.') + // eslint-disable-next-line @typescript-eslint/no-explicit-any + let currentObj = obj + for (const pathPart of pathParts) { + currentObj = + currentObj === null || currentObj === void 0 + ? void 0 + : currentObj[pathPart] + } + return currentObj + } + //# sourceMappingURL=bundlingUtils.js.map + + /***/ + }, + + /***/ 43302: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.Task = exports.deepCopyForResponse = void 0 + const status_1 = __webpack_require__(53501) + const googleError_1 = __webpack_require__(6634) + /** + * Creates a deep copy of the object with the consideration of subresponse + * fields for bundling. + * + * @param {Object} obj - The source object. + * @param {Object?} subresponseInfo - The information to copy the subset of + * the field for the response. Do nothing if it's null. + * @param {String} subresponseInfo.field - The field name. + * @param {number} subresponseInfo.start - The offset where the copying + * element should starts with. + * @param {number} subresponseInfo.end - The ending index where the copying + * region of the elements ends. + * @return {Object} The copied object. + * @private + */ + function deepCopyForResponse( + // eslint-disable-next-line @typescript-eslint/no-explicit-any + obj, + subresponseInfo + ) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + let result + if (obj === null) { + return null + } + if (obj === undefined) { + return undefined + } + if (Array.isArray(obj)) { + result = [] + obj.forEach(element => { + result.push(deepCopyForResponse(element, null)) + }) + return result + } + // Some objects (such as ByteBuffer) have copy method. + if (obj.copy !== undefined) { + return obj.copy() + } + // ArrayBuffer should be copied through slice(). + if (obj instanceof ArrayBuffer) { + return obj.slice(0) + } + if (typeof obj === 'object') { + result = {} + Object.keys(obj).forEach(key => { + if ( + subresponseInfo && + key === subresponseInfo.field && + Array.isArray(obj[key]) + ) { + // Note that subresponses are not deep-copied. This is safe because + // those subresponses are not shared among callbacks. + result[key] = obj[key].slice( + subresponseInfo.start, + subresponseInfo.end + ) + } else { + result[key] = deepCopyForResponse(obj[key], null) + } + }) + return result + } + return obj + } + exports.deepCopyForResponse = deepCopyForResponse + class Task { + /** + * A task coordinates the execution of a single bundle. + * + * @param {function} apiCall - The function to conduct calling API. + * @param {Object} bundlingRequest - The base request object to be used + * for the actual API call. + * @param {string} bundledField - The name of the field in bundlingRequest + * to be bundled. + * @param {string=} subresponseField - The name of the field in the response + * to be passed to the callback. + * @constructor + * @private + */ + constructor(apiCall, bundlingRequest, bundledField, subresponseField) { + this._apiCall = apiCall + this._request = bundlingRequest + this._bundledField = bundledField + this._subresponseField = subresponseField + this._data = [] + } + /** + * Returns the number of elements in a task. + * @return {number} The number of elements. + */ + getElementCount() { + let count = 0 + for (let i = 0; i < this._data.length; ++i) { + count += this._data[i].elements.length + } + return count + } + /** + * Returns the total byte size of the elements in a task. + * @return {number} The byte size. + */ + getRequestByteSize() { + let size = 0 + for (let i = 0; i < this._data.length; ++i) { + size += this._data[i].bytes + } + return size + } + /** + * Invokes the actual API call with current elements. + * @return {string[]} - the list of ids for invocations to be run. + */ + run() { + if (this._data.length === 0) { + return [] + } + const request = this._request + const elements = [] + const ids = [] + for (let i = 0; i < this._data.length; ++i) { + elements.push(...this._data[i].elements) + ids.push(this._data[i].callback.id) + } + request[this._bundledField] = elements + // eslint-disable-next-line @typescript-eslint/no-this-alias + const self = this + this.callCanceller = this._apiCall(request, (err, response) => { + const responses = [] + if (err) { + self._data.forEach(() => { + responses.push(undefined) + }) + } else { + let subresponseInfo = null + if (self._subresponseField) { + subresponseInfo = { + field: self._subresponseField, + start: 0 + } + } + self._data.forEach(data => { + if (subresponseInfo) { + subresponseInfo.end = + subresponseInfo.start + data.elements.length + } + responses.push(deepCopyForResponse(response, subresponseInfo)) + if (subresponseInfo) { + subresponseInfo.start = subresponseInfo.end + } + }) + } + for (let i = 0; i < self._data.length; ++i) { + if (self._data[i].cancelled) { + const error = new googleError_1.GoogleError('cancelled') + error.code = status_1.Status.CANCELLED + self._data[i].callback(error) + } else { + self._data[i].callback(err, responses[i]) + } + } + }) + return ids + } + /** + * Appends the list of elements into the task. + * @param {Object[]} elements - the new list of elements. + * @param {number} bytes - the byte size required to encode elements in the API. + * @param {APICallback} callback - the callback of the method call. + */ + extend(elements, bytes, callback) { + this._data.push({ + elements, + bytes, + callback + }) + } + /** + * Cancels a part of elements. + * @param {string} id - The identifier of the part of elements. + * @return {boolean} Whether the entire task will be canceled or not. + */ + cancel(id) { + if (this.callCanceller) { + let allCancelled = true + this._data.forEach(d => { + if (d.callback.id === id) { + d.cancelled = true + } + if (!d.cancelled) { + allCancelled = false + } + }) + if (allCancelled) { + this.callCanceller.cancel() + } + return allCancelled + } + for (let i = 0; i < this._data.length; ++i) { + if (this._data[i].callback.id === id) { + const error = new googleError_1.GoogleError('cancelled') + error.code = status_1.Status.CANCELLED + this._data[i].callback(error) + this._data.splice(i, 1) + break + } + } + return this._data.length === 0 + } + } + exports.Task = Task + //# sourceMappingURL=task.js.map + + /***/ + }, + + /***/ 53047: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.OngoingCallPromise = exports.OngoingCall = void 0 + const status_1 = __webpack_require__(53501) + const googleError_1 = __webpack_require__(6634) + class OngoingCall { + /** + * OngoingCall manages callback, API calls, and cancellation + * of the API calls. + * @param {APICallback=} callback + * The callback to be called asynchronously when the API call + * finishes. + * @constructor + * @property {APICallback} callback + * The callback function to be called. + * @private + */ + constructor(callback) { + this.callback = callback + this.completed = false + } + /** + * Cancels the ongoing promise. + */ + cancel() { + if (this.completed) { + return + } + this.completed = true + if (this.cancelFunc) { + this.cancelFunc() + } else { + const error = new googleError_1.GoogleError('cancelled') + error.code = status_1.Status.CANCELLED + this.callback(error) + } + } + /** + * Call calls the specified function. Result will be used to fulfill + * the promise. + * + * @param {SimpleCallbackFunction} func + * A function for an API call. + * @param {Object} argument + * A request object. + */ + call(func, argument) { + if (this.completed) { + return + } + // eslint-disable-next-line + const canceller = func(argument, (...args) => { + this.completed = true + setImmediate(this.callback, ...args) + }) + this.cancelFunc = () => canceller.cancel() + } + } + exports.OngoingCall = OngoingCall + class OngoingCallPromise extends OngoingCall { + /** + * GaxPromise is GRPCCallbackWrapper, but it holds a promise when + * the API call finishes. + * @constructor + * @private + */ + constructor() { + let resolveCallback + let rejectCallback + const callback = (err, response, next, rawResponse) => { + if (err) { + rejectCallback(err) + } else if (response !== undefined) { + resolveCallback([response, next || null, rawResponse || null]) + } else { + throw new googleError_1.GoogleError( + 'Neither error nor response are defined' + ) + } + } + const promise = new Promise((resolve, reject) => { + resolveCallback = resolve + rejectCallback = reject + }) + super(callback) + this.promise = promise + this.promise.cancel = () => { + this.cancel() + } + } + } + exports.OngoingCallPromise = OngoingCallPromise + //# sourceMappingURL=call.js.map + + /***/ + }, + + /***/ 79712: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.createApiCall = void 0 + /** + * Provides function wrappers that implement page streaming and retrying. + */ + const apiCaller_1 = __webpack_require__(55398) + const retries_1 = __webpack_require__(69742) + const timeout_1 = __webpack_require__(4531) + /** + * Converts an rpc call into an API call governed by the settings. + * + * In typical usage, `func` will be a promise to a callable used to make an rpc + * request. This will mostly likely be a bound method from a request stub used + * to make an rpc call. It is not a direct function but a Promise instance, + * because of its asynchronism (typically, obtaining the auth information). + * + * The result is a function which manages the API call with the given settings + * and the options on the invocation. + * + * @param {Promise|GRPCCall} func - is either a promise to be used to make + * a bare RPC call, or just a bare RPC call. + * @param {CallSettings} settings - provides the settings for this call + * @param {Descriptor} descriptor - optionally specify the descriptor for + * the method call. + * @return {GaxCall} func - a bound method on a request stub used + * to make an rpc call. + */ + function createApiCall(func, settings, descriptor) { + // we want to be able to accept both promise resolving to a function and a + // function. Currently client librares are only calling this method with a + // promise, but it will change. + const funcPromise = + typeof func === 'function' ? Promise.resolve(func) : func + // the following apiCaller will be used for all calls of this function... + const apiCaller = apiCaller_1.createAPICaller(settings, descriptor) + return (request, callOptions, callback) => { + const thisSettings = settings.merge(callOptions) + let currentApiCaller = apiCaller + // special case: if bundling is disabled for this one call, + // use default API caller instead + if (settings.isBundling && !thisSettings.isBundling) { + currentApiCaller = apiCaller_1.createAPICaller(settings, undefined) + } + const ongoingCall = currentApiCaller.init(callback) + funcPromise + .then(func => { + var _a + // Initially, the function is just what gRPC server stub contains. + func = currentApiCaller.wrap(func) + const streaming = + (_a = currentApiCaller.descriptor) === null || _a === void 0 + ? void 0 + : _a.streaming + const retry = thisSettings.retry + if ( + !streaming && + retry && + retry.retryCodes && + retry.retryCodes.length > 0 + ) { + retry.backoffSettings.initialRpcTimeoutMillis = + retry.backoffSettings.initialRpcTimeoutMillis || + thisSettings.timeout + return retries_1.retryable( + func, + thisSettings.retry, + thisSettings.otherArgs, + thisSettings.apiName + ) + } + return timeout_1.addTimeoutArg( + func, + thisSettings.timeout, + thisSettings.otherArgs + ) + }) + .then(apiCall => { + // After adding retries / timeouts, the call function becomes simpler: + // it only accepts request and callback. + currentApiCaller.call(apiCall, request, thisSettings, ongoingCall) + }) + .catch(err => { + currentApiCaller.fail(ongoingCall, err) + }) + // Calls normally return a "cancellable promise" that can be used to `await` for the actual result, + // or to cancel the ongoing call. + return currentApiCaller.result(ongoingCall) + } + } + exports.createApiCall = createApiCall + //# sourceMappingURL=createApiCall.js.map + + /***/ + }, + + /***/ 13627: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + var longRunningDescriptor_1 = __webpack_require__(8096) + Object.defineProperty(exports, 'LongrunningDescriptor', { + enumerable: true, + get: function () { + return longRunningDescriptor_1.LongRunningDescriptor + } + }) + var pageDescriptor_1 = __webpack_require__(71172) + Object.defineProperty(exports, 'PageDescriptor', { + enumerable: true, + get: function () { + return pageDescriptor_1.PageDescriptor + } + }) + var streamDescriptor_1 = __webpack_require__(65880) + Object.defineProperty(exports, 'StreamDescriptor', { + enumerable: true, + get: function () { + return streamDescriptor_1.StreamDescriptor + } + }) + var bundleDescriptor_1 = __webpack_require__(94847) + Object.defineProperty(exports, 'BundleDescriptor', { + enumerable: true, + get: function () { + return bundleDescriptor_1.BundleDescriptor + } + }) + //# sourceMappingURL=descriptor.js.map + + /***/ + }, + + /***/ 90418: /***/ (module, exports, __webpack_require__) => { + 'use strict' + + /** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.fallback = exports.protobuf = exports.createApiCall = exports.lro = exports.GrpcClient = exports.version = exports.routingHeader = void 0 + const protobuf = __webpack_require__(85881) + exports.protobuf = protobuf + const gax = __webpack_require__(80978) + const nodeFetch = __webpack_require__(80467) + const routingHeader = __webpack_require__(8827) + exports.routingHeader = routingHeader + const abort_controller_1 = __webpack_require__(61659) + const status_1 = __webpack_require__(53501) + const google_auth_library_1 = __webpack_require__(20810) + const operationsClient_1 = __webpack_require__(82450) + const createApiCall_1 = __webpack_require__(79712) + const isbrowser_1 = __webpack_require__(95021) + const fallbackError_1 = __webpack_require__(48848) + var pathTemplate_1 = __webpack_require__(20513) + Object.defineProperty(exports, 'PathTemplate', { + enumerable: true, + get: function () { + return pathTemplate_1.PathTemplate + } + }) + var gax_1 = __webpack_require__(80978) + Object.defineProperty(exports, 'CallSettings', { + enumerable: true, + get: function () { + return gax_1.CallSettings + } + }) + Object.defineProperty(exports, 'constructSettings', { + enumerable: true, + get: function () { + return gax_1.constructSettings + } + }) + Object.defineProperty(exports, 'RetryOptions', { + enumerable: true, + get: function () { + return gax_1.RetryOptions + } + }) + exports.version = __webpack_require__(56156).version + '-fallback' + var descriptor_1 = __webpack_require__(13627) + Object.defineProperty(exports, 'BundleDescriptor', { + enumerable: true, + get: function () { + return descriptor_1.BundleDescriptor + } + }) + Object.defineProperty(exports, 'LongrunningDescriptor', { + enumerable: true, + get: function () { + return descriptor_1.LongrunningDescriptor + } + }) + Object.defineProperty(exports, 'PageDescriptor', { + enumerable: true, + get: function () { + return descriptor_1.PageDescriptor + } + }) + Object.defineProperty(exports, 'StreamDescriptor', { + enumerable: true, + get: function () { + return descriptor_1.StreamDescriptor + } + }) + var streaming_1 = __webpack_require__(67389) + Object.defineProperty(exports, 'StreamType', { + enumerable: true, + get: function () { + return streaming_1.StreamType + } + }) + const CLIENT_VERSION_HEADER = 'x-goog-api-client' + class GrpcClient { + /** + * gRPC-fallback version of GrpcClient + * Implements GrpcClient API for a browser using grpc-fallback protocol (sends serialized protobuf to HTTP/1 $rpc endpoint). + * + * @param {Object=} options.auth - An instance of OAuth2Client to use in browser, or an instance of GoogleAuth from google-auth-library + * to use in Node.js. Required for browser, optional for Node.js. + * @constructor + */ + constructor(options = {}) { + if (isbrowser_1.isBrowser()) { + if (!options.auth) { + throw new Error( + JSON.stringify(options) + + 'You need to pass auth instance to use gRPC-fallback client in browser. Use OAuth2Client from google-auth-library.' + ) + } + this.auth = options.auth + } else { + this.auth = + options.auth || new google_auth_library_1.GoogleAuth(options) + } + this.fallback = true + this.grpcVersion = 'fallback' // won't be used anywhere but we need it to exist in the class + } + /** + * gRPC-fallback version of loadProto + * Loads the protobuf root object from a JSON object created from a proto file + * @param {Object} jsonObject - A JSON version of a protofile created usin protobuf.js + * @returns {Object} Root namespace of proto JSON + */ + loadProto(jsonObject) { + const rootObject = protobuf.Root.fromJSON(jsonObject) + return rootObject + } + getServiceMethods(service) { + const methods = Object.keys(service.methods) + const methodsLowerCamelCase = methods.map(method => { + return method[0].toLowerCase() + method.substring(1) + }) + return methodsLowerCamelCase + } + /** + * gRPC-fallback version of constructSettings + * A wrapper of {@link constructSettings} function under the gRPC context. + * + * Most of parameters are common among constructSettings, please take a look. + * @param {string} serviceName - The fullly-qualified name of the service. + * @param {Object} clientConfig - A dictionary of the client config. + * @param {Object} configOverrides - A dictionary of overriding configs. + * @param {Object} headers - A dictionary of additional HTTP header name to + * its value. + * @return {Object} A mapping of method names to CallSettings. + */ + constructSettings(serviceName, clientConfig, configOverrides, headers) { + function buildMetadata(abTests, moreHeaders) { + const metadata = {} + if (!headers) { + headers = {} + } + // Since gRPC expects each header to be an array, + // we are doing the same for fallback here. + for (const key in headers) { + metadata[key] = Array.isArray(headers[key]) + ? headers[key] + : [headers[key]] + } + // gRPC-fallback request must have 'grpc-web/' in 'x-goog-api-client' + const clientVersions = [] + if ( + metadata[CLIENT_VERSION_HEADER] && + metadata[CLIENT_VERSION_HEADER][0] + ) { + clientVersions.push( + ...metadata[CLIENT_VERSION_HEADER][0].split(' ') + ) + } + clientVersions.push(`grpc-web/${exports.version}`) + metadata[CLIENT_VERSION_HEADER] = [clientVersions.join(' ')] + if (!moreHeaders) { + return metadata + } + for (const key in moreHeaders) { + if (key.toLowerCase() !== CLIENT_VERSION_HEADER) { + const value = moreHeaders[key] + if (Array.isArray(value)) { + if (metadata[key] === undefined) { + metadata[key] = value + } else { + if (Array.isArray(metadata[key])) { + metadata[key].push(...value) + } else { + throw new Error( + `Can not add value ${value} to the call metadata.` + ) + } + } + } else { + metadata[key] = [value] + } + } + } + return metadata + } + return gax.constructSettings( + serviceName, + clientConfig, + configOverrides, + status_1.Status, + { metadataBuilder: buildMetadata } + ) + } + /** + * gRPC-fallback version of createStub + * Creates a gRPC-fallback stub with authentication headers built from supplied OAuth2Client instance + * + * @param {function} CreateStub - The constructor function of the stub. + * @param {Object} service - A protobufjs Service object (as returned by lookupService) + * @param {Object} opts - Connection options, as described below. + * @param {string} opts.servicePath - The hostname of the API endpoint service. + * @param {number} opts.port - The port of the service. + * @return {Promise} A promise which resolves to a gRPC-fallback service stub, which is a protobuf.js service stub instance modified to match the gRPC stub API + */ + async createStub(service, opts) { + // an RPC function to be passed to protobufjs RPC API + function serviceClientImpl(method, requestData, callback) { + return [method, requestData, callback] + } + // decoder for google.rpc.Status messages + const statusDecoder = new fallbackError_1.FallbackErrorDecoder() + if (!this.authClient) { + if (this.auth && 'getClient' in this.auth) { + this.authClient = await this.auth.getClient() + } else if (this.auth && 'getRequestHeaders' in this.auth) { + this.authClient = this.auth + } + } + if (!this.authClient) { + throw new Error('No authentication was provided') + } + const authHeader = await this.authClient.getRequestHeaders() + const serviceStub = service.create(serviceClientImpl, false, false) + const methods = this.getServiceMethods(service) + const newServiceStub = service.create(serviceClientImpl, false, false) + for (const methodName of methods) { + newServiceStub[methodName] = (req, options, metadata, callback) => { + const [method, requestData, serviceCallback] = serviceStub[ + methodName + ].apply(serviceStub, [req, callback]) + // eslint-disable-next-line @typescript-eslint/no-explicit-any + let cancelController, cancelSignal + if ( + isbrowser_1.isBrowser && + typeof AbortController !== 'undefined' + ) { + // eslint-disable-next-line no-undef + cancelController = new AbortController() + } else { + cancelController = new abort_controller_1.AbortController() + } + if (cancelController) { + cancelSignal = cancelController.signal + } + let cancelRequested = false + const headers = Object.assign({}, authHeader) + headers['Content-Type'] = 'application/x-protobuf' + for (const key of Object.keys(options)) { + headers[key] = options[key][0] + } + const grpcFallbackProtocol = opts.protocol || 'https' + let servicePath = opts.servicePath + if ( + !servicePath && + service.options && + service.options['(google.api.default_host)'] + ) { + servicePath = service.options['(google.api.default_host)'] + } + if (!servicePath) { + serviceCallback(new Error('Service path is undefined')) + return + } + let servicePort + const match = servicePath.match(/^(.*):(\d+)$/) + if (match) { + servicePath = match[1] + servicePort = match[2] + } + if (opts.port) { + servicePort = opts.port + } else if (!servicePort) { + servicePort = 443 + } + const protoNamespaces = [] + let currNamespace = method.parent + while (currNamespace.name !== '') { + protoNamespaces.unshift(currNamespace.name) + currNamespace = currNamespace.parent + } + const protoServiceName = protoNamespaces.join('.') + const rpcName = method.name + const url = `${grpcFallbackProtocol}://${servicePath}:${servicePort}/$rpc/${protoServiceName}/${rpcName}` + const fetch = isbrowser_1.isBrowser() + ? // eslint-disable-next-line no-undef + window.fetch + : nodeFetch + fetch(url, { + headers, + method: 'post', + body: requestData, + signal: cancelSignal + }) + .then(response => { + return Promise.all([ + Promise.resolve(response.ok), + response.arrayBuffer() + ]) + }) + .then(([ok, buffer]) => { + if (!ok) { + const error = statusDecoder.decodeErrorFromBuffer(buffer) + throw error + } + serviceCallback(null, new Uint8Array(buffer)) + }) + .catch(err => { + if (!cancelRequested || err.name !== 'AbortError') { + serviceCallback(err) + } + }) + return { + cancel: () => { + if (!cancelController) { + console.warn( + 'AbortController not found: Cancellation is not supported in this environment' + ) + return + } + cancelRequested = true + cancelController.abort() + } + } + } + } + return newServiceStub + } + } + exports.GrpcClient = GrpcClient + /** + * gRPC-fallback version of lro + * + * @param {Object=} options.auth - An instance of google-auth-library. + * @return {Object} A OperationsClientBuilder that will return a OperationsClient + */ + function lro(options) { + options = Object.assign({ scopes: [] }, options) + const gaxGrpc = new GrpcClient(options) + return new operationsClient_1.OperationsClientBuilder(gaxGrpc) + } + exports.lro = lro + /** + * gRPC-fallback version of createApiCall + * + * Converts an rpc call into an API call governed by the settings. + * + * In typical usage, `func` will be a promise to a callable used to make an rpc + * request. This will mostly likely be a bound method from a request stub used + * to make an rpc call. It is not a direct function but a Promise instance, + * because of its asynchronism (typically, obtaining the auth information). + * + * The result is a function which manages the API call with the given settings + * and the options on the invocation. + * + * Throws exception on unsupported streaming calls + * + * @param {Promise|GRPCCall} func - is either a promise to be used to make + * a bare RPC call, or just a bare RPC call. + * @param {CallSettings} settings - provides the settings for this call + * @param {Descriptor} descriptor - optionally specify the descriptor for + * the method call. + * @return {GaxCall} func - a bound method on a request stub used + * to make an rpc call. + */ + function createApiCall(func, settings, descriptor) { + if (descriptor && 'streaming' in descriptor) { + return () => { + throw new Error( + 'The gRPC-fallback client library (e.g. browser version of the library) currently does not support streaming calls.' + ) + } + } + return createApiCall_1.createApiCall(func, settings, descriptor) + } + exports.createApiCall = createApiCall + exports.protobufMinimal = __webpack_require__(96916) + // Different environments or bundlers may or may not respect "browser" field + // in package.json (e.g. Electron does not respect it, but if you run the code + // through webpack first, it will follow the "browser" field). + // To make it safer and more compatible, let's make sure that if you do + // const gax = require("google-gax"); + // you can always ask for gax.fallback, regardless of "browser" field being + // understood or not. + const fallback = module.exports + exports.fallback = fallback + //# sourceMappingURL=fallback.js.map + + /***/ + }, + + /***/ 48848: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.FallbackErrorDecoder = void 0 + const protobuf = __webpack_require__(85881) + const status_1 = __webpack_require__(53501) + class FallbackErrorDecoder { + constructor() { + // eslint-disable-next-line @typescript-eslint/no-var-requires + const errorProtoJson = __webpack_require__(8719) + this.root = protobuf.Root.fromJSON(errorProtoJson) + this.anyType = this.root.lookupType('google.protobuf.Any') + this.statusType = this.root.lookupType('google.rpc.Status') + } + decodeProtobufAny(anyValue) { + const match = anyValue.type_url.match(/^type.googleapis.com\/(.*)/) + if (!match) { + throw new Error( + `Unknown type encoded in google.protobuf.any: ${anyValue.type_url}` + ) + } + const typeName = match[1] + const type = this.root.lookupType(typeName) + if (!type) { + throw new Error(`Cannot lookup type ${typeName}`) + } + return type.decode(anyValue.value) + } + // Decodes gRPC-fallback error which is an instance of google.rpc.Status. + decodeRpcStatus(buffer) { + const uint8array = new Uint8Array(buffer) + const status = this.statusType.decode(uint8array) + // google.rpc.Status contains an array of google.protobuf.Any + // which need a special treatment + const result = { + code: status.code, + message: status.message, + details: status.details.map(detail => + this.decodeProtobufAny(detail) + ) + } + return result + } + // Construct an Error from a StatusObject. + // Adapted from https://github.com/grpc/grpc-node/blob/master/packages/grpc-js/src/call.ts#L79 + callErrorFromStatus(status) { + status.message = `${status.code} ${status_1.Status[status.code]}: ${ + status.message + }` + return Object.assign(new Error(status.message), status) + } + // Decodes gRPC-fallback error which is an instance of google.rpc.Status, + // and puts it into the object similar to gRPC ServiceError object. + decodeErrorFromBuffer(buffer) { + return this.callErrorFromStatus(this.decodeRpcStatus(buffer)) + } + } + exports.FallbackErrorDecoder = FallbackErrorDecoder + //# sourceMappingURL=fallbackError.js.map + + /***/ + }, + + /***/ 80978: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + /** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.constructSettings = exports.createBundleOptions = exports.createMaxRetriesBackoffSettings = exports.createDefaultBackoffSettings = exports.createBackoffSettings = exports.createRetryOptions = exports.CallSettings = exports.RetryOptions = void 0 + /** + * Encapsulates the overridable settings for a particular API call. + * + * ``CallOptions`` is an optional arg for all GAX API calls. It is used to + * configure the settings of a specific API call. + * + * When provided, its values override the GAX service defaults for that + * particular call. + * + * Typically the API clients will accept this as the second to the last + * argument. See the examples below. + * @typedef {Object} CallOptions + * @property {number=} timeout - The client-side timeout for API calls. + * @property {RetryOptions=} retry - determines whether and how to retry + * on transient errors. When set to null, the call will not retry. + * @property {boolean=} autoPaginate - If set to false and the call is + * configured for paged iteration, page unrolling is not performed, instead + * the callback will be called with the response object. + * @property {Object=} pageToken - If set and the call is configured for + * paged iteration, paged iteration is not performed and requested with this + * pageToken. + * @property {number} maxResults - If set and the call is configured for + * paged iteration, the call will stop when the number of response elements + * reaches to the specified size. By default, it will unroll the page to + * the end of the list. + * @property {boolean=} isBundling - If set to false and the call is configured + * for bundling, bundling is not performed. + * @property {BackoffSettings=} longrunning - BackoffSettings used for polling. + * @example + * // suppress bundling for bundled method. + * api.bundlingMethod( + * param, {optParam: aValue, isBundling: false}, function(err, response) { + * // handle response. + * }); + * @example + * // suppress streaming for page-streaming method. + * api.pageStreamingMethod( + * param, {optParam: aValue, autoPaginate: false}, function(err, page) { + * // not returning a stream, but callback is called with the paged response. + * }); + */ + /** + * Per-call configurable settings for retrying upon transient failure. + * @typedef {Object} RetryOptions + * @property {String[]} retryCodes + * @property {BackoffSettings} backoffSettings + */ + class RetryOptions { + constructor(retryCodes, backoffSettings) { + this.retryCodes = retryCodes + this.backoffSettings = backoffSettings + } + } + exports.RetryOptions = RetryOptions + class CallSettings { + /** + * @param {Object} settings - An object containing parameters of this settings. + * @param {number} settings.timeout - The client-side timeout for API calls. + * This parameter is ignored for retrying calls. + * @param {RetryOptions} settings.retry - The configuration for retrying upon + * transient error. If set to null, this call will not retry. + * @param {boolean} settings.autoPaginate - If there is no `pageDescriptor`, + * this attrbute has no meaning. Otherwise, determines whether a page + * streamed response should make the page structure transparent to the user by + * flattening the repeated field in the returned generator. + * @param {number} settings.pageToken - If there is no `pageDescriptor`, + * this attribute has no meaning. Otherwise, determines the page token used + * in the page streaming request. + * @param {Object} settings.otherArgs - Additional arguments to be passed to + * the API calls. + * + * @constructor + */ + constructor(settings) { + var _a + settings = settings || {} + this.timeout = settings.timeout || 30 * 1000 + this.retry = settings.retry + this.autoPaginate = + 'autoPaginate' in settings ? settings.autoPaginate : true + this.pageToken = settings.pageToken + this.maxResults = settings.maxResults + this.otherArgs = settings.otherArgs || {} + this.bundleOptions = settings.bundleOptions + this.isBundling = + 'isBundling' in settings ? settings.isBundling : true + this.longrunning = + 'longrunning' in settings ? settings.longrunning : undefined + this.apiName = + (_a = settings.apiName) !== null && _a !== void 0 ? _a : undefined + this.retryRequestOptions = settings.retryRequestOptions + } + /** + * Returns a new CallSettings merged from this and a CallOptions object. + * + * @param {CallOptions} options - an instance whose values override + * those in this object. If null, ``merge`` returns a copy of this + * object + * @return {CallSettings} The merged CallSettings instance. + */ + merge(options) { + if (!options) { + return new CallSettings(this) + } + let timeout = this.timeout + let retry = this.retry + let autoPaginate = this.autoPaginate + let pageToken = this.pageToken + let pageSize = this.pageSize + let maxResults = this.maxResults + let otherArgs = this.otherArgs + let isBundling = this.isBundling + let longrunning = this.longrunning + let apiName = this.apiName + let retryRequestOptions = this.retryRequestOptions + if ('timeout' in options) { + timeout = options.timeout + } + if ('retry' in options) { + retry = options.retry + } + if ('autoPaginate' in options && !options.autoPaginate) { + autoPaginate = false + } + if ('pageToken' in options) { + autoPaginate = false + pageToken = options.pageToken + } + if ('pageSize' in options) { + pageSize = options.pageSize + } + if ('maxResults' in options) { + maxResults = options.maxResults + } + if ('otherArgs' in options) { + otherArgs = {} + for (const key in this.otherArgs) { + otherArgs[key] = this.otherArgs[key] + } + for (const optionsKey in options.otherArgs) { + otherArgs[optionsKey] = options.otherArgs[optionsKey] + } + } + if ('isBundling' in options) { + isBundling = options.isBundling + } + if ('maxRetries' in options) { + retry.backoffSettings.maxRetries = options.maxRetries + delete retry.backoffSettings.totalTimeoutMillis + } + if ('longrunning' in options) { + longrunning = options.longrunning + } + if ('apiName' in options) { + apiName = options.apiName + } + if ('retryRequestOptions' in options) { + retryRequestOptions = options.retryRequestOptions + } + return new CallSettings({ + timeout, + retry, + bundleOptions: this.bundleOptions, + longrunning, + autoPaginate, + pageToken, + pageSize, + maxResults, + otherArgs, + isBundling, + apiName, + retryRequestOptions + }) + } + } + exports.CallSettings = CallSettings + /** + * Per-call configurable settings for retrying upon transient failure. + * + * @param {number[]} retryCodes - a list of Google API canonical error codes + * upon which a retry should be attempted. + * @param {BackoffSettings} backoffSettings - configures the retry + * exponential backoff algorithm. + * @return {RetryOptions} A new RetryOptions object. + * + */ + function createRetryOptions(retryCodes, backoffSettings) { + return { + retryCodes, + backoffSettings + } + } + exports.createRetryOptions = createRetryOptions + /** + * Parameters to the exponential backoff algorithm for retrying. + * + * @param {number} initialRetryDelayMillis - the initial delay time, + * in milliseconds, between the completion of the first failed request and the + * initiation of the first retrying request. + * @param {number} retryDelayMultiplier - the multiplier by which to + * increase the delay time between the completion of failed requests, and the + * initiation of the subsequent retrying request. + * @param {number} maxRetryDelayMillis - the maximum delay time, in + * milliseconds, between requests. When this value is reached, + * ``retryDelayMultiplier`` will no longer be used to increase delay time. + * @param {number} initialRpcTimeoutMillis - the initial timeout parameter + * to the request. + * @param {number} rpcTimeoutMultiplier - the multiplier by which to + * increase the timeout parameter between failed requests. + * @param {number} maxRpcTimeoutMillis - the maximum timeout parameter, in + * milliseconds, for a request. When this value is reached, + * ``rpcTimeoutMultiplier`` will no longer be used to increase the timeout. + * @param {number} totalTimeoutMillis - the total time, in milliseconds, + * starting from when the initial request is sent, after which an error will + * be returned, regardless of the retrying attempts made meanwhile. + * @return {BackoffSettings} a new settings. + * + */ + function createBackoffSettings( + initialRetryDelayMillis, + retryDelayMultiplier, + maxRetryDelayMillis, + initialRpcTimeoutMillis, + rpcTimeoutMultiplier, + maxRpcTimeoutMillis, + totalTimeoutMillis + ) { + return { + initialRetryDelayMillis, + retryDelayMultiplier, + maxRetryDelayMillis, + initialRpcTimeoutMillis, + rpcTimeoutMultiplier, + maxRpcTimeoutMillis, + totalTimeoutMillis + } + } + exports.createBackoffSettings = createBackoffSettings + function createDefaultBackoffSettings() { + return createBackoffSettings(100, 1.3, 60000, null, null, null, null) + } + exports.createDefaultBackoffSettings = createDefaultBackoffSettings + /** + * Parameters to the exponential backoff algorithm for retrying. + * This function is unsupported, and intended for internal use only. + * + * @param {number} initialRetryDelayMillis - the initial delay time, + * in milliseconds, between the completion of the first failed request and the + * initiation of the first retrying request. + * @param {number} retryDelayMultiplier - the multiplier by which to + * increase the delay time between the completion of failed requests, and the + * initiation of the subsequent retrying request. + * @param {number} maxRetryDelayMillis - the maximum delay time, in + * milliseconds, between requests. When this value is reached, + * ``retryDelayMultiplier`` will no longer be used to increase delay time. + * @param {number} initialRpcTimeoutMillis - the initial timeout parameter + * to the request. + * @param {number} rpcTimeoutMultiplier - the multiplier by which to + * increase the timeout parameter between failed requests. + * @param {number} maxRpcTimeoutMillis - the maximum timeout parameter, in + * milliseconds, for a request. When this value is reached, + * ``rpcTimeoutMultiplier`` will no longer be used to increase the timeout. + * @param {number} maxRetries - the maximum number of retrying attempts that + * will be made. If reached, an error will be returned. + * @return {BackoffSettings} a new settings. + * + */ + function createMaxRetriesBackoffSettings( + initialRetryDelayMillis, + retryDelayMultiplier, + maxRetryDelayMillis, + initialRpcTimeoutMillis, + rpcTimeoutMultiplier, + maxRpcTimeoutMillis, + maxRetries + ) { + return { + initialRetryDelayMillis, + retryDelayMultiplier, + maxRetryDelayMillis, + initialRpcTimeoutMillis, + rpcTimeoutMultiplier, + maxRpcTimeoutMillis, + maxRetries + } + } + exports.createMaxRetriesBackoffSettings = createMaxRetriesBackoffSettings + /** + * Creates a new {@link BundleOptions}. + * + * @private + * @param {Object} options - An object to hold optional parameters. See + * properties for the content of options. + * @return {BundleOptions} - A new options. + */ + function createBundleOptions(options) { + const params = [ + 'element_count_threshold', + 'element_count_limit', + 'request_byte_threshold', + 'request_byte_limit', + 'delay_threshold_millis' + ] + params.forEach(param => { + if (param in options && typeof options[param] !== 'number') { + throw new Error(`${param} should be a number`) + } + }) + const elementCountThreshold = options.element_count_threshold || 0 + const elementCountLimit = options.element_count_limit || 0 + const requestByteThreshold = options.request_byte_threshold || 0 + const requestByteLimit = options.request_byte_limit || 0 + const delayThreshold = options.delay_threshold_millis || 0 + if ( + elementCountThreshold === 0 && + requestByteThreshold === 0 && + delayThreshold === 0 + ) { + throw new Error('one threshold should be > 0') + } + return { + elementCountThreshold, + elementCountLimit, + requestByteThreshold, + requestByteLimit, + delayThreshold + } + } + exports.createBundleOptions = createBundleOptions + /** + * Helper for {@link constructSettings} + * + * @private + * + * @param {Object} methodConfig - A dictionary representing a single + * `methods` entry of the standard API client config file. (See + * {@link constructSettings} for information on this yaml.) + * @param {?Object} retryCodes - A dictionary parsed from the + * `retry_codes_def` entry of the standard API client config + * file. (See {@link constructSettings} for information on this yaml.) + * @param {Object} retryParams - A dictionary parsed from the + * `retry_params` entry of the standard API client config + * file. (See {@link constructSettings} for information on this yaml.) + * @param {Object} retryNames - A dictionary mapping the string names + * used in the standard API client config file to API response + * status codes. + * @return {?RetryOptions} The new retry options. + */ + function constructRetry( + methodConfig, + retryCodes, + retryParams, + retryNames + ) { + if (!methodConfig) { + return null + } + let codes = null + if (retryCodes && 'retry_codes_name' in methodConfig) { + const retryCodesName = methodConfig['retry_codes_name'] + codes = (retryCodes[retryCodesName] || []).map(name => { + return Number(retryNames[name]) + }) + } + let backoffSettings = null + if (retryParams && 'retry_params_name' in methodConfig) { + const params = retryParams[methodConfig.retry_params_name] + backoffSettings = createBackoffSettings( + params.initial_retry_delay_millis, + params.retry_delay_multiplier, + params.max_retry_delay_millis, + params.initial_rpc_timeout_millis, + params.rpc_timeout_multiplier, + params.max_rpc_timeout_millis, + params.total_timeout_millis + ) + } + return createRetryOptions(codes, backoffSettings) + } + /** + * Helper for {@link constructSettings} + * + * Takes two retry options, and merges them into a single RetryOption instance. + * + * @private + * + * @param {RetryOptions} retry - The base RetryOptions. + * @param {RetryOptions} overrides - The RetryOptions used for overriding + * `retry`. Use the values if it is not null. If entire `overrides` is null, + * ignore the base retry and return null. + * @return {?RetryOptions} The merged RetryOptions. + */ + function mergeRetryOptions(retry, overrides) { + if (!overrides) { + return null + } + if (!overrides.retryCodes && !overrides.backoffSettings) { + return retry + } + let codes = retry.retryCodes + if (overrides.retryCodes) { + codes = overrides.retryCodes + } + let backoffSettings = retry.backoffSettings + if (overrides.backoffSettings) { + backoffSettings = overrides.backoffSettings + } + return createRetryOptions(codes, backoffSettings) + } + /** + * Constructs a dictionary mapping method names to {@link CallSettings}. + * + * The `clientConfig` parameter is parsed from a client configuration JSON + * file of the form: + * + * { + * "interfaces": { + * "google.fake.v1.ServiceName": { + * "retry_codes": { + * "idempotent": ["UNAVAILABLE", "DEADLINE_EXCEEDED"], + * "non_idempotent": [] + * }, + * "retry_params": { + * "default": { + * "initial_retry_delay_millis": 100, + * "retry_delay_multiplier": 1.2, + * "max_retry_delay_millis": 1000, + * "initial_rpc_timeout_millis": 2000, + * "rpc_timeout_multiplier": 1.5, + * "max_rpc_timeout_millis": 30000, + * "total_timeout_millis": 45000 + * } + * }, + * "methods": { + * "CreateFoo": { + * "retry_codes_name": "idempotent", + * "retry_params_name": "default" + * }, + * "Publish": { + * "retry_codes_name": "non_idempotent", + * "retry_params_name": "default", + * "bundling": { + * "element_count_threshold": 40, + * "element_count_limit": 200, + * "request_byte_threshold": 90000, + * "request_byte_limit": 100000, + * "delay_threshold_millis": 100 + * } + * } + * } + * } + * } + * } + * + * @param {String} serviceName - The fully-qualified name of this + * service, used as a key into the client config file (in the + * example above, this value should be 'google.fake.v1.ServiceName'). + * @param {Object} clientConfig - A dictionary parsed from the + * standard API client config file. + * @param {Object} configOverrides - A dictionary in the same structure of + * client_config to override the settings. + * @param {Object.} retryNames - A dictionary mapping the strings + * referring to response status codes to objects representing + * those codes. + * @param {Object} otherArgs - the non-request arguments to be passed to the API + * calls. + * @return {Object} A mapping from method name to CallSettings, or null if the + * service is not found in the config. + */ + function constructSettings( + serviceName, + clientConfig, + configOverrides, + retryNames, + otherArgs + ) { + otherArgs = otherArgs || {} + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const defaults = {} + const serviceConfig = (clientConfig.interfaces || {})[serviceName] + if (!serviceConfig) { + return null + } + // users can override the config from client side, like bundling options. + // The detailed structure of the clientConfig can be found here: https://github.com/googleapis/gax-nodejs/blob/master/src/gax.ts#L546 + // The way to override bundling options: + // + // const customConfig = {"interfaces": {"service": {"methods": {"methodName": {"bundling": {..}}}}}} + // const client = new Client({ projectId, customConfig }); + const overrides = (configOverrides.interfaces || {})[serviceName] || {} + const methods = serviceConfig.methods + const overridingMethods = overrides.methods || {} + for (const methodName in methods) { + const methodConfig = methods[methodName] + const jsName = methodName[0].toLowerCase() + methodName.slice(1) + let retry = constructRetry( + methodConfig, + serviceConfig.retry_codes, + serviceConfig.retry_params, + retryNames + ) + let bundlingConfig = methodConfig.bundling + let timeout = methodConfig.timeout_millis + if (methodName in overridingMethods) { + const overridingMethod = overridingMethods[methodName] + if (overridingMethod) { + if ('bundling' in overridingMethod) { + bundlingConfig = overridingMethod.bundling + } + if ('timeout_millis' in overridingMethod) { + timeout = overridingMethod.timeout_millis + } + } + retry = mergeRetryOptions( + retry, + constructRetry( + overridingMethod, + overrides.retry_codes, + overrides.retry_params, + retryNames + ) + ) + } + const apiName = serviceName + defaults[jsName] = new CallSettings({ + timeout, + retry, + bundleOptions: bundlingConfig + ? createBundleOptions(bundlingConfig) + : null, + otherArgs, + apiName + }) + } + return defaults + } + exports.constructSettings = constructSettings + //# sourceMappingURL=gax.js.map + + /***/ + }, + + /***/ 6634: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + /** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.GoogleError = void 0 + class GoogleError extends Error {} + exports.GoogleError = GoogleError + //# sourceMappingURL=googleError.js.map + + /***/ + }, + + /***/ 68976: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.GoogleProtoFilesRoot = exports.GrpcClient = exports.ClientStub = void 0 + const grpcProtoLoader = __webpack_require__(98171) + const fs = __webpack_require__(35747) + const google_auth_library_1 = __webpack_require__(20810) + const grpc = __webpack_require__(7025) + const path = __webpack_require__(85622) + const protobuf = __webpack_require__(85881) + const gax = __webpack_require__(80978) + const googleProtoFilesDir = __webpack_require__.ab + 'protos' + // INCLUDE_DIRS is passed to @grpc/proto-loader + const INCLUDE_DIRS = [] + INCLUDE_DIRS.push(googleProtoFilesDir) + // COMMON_PROTO_FILES logic is here for protobufjs loads (see + // GoogleProtoFilesRoot below) + const commonProtoFiles = __webpack_require__(9397) + // use the correct path separator for the OS we are running on + const COMMON_PROTO_FILES = commonProtoFiles.map(file => + file.replace(/[/\\]/g, path.sep) + ) + class ClientStub extends grpc.Client {} + exports.ClientStub = ClientStub + class GrpcClient { + /** + * A class which keeps the context of gRPC and auth for the gRPC. + * + * @param {Object=} options - The optional parameters. It will be directly + * passed to google-auth-library library, so parameters like keyFile or + * credentials will be valid. + * @param {Object=} options.auth - An instance of google-auth-library. + * When specified, this auth instance will be used instead of creating + * a new one. + * @param {Object=} options.grpc - When specified, this will be used + * for the 'grpc' module in this context. By default, it will load the grpc + * module in the standard way. + * @constructor + */ + constructor(options = {}) { + var _a + this.auth = + options.auth || new google_auth_library_1.GoogleAuth(options) + this.fallback = false + const minimumVersion = 10 + const major = Number( + (_a = process.version.match(/^v(\d+)/)) === null || _a === void 0 + ? void 0 + : _a[1] + ) + if (Number.isNaN(major) || major < minimumVersion) { + const errorMessage = + `Node.js v${minimumVersion}.0.0 is a minimum requirement. To learn about legacy version support visit: ` + + 'https://github.com/googleapis/google-cloud-node#supported-nodejs-versions' + throw new Error(errorMessage) + } + if ('grpc' in options) { + this.grpc = options.grpc + this.grpcVersion = '' + } else { + this.grpc = grpc + this.grpcVersion = __webpack_require__(68160) /* .version */.i8 + } + } + /** + * Creates a gRPC credentials. It asks the auth data if necessary. + * @private + * @param {Object} opts - options values for configuring credentials. + * @param {Object=} opts.sslCreds - when specified, this is used instead + * of default channel credentials. + * @return {Promise} The promise which will be resolved to the gRPC credential. + */ + async _getCredentials(opts) { + if (opts.sslCreds) { + return opts.sslCreds + } + const grpc = this.grpc + const sslCreds = grpc.credentials.createSsl() + const client = await this.auth.getClient() + const credentials = grpc.credentials.combineChannelCredentials( + sslCreds, + grpc.credentials.createFromGoogleCredential(client) + ) + return credentials + } + /** + * Loads the gRPC service from the proto file(s) at the given path and with the + * given options. + * @param filename The path to the proto file(s). + * @param options Options for loading the proto file. + */ + loadFromProto(filename, options) { + const packageDef = grpcProtoLoader.loadSync(filename, options) + return this.grpc.loadPackageDefinition(packageDef) + } + /** + * Load grpc proto service from a filename hooking in googleapis common protos + * when necessary. + * @param {String} protoPath - The directory to search for the protofile. + * @param {String|String[]} filename - The filename(s) of the proto(s) to be loaded. + * If omitted, protoPath will be treated as a file path to load. + * @return {Object} The gRPC loaded result (the toplevel namespace + * object). + */ + loadProto(protoPath, filename) { + if (!filename) { + filename = path.basename(protoPath) + protoPath = path.dirname(protoPath) + } + if (Array.isArray(filename) && filename.length === 0) { + return {} + } + // This set of @grpc/proto-loader options + // 'closely approximates the existing behavior of grpc.load' + const includeDirs = INCLUDE_DIRS.slice() + includeDirs.unshift(protoPath) + const options = { + keepCase: false, + longs: String, + enums: String, + defaults: true, + oneofs: true, + includeDirs + } + return this.loadFromProto(filename, options) + } + static _resolveFile(protoPath, filename) { + if (fs.existsSync(path.join(protoPath, filename))) { + return path.join(protoPath, filename) + } else if (COMMON_PROTO_FILES.indexOf(filename) > -1) { + return path.join(googleProtoFilesDir, filename) + } + throw new Error(filename + ' could not be found in ' + protoPath) + } + metadataBuilder(headers) { + const Metadata = this.grpc.Metadata + const baseMetadata = new Metadata() + for (const key in headers) { + const value = headers[key] + if (Array.isArray(value)) { + value.forEach(v => baseMetadata.add(key, v)) + } else { + baseMetadata.set(key, `${value}`) + } + } + return function buildMetadata(abTests, moreHeaders) { + // TODO: bring the A/B testing info into the metadata. + let copied = false + let metadata = baseMetadata + if (moreHeaders) { + for (const key in moreHeaders) { + if (key.toLowerCase() !== 'x-goog-api-client') { + if (!copied) { + copied = true + metadata = metadata.clone() + } + const value = moreHeaders[key] + if (Array.isArray(value)) { + value.forEach(v => metadata.add(key, v)) + } else { + metadata.set(key, `${value}`) + } + } + } + } + return metadata + } + } + /** + * A wrapper of {@link constructSettings} function under the gRPC context. + * + * Most of parameters are common among constructSettings, please take a look. + * @param {string} serviceName - The fullly-qualified name of the service. + * @param {Object} clientConfig - A dictionary of the client config. + * @param {Object} configOverrides - A dictionary of overriding configs. + * @param {Object} headers - A dictionary of additional HTTP header name to + * its value. + * @return {Object} A mapping of method names to CallSettings. + */ + constructSettings(serviceName, clientConfig, configOverrides, headers) { + return gax.constructSettings( + serviceName, + clientConfig, + configOverrides, + this.grpc.status, + { metadataBuilder: this.metadataBuilder(headers) } + ) + } + /** + * Creates a gRPC stub with current gRPC and auth. + * @param {function} CreateStub - The constructor function of the stub. + * @param {Object} options - The optional arguments to customize + * gRPC connection. This options will be passed to the constructor of + * gRPC client too. + * @param {string} options.servicePath - The name of the server of the service. + * @param {number} options.port - The port of the service. + * @param {grpcTypes.ClientCredentials=} options.sslCreds - The credentials to be used + * to set up gRPC connection. + * @return {Promise} A promise which resolves to a gRPC stub instance. + */ + async createStub(CreateStub, options) { + // The following options are understood by grpc-gcp and need a special treatment + // (should be passed without a `grpc.` prefix) + const grpcGcpOptions = [ + 'grpc.callInvocationTransformer', + 'grpc.channelFactoryOverride', + 'grpc.gcpApiConfig' + ] + const serviceAddress = options.servicePath + ':' + options.port + const creds = await this._getCredentials(options) + const grpcOptions = {} + // @grpc/grpc-js limits max receive/send message length starting from v0.8.0 + // https://github.com/grpc/grpc-node/releases/tag/%40grpc%2Fgrpc-js%400.8.0 + // To keep the existing behavior and avoid libraries breakage, we pass -1 there as suggested. + grpcOptions['grpc.max_receive_message_length'] = -1 + grpcOptions['grpc.max_send_message_length'] = -1 + grpcOptions['grpc.initial_reconnect_backoff_ms'] = 1000 + Object.keys(options).forEach(key => { + const value = options[key] + // the older versions had a bug which required users to call an option + // grpc.grpc.* to make it actually pass to gRPC as grpc.*, let's handle + // this here until the next major release + if (key.startsWith('grpc.grpc.')) { + key = key.replace(/^grpc\./, '') + } + if (key.startsWith('grpc.')) { + if (grpcGcpOptions.includes(key)) { + key = key.replace(/^grpc\./, '') + } + grpcOptions[key] = value + } + }) + const stub = new CreateStub(serviceAddress, creds, grpcOptions) + return stub + } + /** + * Creates a 'bytelength' function for a given proto message class. + * + * See {@link BundleDescriptor} about the meaning of the return value. + * + * @param {function} message - a constructor function that is generated by + * protobuf.js. Assumes 'encoder' field in the message. + * @return {function(Object):number} - a function to compute the byte length + * for an object. + */ + static createByteLengthFunction(message) { + return function getByteLength(obj) { + return message.encode(obj).finish().length + } + } + } + exports.GrpcClient = GrpcClient + class GoogleProtoFilesRoot extends protobuf.Root { + constructor(...args) { + super(...args) + } + // Causes the loading of an included proto to check if it is a common + // proto. If it is a common proto, use the bundled proto. + resolvePath(originPath, includePath) { + originPath = path.normalize(originPath) + includePath = path.normalize(includePath) + // Fully qualified paths don't need to be resolved. + if (path.isAbsolute(includePath)) { + if (!fs.existsSync(includePath)) { + throw new Error( + 'The include `' + includePath + '` was not found.' + ) + } + return includePath + } + if (COMMON_PROTO_FILES.indexOf(includePath) > -1) { + return path.join(googleProtoFilesDir, includePath) + } + return GoogleProtoFilesRoot._findIncludePath(originPath, includePath) + } + static _findIncludePath(originPath, includePath) { + originPath = path.normalize(originPath) + includePath = path.normalize(includePath) + let current = originPath + let found = fs.existsSync(path.join(current, includePath)) + while (!found && current.length > 0) { + current = current.substring(0, current.lastIndexOf(path.sep)) + found = fs.existsSync(path.join(current, includePath)) + } + if (!found) { + throw new Error('The include `' + includePath + '` was not found.') + } + return path.join(current, includePath) + } + } + exports.GoogleProtoFilesRoot = GoogleProtoFilesRoot + //# sourceMappingURL=grpc.js.map + + /***/ + }, + + /***/ 28118: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + // Copyright 2020 Google LLC + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // https://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. + // + // ** This file is automatically generated by gapic-generator-typescript. ** + // ** https://github.com/googleapis/gapic-generator-typescript ** + // ** All changes to this file may be overwritten. ** + Object.defineProperty(exports, '__esModule', { value: true }) + exports.IamClient = void 0 + const grpc_1 = __webpack_require__(68976) + const fallback_1 = __webpack_require__(90418) + const createApiCall_1 = __webpack_require__(79712) + const routingHeader = __webpack_require__(8827) + const gapicConfig = __webpack_require__(80784) + const fallback = __webpack_require__(90418) + const path = __webpack_require__(85622) + let version = __webpack_require__(56156).version + /** + * Google Cloud IAM Client. + * This is manually written for providing methods [setIamPolicy, getIamPolicy, testIamPerssion] to the generated client. + */ + class IamClient { + constructor( + gaxGrpc, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + options + ) { + this._terminated = false + this.descriptors = { page: {}, stream: {}, longrunning: {} } + this.innerApiCalls = {} + this.gaxGrpc = gaxGrpc + // Ensure that options include the service address and port. + const opts = Object.assign( + { + servicePath: options.servicePath, + port: options.port, + clientConfig: options.clientConfig, + apiEndpoint: options.apiEndpoint, + fallback: options.fallback + }, + options + ) + version = opts.fallback ? fallback.version : version + this._gaxGrpc = opts.fallback + ? new fallback_1.GrpcClient(opts) + : new grpc_1.GrpcClient(opts) + opts.scopes = this.constructor.scopes + // Save options to use in initialize() method. + this._opts = opts + // Save the auth object to the client, for use by other methods. + this.auth = gaxGrpc.auth + // Determine the client header string. + const clientHeader = [`gax/${version}`, `gapic/${version}`] + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`) + } else { + clientHeader.push(`gl-web/${version}`) + } + if (!opts.fallback) { + clientHeader.push(`grpc/${gaxGrpc.grpcVersion}`) + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`) + } + // Load the applicable protos. + // For Node.js, pass the path to JSON proto file. + // For browsers, pass the JSON content. + const nodejsProtoPath = __webpack_require__.ab + 'iam_service.json' + this._protos = this._gaxGrpc.loadProto( + opts.fallback + ? // eslint-disable-next-line @typescript-eslint/no-var-requires + __webpack_require__(39616) + : __webpack_require__.ab + 'iam_service.json' + ) + // Put together the default options sent with requests. + this._defaults = gaxGrpc.constructSettings( + 'google.iam.v1.IAMPolicy', + gapicConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') } + ) + this.innerApiCalls = {} + } + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.iamPolicyStub) { + return this.iamPolicyStub + } + // Put together the "service stub" for + // google.iam.v1.IAMPolicy. + this.iamPolicyStub = this.gaxGrpc.createStub( + this._opts.fallback + ? this._protos.lookupService('google.iam.v1.IAMPolicy') + : this._protos.google.iam.v1.IAMPolicy, + this._opts + ) + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const iamPolicyStubMethods = [ + 'getIamPolicy', + 'setIamPolicy', + 'testIamPermissions' + ] + for (const methodName of iamPolicyStubMethods) { + const innerCallPromise = this.iamPolicyStub.then( + stub => (...args) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.') + } + const func = stub[methodName] + return func.apply(stub, args) + }, + err => () => { + throw err + } + ) + this.innerApiCalls[methodName] = createApiCall_1.createApiCall( + innerCallPromise, + this._defaults[methodName], + this.descriptors.page[methodName] + ) + } + return this.iamPolicyStub + } + /** + * The DNS address for this API service. + */ + static get servicePath() { + return 'cloudkms.googleapis.com' + } + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + */ + static get apiEndpoint() { + return 'cloudkms.googleapis.com' + } + /** + * The port for this API service. + */ + static get port() { + return 443 + } + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloudkms' + ] + } + getProjectId(callback) { + if (this.auth && 'getProjectId' in this.auth) { + return this.auth.getProjectId(callback) + } + if (callback) { + callback(new Error('Cannot determine project ID.')) + } else { + return Promise.reject('Cannot determine project ID.') + } + } + getIamPolicy(request, optionsOrCallback, callback) { + let options + if (optionsOrCallback instanceof Function && callback === undefined) { + callback = optionsOrCallback + options = {} + } else { + options = optionsOrCallback + } + request = request || {} + options = options || {} + options.otherArgs = options.otherArgs || {} + options.otherArgs.headers = options.otherArgs.headers || {} + options.otherArgs.headers[ + 'x-goog-request-params' + ] = routingHeader.fromParams({ + resource: request.resource + }) + this.initialize() + return this.innerApiCalls.getIamPolicy(request, options, callback) + } + setIamPolicy(request, optionsOrCallback, callback) { + let options + if (optionsOrCallback instanceof Function && callback === undefined) { + callback = optionsOrCallback + options = {} + } else { + options = optionsOrCallback + } + request = request || {} + options = options || {} + options.otherArgs = options.otherArgs || {} + options.otherArgs.headers = options.otherArgs.headers || {} + options.otherArgs.headers[ + 'x-goog-request-params' + ] = routingHeader.fromParams({ + resource: request.resource + }) + this.initialize() + return this.innerApiCalls.setIamPolicy(request, options, callback) + } + testIamPermissions(request, optionsOrCallback, callback) { + let options + if (optionsOrCallback instanceof Function && callback === undefined) { + callback = optionsOrCallback + options = {} + } else { + options = optionsOrCallback + } + request = request || {} + options = options || {} + options.otherArgs = options.otherArgs || {} + options.otherArgs.headers = options.otherArgs.headers || {} + options.otherArgs.headers[ + 'x-goog-request-params' + ] = routingHeader.fromParams({ + resource: request.resource + }) + this.initialize() + return this.innerApiCalls.testIamPermissions( + request, + options, + callback + ) + } + /** + * Terminate the GRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + */ + close() { + this.initialize() + if (!this._terminated) { + return this.iamPolicyStub.then(stub => { + this._terminated = true + stub.close() + }) + } + return Promise.resolve() + } + } + exports.IamClient = IamClient + //# sourceMappingURL=iamService.js.map + + /***/ + }, + + /***/ 12263: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.fallback = exports.protobuf = exports.version = exports.createByteLengthFunction = exports.IamProtos = exports.operationsProtos = exports.lro = exports.routingHeader = exports.grpc = void 0 + const grpc = __webpack_require__(7025) + exports.grpc = grpc + const grpc_1 = __webpack_require__(68976) + const IamProtos = __webpack_require__(83555) + exports.IamProtos = IamProtos + const operationsProtos = __webpack_require__(59081) + exports.operationsProtos = operationsProtos + const operationsClient = __webpack_require__(82450) + const routingHeader = __webpack_require__(8827) + exports.routingHeader = routingHeader + var google_auth_library_1 = __webpack_require__(20810) + Object.defineProperty(exports, 'GoogleAuth', { + enumerable: true, + get: function () { + return google_auth_library_1.GoogleAuth + } + }) + var call_1 = __webpack_require__(53047) + Object.defineProperty(exports, 'OngoingCall', { + enumerable: true, + get: function () { + return call_1.OngoingCall + } + }) + var createApiCall_1 = __webpack_require__(79712) + Object.defineProperty(exports, 'createApiCall', { + enumerable: true, + get: function () { + return createApiCall_1.createApiCall + } + }) + var descriptor_1 = __webpack_require__(13627) + Object.defineProperty(exports, 'BundleDescriptor', { + enumerable: true, + get: function () { + return descriptor_1.BundleDescriptor + } + }) + Object.defineProperty(exports, 'LongrunningDescriptor', { + enumerable: true, + get: function () { + return descriptor_1.LongrunningDescriptor + } + }) + Object.defineProperty(exports, 'PageDescriptor', { + enumerable: true, + get: function () { + return descriptor_1.PageDescriptor + } + }) + Object.defineProperty(exports, 'StreamDescriptor', { + enumerable: true, + get: function () { + return descriptor_1.StreamDescriptor + } + }) + var gax_1 = __webpack_require__(80978) + Object.defineProperty(exports, 'CallSettings', { + enumerable: true, + get: function () { + return gax_1.CallSettings + } + }) + Object.defineProperty(exports, 'constructSettings', { + enumerable: true, + get: function () { + return gax_1.constructSettings + } + }) + Object.defineProperty(exports, 'RetryOptions', { + enumerable: true, + get: function () { + return gax_1.RetryOptions + } + }) + Object.defineProperty(exports, 'createRetryOptions', { + enumerable: true, + get: function () { + return gax_1.createRetryOptions + } + }) + Object.defineProperty(exports, 'createBundleOptions', { + enumerable: true, + get: function () { + return gax_1.createBundleOptions + } + }) + Object.defineProperty(exports, 'createBackoffSettings', { + enumerable: true, + get: function () { + return gax_1.createBackoffSettings + } + }) + Object.defineProperty(exports, 'createDefaultBackoffSettings', { + enumerable: true, + get: function () { + return gax_1.createDefaultBackoffSettings + } + }) + Object.defineProperty(exports, 'createMaxRetriesBackoffSettings', { + enumerable: true, + get: function () { + return gax_1.createMaxRetriesBackoffSettings + } + }) + var googleError_1 = __webpack_require__(6634) + Object.defineProperty(exports, 'GoogleError', { + enumerable: true, + get: function () { + return googleError_1.GoogleError + } + }) + var grpc_2 = __webpack_require__(68976) + Object.defineProperty(exports, 'ClientStub', { + enumerable: true, + get: function () { + return grpc_2.ClientStub + } + }) + Object.defineProperty(exports, 'GoogleProtoFilesRoot', { + enumerable: true, + get: function () { + return grpc_2.GoogleProtoFilesRoot + } + }) + Object.defineProperty(exports, 'GrpcClient', { + enumerable: true, + get: function () { + return grpc_2.GrpcClient + } + }) + var longrunning_1 = __webpack_require__(83481) + Object.defineProperty(exports, 'Operation', { + enumerable: true, + get: function () { + return longrunning_1.Operation + } + }) + Object.defineProperty(exports, 'operation', { + enumerable: true, + get: function () { + return longrunning_1.operation + } + }) + var pathTemplate_1 = __webpack_require__(20513) + Object.defineProperty(exports, 'PathTemplate', { + enumerable: true, + get: function () { + return pathTemplate_1.PathTemplate + } + }) + var status_1 = __webpack_require__(53501) + Object.defineProperty(exports, 'Status', { + enumerable: true, + get: function () { + return status_1.Status + } + }) + var streaming_1 = __webpack_require__(67389) + Object.defineProperty(exports, 'StreamType', { + enumerable: true, + get: function () { + return streaming_1.StreamType + } + }) + function lro(options) { + options = Object.assign({ scopes: lro.ALL_SCOPES }, options) + const gaxGrpc = new grpc_1.GrpcClient(options) + return new operationsClient.OperationsClientBuilder(gaxGrpc) + } + exports.lro = lro + lro.SERVICE_ADDRESS = operationsClient.SERVICE_ADDRESS + lro.ALL_SCOPES = operationsClient.ALL_SCOPES + var operationsClient_1 = __webpack_require__(82450) + Object.defineProperty(exports, 'OperationsClient', { + enumerable: true, + get: function () { + return operationsClient_1.OperationsClient + } + }) + var iamService_1 = __webpack_require__(28118) + Object.defineProperty(exports, 'IamClient', { + enumerable: true, + get: function () { + return iamService_1.IamClient + } + }) + exports.createByteLengthFunction = + grpc_1.GrpcClient.createByteLengthFunction + exports.version = __webpack_require__(56156).version + const protobuf = __webpack_require__(85881) + exports.protobuf = protobuf + exports.protobufMinimal = __webpack_require__(96916) + const fallback = __webpack_require__(90418) + exports.fallback = fallback + var grpc_js_1 = __webpack_require__(7025) + Object.defineProperty(exports, 'ChannelCredentials', { + enumerable: true, + get: function () { + return grpc_js_1.ChannelCredentials + } + }) + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 95021: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + /** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.isBrowser = void 0 + function isBrowser() { + return typeof window !== 'undefined' + } + exports.isBrowser = isBrowser + //# sourceMappingURL=isbrowser.js.map + + /***/ + }, + + /***/ 74729: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.LongrunningApiCaller = void 0 + const call_1 = __webpack_require__(53047) + const gax_1 = __webpack_require__(80978) + const longrunning_1 = __webpack_require__(83481) + class LongrunningApiCaller { + /** + * Creates an API caller that performs polling on a long running operation. + * + * @private + * @constructor + * @param {LongRunningDescriptor} longrunningDescriptor - Holds the + * decoders used for unpacking responses and the operationsClient + * used for polling the operation. + */ + constructor(longrunningDescriptor) { + this.longrunningDescriptor = longrunningDescriptor + } + init(callback) { + if (callback) { + return new call_1.OngoingCall(callback) + } + return new call_1.OngoingCallPromise() + } + wrap(func) { + return func + } + call(apiCall, argument, settings, canceller) { + canceller.call((argument, callback) => { + return this._wrapOperation(apiCall, settings, argument, callback) + }, argument) + } + _wrapOperation(apiCall, settings, argument, callback) { + let backoffSettings = settings.longrunning + if (!backoffSettings) { + backoffSettings = gax_1.createDefaultBackoffSettings() + } + const longrunningDescriptor = this.longrunningDescriptor + return apiCall(argument, (err, rawResponse) => { + if (err) { + callback(err, null, null, rawResponse) + return + } + const operation = new longrunning_1.Operation( + rawResponse, + longrunningDescriptor, + backoffSettings, + settings + ) + callback(null, operation, rawResponse) + }) + } + fail(canceller, err) { + canceller.callback(err) + } + result(canceller) { + return canceller.promise + } + } + exports.LongrunningApiCaller = LongrunningApiCaller + //# sourceMappingURL=longRunningApiCaller.js.map + + /***/ + }, + + /***/ 8096: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.LongRunningDescriptor = void 0 + const longRunningApiCaller_1 = __webpack_require__(74729) + /** + * A descriptor for long-running operations. + */ + class LongRunningDescriptor { + constructor(operationsClient, responseDecoder, metadataDecoder) { + this.operationsClient = operationsClient + this.responseDecoder = responseDecoder + this.metadataDecoder = metadataDecoder + } + getApiCaller() { + return new longRunningApiCaller_1.LongrunningApiCaller(this) + } + } + exports.LongRunningDescriptor = LongRunningDescriptor + //# sourceMappingURL=longRunningDescriptor.js.map + + /***/ + }, + + /***/ 83481: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.operation = exports.Operation = void 0 + const events_1 = __webpack_require__(28614) + const status_1 = __webpack_require__(53501) + const googleError_1 = __webpack_require__(6634) + const operationProtos = __webpack_require__(59081) + class Operation extends events_1.EventEmitter { + /** + * Wrapper for a google.longrunnung.Operation. + * + * @constructor + * + * @param {google.longrunning.Operation} grpcOp - The operation to be wrapped. + * @param {LongRunningDescriptor} longrunningDescriptor - This defines the + * operations service client and unpacking mechanisms for the operation. + * @param {BackoffSettings} backoffSettings - The backoff settings used in + * in polling the operation. + * @param {CallOptions} callOptions - CallOptions used in making get operation + * requests. + */ + constructor( + grpcOp, + longrunningDescriptor, + backoffSettings, + callOptions + ) { + super() + this.completeListeners = 0 + this.hasActiveListeners = false + this.latestResponse = grpcOp + this.name = this.latestResponse.name + this.done = this.latestResponse.done + this.error = this.latestResponse.error + this.longrunningDescriptor = longrunningDescriptor + this.result = null + this.metadata = null + this.backoffSettings = backoffSettings + this._unpackResponse(grpcOp) + this._listenForEvents() + this._callOptions = callOptions + } + /** + * Begin listening for events on the operation. This method keeps track of how + * many "complete" listeners are registered and removed, making sure polling + * is handled automatically. + * + * As long as there is one active "complete" listener, the connection is open. + * When there are no more listeners, the polling stops. + * + * @private + */ + _listenForEvents() { + this.on('newListener', event => { + if (event === 'complete') { + this.completeListeners++ + if (!this.hasActiveListeners) { + this.hasActiveListeners = true + this.startPolling_() + } + } + }) + this.on('removeListener', event => { + if (event === 'complete' && --this.completeListeners === 0) { + this.hasActiveListeners = false + } + }) + } + /** + * Cancels current polling api call and cancels the operation. + * + * @return {Promise} the promise of the OperationsClient#cancelOperation api + * request. + */ + cancel() { + if (this.currentCallPromise_) { + this.currentCallPromise_.cancel() + } + const operationsClient = this.longrunningDescriptor.operationsClient + const cancelRequest = new operationProtos.google.longrunning.CancelOperationRequest() + cancelRequest.name = this.latestResponse.name + return operationsClient.cancelOperation(cancelRequest) + } + getOperation(callback) { + // eslint-disable-next-line @typescript-eslint/no-this-alias + const self = this + const operationsClient = this.longrunningDescriptor.operationsClient + function promisifyResponse() { + if (!callback) { + return new Promise((resolve, reject) => { + if (self.latestResponse.error) { + const error = new googleError_1.GoogleError( + self.latestResponse.error.message + ) + error.code = self.latestResponse.error.code + reject(error) + } else { + resolve([self.result, self.metadata, self.latestResponse]) + } + }) + } + return + } + if (this.latestResponse.done) { + this._unpackResponse(this.latestResponse, callback) + return promisifyResponse() + } + const request = new operationProtos.google.longrunning.GetOperationRequest() + request.name = this.latestResponse.name + this.currentCallPromise_ = operationsClient.getOperationInternal( + request, + this._callOptions + ) + const noCallbackPromise = this.currentCallPromise_.then(responses => { + self.latestResponse = responses[0] + self._unpackResponse(responses[0], callback) + return promisifyResponse() + }) + if (!callback) { + return noCallbackPromise + } + } + _unpackResponse(op, callback) { + const responseDecoder = this.longrunningDescriptor.responseDecoder + const metadataDecoder = this.longrunningDescriptor.metadataDecoder + let response + let metadata + if (op.done) { + if (op.result === 'error') { + const error = new googleError_1.GoogleError(op.error.message) + error.code = op.error.code + this.error = error + if (callback) { + callback(error) + } + return + } + if (responseDecoder && op.response) { + this.response = op.response + response = responseDecoder(op.response.value) + this.result = response + this.done = true + } + } + if (metadataDecoder && op.metadata) { + metadata = metadataDecoder(op.metadata.value) + this.metadata = metadata + } + if (callback) { + callback(null, response, metadata, op) + } + } + /** + * Poll `getOperation` to check the operation's status. This runs a loop to + * ping using the backoff strategy specified at initialization. + * + * Note: This method is automatically called once a "complete" event handler + * is registered on the operation. + * + * @private + */ + startPolling_() { + // eslint-disable-next-line @typescript-eslint/no-this-alias + const self = this + let now = new Date() + const delayMult = this.backoffSettings.retryDelayMultiplier + const maxDelay = this.backoffSettings.maxRetryDelayMillis + let delay = this.backoffSettings.initialRetryDelayMillis + let deadline = Infinity + if (this.backoffSettings.totalTimeoutMillis) { + deadline = now.getTime() + this.backoffSettings.totalTimeoutMillis + } + let previousMetadataBytes + if (this.latestResponse.metadata) { + previousMetadataBytes = this.latestResponse.metadata.value + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function emit(event, ...args) { + self.emit(event, ...args) + } + // Helper function to replace nodejs buffer's equals() + function arrayEquals(a, b) { + if (a.byteLength !== b.byteLength) { + return false + } + for (let i = 0; i < a.byteLength; ++i) { + if (a[i] !== b[i]) return false + } + return true + } + function retry() { + if (!self.hasActiveListeners) { + return + } + if (now.getTime() >= deadline) { + const error = new googleError_1.GoogleError( + 'Total timeout exceeded before any response was received' + ) + error.code = status_1.Status.DEADLINE_EXCEEDED + setImmediate(emit, 'error', error) + return + } + self.getOperation((err, result, metadata, rawResponse) => { + if (err) { + setImmediate(emit, 'error', err) + return + } + if (!result) { + if ( + rawResponse.metadata && + (!previousMetadataBytes || + (rawResponse && + !arrayEquals( + rawResponse.metadata.value, + previousMetadataBytes + ))) + ) { + setImmediate(emit, 'progress', metadata, rawResponse) + previousMetadataBytes = rawResponse.metadata.value + } + // special case: some APIs fail to set either result or error + // but set done = true (e.g. speech with silent file). + // Don't hang forever in this case. + if (rawResponse.done) { + const error = new googleError_1.GoogleError( + 'Long running operation has finished but there was no result' + ) + error.code = status_1.Status.UNKNOWN + setImmediate(emit, 'error', error) + return + } + setTimeout(() => { + now = new Date() + delay = Math.min(delay * delayMult, maxDelay) + retry() + }, delay) + return + } + setImmediate(emit, 'complete', result, metadata, rawResponse) + }) + } + retry() + } + /** + * Wraps the `complete` and `error` events in a Promise. + * + * @return {promise} - Promise that resolves on operation completion and rejects + * on operation error. + */ + promise() { + return new Promise((resolve, reject) => { + this.on('error', reject).on( + 'complete', + (result, metadata, rawResponse) => { + resolve([result, metadata, rawResponse]) + } + ) + }) + } + } + exports.Operation = Operation + /** + * Method used to create Operation objects. + * + * @constructor + * + * @param {google.longrunning.Operation} op - The operation to be wrapped. + * @param {LongRunningDescriptor} longrunningDescriptor - This defines the + * operations service client and unpacking mechanisms for the operation. + * @param {BackoffSettings} backoffSettings - The backoff settings used in + * in polling the operation. + * @param {CallOptions=} callOptions - CallOptions used in making get operation + * requests. + */ + function operation( + op, + longrunningDescriptor, + backoffSettings, + callOptions + ) { + return new Operation( + op, + longrunningDescriptor, + backoffSettings, + callOptions + ) + } + exports.operation = operation + //# sourceMappingURL=longrunning.js.map + + /***/ + }, + + /***/ 56513: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.NormalApiCaller = void 0 + const call_1 = __webpack_require__(53047) + /** + * Creates an API caller for regular unary methods. + */ + class NormalApiCaller { + init(callback) { + if (callback) { + return new call_1.OngoingCall(callback) + } + return new call_1.OngoingCallPromise() + } + wrap(func) { + return func + } + call(apiCall, argument, settings, canceller) { + canceller.call(apiCall, argument) + } + fail(canceller, err) { + canceller.callback(err) + } + result(canceller) { + return canceller.promise + } + } + exports.NormalApiCaller = NormalApiCaller + //# sourceMappingURL=normalApiCaller.js.map + + /***/ + }, + + /***/ 69742: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.retryable = void 0 + const status_1 = __webpack_require__(53501) + const googleError_1 = __webpack_require__(6634) + const timeout_1 = __webpack_require__(4531) + /** + * Creates a function equivalent to func, but that retries on certain + * exceptions. + * + * @private + * + * @param {GRPCCall} func - A function. + * @param {RetryOptions} retry - Configures the exceptions upon which the + * function eshould retry, and the parameters to the exponential backoff retry + * algorithm. + * @param {GRPCCallOtherArgs} otherArgs - the additional arguments to be passed to func. + * @return {SimpleCallbackFunction} A function that will retry. + */ + function retryable(func, retry, otherArgs, apiName) { + const delayMult = retry.backoffSettings.retryDelayMultiplier + const maxDelay = retry.backoffSettings.maxRetryDelayMillis + const timeoutMult = retry.backoffSettings.rpcTimeoutMultiplier + const maxTimeout = retry.backoffSettings.maxRpcTimeoutMillis + let delay = retry.backoffSettings.initialRetryDelayMillis + let timeout = retry.backoffSettings.initialRpcTimeoutMillis + /** + * Equivalent to ``func``, but retries upon transient failure. + * + * Retrying is done through an exponential backoff algorithm configured + * by the options in ``retry``. + * @param {RequestType} argument The request object. + * @param {APICallback} callback The callback. + * @return {GRPCCall} + */ + return (argument, callback) => { + let canceller + let timeoutId + let now = new Date() + let deadline + if (retry.backoffSettings.totalTimeoutMillis) { + deadline = now.getTime() + retry.backoffSettings.totalTimeoutMillis + } + let retries = 0 + const maxRetries = retry.backoffSettings.maxRetries + // TODO: define A/B testing values for retry behaviors. + /** Repeat the API call as long as necessary. */ + function repeat() { + timeoutId = null + if (deadline && now.getTime() >= deadline) { + const error = new googleError_1.GoogleError( + `Total timeout of API ${apiName} exceeded ${retry.backoffSettings.totalTimeoutMillis} milliseconds before any response was received.` + ) + error.code = status_1.Status.DEADLINE_EXCEEDED + callback(error) + return + } + if (retries && retries >= maxRetries) { + const error = new googleError_1.GoogleError( + 'Exceeded maximum number of retries before any ' + + 'response was received' + ) + error.code = status_1.Status.DEADLINE_EXCEEDED + callback(error) + return + } + retries++ + const toCall = timeout_1.addTimeoutArg(func, timeout, otherArgs) + canceller = toCall(argument, (err, response, next, rawResponse) => { + if (!err) { + callback(null, response, next, rawResponse) + return + } + canceller = null + if (retry.retryCodes.indexOf(err.code) < 0) { + err.note = + 'Exception occurred in retry method that was ' + + 'not classified as transient' + callback(err) + } else { + const toSleep = Math.random() * delay + timeoutId = setTimeout(() => { + now = new Date() + delay = Math.min(delay * delayMult, maxDelay) + const timeoutCal = + timeout && timeoutMult ? timeout * timeoutMult : 0 + const rpcTimeout = maxTimeout ? maxTimeout : 0 + const newDeadline = deadline ? deadline - now.getTime() : 0 + timeout = Math.min(timeoutCal, rpcTimeout, newDeadline) + repeat() + }, toSleep) + } + }) + } + if (maxRetries && deadline) { + const error = new googleError_1.GoogleError( + 'Cannot set both totalTimeoutMillis and maxRetries ' + + 'in backoffSettings.' + ) + error.code = status_1.Status.INVALID_ARGUMENT + callback(error) + } else { + repeat() + } + return { + cancel() { + if (timeoutId) { + clearTimeout(timeoutId) + } + if (canceller) { + canceller.cancel() + } else { + const error = new googleError_1.GoogleError('cancelled') + error.code = status_1.Status.CANCELLED + callback(error) + } + } + } + } + } + exports.retryable = retryable + //# sourceMappingURL=retries.js.map + + /***/ + }, + + /***/ 4531: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + /** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.addTimeoutArg = void 0 + /** + * Updates func so that it gets called with the timeout as its final arg. + * + * This converts a function, func, into another function with updated deadline. + * + * @private + * + * @param {GRPCCall} func - a function to be updated. + * @param {number} timeout - to be added to the original function as it final + * positional arg. + * @param {Object} otherArgs - the additional arguments to be passed to func. + * @param {Object=} abTests - the A/B testing key/value pairs. + * @return {function(Object, APICallback)} + * the function with other arguments and the timeout. + */ + function addTimeoutArg(func, timeout, otherArgs, abTests) { + // TODO: this assumes the other arguments consist of metadata and options, + // which is specific to gRPC calls. Remove the hidden dependency on gRPC. + return (argument, callback) => { + const now = new Date() + const options = otherArgs.options || {} + options.deadline = new Date(now.getTime() + timeout) + const metadata = otherArgs.metadataBuilder + ? otherArgs.metadataBuilder(abTests, otherArgs.headers || {}) + : null + return func(argument, metadata, options, callback) + } + } + exports.addTimeoutArg = addTimeoutArg + //# sourceMappingURL=timeout.js.map + + /***/ + }, + + /***/ 82450: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.OperationsClientBuilder = exports.OperationsClient = exports.ALL_SCOPES = exports.SERVICE_ADDRESS = void 0 + const path = __webpack_require__(85622) + const createApiCall_1 = __webpack_require__(79712) + const descriptor_1 = __webpack_require__(13627) + const gax = __webpack_require__(80978) + const configData = __webpack_require__(86065) + exports.SERVICE_ADDRESS = 'longrunning.googleapis.com' + const version = __webpack_require__(56156).version + const DEFAULT_SERVICE_PORT = 443 + const CODE_GEN_NAME_VERSION = 'gapic/0.7.1' + /** + * The scopes needed to make gRPC calls to all of the methods defined in + * this service. + */ + exports.ALL_SCOPES = [] + /** + * Manages long-running operations with an API service. + * + * When an API method normally takes long time to complete, it can be designed + * to return {@link Operation} to the client, and the client can use this + * interface to receive the real response asynchronously by polling the + * operation resource, or pass the operation resource to another API (such as + * Google Cloud Pub/Sub API) to receive the response. Any API service that + * returns long-running operations should implement the `Operations` interface + * so developers can have a consistent client experience. + * + * This will be created through a builder function which can be obtained by the + * module. See the following example of how to initialize the module and how to + * access to the builder. + * @see {@link operationsClient} + * + * @class + */ + class OperationsClient { + constructor( + gaxGrpc, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + operationsProtos, + options + ) { + const opts = Object.assign( + { + servicePath: exports.SERVICE_ADDRESS, + port: DEFAULT_SERVICE_PORT, + clientConfig: {} + }, + options + ) + const googleApiClient = ['gl-node/' + process.versions.node] + if (opts.libName && opts.libVersion) { + googleApiClient.push(opts.libName + '/' + opts.libVersion) + } + googleApiClient.push(CODE_GEN_NAME_VERSION, 'gax/' + version) + if (opts.fallback) { + googleApiClient.push('gl-web/' + version) + } else { + googleApiClient.push('grpc/' + gaxGrpc.grpcVersion) + } + const defaults = gaxGrpc.constructSettings( + 'google.longrunning.Operations', + configData, + opts.clientConfig || {}, + { 'x-goog-api-client': googleApiClient.join(' ') } + ) + this.auth = gaxGrpc.auth + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {} + this.descriptor = { + listOperations: new descriptor_1.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'operations' + ) + } + // Put together the "service stub" for + // google.longrunning.Operations. + const operationsStub = gaxGrpc.createStub( + opts.fallback + ? operationsProtos.lookupService('google.longrunning.Operations') + : operationsProtos.google.longrunning.Operations, + opts + ) + const operationsStubMethods = [ + 'getOperation', + 'listOperations', + 'cancelOperation', + 'deleteOperation' + ] + for (const methodName of operationsStubMethods) { + const innerCallPromise = operationsStub.then( + stub => (...args) => { + const func = stub[methodName] + return func.apply(stub, args) + }, + err => () => { + throw err + } + ) + this.innerApiCalls[methodName] = createApiCall_1.createApiCall( + innerCallPromise, + defaults[methodName], + this.descriptor[methodName] + ) + } + } + getProjectId(callback) { + if (this.auth && 'getProjectId' in this.auth) { + return this.auth.getProjectId(callback) + } + if (callback) { + callback(new Error('Cannot determine project ID.')) + } else { + return Promise.reject('Cannot determine project ID.') + } + } + // Service calls + getOperationInternal(request, options, callback) { + request = request || {} + options = options || {} + return this.innerApiCalls.getOperation(request, options, callback) + } + /** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. The promise has a method named + * "cancel" which cancels the ongoing API call. + * + * @example + * + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + */ + getOperation(request, optionsOrCallback, callback) { + let options + if (optionsOrCallback instanceof Function && callback === undefined) { + callback = optionsOrCallback + options = {} + } else { + options = optionsOrCallback + } + request = request || {} + options = options || {} + return this.innerApiCalls.getOperation(request, options, callback) + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. + * + * NOTE: the `name` binding below allows API services to override the binding + * to use different resource name schemes. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error, ?Array, ?Object, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is Array of + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. + * + * When autoPaginate: false is specified through options, it contains the + * result in a single response. If the response indicates the next page + * exists, the third parameter is set to be used for the next request object. + * The fourth parameter keeps the raw response object of an object + * representing [google.longrunning.ListOperationsResponse]{@link + * external:"google.longrunning.ListOperationsResponse"}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is Array of + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. + * + * When autoPaginate: false is specified through options, the array has + * three elements. The first element is Array of + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"} in a single response. The second + * element is the next request object if the response indicates the next page + * exists, or null. The third element is an object representing + * [google.longrunning.ListOperationsResponse]{@link + * external:"google.longrunning.ListOperationsResponse"}. + * + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * + * const client = longrunning.operationsClient(); + * const request = { + * name: '', + * filter: '' + * }; + * // Iterate over all elements. + * const [resources] = await client.listOperations(request); + * for (const resource of resources) { + * console.log(resources); + * } + * + * // Or obtain the paged response. + * const options = {autoPaginate: false}; + * let nextRequest = request; + * while(nextRequest) { + * const response = await client.listOperations(nextRequest, options); + * const resources = response[0]; + * nextRequest = response[1]; + * const rawResponse = response[2]; + * for (const resource of resources) { + * // doThingsWith(resource); + * } + * }; + */ + listOperations(request, optionsOrCallback, callback) { + let options + if (optionsOrCallback instanceof Function && callback === undefined) { + callback = optionsOrCallback + options = {} + } else { + options = optionsOrCallback + } + request = request || {} + options = options || {} + return this.innerApiCalls.listOperations(request, options, callback) + } + /** + * Equivalent to {@link listOperations}, but returns a NodeJS Stream object. + * + * This fetches the paged responses for {@link listOperations} continuously + * and invokes the callback registered for 'data' event for each element in + * the responses. + * + * The returned object has 'end' method when no more elements are required. + * + * autoPaginate option will be ignored. + * + * @see {@link https://nodejs.org/api/stream.html} + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @return {Stream} - An object stream which emits an object representing [google.longrunning.Operation]{@link external:"google.longrunning.Operation"} on 'data' event. + * + * @example + * + * const client = longrunning.operationsClient(); + * const request = { + * name: '', + * filter: '' + * }; + * client.listOperationsStream(request) + * .on('data', element => { + * // doThingsWith(element) + * }) + * .on('error', err => { + * console.error(err); + * }); + */ + listOperationsStream(request, options) { + const callSettings = new gax.CallSettings(options) + return this.descriptor.listOperations.createStream( + this.innerApiCalls.listOperations, + request, + callSettings + ) + } + /** + * Equivalent to {@link listOperations}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listOperationsAsync(request, options) { + request = request || {} + options = options || {} + const callSettings = new gax.CallSettings(options) + return this.descriptor.listOperations.asyncIterate( + this.innerApiCalls.listOperations, + request, + callSettings + ) + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + */ + cancelOperation(request, optionsOrCallback, callback) { + let options + if (optionsOrCallback instanceof Function && callback === undefined) { + callback = optionsOrCallback + options = {} + } else { + options = optionsOrCallback + } + request = request || {} + options = options || {} + return this.innerApiCalls.cancelOperation(request, options, callback) + } + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + */ + deleteOperation(request, optionsOrCallback, callback) { + let options + if (optionsOrCallback instanceof Function && callback === undefined) { + callback = optionsOrCallback + options = {} + } else { + options = optionsOrCallback + } + request = request || {} + options = options || {} + return this.innerApiCalls.deleteOperation(request, options, callback) + } + } + exports.OperationsClient = OperationsClient + class OperationsClientBuilder { + /** + * Builds a new Operations Client + * @param gaxGrpc {GrpcClient} + */ + constructor(gaxGrpc) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + let operationsProtos // loaded protos have any type + if (gaxGrpc.fallback) { + // eslint-disable-next-line @typescript-eslint/no-var-requires + const protoJson = __webpack_require__(24199) + operationsProtos = gaxGrpc.loadProto(protoJson) + } else { + operationsProtos = gaxGrpc.loadProto( + __webpack_require__.ab + 'operations.json' + ) + Object.assign(this, operationsProtos.google.longrunning) + } + /** + * Build a new instance of {@link OperationsClient}. + * + * @param {Object=} opts - The optional parameters. + * @param {String=} opts.servicePath - Domain name of the API remote host. + * @param {number=} opts.port - The port on which to connect to the remote host. + * @param {grpc.ClientCredentials=} opts.sslCreds - A ClientCredentials for use with an SSL-enabled channel. + * @param {Object=} opts.clientConfig - The customized config to build the call settings. See {@link gax.constructSettings} for the format. + */ + this.operationsClient = opts => { + if (gaxGrpc.fallback) { + opts.fallback = true + } + return new OperationsClient(gaxGrpc, operationsProtos, opts) + } + Object.assign(this.operationsClient, OperationsClient) + } + } + exports.OperationsClientBuilder = OperationsClientBuilder + //# sourceMappingURL=operationsClient.js.map + + /***/ + }, + + /***/ 71172: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.PageDescriptor = void 0 + const ended = __webpack_require__(66634) + const stream_1 = __webpack_require__(92413) + const normalApiCaller_1 = __webpack_require__(56513) + const pagedApiCaller_1 = __webpack_require__(37441) + /** + * A descriptor for methods that support pagination. + */ + class PageDescriptor { + constructor( + requestPageTokenField, + responsePageTokenField, + resourceField + ) { + this.requestPageTokenField = requestPageTokenField + this.responsePageTokenField = responsePageTokenField + this.resourceField = resourceField + } + /** + * Creates a new object Stream which emits the resource on 'data' event. + */ + createStream(apiCall, request, options) { + const stream = new stream_1.PassThrough({ objectMode: true }) + options = Object.assign({}, options, { autoPaginate: false }) + const maxResults = 'maxResults' in options ? options.maxResults : -1 + let pushCount = 0 + let started = false + function callback(err, resources, next, apiResp) { + if (err) { + stream.emit('error', err) + return + } + // emit full api response with every page. + stream.emit('response', apiResp) + for (let i = 0; i < resources.length; ++i) { + if (ended(stream)) { + return + } + if (resources[i] === null) { + continue + } + stream.push(resources[i]) + pushCount++ + if (pushCount === maxResults) { + stream.end() + } + } + if (ended(stream)) { + return + } + if (!next) { + stream.end() + return + } + // When pageToken is specified in the original options, it will overwrite + // the page token field in the next request. Therefore it must be cleared. + if ('pageToken' in options) { + delete options.pageToken + } + if (stream.isPaused()) { + request = next + started = false + } else { + setImmediate(apiCall, next, options, callback) + } + } + stream.on('resume', () => { + if (!started) { + started = true + apiCall(request, options, callback) + } + }) + return stream + } + /** + * Create an async iterable which can be recursively called for data on-demand. + */ + asyncIterate(apiCall, request, options) { + options = Object.assign({}, options, { autoPaginate: false }) + const iterable = this.createIterator(apiCall, request, options) + return iterable + } + createIterator(apiCall, request, options) { + const asyncIterable = { + [Symbol.asyncIterator]() { + let nextPageRequest = request + const cache = [] + return { + async next() { + if (cache.length > 0) { + return Promise.resolve({ + done: false, + value: cache.shift() + }) + } + if (nextPageRequest) { + let result + ;[result, nextPageRequest] = await apiCall( + nextPageRequest, + options + ) + cache.push(...result) + } + if (cache.length === 0) { + return Promise.resolve({ done: true, value: undefined }) + } + return Promise.resolve({ done: false, value: cache.shift() }) + } + } + } + } + return asyncIterable + } + getApiCaller(settings) { + if (!settings.autoPaginate) { + return new normalApiCaller_1.NormalApiCaller() + } + return new pagedApiCaller_1.PagedApiCaller(this) + } + } + exports.PageDescriptor = PageDescriptor + //# sourceMappingURL=pageDescriptor.js.map + + /***/ + }, + + /***/ 37441: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.PagedApiCaller = void 0 + const call_1 = __webpack_require__(53047) + const googleError_1 = __webpack_require__(6634) + const resourceCollector_1 = __webpack_require__(50389) + class PagedApiCaller { + /** + * Creates an API caller that returns a stream to performs page-streaming. + * + * @private + * @constructor + * @param {PageDescriptor} pageDescriptor - indicates the structure + * of page streaming to be performed. + */ + constructor(pageDescriptor) { + this.pageDescriptor = pageDescriptor + } + /** + * This function translates between regular gRPC calls (that accepts a request and returns a response, + * and does not know anything about pages and page tokens) and the users' callback (that expects + * to see resources from one page, a request to get the next page, and the raw response from the server). + * + * It generates a function that can be passed as a callback function to a gRPC call, will understand + * pagination-specific fields in the response, and call the users' callback after having those fields + * parsed. + * + * @param request Request object. It needs to be passed to all subsequent next page requests + * (the main content of the request object stays unchanged, only the next page token changes) + * @param callback The user's callback that expects the page content, next page request, and raw response. + */ + generateParseResponseCallback(request, callback) { + const resourceFieldName = this.pageDescriptor.resourceField + const responsePageTokenFieldName = this.pageDescriptor + .responsePageTokenField + const requestPageTokenFieldName = this.pageDescriptor + .requestPageTokenField + return (err, response) => { + if (err) { + callback(err) + return + } + if (!request) { + callback( + new googleError_1.GoogleError( + 'Undefined request in pagination method callback.' + ) + ) + return + } + if (!response) { + callback( + new googleError_1.GoogleError( + 'Undefined response in pagination method callback.' + ) + ) + return + } + const resources = response[resourceFieldName] + const pageToken = response[responsePageTokenFieldName] + let nextPageRequest = null + if (pageToken) { + nextPageRequest = Object.assign({}, request) + nextPageRequest[requestPageTokenFieldName] = pageToken + } + callback(err, resources, nextPageRequest, response) + } + } + /** + * Adds a special ability to understand pagination-specific fields to the existing gRPC call. + * The original gRPC call just calls callback(err, result). + * The wrapped one will call callback(err, resources, nextPageRequest, rawResponse) instead. + * + * @param func gRPC call (normally, a service stub call). The gRPC call is expected to accept four parameters: + * request, metadata, call options, and callback. + */ + wrap(func) { + // eslint-disable-next-line @typescript-eslint/no-this-alias + const self = this + return function wrappedCall(argument, metadata, options, callback) { + return func( + argument, + metadata, + options, + self.generateParseResponseCallback(argument, callback) + ) + } + } + /** + * Makes it possible to use both callback-based and promise-based calls. + * Returns an OngoingCall or OngoingCallPromise object. + * Regardless of which one is returned, it always has a `.callback` to call. + * + * @param settings Call settings. Can only be used to replace Promise with another promise implementation. + * @param [callback] Callback to be called, if any. + */ + init(callback) { + if (callback) { + return new call_1.OngoingCall(callback) + } + return new call_1.OngoingCallPromise() + } + /** + * Implements auto-pagination logic. + * + * @param apiCall A function that performs gRPC request and calls its callback with a response or an error. + * It's supposed to be a gRPC service stub function wrapped into several layers of wrappers that make it + * accept just two parameters: (request, callback). + * @param request A request object that came from the user. + * @param settings Call settings. We are interested in `maxResults`, autoPaginate`, `pageToken`, and `pageSize` + * (they are all optional). + * @param ongoingCall An instance of OngoingCall or OngoingCallPromise that can be used for call cancellation, + * and is used to return results to the user. + */ + call(apiCall, request, settings, ongoingCall) { + request = Object.assign({}, request) + // If settings object contain pageToken or pageSize, override the corresponding fields in the request object. + if (settings.pageToken) { + request[this.pageDescriptor.requestPageTokenField] = + settings.pageToken + } + if (settings.pageSize) { + request[this.pageDescriptor.requestPageSizeField] = + settings.pageSize + } + if (!settings.autoPaginate) { + // they don't want auto-pagination this time - okay, just call once + ongoingCall.call(apiCall, request) + return + } + const maxResults = settings.maxResults || -1 + const resourceCollector = new resourceCollector_1.ResourceCollector( + apiCall, + maxResults + ) + resourceCollector.processAllPages(request).then( + resources => ongoingCall.callback(null, resources), + err => ongoingCall.callback(err) + ) + } + fail(ongoingCall, err) { + ongoingCall.callback(err) + } + result(ongoingCall) { + return ongoingCall.promise + } + } + exports.PagedApiCaller = PagedApiCaller + //# sourceMappingURL=pagedApiCaller.js.map + + /***/ + }, + + /***/ 50389: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + /** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.ResourceCollector = void 0 + /** + * ResourceCollector class implements asynchronous logic of calling the API call that supports pagination, + * page by page, collecting all resources (up to `maxResults`) in the array. + * + * Usage: + * const resourceCollector = new ResourceCollector(apiCall, maxResults); // -1 for unlimited + * resourceCollector.processAllPages(request).then(resources => ...); + */ + class ResourceCollector { + constructor(apiCall, maxResults = -1) { + this.apiCall = apiCall + this.resources = [] + this.maxResults = maxResults + } + callback(err, resources, nextPageRequest) { + if (err) { + // Something went wrong with this request - failing everything + this.rejectCallback(err) + return + } + // Process one page + for (const resource of resources) { + this.resources.push(resource) + if (this.resources.length === this.maxResults) { + nextPageRequest = null + break + } + } + // All done? + if (!nextPageRequest) { + this.resolveCallback(this.resources) + return + } + // Schedule the next call + const callback = (...args) => this.callback(...args) + setImmediate(this.apiCall, nextPageRequest, callback) + } + processAllPages(firstRequest) { + return new Promise((resolve, reject) => { + this.resolveCallback = resolve + this.rejectCallback = reject + // Schedule the first call + const callback = (...args) => this.callback(...args) + setImmediate(this.apiCall, firstRequest, callback) + }) + } + } + exports.ResourceCollector = ResourceCollector + //# sourceMappingURL=resourceCollector.js.map + + /***/ + }, + + /***/ 20513: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + /** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.PathTemplate = void 0 + class PathTemplate { + /** + * @param {String} data the of the template + * + * @constructor + */ + constructor(data) { + this.bindings = {} + this.data = data + this.segments = this.parsePathTemplate(data) + this.size = this.segments.length + } + /** + * Matches a fully-qualified path template string. + * + * @param {String} path a fully-qualified path template string + * @return {Object} contains const names matched to binding values + * @throws {TypeError} if path can't be matched to this template + */ + match(path) { + let pathSegments = path.split('/') + const bindings = {} + if (pathSegments.length !== this.segments.length) { + // if the path contains a wildcard, then the length may differ by 1. + if (!this.data.includes('**')) { + throw new TypeError( + `This path ${path} does not match path template ${this.data}, the number of parameters is not same.` + ) + } else if (pathSegments.length !== this.segments.length + 1) { + throw new TypeError( + `This path ${path} does not match path template ${this.data}, the number of parameters is not same with one wildcard.` + ) + } + } + for ( + let index = 0; + index < this.segments.length && pathSegments.length > 0; + index++ + ) { + if (this.segments[index] !== pathSegments[0]) { + if (!this.segments[index].includes('*')) { + throw new TypeError( + `segment does not match, ${this.segments[index]} and ${pathSegments[index]}.` + ) + } else { + let segment = this.segments[index] + const variable = + segment.match(/(?<={)[$0-9a-zA-Z_]+(?==.*})/g) || [] + if (segment.includes('**')) { + bindings[variable[0]] = + pathSegments[0] + '/' + pathSegments[1] + pathSegments = pathSegments.slice(2) + } else { + // atomic resource + if (variable.length === 1) { + bindings[variable[0]] = pathSegments[0] + } else { + // non-slash resource + // segment: {blurb_id=*}.{legacy_user=*} to match pathSegments: ['bar.user2'] + // split the match pathSegments[0] -> value: ['bar', 'user2'] + // compare the length of two arrays, and compare array items + const value = pathSegments[0].split(/[-_.~]/) + if (value.length !== variable.length) { + throw new Error( + `segment ${segment} does not match ${pathSegments[0]}` + ) + } + for (const v of variable) { + bindings[v] = value[0] + segment = segment.replace(`{${v}=*}`, `${value[0]}`) + value.shift() + } + // segment: {blurb_id=*}.{legacy_user=*} matching pathSegments: ['bar~user2'] should fail + if (segment !== pathSegments[0]) { + throw new TypeError( + `non slash resource pattern ${this.segments[index]} and ${pathSegments[0]} should have same separator` + ) + } + } + pathSegments.shift() + } + } + } else { + pathSegments.shift() + } + } + return bindings + } + /** + * Renders a path template using the provided bindings. + * + * @param {Object} bindings a mapping of const names to binding strings + * @return {String} a rendered representation of the path template + * @throws {TypeError} if a key is missing, or if a sub-template cannot be + * parsed + */ + render(bindings) { + if ( + Object.keys(bindings).length !== Object.keys(this.bindings).length + ) { + throw new TypeError( + `The number of variables ${ + Object.keys(bindings).length + } does not match the number of needed variables ${ + Object.keys(this.bindings).length + }` + ) + } + let path = this.inspect() + for (const key of Object.keys(bindings)) { + const b = bindings[key].toString() + if (!this.bindings[key]) { + throw new TypeError( + `render fails for not matching ${bindings[key]}` + ) + } + const variable = this.bindings[key] + if (variable === '*') { + if (!b.match(/[^/{}]+/)) { + throw new TypeError(`render fails for not matching ${b}`) + } + path = path.replace(`{${key}=*}`, `${b}`) + } else if (variable === '**') { + if (!b.match(/[^{}]+/)) { + throw new TypeError(`render fails for not matching ${b}`) + } + path = path.replace(`{${key}=**}`, `${b}`) + } + } + return path + } + /** + * Renders the path template. + * + * @return {string} contains const names matched to binding values + */ + inspect() { + return this.segments.join('/') + } + /** + * Parse the path template. + * + * @return {string[]} return segments of the input path. + * For example: 'buckets/{hello}'' will give back ['buckets', {hello=*}] + */ + parsePathTemplate(data) { + const pathSegments = splitPathTemplate(data) + let index = 0 + let wildCardCount = 0 + const segments = [] + pathSegments.forEach(segment => { + // * or ** -> segments.push('{$0=*}'); + // -> bindings['$0'] = '*' + if (segment === '*' || segment === '**') { + this.bindings[`$${index}`] = segment + segments.push(`{$${index}=${segment}}`) + index = index + 1 + if (segment === '**') { + wildCardCount = wildCardCount + 1 + } + } + // {project}~{location} -> {project=*}~{location=*} + else if ( + segment.match( + /(?<={)[0-9a-zA-Z-.~_]+(?:}[-._~]?{)[0-9a-zA-Z-.~_]+(?=})/ + ) + ) { + // [project, location] + const variable = segment.match(/(?<=\{).*?(?=(?:=.*?)?\})/g) || [] + for (const v of variable) { + this.bindings[v] = '*' + segment = segment.replace(v, v + '=*') + } + segments.push(segment) + } + // {project} / {project=*} -> segments.push('{project=*}'); + // -> bindings['project'] = '*' + else if (segment.match(/(?<={)[0-9a-zA-Z-.~_]+(?=(=\*)?})/)) { + const variable = segment.match( + /(?<={)[0-9a-zA-Z-.~_]+(?=(=\*)?})/ + ) + this.bindings[variable[0]] = '*' + segments.push(`{${variable[0]}=*}`) + } + // {project=**} -> segments.push('{project=**}'); + // -> bindings['project'] = '**' + else if (segment.match(/(?<={)[0-9a-zA-Z-.~_]+(?=(=\*\*)})/)) { + const variable = segment.match( + /(?<={)[0-9a-zA-Z-.~_]+(?=(=\*\*)})/ + ) + this.bindings[variable[0]] = '**' + segments.push(`{${variable[0]}=**}`) + wildCardCount = wildCardCount + 1 + } + // {hello=/what} -> segments.push('{hello=/what}'); + // -> no binding in this case + else if (segment.match(/(?<={)[0-9a-zA-Z-.~_]+=[^*]+(?=})/)) { + segments.push(segment) + } + // helloazAZ09-.~_what -> segments.push('helloazAZ09-.~_what'); + // -> no binding in this case + else if (segment.match(/[0-9a-zA-Z-.~_]+/)) { + segments.push(segment) + } + if (wildCardCount > 1) { + throw new TypeError('Can not have more than one wildcard.') + } + }) + return segments + } + } + exports.PathTemplate = PathTemplate + /** + * Split the path template by `/`. + * It can not be simply splitted by `/` because there might be `/` in the segments. + * For example: 'a/b/{a=hello/world}' we do not want to break the brackets pair + * so above path will be splitted as ['a', 'b', '{a=hello/world}'] + */ + function splitPathTemplate(data) { + let left = 0 + let right = 0 + let bracketCount = 0 + const segments = [] + while (right >= left && right < data.length) { + if (data.charAt(right) === '{') { + bracketCount = bracketCount + 1 + } else if (data.charAt(right) === '}') { + bracketCount = bracketCount - 1 + } else if (data.charAt(right) === '/') { + if (right === data.length - 1) { + throw new TypeError('Invalid path, it can not be ended by /') + } + if (bracketCount === 0) { + // complete bracket, to avoid the case a/b/**/*/{a=hello/world} + segments.push(data.substring(left, right)) + left = right + 1 + } + } + if (right === data.length - 1) { + if (bracketCount !== 0) { + throw new TypeError('Brackets are invalid.') + } + segments.push(data.substring(left)) + } + right = right + 1 + } + return segments + } + //# sourceMappingURL=pathTemplate.js.map + + /***/ + }, + + /***/ 8827: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.fromParams = void 0 + const querystring = __webpack_require__(71191) + /** + * Helpers for constructing routing headers. + * + * These headers are used by Google infrastructure to determine how to route + * requests, especially for services that are regional. + * + * Generally, these headers are specified as gRPC metadata. + */ + /** + * Constructs the routing header from the given params + * + * @param {Object} params - the request header parameters. + * @return {string} the routing header value. + */ + function fromParams(params) { + return querystring.stringify(params) + } + exports.fromParams = fromParams + //# sourceMappingURL=routingHeader.js.map + + /***/ + }, + + /***/ 53501: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + /** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.Status = void 0 + // The following is a copy of the Status enum defined in @grpc/grpc-js, + // src/constants.ts. We need to use some of these statuses here and there, + // but we don't want to include the whole @grpc/grpc-js into the browser + // bundle just to have this small enum. + var Status + ;(function (Status) { + Status[(Status['OK'] = 0)] = 'OK' + Status[(Status['CANCELLED'] = 1)] = 'CANCELLED' + Status[(Status['UNKNOWN'] = 2)] = 'UNKNOWN' + Status[(Status['INVALID_ARGUMENT'] = 3)] = 'INVALID_ARGUMENT' + Status[(Status['DEADLINE_EXCEEDED'] = 4)] = 'DEADLINE_EXCEEDED' + Status[(Status['NOT_FOUND'] = 5)] = 'NOT_FOUND' + Status[(Status['ALREADY_EXISTS'] = 6)] = 'ALREADY_EXISTS' + Status[(Status['PERMISSION_DENIED'] = 7)] = 'PERMISSION_DENIED' + Status[(Status['RESOURCE_EXHAUSTED'] = 8)] = 'RESOURCE_EXHAUSTED' + Status[(Status['FAILED_PRECONDITION'] = 9)] = 'FAILED_PRECONDITION' + Status[(Status['ABORTED'] = 10)] = 'ABORTED' + Status[(Status['OUT_OF_RANGE'] = 11)] = 'OUT_OF_RANGE' + Status[(Status['UNIMPLEMENTED'] = 12)] = 'UNIMPLEMENTED' + Status[(Status['INTERNAL'] = 13)] = 'INTERNAL' + Status[(Status['UNAVAILABLE'] = 14)] = 'UNAVAILABLE' + Status[(Status['DATA_LOSS'] = 15)] = 'DATA_LOSS' + Status[(Status['UNAUTHENTICATED'] = 16)] = 'UNAUTHENTICATED' + })((Status = exports.Status || (exports.Status = {}))) + //# sourceMappingURL=status.js.map + + /***/ + }, + + /***/ 65880: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.StreamDescriptor = void 0 + const streamingApiCaller_1 = __webpack_require__(32936) + /** + * A descriptor for streaming calls. + */ + class StreamDescriptor { + constructor(streamType) { + this.type = streamType + this.streaming = true + } + getApiCaller(settings) { + // Right now retrying does not work with gRPC-streaming, because retryable + // assumes an API call returns an event emitter while gRPC-streaming methods + // return Stream. + // TODO: support retrying. + settings.retry = null + return new streamingApiCaller_1.StreamingApiCaller(this) + } + } + exports.StreamDescriptor = StreamDescriptor + //# sourceMappingURL=streamDescriptor.js.map + + /***/ + }, + + /***/ 67389: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.StreamProxy = exports.StreamType = void 0 + // eslint-disable-next-line @typescript-eslint/no-var-requires + const duplexify = __webpack_require__(76599) + // eslint-disable-next-line @typescript-eslint/no-var-requires + const retryRequest = __webpack_require__(48679) + /** + * The type of gRPC streaming. + * @enum {number} + */ + var StreamType + ;(function (StreamType) { + /** Client sends a single request, server streams responses. */ + StreamType[(StreamType['SERVER_STREAMING'] = 1)] = 'SERVER_STREAMING' + /** Client streams requests, server returns a single response. */ + StreamType[(StreamType['CLIENT_STREAMING'] = 2)] = 'CLIENT_STREAMING' + /** Both client and server stream objects. */ + StreamType[(StreamType['BIDI_STREAMING'] = 3)] = 'BIDI_STREAMING' + })((StreamType = exports.StreamType || (exports.StreamType = {}))) + class StreamProxy extends duplexify { + /** + * StreamProxy is a proxy to gRPC-streaming method. + * + * @private + * @constructor + * @param {StreamType} type - the type of gRPC stream. + * @param {ApiCallback} callback - the callback for further API call. + */ + constructor(type, callback) { + super(undefined, undefined, { + objectMode: true, + readable: type !== StreamType.CLIENT_STREAMING, + writable: type !== StreamType.SERVER_STREAMING + }) + this.type = type + this._callback = callback + this._isCancelCalled = false + } + cancel() { + if (this.stream) { + this.stream.cancel() + } else { + this._isCancelCalled = true + } + } + /** + * Forward events from an API request stream to the user's stream. + * @param {Stream} stream - The API request stream. + */ + forwardEvents(stream) { + const eventsToForward = ['metadata', 'response', 'status'] + eventsToForward.forEach(event => { + stream.on(event, this.emit.bind(this, event)) + }) + // We also want to supply the status data as 'response' event to support + // the behavior of google-cloud-node expects. + // see: + // https://github.com/GoogleCloudPlatform/google-cloud-node/pull/1775#issuecomment-259141029 + // https://github.com/GoogleCloudPlatform/google-cloud-node/blob/116436fa789d8b0f7fc5100b19b424e3ec63e6bf/packages/common/src/grpc-service.js#L355 + stream.on('metadata', metadata => { + // Create a response object with succeeds. + // TODO: unify this logic with the decoration of gRPC response when it's + // added. see: https://github.com/googleapis/gax-nodejs/issues/65 + stream.emit('response', { + code: 200, + details: '', + message: 'OK', + metadata + }) + }) + } + /** + * Specifies the target stream. + * @param {ApiCall} apiCall - the API function to be called. + * @param {Object} argument - the argument to be passed to the apiCall. + */ + setStream(apiCall, argument, retryRequestOptions = {}) { + if (this.type === StreamType.SERVER_STREAMING) { + const retryStream = retryRequest(null, { + objectMode: true, + request: () => { + if (this._isCancelCalled) { + if (this.stream) { + this.stream.cancel() + } + return + } + const stream = apiCall(argument, this._callback) + this.stream = stream + this.forwardEvents(stream) + return stream + }, + retries: retryRequestOptions.retries, + currentRetryAttempt: retryRequestOptions.currentRetryAttempt, + noResponseRetries: retryRequestOptions.noResponseRetries, + shouldRetryFn: retryRequestOptions.shouldRetryFn + }) + this.setReadable(retryStream) + return + } + const stream = apiCall(argument, this._callback) + this.stream = stream + this.forwardEvents(stream) + if (this.type === StreamType.CLIENT_STREAMING) { + this.setWritable(stream) + } + if (this.type === StreamType.BIDI_STREAMING) { + this.setReadable(stream) + this.setWritable(stream) + } + if (this._isCancelCalled && this.stream) { + this.stream.cancel() + } + } + } + exports.StreamProxy = StreamProxy + //# sourceMappingURL=streaming.js.map + + /***/ + }, + + /***/ 32936: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.StreamingApiCaller = void 0 + const warnings_1 = __webpack_require__(16328) + const streaming_1 = __webpack_require__(67389) + class StreamingApiCaller { + /** + * An API caller for methods of gRPC streaming. + * @private + * @constructor + * @param {StreamDescriptor} descriptor - the descriptor of the method structure. + */ + constructor(descriptor) { + this.descriptor = descriptor + } + init(callback) { + return new streaming_1.StreamProxy(this.descriptor.type, callback) + } + wrap(func) { + switch (this.descriptor.type) { + case streaming_1.StreamType.SERVER_STREAMING: + return (argument, metadata, options) => { + return func(argument, metadata, options) + } + case streaming_1.StreamType.CLIENT_STREAMING: + return (argument, metadata, options, callback) => { + return func(metadata, options, callback) + } + case streaming_1.StreamType.BIDI_STREAMING: + return (argument, metadata, options) => { + return func(metadata, options) + } + default: + warnings_1.warn( + 'streaming_wrap_unknown_stream_type', + `Unknown stream type: ${this.descriptor.type}` + ) + } + return func + } + call(apiCall, argument, settings, stream) { + stream.setStream(apiCall, argument, settings.retryRequestOptions) + } + fail(stream, err) { + stream.emit('error', err) + } + result(stream) { + return stream + } + } + exports.StreamingApiCaller = StreamingApiCaller + //# sourceMappingURL=streamingApiCaller.js.map + + /***/ + }, + + /***/ 16328: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /** + * Copyright 2020 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.warn = void 0 + const isbrowser_1 = __webpack_require__(95021) + const emittedWarnings = new Set() + function warn(code, message) { + // Only show a given warning once + if (emittedWarnings.has(code)) { + return + } + emittedWarnings.add(code) + if (isbrowser_1.isBrowser()) { + console.warn(message) + } else { + process.emitWarning(message) + } + } + exports.warn = warn + //# sourceMappingURL=warnings.js.map + + /***/ + }, + + /***/ 92098: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /** + * Copyright 2018 Google LLC + * + * Distributed under MIT license. + * See file LICENSE for detail or copy at https://opensource.org/licenses/MIT + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.getPem = void 0 + const fs = __webpack_require__(35747) + const forge = __webpack_require__(57655) + const util_1 = __webpack_require__(31669) + const readFile = util_1.promisify(fs.readFile) + function getPem(filename, callback) { + if (callback) { + getPemAsync(filename) + .then(pem => callback(null, pem)) + .catch(err => callback(err, null)) + } else { + return getPemAsync(filename) + } + } + exports.getPem = getPem + function getPemAsync(filename) { + return readFile(filename, { encoding: 'base64' }).then(keyp12 => { + return convertToPem(keyp12) + }) + } + /** + * Converts a P12 in base64 encoding to a pem. + * @param p12base64 String containing base64 encoded p12. + * @returns a string containing the pem. + */ + function convertToPem(p12base64) { + const p12Der = forge.util.decode64(p12base64) + const p12Asn1 = forge.asn1.fromDer(p12Der) + const p12 = forge.pkcs12.pkcs12FromAsn1(p12Asn1, 'notasecret') + const bags = p12.getBags({ friendlyName: 'privatekey' }) + if (bags.friendlyName) { + const privateKey = bags.friendlyName[0].key + const pem = forge.pki.privateKeyToPem(privateKey) + return pem.replace(/\r\n/g, '\n') + } else { + throw new Error('Unable to get friendly name.') + } + } + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 76031: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + /** + * Copyright 2018 Google LLC + * + * Distributed under MIT license. + * See file LICENSE for detail or copy at https://opensource.org/licenses/MIT + */ + Object.defineProperty(exports, '__esModule', { value: true }) + exports.GoogleToken = void 0 + const fs = __webpack_require__(35747) + const gaxios_1 = __webpack_require__(59555) + const jws = __webpack_require__(4636) + const mime = __webpack_require__(29994) + const util_1 = __webpack_require__(31669) + const readFile = fs.readFile + ? util_1.promisify(fs.readFile) + : async () => { + // if running in the web-browser, fs.readFile may not have been shimmed. + throw new ErrorWithCode( + 'use key rather than keyFile.', + 'MISSING_CREDENTIALS' + ) + } + const GOOGLE_TOKEN_URL = 'https://www.googleapis.com/oauth2/v4/token' + const GOOGLE_REVOKE_TOKEN_URL = + 'https://accounts.google.com/o/oauth2/revoke?token=' + class ErrorWithCode extends Error { + constructor(message, code) { + super(message) + this.code = code + } + } + let getPem + class GoogleToken { + /** + * Create a GoogleToken. + * + * @param options Configuration object. + */ + constructor(options) { + this.configure(options) + } + get accessToken() { + return this.rawToken ? this.rawToken.access_token : undefined + } + get idToken() { + return this.rawToken ? this.rawToken.id_token : undefined + } + get tokenType() { + return this.rawToken ? this.rawToken.token_type : undefined + } + get refreshToken() { + return this.rawToken ? this.rawToken.refresh_token : undefined + } + /** + * Returns whether the token has expired. + * + * @return true if the token has expired, false otherwise. + */ + hasExpired() { + const now = new Date().getTime() + if (this.rawToken && this.expiresAt) { + return now >= this.expiresAt + } else { + return true + } + } + getToken(callback, opts = {}) { + if (typeof callback === 'object') { + opts = callback + callback = undefined + } + opts = Object.assign( + { + forceRefresh: false + }, + opts + ) + if (callback) { + const cb = callback + this.getTokenAsync(opts).then(t => cb(null, t), callback) + return + } + return this.getTokenAsync(opts) + } + /** + * Given a keyFile, extract the key and client email if available + * @param keyFile Path to a json, pem, or p12 file that contains the key. + * @returns an object with privateKey and clientEmail properties + */ + async getCredentials(keyFile) { + const mimeType = mime.getType(keyFile) + switch (mimeType) { + case 'application/json': { + // *.json file + const key = await readFile(keyFile, 'utf8') + const body = JSON.parse(key) + const privateKey = body.private_key + const clientEmail = body.client_email + if (!privateKey || !clientEmail) { + throw new ErrorWithCode( + 'private_key and client_email are required.', + 'MISSING_CREDENTIALS' + ) + } + return { privateKey, clientEmail } + } + case 'application/x-x509-ca-cert': { + // *.pem file + const privateKey = await readFile(keyFile, 'utf8') + return { privateKey } + } + case 'application/x-pkcs12': { + // *.p12 file + // NOTE: The loading of `google-p12-pem` is deferred for performance + // reasons. The `node-forge` npm module in `google-p12-pem` adds a fair + // bit time to overall module loading, and is likely not frequently + // used. In a future release, p12 support will be entirely removed. + if (!getPem) { + getPem = ( + await Promise.resolve().then(() => __webpack_require__(92098)) + ).getPem + } + const privateKey = await getPem(keyFile) + return { privateKey } + } + default: + throw new ErrorWithCode( + 'Unknown certificate type. Type is determined based on file extension. ' + + 'Current supported extensions are *.json, *.pem, and *.p12.', + 'UNKNOWN_CERTIFICATE_TYPE' + ) + } + } + async getTokenAsync(opts) { + if (this.hasExpired() === false && opts.forceRefresh === false) { + return Promise.resolve(this.rawToken) + } + if (!this.key && !this.keyFile) { + throw new Error('No key or keyFile set.') + } + if (!this.key && this.keyFile) { + const creds = await this.getCredentials(this.keyFile) + this.key = creds.privateKey + this.iss = creds.clientEmail || this.iss + if (!creds.clientEmail) { + this.ensureEmail() + } + } + return this.requestToken() + } + ensureEmail() { + if (!this.iss) { + throw new ErrorWithCode('email is required.', 'MISSING_CREDENTIALS') + } + } + revokeToken(callback) { + if (callback) { + this.revokeTokenAsync().then(() => callback(), callback) + return + } + return this.revokeTokenAsync() + } + async revokeTokenAsync() { + if (!this.accessToken) { + throw new Error('No token to revoke.') + } + const url = GOOGLE_REVOKE_TOKEN_URL + this.accessToken + await gaxios_1.request({ url }) + this.configure({ + email: this.iss, + sub: this.sub, + key: this.key, + keyFile: this.keyFile, + scope: this.scope, + additionalClaims: this.additionalClaims + }) + } + /** + * Configure the GoogleToken for re-use. + * @param {object} options Configuration object. + */ + configure(options = {}) { + this.keyFile = options.keyFile + this.key = options.key + this.rawToken = undefined + this.iss = options.email || options.iss + this.sub = options.sub + this.additionalClaims = options.additionalClaims + if (typeof options.scope === 'object') { + this.scope = options.scope.join(' ') + } else { + this.scope = options.scope + } + } + /** + * Request the token from Google. + */ + async requestToken() { + const iat = Math.floor(new Date().getTime() / 1000) + const additionalClaims = this.additionalClaims || {} + const payload = Object.assign( + { + iss: this.iss, + scope: this.scope, + aud: GOOGLE_TOKEN_URL, + exp: iat + 3600, + iat, + sub: this.sub + }, + additionalClaims + ) + const signedJWT = jws.sign({ + header: { alg: 'RS256' }, + payload, + secret: this.key + }) + try { + const r = await gaxios_1.request({ + method: 'POST', + url: GOOGLE_TOKEN_URL, + data: { + grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer', + assertion: signedJWT + }, + headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, + responseType: 'json' + }) + this.rawToken = r.data + this.expiresAt = + r.data.expires_in === null || r.data.expires_in === undefined + ? undefined + : (iat + r.data.expires_in) * 1000 + return this.rawToken + } catch (e) { + this.rawToken = undefined + this.tokenExpires = undefined + const body = e.response && e.response.data ? e.response.data : {} + if (body.error) { + const desc = body.error_description + ? `: ${body.error_description}` + : '' + e.message = `${body.error}${desc}` + } + throw e + } + } + } + exports.GoogleToken = GoogleToken + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 13679: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + 'use strict' + + module.exports = { + afterRequest: __webpack_require__(24391), + beforeRequest: __webpack_require__(94440), + browser: __webpack_require__(99850), + cache: __webpack_require__(77654), + content: __webpack_require__(73656), + cookie: __webpack_require__(67948), + creator: __webpack_require__(33412), + entry: __webpack_require__(32525), + har: __webpack_require__(84943), + header: __webpack_require__(68344), + log: __webpack_require__(69142), + page: __webpack_require__(29075), + pageTimings: __webpack_require__(15096), + postData: __webpack_require__(73697), + query: __webpack_require__(70877), + request: __webpack_require__(92084), + response: __webpack_require__(20702), + timings: __webpack_require__(36941) + } + + /***/ + }, + + /***/ 74944: /***/ module => { + function HARError(errors) { + var message = 'validation failed' + + this.name = 'HARError' + this.message = message + this.errors = errors + + if (typeof Error.captureStackTrace === 'function') { + Error.captureStackTrace(this, this.constructor) + } else { + this.stack = new Error(message).stack + } + } + + HARError.prototype = Error.prototype + + module.exports = HARError + + /***/ + }, + + /***/ 75697: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + var Ajv = __webpack_require__(64941) + var HARError = __webpack_require__(74944) + var schemas = __webpack_require__(13679) + + var ajv + + function createAjvInstance() { + var ajv = new Ajv({ + allErrors: true + }) + ajv.addMetaSchema(__webpack_require__(81030)) + ajv.addSchema(schemas) + + return ajv + } + + function validate(name, data) { + data = data || {} + + // validator config + ajv = ajv || createAjvInstance() + + var validate = ajv.getSchema(name + '.json') + + return new Promise(function (resolve, reject) { + var valid = validate(data) + + !valid ? reject(new HARError(validate.errors)) : resolve(data) + }) + } + + exports.afterRequest = function (data) { + return validate('afterRequest', data) + } + + exports.beforeRequest = function (data) { + return validate('beforeRequest', data) + } + + exports.browser = function (data) { + return validate('browser', data) + } + + exports.cache = function (data) { + return validate('cache', data) + } + + exports.content = function (data) { + return validate('content', data) + } + + exports.cookie = function (data) { + return validate('cookie', data) + } + + exports.creator = function (data) { + return validate('creator', data) + } + + exports.entry = function (data) { + return validate('entry', data) + } + + exports.har = function (data) { + return validate('har', data) + } + + exports.header = function (data) { + return validate('header', data) + } + + exports.log = function (data) { + return validate('log', data) + } + + exports.page = function (data) { + return validate('page', data) + } + + exports.pageTimings = function (data) { + return validate('pageTimings', data) + } + + exports.postData = function (data) { + return validate('postData', data) + } + + exports.query = function (data) { + return validate('query', data) + } + + exports.request = function (data) { + return validate('request', data) + } + + exports.response = function (data) { + return validate('response', data) + } + + exports.timings = function (data) { + return validate('timings', data) + } + + /***/ + }, + + /***/ 31621: /***/ module => { + 'use strict' + + module.exports = (flag, argv = process.argv) => { + const prefix = flag.startsWith('-') + ? '' + : flag.length === 1 + ? '-' + : '--' + const position = argv.indexOf(prefix + flag) + const terminatorPosition = argv.indexOf('--') + return ( + position !== -1 && + (terminatorPosition === -1 || position < terminatorPosition) + ) + } + + /***/ + }, + + /***/ 86426: /***/ module => { + /** + * A function for converting hex <-> dec w/o loss of precision. + * + * The problem is that parseInt("0x12345...") isn't precise enough to convert + * 64-bit integers correctly. + * + * Internally, this uses arrays to encode decimal digits starting with the least + * significant: + * 8 = [8] + * 16 = [6, 1] + * 1024 = [4, 2, 0, 1] + * + * Source: http://www.danvk.org/hex2dec.html + */ + + // Adds two arrays for the given base (10 or 16), returning the result. + // This turns out to be the only "primitive" operation we need. + function add(x, y, base) { + var z = [] + var n = Math.max(x.length, y.length) + var carry = 0 + var i = 0 + while (i < n || carry) { + var xi = i < x.length ? x[i] : 0 + var yi = i < y.length ? y[i] : 0 + var zi = carry + xi + yi + z.push(zi % base) + carry = Math.floor(zi / base) + i++ + } + return z + } + + // Returns a*x, where x is an array of decimal digits and a is an ordinary + // JavaScript number. base is the number base of the array x. + function multiplyByNumber(num, x, base) { + if (num < 0) return null + if (num == 0) return [] + + var result = [] + var power = x + while (true) { + if (num & 1) { + result = add(result, power, base) + } + num = num >> 1 + if (num === 0) break + power = add(power, power, base) + } + + return result + } + + function parseToDigitsArray(str, base) { + var digits = str.split('') + var ary = [] + for (var i = digits.length - 1; i >= 0; i--) { + var n = parseInt(digits[i], base) + if (isNaN(n)) return null + ary.push(n) + } + return ary + } + + function convertBase(str, fromBase, toBase) { + var digits = parseToDigitsArray(str, fromBase) + if (digits === null) return null + + var outArray = [] + var power = [1] + for (var i = 0; i < digits.length; i++) { + // invariant: at this point, fromBase^i = power + if (digits[i]) { + outArray = add( + outArray, + multiplyByNumber(digits[i], power, toBase), + toBase + ) + } + power = multiplyByNumber(fromBase, power, toBase) + } + + var out = '' + for (var i = outArray.length - 1; i >= 0; i--) { + out += outArray[i].toString(toBase) + } + if (out === '') { + out = '0' + } + return out + } + + function decToHex(decStr, opts) { + var hidePrefix = opts && opts.prefix === false + var hex = convertBase(decStr, 10, 16) + return hex ? (hidePrefix ? hex : '0x' + hex) : null + } + + function hexToDec(hexStr) { + if (hexStr.substring(0, 2) === '0x') hexStr = hexStr.substring(2) + hexStr = hexStr.toLowerCase() + return convertBase(hexStr, 16, 10) + } + + module.exports = { + hexToDec: hexToDec, + decToHex: decToHex + } + + /***/ + }, + + /***/ 77492: /***/ function ( + __unused_webpack_module, + exports, + __webpack_require__ + ) { + 'use strict' + + var __awaiter = + (this && this.__awaiter) || + function (thisArg, _arguments, P, generator) { + function adopt(value) { + return value instanceof P + ? value + : new P(function (resolve) { + resolve(value) + }) + } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { + try { + step(generator.next(value)) + } catch (e) { + reject(e) + } + } + function rejected(value) { + try { + step(generator['throw'](value)) + } catch (e) { + reject(e) + } + } + function step(result) { + result.done + ? resolve(result.value) + : adopt(result.value).then(fulfilled, rejected) + } + step( + (generator = generator.apply(thisArg, _arguments || [])).next() + ) + }) + } + var __importDefault = + (this && this.__importDefault) || + function (mod) { + return mod && mod.__esModule ? mod : { default: mod } + } + Object.defineProperty(exports, '__esModule', { value: true }) + const net_1 = __importDefault(__webpack_require__(11631)) + const tls_1 = __importDefault(__webpack_require__(4016)) + const url_1 = __importDefault(__webpack_require__(78835)) + const debug_1 = __importDefault(__webpack_require__(38237)) + const once_1 = __importDefault(__webpack_require__(81040)) + const agent_base_1 = __webpack_require__(49690) + const debug = debug_1.default('http-proxy-agent') + function isHTTPS(protocol) { + return typeof protocol === 'string' + ? /^https:?$/i.test(protocol) + : false + } + /** + * The `HttpProxyAgent` implements an HTTP Agent subclass that connects + * to the specified "HTTP proxy server" in order to proxy HTTP requests. + * + * @api public + */ + class HttpProxyAgent extends agent_base_1.Agent { + constructor(_opts) { + let opts + if (typeof _opts === 'string') { + opts = url_1.default.parse(_opts) + } else { + opts = _opts + } + if (!opts) { + throw new Error( + 'an HTTP(S) proxy server `host` and `port` must be specified!' + ) + } + debug('Creating new HttpProxyAgent instance: %o', opts) + super(opts) + const proxy = Object.assign({}, opts) + // If `true`, then connect to the proxy server over TLS. + // Defaults to `false`. + this.secureProxy = opts.secureProxy || isHTTPS(proxy.protocol) + // Prefer `hostname` over `host`, and set the `port` if needed. + proxy.host = proxy.hostname || proxy.host + if (typeof proxy.port === 'string') { + proxy.port = parseInt(proxy.port, 10) + } + if (!proxy.port && proxy.host) { + proxy.port = this.secureProxy ? 443 : 80 + } + if (proxy.host && proxy.path) { + // If both a `host` and `path` are specified then it's most likely + // the result of a `url.parse()` call... we need to remove the + // `path` portion so that `net.connect()` doesn't attempt to open + // that as a Unix socket file. + delete proxy.path + delete proxy.pathname + } + this.proxy = proxy + } + /** + * Called when the node-core HTTP client library is creating a + * new HTTP request. + * + * @api protected + */ + callback(req, opts) { + return __awaiter(this, void 0, void 0, function* () { + const { proxy, secureProxy } = this + const parsed = url_1.default.parse(req.path) + if (!parsed.protocol) { + parsed.protocol = 'http:' + } + if (!parsed.hostname) { + parsed.hostname = opts.hostname || opts.host || null + } + if (parsed.port == null && typeof opts.port) { + parsed.port = String(opts.port) + } + if (parsed.port === '80') { + // if port is 80, then we can remove the port so that the + // ":80" portion is not on the produced URL + delete parsed.port + } + // Change the `http.ClientRequest` instance's "path" field + // to the absolute path of the URL that will be requested. + req.path = url_1.default.format(parsed) + // Inject the `Proxy-Authorization` header if necessary. + if (proxy.auth) { + req.setHeader( + 'Proxy-Authorization', + `Basic ${Buffer.from(proxy.auth).toString('base64')}` + ) + } + // Create a socket connection to the proxy server. + let socket + if (secureProxy) { + debug('Creating `tls.Socket`: %o', proxy) + socket = tls_1.default.connect(proxy) + } else { + debug('Creating `net.Socket`: %o', proxy) + socket = net_1.default.connect(proxy) + } + // At this point, the http ClientRequest's internal `_header` field + // might have already been set. If this is the case then we'll need + // to re-generate the string since we just changed the `req.path`. + if (req._header) { + let first + let endOfHeaders + debug('Regenerating stored HTTP header string for request') + req._header = null + req._implicitHeader() + if (req.output && req.output.length > 0) { + // Node < 12 + debug( + 'Patching connection write() output buffer with updated header' + ) + first = req.output[0] + endOfHeaders = first.indexOf('\r\n\r\n') + 4 + req.output[0] = req._header + first.substring(endOfHeaders) + debug('Output buffer: %o', req.output) + } else if (req.outputData && req.outputData.length > 0) { + // Node >= 12 + debug( + 'Patching connection write() output buffer with updated header' + ) + first = req.outputData[0].data + endOfHeaders = first.indexOf('\r\n\r\n') + 4 + req.outputData[0].data = + req._header + first.substring(endOfHeaders) + debug('Output buffer: %o', req.outputData[0].data) + } + } + // Wait for the socket's `connect` event, so that this `callback()` + // function throws instead of the `http` request machinery. This is + // important for i.e. `PacProxyAgent` which determines a failed proxy + // connection via the `callback()` function throwing. + yield once_1.default(socket, 'connect') + return socket + }) + } + } + exports.default = HttpProxyAgent + //# sourceMappingURL=agent.js.map + + /***/ + }, + + /***/ 23764: /***/ function ( + module, + __unused_webpack_exports, + __webpack_require__ + ) { + 'use strict' + + var __importDefault = + (this && this.__importDefault) || + function (mod) { + return mod && mod.__esModule ? mod : { default: mod } + } + const agent_1 = __importDefault(__webpack_require__(77492)) + function createHttpProxyAgent(opts) { + return new agent_1.default(opts) + } + ;(function (createHttpProxyAgent) { + createHttpProxyAgent.HttpProxyAgent = agent_1.default + createHttpProxyAgent.prototype = agent_1.default.prototype + })(createHttpProxyAgent || (createHttpProxyAgent = {})) + module.exports = createHttpProxyAgent + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 42479: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + // Copyright 2015 Joyent, Inc. + + var parser = __webpack_require__(95086) + var signer = __webpack_require__(38143) + var verify = __webpack_require__(51227) + var utils = __webpack_require__(65689) + + ///--- API + + module.exports = { + parse: parser.parseRequest, + parseRequest: parser.parseRequest, + + sign: signer.signRequest, + signRequest: signer.signRequest, + createSigner: signer.createSigner, + isSigner: signer.isSigner, + + sshKeyToPEM: utils.sshKeyToPEM, + sshKeyFingerprint: utils.fingerprint, + pemToRsaSSHKey: utils.pemToRsaSSHKey, + + verify: verify.verifySignature, + verifySignature: verify.verifySignature, + verifyHMAC: verify.verifyHMAC + } + + /***/ + }, + + /***/ 95086: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + // Copyright 2012 Joyent, Inc. All rights reserved. + + var assert = __webpack_require__(66631) + var util = __webpack_require__(31669) + var utils = __webpack_require__(65689) + + ///--- Globals + + var HASH_ALGOS = utils.HASH_ALGOS + var PK_ALGOS = utils.PK_ALGOS + var HttpSignatureError = utils.HttpSignatureError + var InvalidAlgorithmError = utils.InvalidAlgorithmError + var validateAlgorithm = utils.validateAlgorithm + + var State = { + New: 0, + Params: 1 + } + + var ParamsState = { + Name: 0, + Quote: 1, + Value: 2, + Comma: 3 + } + + ///--- Specific Errors + + function ExpiredRequestError(message) { + HttpSignatureError.call(this, message, ExpiredRequestError) + } + util.inherits(ExpiredRequestError, HttpSignatureError) + + function InvalidHeaderError(message) { + HttpSignatureError.call(this, message, InvalidHeaderError) + } + util.inherits(InvalidHeaderError, HttpSignatureError) + + function InvalidParamsError(message) { + HttpSignatureError.call(this, message, InvalidParamsError) + } + util.inherits(InvalidParamsError, HttpSignatureError) + + function MissingHeaderError(message) { + HttpSignatureError.call(this, message, MissingHeaderError) + } + util.inherits(MissingHeaderError, HttpSignatureError) + + function StrictParsingError(message) { + HttpSignatureError.call(this, message, StrictParsingError) + } + util.inherits(StrictParsingError, HttpSignatureError) + + ///--- Exported API + + module.exports = { + /** + * Parses the 'Authorization' header out of an http.ServerRequest object. + * + * Note that this API will fully validate the Authorization header, and throw + * on any error. It will not however check the signature, or the keyId format + * as those are specific to your environment. You can use the options object + * to pass in extra constraints. + * + * As a response object you can expect this: + * + * { + * "scheme": "Signature", + * "params": { + * "keyId": "foo", + * "algorithm": "rsa-sha256", + * "headers": [ + * "date" or "x-date", + * "digest" + * ], + * "signature": "base64" + * }, + * "signingString": "ready to be passed to crypto.verify()" + * } + * + * @param {Object} request an http.ServerRequest. + * @param {Object} options an optional options object with: + * - clockSkew: allowed clock skew in seconds (default 300). + * - headers: required header names (def: date or x-date) + * - algorithms: algorithms to support (default: all). + * - strict: should enforce latest spec parsing + * (default: false). + * @return {Object} parsed out object (see above). + * @throws {TypeError} on invalid input. + * @throws {InvalidHeaderError} on an invalid Authorization header error. + * @throws {InvalidParamsError} if the params in the scheme are invalid. + * @throws {MissingHeaderError} if the params indicate a header not present, + * either in the request headers from the params, + * or not in the params from a required header + * in options. + * @throws {StrictParsingError} if old attributes are used in strict parsing + * mode. + * @throws {ExpiredRequestError} if the value of date or x-date exceeds skew. + */ + parseRequest: function parseRequest(request, options) { + assert.object(request, 'request') + assert.object(request.headers, 'request.headers') + if (options === undefined) { + options = {} + } + if (options.headers === undefined) { + options.headers = [request.headers['x-date'] ? 'x-date' : 'date'] + } + assert.object(options, 'options') + assert.arrayOfString(options.headers, 'options.headers') + assert.optionalFinite(options.clockSkew, 'options.clockSkew') + + var authzHeaderName = + options.authorizationHeaderName || 'authorization' + + if (!request.headers[authzHeaderName]) { + throw new MissingHeaderError( + 'no ' + authzHeaderName + ' header ' + 'present in the request' + ) + } + + options.clockSkew = options.clockSkew || 300 + + var i = 0 + var state = State.New + var substate = ParamsState.Name + var tmpName = '' + var tmpValue = '' + + var parsed = { + scheme: '', + params: {}, + signingString: '' + } + + var authz = request.headers[authzHeaderName] + for (i = 0; i < authz.length; i++) { + var c = authz.charAt(i) + + switch (Number(state)) { + case State.New: + if (c !== ' ') parsed.scheme += c + else state = State.Params + break + + case State.Params: + switch (Number(substate)) { + case ParamsState.Name: + var code = c.charCodeAt(0) + // restricted name of A-Z / a-z + if ( + (code >= 0x41 && code <= 0x5a) || // A-Z + (code >= 0x61 && code <= 0x7a) + ) { + // a-z + tmpName += c + } else if (c === '=') { + if (tmpName.length === 0) + throw new InvalidHeaderError('bad param format') + substate = ParamsState.Quote + } else { + throw new InvalidHeaderError('bad param format') + } + break + + case ParamsState.Quote: + if (c === '"') { + tmpValue = '' + substate = ParamsState.Value + } else { + throw new InvalidHeaderError('bad param format') + } + break + + case ParamsState.Value: + if (c === '"') { + parsed.params[tmpName] = tmpValue + substate = ParamsState.Comma + } else { + tmpValue += c + } + break + + case ParamsState.Comma: + if (c === ',') { + tmpName = '' + substate = ParamsState.Name + } else { + throw new InvalidHeaderError('bad param format') + } + break + + default: + throw new Error('Invalid substate') + } + break + + default: + throw new Error('Invalid substate') + } + } + + if (!parsed.params.headers || parsed.params.headers === '') { + if (request.headers['x-date']) { + parsed.params.headers = ['x-date'] + } else { + parsed.params.headers = ['date'] + } + } else { + parsed.params.headers = parsed.params.headers.split(' ') + } + + // Minimally validate the parsed object + if (!parsed.scheme || parsed.scheme !== 'Signature') + throw new InvalidHeaderError('scheme was not "Signature"') + + if (!parsed.params.keyId) + throw new InvalidHeaderError('keyId was not specified') + + if (!parsed.params.algorithm) + throw new InvalidHeaderError('algorithm was not specified') + + if (!parsed.params.signature) + throw new InvalidHeaderError('signature was not specified') + + // Check the algorithm against the official list + parsed.params.algorithm = parsed.params.algorithm.toLowerCase() + try { + validateAlgorithm(parsed.params.algorithm) + } catch (e) { + if (e instanceof InvalidAlgorithmError) + throw new InvalidParamsError( + parsed.params.algorithm + ' is not ' + 'supported' + ) + else throw e + } + + // Build the signingString + for (i = 0; i < parsed.params.headers.length; i++) { + var h = parsed.params.headers[i].toLowerCase() + parsed.params.headers[i] = h + + if (h === 'request-line') { + if (!options.strict) { + /* + * We allow headers from the older spec drafts if strict parsing isn't + * specified in options. + */ + parsed.signingString += + request.method + + ' ' + + request.url + + ' HTTP/' + + request.httpVersion + } else { + /* Strict parsing doesn't allow older draft headers. */ + throw new StrictParsingError( + 'request-line is not a valid header ' + + 'with strict parsing enabled.' + ) + } + } else if (h === '(request-target)') { + parsed.signingString += + '(request-target): ' + + request.method.toLowerCase() + + ' ' + + request.url + } else { + var value = request.headers[h] + if (value === undefined) + throw new MissingHeaderError(h + ' was not in the request') + parsed.signingString += h + ': ' + value + } + + if (i + 1 < parsed.params.headers.length) + parsed.signingString += '\n' + } + + // Check against the constraints + var date + if (request.headers.date || request.headers['x-date']) { + if (request.headers['x-date']) { + date = new Date(request.headers['x-date']) + } else { + date = new Date(request.headers.date) + } + var now = new Date() + var skew = Math.abs(now.getTime() - date.getTime()) + + if (skew > options.clockSkew * 1000) { + throw new ExpiredRequestError( + 'clock skew of ' + + skew / 1000 + + 's was greater than ' + + options.clockSkew + + 's' + ) + } + } + + options.headers.forEach(function (hdr) { + // Remember that we already checked any headers in the params + // were in the request, so if this passes we're good. + if (parsed.params.headers.indexOf(hdr.toLowerCase()) < 0) + throw new MissingHeaderError(hdr + ' was not a signed header') + }) + + if (options.algorithms) { + if (options.algorithms.indexOf(parsed.params.algorithm) === -1) + throw new InvalidParamsError( + parsed.params.algorithm + ' is not a supported algorithm' + ) + } + + parsed.algorithm = parsed.params.algorithm.toUpperCase() + parsed.keyId = parsed.params.keyId + return parsed + } + } + + /***/ + }, + + /***/ 38143: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + // Copyright 2012 Joyent, Inc. All rights reserved. + + var assert = __webpack_require__(66631) + var crypto = __webpack_require__(76417) + var http = __webpack_require__(98605) + var util = __webpack_require__(31669) + var sshpk = __webpack_require__(87022) + var jsprim = __webpack_require__(6287) + var utils = __webpack_require__(65689) + + var sprintf = __webpack_require__(31669).format + + var HASH_ALGOS = utils.HASH_ALGOS + var PK_ALGOS = utils.PK_ALGOS + var InvalidAlgorithmError = utils.InvalidAlgorithmError + var HttpSignatureError = utils.HttpSignatureError + var validateAlgorithm = utils.validateAlgorithm + + ///--- Globals + + var AUTHZ_FMT = + 'Signature keyId="%s",algorithm="%s",headers="%s",signature="%s"' + + ///--- Specific Errors + + function MissingHeaderError(message) { + HttpSignatureError.call(this, message, MissingHeaderError) + } + util.inherits(MissingHeaderError, HttpSignatureError) + + function StrictParsingError(message) { + HttpSignatureError.call(this, message, StrictParsingError) + } + util.inherits(StrictParsingError, HttpSignatureError) + + /* See createSigner() */ + function RequestSigner(options) { + assert.object(options, 'options') + + var alg = [] + if (options.algorithm !== undefined) { + assert.string(options.algorithm, 'options.algorithm') + alg = validateAlgorithm(options.algorithm) + } + this.rs_alg = alg + + /* + * RequestSigners come in two varieties: ones with an rs_signFunc, and ones + * with an rs_signer. + * + * rs_signFunc-based RequestSigners have to build up their entire signing + * string within the rs_lines array and give it to rs_signFunc as a single + * concat'd blob. rs_signer-based RequestSigners can add a line at a time to + * their signing state by using rs_signer.update(), thus only needing to + * buffer the hash function state and one line at a time. + */ + if (options.sign !== undefined) { + assert.func(options.sign, 'options.sign') + this.rs_signFunc = options.sign + } else if (alg[0] === 'hmac' && options.key !== undefined) { + assert.string(options.keyId, 'options.keyId') + this.rs_keyId = options.keyId + + if (typeof options.key !== 'string' && !Buffer.isBuffer(options.key)) + throw new TypeError( + 'options.key for HMAC must be a string or Buffer' + ) + + /* + * Make an rs_signer for HMACs, not a rs_signFunc -- HMACs digest their + * data in chunks rather than requiring it all to be given in one go + * at the end, so they are more similar to signers than signFuncs. + */ + this.rs_signer = crypto.createHmac(alg[1].toUpperCase(), options.key) + this.rs_signer.sign = function () { + var digest = this.digest('base64') + return { + hashAlgorithm: alg[1], + toString: function () { + return digest + } + } + } + } else if (options.key !== undefined) { + var key = options.key + if (typeof key === 'string' || Buffer.isBuffer(key)) + key = sshpk.parsePrivateKey(key) + + assert.ok( + sshpk.PrivateKey.isPrivateKey(key, [1, 2]), + 'options.key must be a sshpk.PrivateKey' + ) + this.rs_key = key + + assert.string(options.keyId, 'options.keyId') + this.rs_keyId = options.keyId + + if (!PK_ALGOS[key.type]) { + throw new InvalidAlgorithmError( + key.type.toUpperCase() + ' type ' + 'keys are not supported' + ) + } + + if (alg[0] !== undefined && key.type !== alg[0]) { + throw new InvalidAlgorithmError( + 'options.key must be a ' + + alg[0].toUpperCase() + + ' key, was given a ' + + key.type.toUpperCase() + + ' key instead' + ) + } + + this.rs_signer = key.createSign(alg[1]) + } else { + throw new TypeError('options.sign (func) or options.key is required') + } + + this.rs_headers = [] + this.rs_lines = [] + } + + /** + * Adds a header to be signed, with its value, into this signer. + * + * @param {String} header + * @param {String} value + * @return {String} value written + */ + RequestSigner.prototype.writeHeader = function (header, value) { + assert.string(header, 'header') + header = header.toLowerCase() + assert.string(value, 'value') + + this.rs_headers.push(header) + + if (this.rs_signFunc) { + this.rs_lines.push(header + ': ' + value) + } else { + var line = header + ': ' + value + if (this.rs_headers.length > 0) line = '\n' + line + this.rs_signer.update(line) + } + + return value + } + + /** + * Adds a default Date header, returning its value. + * + * @return {String} + */ + RequestSigner.prototype.writeDateHeader = function () { + return this.writeHeader('date', jsprim.rfc1123(new Date())) + } + + /** + * Adds the request target line to be signed. + * + * @param {String} method, HTTP method (e.g. 'get', 'post', 'put') + * @param {String} path + */ + RequestSigner.prototype.writeTarget = function (method, path) { + assert.string(method, 'method') + assert.string(path, 'path') + method = method.toLowerCase() + this.writeHeader('(request-target)', method + ' ' + path) + } + + /** + * Calculate the value for the Authorization header on this request + * asynchronously. + * + * @param {Func} callback (err, authz) + */ + RequestSigner.prototype.sign = function (cb) { + assert.func(cb, 'callback') + + if (this.rs_headers.length < 1) + throw new Error('At least one header must be signed') + + var alg, authz + if (this.rs_signFunc) { + var data = this.rs_lines.join('\n') + var self = this + this.rs_signFunc(data, function (err, sig) { + if (err) { + cb(err) + return + } + try { + assert.object(sig, 'signature') + assert.string(sig.keyId, 'signature.keyId') + assert.string(sig.algorithm, 'signature.algorithm') + assert.string(sig.signature, 'signature.signature') + alg = validateAlgorithm(sig.algorithm) + + authz = sprintf( + AUTHZ_FMT, + sig.keyId, + sig.algorithm, + self.rs_headers.join(' '), + sig.signature + ) + } catch (e) { + cb(e) + return + } + cb(null, authz) + }) + } else { + try { + var sigObj = this.rs_signer.sign() + } catch (e) { + cb(e) + return + } + alg = + (this.rs_alg[0] || this.rs_key.type) + '-' + sigObj.hashAlgorithm + var signature = sigObj.toString() + authz = sprintf( + AUTHZ_FMT, + this.rs_keyId, + alg, + this.rs_headers.join(' '), + signature + ) + cb(null, authz) + } + } + + ///--- Exported API + + module.exports = { + /** + * Identifies whether a given object is a request signer or not. + * + * @param {Object} object, the object to identify + * @returns {Boolean} + */ + isSigner: function (obj) { + if (typeof obj === 'object' && obj instanceof RequestSigner) + return true + return false + }, + + /** + * Creates a request signer, used to asynchronously build a signature + * for a request (does not have to be an http.ClientRequest). + * + * @param {Object} options, either: + * - {String} keyId + * - {String|Buffer} key + * - {String} algorithm (optional, required for HMAC) + * or: + * - {Func} sign (data, cb) + * @return {RequestSigner} + */ + createSigner: function createSigner(options) { + return new RequestSigner(options) + }, + + /** + * Adds an 'Authorization' header to an http.ClientRequest object. + * + * Note that this API will add a Date header if it's not already set. Any + * other headers in the options.headers array MUST be present, or this + * will throw. + * + * You shouldn't need to check the return type; it's just there if you want + * to be pedantic. + * + * The optional flag indicates whether parsing should use strict enforcement + * of the version draft-cavage-http-signatures-04 of the spec or beyond. + * The default is to be loose and support + * older versions for compatibility. + * + * @param {Object} request an instance of http.ClientRequest. + * @param {Object} options signing parameters object: + * - {String} keyId required. + * - {String} key required (either a PEM or HMAC key). + * - {Array} headers optional; defaults to ['date']. + * - {String} algorithm optional (unless key is HMAC); + * default is the same as the sshpk default + * signing algorithm for the type of key given + * - {String} httpVersion optional; defaults to '1.1'. + * - {Boolean} strict optional; defaults to 'false'. + * @return {Boolean} true if Authorization (and optionally Date) were added. + * @throws {TypeError} on bad parameter types (input). + * @throws {InvalidAlgorithmError} if algorithm was bad or incompatible with + * the given key. + * @throws {sshpk.KeyParseError} if key was bad. + * @throws {MissingHeaderError} if a header to be signed was specified but + * was not present. + */ + signRequest: function signRequest(request, options) { + assert.object(request, 'request') + assert.object(options, 'options') + assert.optionalString(options.algorithm, 'options.algorithm') + assert.string(options.keyId, 'options.keyId') + assert.optionalArrayOfString(options.headers, 'options.headers') + assert.optionalString(options.httpVersion, 'options.httpVersion') + + if (!request.getHeader('Date')) + request.setHeader('Date', jsprim.rfc1123(new Date())) + if (!options.headers) options.headers = ['date'] + if (!options.httpVersion) options.httpVersion = '1.1' + + var alg = [] + if (options.algorithm) { + options.algorithm = options.algorithm.toLowerCase() + alg = validateAlgorithm(options.algorithm) + } + + var i + var stringToSign = '' + for (i = 0; i < options.headers.length; i++) { + if (typeof options.headers[i] !== 'string') + throw new TypeError('options.headers must be an array of Strings') + + var h = options.headers[i].toLowerCase() + + if (h === 'request-line') { + if (!options.strict) { + /** + * We allow headers from the older spec drafts if strict parsing isn't + * specified in options. + */ + stringToSign += + request.method + + ' ' + + request.path + + ' HTTP/' + + options.httpVersion + } else { + /* Strict parsing doesn't allow older draft headers. */ + throw new StrictParsingError( + 'request-line is not a valid header ' + + 'with strict parsing enabled.' + ) + } + } else if (h === '(request-target)') { + stringToSign += + '(request-target): ' + + request.method.toLowerCase() + + ' ' + + request.path + } else { + var value = request.getHeader(h) + if (value === undefined || value === '') { + throw new MissingHeaderError(h + ' was not in the request') + } + stringToSign += h + ': ' + value + } + + if (i + 1 < options.headers.length) stringToSign += '\n' + } + + /* This is just for unit tests. */ + if (request.hasOwnProperty('_stringToSign')) { + request._stringToSign = stringToSign + } + + var signature + if (alg[0] === 'hmac') { + if ( + typeof options.key !== 'string' && + !Buffer.isBuffer(options.key) + ) + throw new TypeError('options.key must be a string or Buffer') + + var hmac = crypto.createHmac(alg[1].toUpperCase(), options.key) + hmac.update(stringToSign) + signature = hmac.digest('base64') + } else { + var key = options.key + if (typeof key === 'string' || Buffer.isBuffer(key)) + key = sshpk.parsePrivateKey(options.key) + + assert.ok( + sshpk.PrivateKey.isPrivateKey(key, [1, 2]), + 'options.key must be a sshpk.PrivateKey' + ) + + if (!PK_ALGOS[key.type]) { + throw new InvalidAlgorithmError( + key.type.toUpperCase() + ' type ' + 'keys are not supported' + ) + } + + if (alg[0] !== undefined && key.type !== alg[0]) { + throw new InvalidAlgorithmError( + 'options.key must be a ' + + alg[0].toUpperCase() + + ' key, was given a ' + + key.type.toUpperCase() + + ' key instead' + ) + } + + var signer = key.createSign(alg[1]) + signer.update(stringToSign) + var sigObj = signer.sign() + if (!HASH_ALGOS[sigObj.hashAlgorithm]) { + throw new InvalidAlgorithmError( + sigObj.hashAlgorithm.toUpperCase() + + ' is not a supported hash algorithm' + ) + } + options.algorithm = key.type + '-' + sigObj.hashAlgorithm + signature = sigObj.toString() + assert.notStrictEqual(signature, '', 'empty signature produced') + } + + var authzHeaderName = + options.authorizationHeaderName || 'Authorization' + + request.setHeader( + authzHeaderName, + sprintf( + AUTHZ_FMT, + options.keyId, + options.algorithm, + options.headers.join(' '), + signature + ) + ) + + return true + } + } + + /***/ + }, + + /***/ 65689: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + // Copyright 2012 Joyent, Inc. All rights reserved. + + var assert = __webpack_require__(66631) + var sshpk = __webpack_require__(87022) + var util = __webpack_require__(31669) + + var HASH_ALGOS = { + sha1: true, + sha256: true, + sha512: true + } + + var PK_ALGOS = { + rsa: true, + dsa: true, + ecdsa: true + } + + function HttpSignatureError(message, caller) { + if (Error.captureStackTrace) + Error.captureStackTrace(this, caller || HttpSignatureError) + + this.message = message + this.name = caller.name + } + util.inherits(HttpSignatureError, Error) + + function InvalidAlgorithmError(message) { + HttpSignatureError.call(this, message, InvalidAlgorithmError) + } + util.inherits(InvalidAlgorithmError, HttpSignatureError) + + function validateAlgorithm(algorithm) { + var alg = algorithm.toLowerCase().split('-') + + if (alg.length !== 2) { + throw new InvalidAlgorithmError( + alg[0].toUpperCase() + ' is not a ' + 'valid algorithm' + ) + } + + if (alg[0] !== 'hmac' && !PK_ALGOS[alg[0]]) { + throw new InvalidAlgorithmError( + alg[0].toUpperCase() + ' type keys ' + 'are not supported' + ) + } + + if (!HASH_ALGOS[alg[1]]) { + throw new InvalidAlgorithmError( + alg[1].toUpperCase() + ' is not a ' + 'supported hash algorithm' + ) + } + + return alg + } + + ///--- API + + module.exports = { + HASH_ALGOS: HASH_ALGOS, + PK_ALGOS: PK_ALGOS, + + HttpSignatureError: HttpSignatureError, + InvalidAlgorithmError: InvalidAlgorithmError, + + validateAlgorithm: validateAlgorithm, + + /** + * Converts an OpenSSH public key (rsa only) to a PKCS#8 PEM file. + * + * The intent of this module is to interoperate with OpenSSL only, + * specifically the node crypto module's `verify` method. + * + * @param {String} key an OpenSSH public key. + * @return {String} PEM encoded form of the RSA public key. + * @throws {TypeError} on bad input. + * @throws {Error} on invalid ssh key formatted data. + */ + sshKeyToPEM: function sshKeyToPEM(key) { + assert.string(key, 'ssh_key') + + var k = sshpk.parseKey(key, 'ssh') + return k.toString('pem') + }, + + /** + * Generates an OpenSSH fingerprint from an ssh public key. + * + * @param {String} key an OpenSSH public key. + * @return {String} key fingerprint. + * @throws {TypeError} on bad input. + * @throws {Error} if what you passed doesn't look like an ssh public key. + */ + fingerprint: function fingerprint(key) { + assert.string(key, 'ssh_key') + + var k = sshpk.parseKey(key, 'ssh') + return k.fingerprint('md5').toString('hex') + }, + + /** + * Converts a PKGCS#8 PEM file to an OpenSSH public key (rsa) + * + * The reverse of the above function. + */ + pemToRsaSSHKey: function pemToRsaSSHKey(pem, comment) { + assert.equal('string', typeof pem, 'typeof pem') + + var k = sshpk.parseKey(pem, 'pem') + k.comment = comment + return k.toString('ssh') + } + } + + /***/ + }, + + /***/ 51227: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + // Copyright 2015 Joyent, Inc. + + var assert = __webpack_require__(66631) + var crypto = __webpack_require__(76417) + var sshpk = __webpack_require__(87022) + var utils = __webpack_require__(65689) + + var HASH_ALGOS = utils.HASH_ALGOS + var PK_ALGOS = utils.PK_ALGOS + var InvalidAlgorithmError = utils.InvalidAlgorithmError + var HttpSignatureError = utils.HttpSignatureError + var validateAlgorithm = utils.validateAlgorithm + + ///--- Exported API + + module.exports = { + /** + * Verify RSA/DSA signature against public key. You are expected to pass in + * an object that was returned from `parse()`. + * + * @param {Object} parsedSignature the object you got from `parse`. + * @param {String} pubkey RSA/DSA private key PEM. + * @return {Boolean} true if valid, false otherwise. + * @throws {TypeError} if you pass in bad arguments. + * @throws {InvalidAlgorithmError} + */ + verifySignature: function verifySignature(parsedSignature, pubkey) { + assert.object(parsedSignature, 'parsedSignature') + if (typeof pubkey === 'string' || Buffer.isBuffer(pubkey)) + pubkey = sshpk.parseKey(pubkey) + assert.ok( + sshpk.Key.isKey(pubkey, [1, 1]), + 'pubkey must be a sshpk.Key' + ) + + var alg = validateAlgorithm(parsedSignature.algorithm) + if (alg[0] === 'hmac' || alg[0] !== pubkey.type) return false + + var v = pubkey.createVerify(alg[1]) + v.update(parsedSignature.signingString) + return v.verify(parsedSignature.params.signature, 'base64') + }, + + /** + * Verify HMAC against shared secret. You are expected to pass in an object + * that was returned from `parse()`. + * + * @param {Object} parsedSignature the object you got from `parse`. + * @param {String} secret HMAC shared secret. + * @return {Boolean} true if valid, false otherwise. + * @throws {TypeError} if you pass in bad arguments. + * @throws {InvalidAlgorithmError} + */ + verifyHMAC: function verifyHMAC(parsedSignature, secret) { + assert.object(parsedSignature, 'parsedHMAC') + assert.string(secret, 'secret') + + var alg = validateAlgorithm(parsedSignature.algorithm) + if (alg[0] !== 'hmac') return false + + var hashAlg = alg[1].toUpperCase() + + var hmac = crypto.createHmac(hashAlg, secret) + hmac.update(parsedSignature.signingString) + + /* + * Now double-hash to avoid leaking timing information - there's + * no easy constant-time compare in JS, so we use this approach + * instead. See for more info: + * https://www.isecpartners.com/blog/2011/february/double-hmac- + * verification.aspx + */ + var h1 = crypto.createHmac(hashAlg, secret) + h1.update(hmac.digest()) + h1 = h1.digest() + var h2 = crypto.createHmac(hashAlg, secret) + h2.update(new Buffer(parsedSignature.params.signature, 'base64')) + h2 = h2.digest() + + /* Node 0.8 returns strings from .digest(). */ + if (typeof h1 === 'string') return h1 === h2 + /* And node 0.10 lacks the .equals() method on Buffers. */ + if (Buffer.isBuffer(h1) && !h1.equals) + return h1.toString('binary') === h2.toString('binary') + + return h1.equals(h2) + } + } + + /***/ + }, + + /***/ 15098: /***/ function ( + __unused_webpack_module, + exports, + __webpack_require__ + ) { + 'use strict' + + var __awaiter = + (this && this.__awaiter) || + function (thisArg, _arguments, P, generator) { + function adopt(value) { + return value instanceof P + ? value + : new P(function (resolve) { + resolve(value) + }) + } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { + try { + step(generator.next(value)) + } catch (e) { + reject(e) + } + } + function rejected(value) { + try { + step(generator['throw'](value)) + } catch (e) { + reject(e) + } + } + function step(result) { + result.done + ? resolve(result.value) + : adopt(result.value).then(fulfilled, rejected) + } + step( + (generator = generator.apply(thisArg, _arguments || [])).next() + ) + }) + } + var __importDefault = + (this && this.__importDefault) || + function (mod) { + return mod && mod.__esModule ? mod : { default: mod } + } + Object.defineProperty(exports, '__esModule', { value: true }) + const net_1 = __importDefault(__webpack_require__(11631)) + const tls_1 = __importDefault(__webpack_require__(4016)) + const url_1 = __importDefault(__webpack_require__(78835)) + const assert_1 = __importDefault(__webpack_require__(42357)) + const debug_1 = __importDefault(__webpack_require__(38237)) + const agent_base_1 = __webpack_require__(49690) + const parse_proxy_response_1 = __importDefault(__webpack_require__(595)) + const debug = debug_1.default('https-proxy-agent:agent') + /** + * The `HttpsProxyAgent` implements an HTTP Agent subclass that connects to + * the specified "HTTP(s) proxy server" in order to proxy HTTPS requests. + * + * Outgoing HTTP requests are first tunneled through the proxy server using the + * `CONNECT` HTTP request method to establish a connection to the proxy server, + * and then the proxy server connects to the destination target and issues the + * HTTP request from the proxy server. + * + * `https:` requests have their socket connection upgraded to TLS once + * the connection to the proxy server has been established. + * + * @api public + */ + class HttpsProxyAgent extends agent_base_1.Agent { + constructor(_opts) { + let opts + if (typeof _opts === 'string') { + opts = url_1.default.parse(_opts) + } else { + opts = _opts + } + if (!opts) { + throw new Error( + 'an HTTP(S) proxy server `host` and `port` must be specified!' + ) + } + debug('creating new HttpsProxyAgent instance: %o', opts) + super(opts) + const proxy = Object.assign({}, opts) + // If `true`, then connect to the proxy server over TLS. + // Defaults to `false`. + this.secureProxy = opts.secureProxy || isHTTPS(proxy.protocol) + // Prefer `hostname` over `host`, and set the `port` if needed. + proxy.host = proxy.hostname || proxy.host + if (typeof proxy.port === 'string') { + proxy.port = parseInt(proxy.port, 10) + } + if (!proxy.port && proxy.host) { + proxy.port = this.secureProxy ? 443 : 80 + } + // ALPN is supported by Node.js >= v5. + // attempt to negotiate http/1.1 for proxy servers that support http/2 + if (this.secureProxy && !('ALPNProtocols' in proxy)) { + proxy.ALPNProtocols = ['http 1.1'] + } + if (proxy.host && proxy.path) { + // If both a `host` and `path` are specified then it's most likely + // the result of a `url.parse()` call... we need to remove the + // `path` portion so that `net.connect()` doesn't attempt to open + // that as a Unix socket file. + delete proxy.path + delete proxy.pathname + } + this.proxy = proxy + } + /** + * Called when the node-core HTTP client library is creating a + * new HTTP request. + * + * @api protected + */ + callback(req, opts) { + return __awaiter(this, void 0, void 0, function* () { + const { proxy, secureProxy } = this + // Create a socket connection to the proxy server. + let socket + if (secureProxy) { + debug('Creating `tls.Socket`: %o', proxy) + socket = tls_1.default.connect(proxy) + } else { + debug('Creating `net.Socket`: %o', proxy) + socket = net_1.default.connect(proxy) + } + const headers = Object.assign({}, proxy.headers) + const hostname = `${opts.host}:${opts.port}` + let payload = `CONNECT ${hostname} HTTP/1.1\r\n` + // Inject the `Proxy-Authorization` header if necessary. + if (proxy.auth) { + headers['Proxy-Authorization'] = `Basic ${Buffer.from( + proxy.auth + ).toString('base64')}` + } + // The `Host` header should only include the port + // number when it is not the default port. + let { host, port, secureEndpoint } = opts + if (!isDefaultPort(port, secureEndpoint)) { + host += `:${port}` + } + headers.Host = host + headers.Connection = 'close' + for (const name of Object.keys(headers)) { + payload += `${name}: ${headers[name]}\r\n` + } + const proxyResponsePromise = parse_proxy_response_1.default(socket) + socket.write(`${payload}\r\n`) + const { statusCode, buffered } = yield proxyResponsePromise + if (statusCode === 200) { + req.once('socket', resume) + if (opts.secureEndpoint) { + const servername = opts.servername || opts.host + if (!servername) { + throw new Error('Could not determine "servername"') + } + // The proxy is connecting to a TLS server, so upgrade + // this socket connection to a TLS connection. + debug('Upgrading socket connection to TLS') + return tls_1.default.connect( + Object.assign( + Object.assign( + {}, + omit(opts, 'host', 'hostname', 'path', 'port') + ), + { socket, servername } + ) + ) + } + return socket + } + // Some other status code that's not 200... need to re-play the HTTP + // header "data" events onto the socket once the HTTP machinery is + // attached so that the node core `http` can parse and handle the + // error status code. + // Close the original socket, and a new "fake" socket is returned + // instead, so that the proxy doesn't get the HTTP request + // written to it (which may contain `Authorization` headers or other + // sensitive data). + // + // See: https://hackerone.com/reports/541502 + socket.destroy() + const fakeSocket = new net_1.default.Socket() + fakeSocket.readable = true + // Need to wait for the "socket" event to re-play the "data" events. + req.once('socket', s => { + debug('replaying proxy buffer for failed request') + assert_1.default(s.listenerCount('data') > 0) + // Replay the "buffered" Buffer onto the fake `socket`, since at + // this point the HTTP module machinery has been hooked up for + // the user. + s.push(buffered) + s.push(null) + }) + return fakeSocket + }) + } + } + exports.default = HttpsProxyAgent + function resume(socket) { + socket.resume() + } + function isDefaultPort(port, secure) { + return Boolean((!secure && port === 80) || (secure && port === 443)) + } + function isHTTPS(protocol) { + return typeof protocol === 'string' + ? /^https:?$/i.test(protocol) + : false + } + function omit(obj, ...keys) { + const ret = {} + let key + for (key in obj) { + if (!keys.includes(key)) { + ret[key] = obj[key] + } + } + return ret + } + //# sourceMappingURL=agent.js.map + + /***/ + }, + + /***/ 77219: /***/ function ( + module, + __unused_webpack_exports, + __webpack_require__ + ) { + 'use strict' + + var __importDefault = + (this && this.__importDefault) || + function (mod) { + return mod && mod.__esModule ? mod : { default: mod } + } + const agent_1 = __importDefault(__webpack_require__(15098)) + function createHttpsProxyAgent(opts) { + return new agent_1.default(opts) + } + ;(function (createHttpsProxyAgent) { + createHttpsProxyAgent.HttpsProxyAgent = agent_1.default + createHttpsProxyAgent.prototype = agent_1.default.prototype + })(createHttpsProxyAgent || (createHttpsProxyAgent = {})) + module.exports = createHttpsProxyAgent + //# sourceMappingURL=index.js.map + + /***/ + }, + + /***/ 595: /***/ function ( + __unused_webpack_module, + exports, + __webpack_require__ + ) { + 'use strict' + + var __importDefault = + (this && this.__importDefault) || + function (mod) { + return mod && mod.__esModule ? mod : { default: mod } + } + Object.defineProperty(exports, '__esModule', { value: true }) + const debug_1 = __importDefault(__webpack_require__(38237)) + const debug = debug_1.default('https-proxy-agent:parse-proxy-response') + function parseProxyResponse(socket) { + return new Promise((resolve, reject) => { + // we need to buffer any HTTP traffic that happens with the proxy before we get + // the CONNECT response, so that if the response is anything other than an "200" + // response code, then we can re-play the "data" events on the socket once the + // HTTP parser is hooked up... + let buffersLength = 0 + const buffers = [] + function read() { + const b = socket.read() + if (b) ondata(b) + else socket.once('readable', read) + } + function cleanup() { + socket.removeListener('end', onend) + socket.removeListener('error', onerror) + socket.removeListener('close', onclose) + socket.removeListener('readable', read) + } + function onclose(err) { + debug('onclose had error %o', err) + } + function onend() { + debug('onend') + } + function onerror(err) { + cleanup() + debug('onerror %o', err) + reject(err) + } + function ondata(b) { + buffers.push(b) + buffersLength += b.length + const buffered = Buffer.concat(buffers, buffersLength) + const endOfHeaders = buffered.indexOf('\r\n\r\n') + if (endOfHeaders === -1) { + // keep buffering + debug('have not received end of HTTP headers yet...') + read() + return + } + const firstLine = buffered.toString( + 'ascii', + 0, + buffered.indexOf('\r\n') + ) + const statusCode = +firstLine.split(' ')[1] + debug('got proxy server response: %o', firstLine) + resolve({ + statusCode, + buffered + }) + } + socket.on('error', onerror) + socket.on('close', onclose) + socket.on('end', onend) + read() + }) + } + exports.default = parseProxyResponse + //# sourceMappingURL=parse-proxy-response.js.map + + /***/ + }, + + /***/ 61852: /***/ (module, exports) => { + 'use strict' + + Object.defineProperty(exports, '__esModule', { + value: true + }) + exports.default = void 0 + + var _default = function _default(filename) { + if (filename.indexOf('.') < 0) return undefined + return '.'.concat(filename.split('.').pop()) + } + + exports.default = _default + module.exports = exports.default + + /***/ + }, + + /***/ 61006: /***/ (module, exports) => { + 'use strict' + + Object.defineProperty(exports, '__esModule', { + value: true + }) + exports.default = void 0 + + function _createForOfIteratorHelper(o, allowArrayLike) { + var it + if (typeof Symbol === 'undefined' || o[Symbol.iterator] == null) { + if ( + Array.isArray(o) || + (it = _unsupportedIterableToArray(o)) || + (allowArrayLike && o && typeof o.length === 'number') + ) { + if (it) o = it + var i = 0 + var F = function F() {} + return { + s: F, + n: function n() { + if (i >= o.length) return { done: true } + return { done: false, value: o[i++] } + }, + e: function e(_e) { + throw _e + }, + f: F + } + } + throw new TypeError( + 'Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.' + ) + } + var normalCompletion = true, + didErr = false, + err + return { + s: function s() { + it = o[Symbol.iterator]() + }, + n: function n() { + var step = it.next() + normalCompletion = step.done + return step + }, + e: function e(_e2) { + didErr = true + err = _e2 + }, + f: function f() { + try { + if (!normalCompletion && it.return != null) it.return() + } finally { + if (didErr) throw err + } + } + } + } + + function _unsupportedIterableToArray(o, minLen) { + if (!o) return + if (typeof o === 'string') return _arrayLikeToArray(o, minLen) + var n = Object.prototype.toString.call(o).slice(8, -1) + if (n === 'Object' && o.constructor) n = o.constructor.name + if (n === 'Map' || n === 'Set') return Array.from(o) + if ( + n === 'Arguments' || + /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) + ) + return _arrayLikeToArray(o, minLen) + } + + function _arrayLikeToArray(arr, len) { + if (len == null || len > arr.length) len = arr.length + for (var i = 0, arr2 = new Array(len); i < len; i++) { + arr2[i] = arr[i] + } + return arr2 + } + + function _typeof(obj) { + '@babel/helpers - typeof' + if ( + typeof Symbol === 'function' && + typeof Symbol.iterator === 'symbol' + ) { + _typeof = function _typeof(obj) { + return typeof obj + } + } else { + _typeof = function _typeof(obj) { + return obj && + typeof Symbol === 'function' && + obj.constructor === Symbol && + obj !== Symbol.prototype + ? 'symbol' + : typeof obj + } + } + return _typeof(obj) + } + + var Space_Separator = /[\u1680\u2000-\u200A\u202F\u205F\u3000]/ + var ID_Start = /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/ + var ID_Continue = /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/ + var unicode = { + Space_Separator: Space_Separator, + ID_Start: ID_Start, + ID_Continue: ID_Continue + } + var util = { + isSpaceSeparator: function isSpaceSeparator(c) { + return typeof c === 'string' && unicode.Space_Separator.test(c) + }, + isIdStartChar: function isIdStartChar(c) { + return ( + typeof c === 'string' && + ((c >= 'a' && c <= 'z') || + (c >= 'A' && c <= 'Z') || + c === '$' || + c === '_' || + unicode.ID_Start.test(c)) + ) + }, + isIdContinueChar: function isIdContinueChar(c) { + return ( + typeof c === 'string' && + ((c >= 'a' && c <= 'z') || + (c >= 'A' && c <= 'Z') || + (c >= '0' && c <= '9') || + c === '$' || + c === '_' || + c === '\u200C' || + c === '\u200D' || + unicode.ID_Continue.test(c)) + ) + }, + isDigit: function isDigit(c) { + return typeof c === 'string' && /[0-9]/.test(c) + }, + isHexDigit: function isHexDigit(c) { + return typeof c === 'string' && /[0-9A-Fa-f]/.test(c) + } + } + var source + var parseState + var stack + var pos + var line + var column + var token + var key + var root + + var parse = function parse(text, reviver) { + source = String(text) + parseState = 'start' + stack = [] + pos = 0 + line = 1 + column = 0 + token = undefined + key = undefined + root = undefined + + do { + token = lex() + parseStates[parseState]() + } while (token.type !== 'eof') + + if (typeof reviver === 'function') { + return internalize( + { + '': root + }, + '', + reviver + ) + } + + return root + } + + function internalize(holder, name, reviver) { + var value = holder[name] + + if (value != null && _typeof(value) === 'object') { + for (var _key in value) { + var replacement = internalize(value, _key, reviver) + + if (replacement === undefined) { + delete value[_key] + } else { + value[_key] = replacement + } + } + } + + return reviver.call(holder, name, value) + } + + var lexState + var buffer + var doubleQuote + + var _sign + + var c + + function lex() { + lexState = 'default' + buffer = '' + doubleQuote = false + _sign = 1 + + for (;;) { + c = peek() + + var _token = lexStates[lexState]() + + if (_token) { + return _token + } + } + } + + function peek() { + if (source[pos]) { + return String.fromCodePoint(source.codePointAt(pos)) + } + } + + function read() { + var c = peek() + + if (c === '\n') { + line++ + column = 0 + } else if (c) { + column += c.length + } else { + column++ + } + + if (c) { + pos += c.length + } + + return c + } + + var lexStates = { + default: function _default() { + switch (c) { + case '\t': + case '\v': + case '\f': + case ' ': + case '\xA0': + case '\uFEFF': + case '\n': + case '\r': + case '\u2028': + case '\u2029': + read() + return + + case '/': + read() + lexState = 'comment' + return + + case undefined: + read() + return newToken('eof') + } + + if (util.isSpaceSeparator(c)) { + read() + return + } + + return lexStates[parseState]() + }, + comment: function comment() { + switch (c) { + case '*': + read() + lexState = 'multiLineComment' + return + + case '/': + read() + lexState = 'singleLineComment' + return + } + + throw invalidChar(read()) + }, + multiLineComment: function multiLineComment() { + switch (c) { + case '*': + read() + lexState = 'multiLineCommentAsterisk' + return + + case undefined: + throw invalidChar(read()) + } + + read() + }, + multiLineCommentAsterisk: function multiLineCommentAsterisk() { + switch (c) { + case '*': + read() + return + + case '/': + read() + lexState = 'default' + return + + case undefined: + throw invalidChar(read()) + } + + read() + lexState = 'multiLineComment' + }, + singleLineComment: function singleLineComment() { + switch (c) { + case '\n': + case '\r': + case '\u2028': + case '\u2029': + read() + lexState = 'default' + return + + case undefined: + read() + return newToken('eof') + } + + read() + }, + value: function value() { + switch (c) { + case '{': + case '[': + return newToken('punctuator', read()) + + case 'n': + read() + literal('ull') + return newToken('null', null) + + case 't': + read() + literal('rue') + return newToken('boolean', true) + + case 'f': + read() + literal('alse') + return newToken('boolean', false) + + case '-': + case '+': + if (read() === '-') { + _sign = -1 + } + + lexState = 'sign' + return + + case '.': + buffer = read() + lexState = 'decimalPointLeading' + return + + case '0': + buffer = read() + lexState = 'zero' + return + + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + buffer = read() + lexState = 'decimalInteger' + return + + case 'I': + read() + literal('nfinity') + return newToken('numeric', Infinity) + + case 'N': + read() + literal('aN') + return newToken('numeric', NaN) + + case '"': + case "'": + doubleQuote = read() === '"' + buffer = '' + lexState = 'string' + return + } + + throw invalidChar(read()) + }, + identifierNameStartEscape: function identifierNameStartEscape() { + if (c !== 'u') { + throw invalidChar(read()) + } + + read() + var u = unicodeEscape() + + switch (u) { + case '$': + case '_': + break + + default: + if (!util.isIdStartChar(u)) { + throw invalidIdentifier() + } + + break + } + + buffer += u + lexState = 'identifierName' + }, + identifierName: function identifierName() { + switch (c) { + case '$': + case '_': + case '\u200C': + case '\u200D': + buffer += read() + return + + case '\\': + read() + lexState = 'identifierNameEscape' + return + } + + if (util.isIdContinueChar(c)) { + buffer += read() + return + } + + return newToken('identifier', buffer) + }, + identifierNameEscape: function identifierNameEscape() { + if (c !== 'u') { + throw invalidChar(read()) + } + + read() + var u = unicodeEscape() + + switch (u) { + case '$': + case '_': + case '\u200C': + case '\u200D': + break + + default: + if (!util.isIdContinueChar(u)) { + throw invalidIdentifier() + } + + break + } + + buffer += u + lexState = 'identifierName' + }, + sign: function sign() { + switch (c) { + case '.': + buffer = read() + lexState = 'decimalPointLeading' + return + + case '0': + buffer = read() + lexState = 'zero' + return + + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + buffer = read() + lexState = 'decimalInteger' + return + + case 'I': + read() + literal('nfinity') + return newToken('numeric', _sign * Infinity) + + case 'N': + read() + literal('aN') + return newToken('numeric', NaN) + } + + throw invalidChar(read()) + }, + zero: function zero() { + switch (c) { + case '.': + buffer += read() + lexState = 'decimalPoint' + return + + case 'e': + case 'E': + buffer += read() + lexState = 'decimalExponent' + return + + case 'x': + case 'X': + buffer += read() + lexState = 'hexadecimal' + return + } + + return newToken('numeric', _sign * 0) + }, + decimalInteger: function decimalInteger() { + switch (c) { + case '.': + buffer += read() + lexState = 'decimalPoint' + return + + case 'e': + case 'E': + buffer += read() + lexState = 'decimalExponent' + return + } + + if (util.isDigit(c)) { + buffer += read() + return + } + + return newToken('numeric', _sign * Number(buffer)) + }, + decimalPointLeading: function decimalPointLeading() { + if (util.isDigit(c)) { + buffer += read() + lexState = 'decimalFraction' + return + } + + throw invalidChar(read()) + }, + decimalPoint: function decimalPoint() { + switch (c) { + case 'e': + case 'E': + buffer += read() + lexState = 'decimalExponent' + return + } + + if (util.isDigit(c)) { + buffer += read() + lexState = 'decimalFraction' + return + } + + return newToken('numeric', _sign * Number(buffer)) + }, + decimalFraction: function decimalFraction() { + switch (c) { + case 'e': + case 'E': + buffer += read() + lexState = 'decimalExponent' + return + } + + if (util.isDigit(c)) { + buffer += read() + return + } + + return newToken('numeric', _sign * Number(buffer)) + }, + decimalExponent: function decimalExponent() { + switch (c) { + case '+': + case '-': + buffer += read() + lexState = 'decimalExponentSign' + return + } + + if (util.isDigit(c)) { + buffer += read() + lexState = 'decimalExponentInteger' + return + } + + throw invalidChar(read()) + }, + decimalExponentSign: function decimalExponentSign() { + if (util.isDigit(c)) { + buffer += read() + lexState = 'decimalExponentInteger' + return + } + + throw invalidChar(read()) + }, + decimalExponentInteger: function decimalExponentInteger() { + if (util.isDigit(c)) { + buffer += read() + return + } + + return newToken('numeric', _sign * Number(buffer)) + }, + hexadecimal: function hexadecimal() { + if (util.isHexDigit(c)) { + buffer += read() + lexState = 'hexadecimalInteger' + return + } + + throw invalidChar(read()) + }, + hexadecimalInteger: function hexadecimalInteger() { + if (util.isHexDigit(c)) { + buffer += read() + return + } + + return newToken('numeric', _sign * Number(buffer)) + }, + string: function string() { + switch (c) { + case '\\': + read() + buffer += escape() + return + + case '"': + if (doubleQuote) { + read() + return newToken('string', buffer) + } + + buffer += read() + return + + case "'": + if (!doubleQuote) { + read() + return newToken('string', buffer) + } + + buffer += read() + return + + case '\n': + case '\r': + throw invalidChar(read()) + + case '\u2028': + case '\u2029': + separatorChar(c) + break + + case undefined: + throw invalidChar(read()) + } + + buffer += read() + }, + start: function start() { + switch (c) { + case '{': + case '[': + return newToken('punctuator', read()) + } + + lexState = 'value' + }, + beforePropertyName: function beforePropertyName() { + switch (c) { + case '$': + case '_': + buffer = read() + lexState = 'identifierName' + return + + case '\\': + read() + lexState = 'identifierNameStartEscape' + return + + case '}': + return newToken('punctuator', read()) + + case '"': + case "'": + doubleQuote = read() === '"' + lexState = 'string' + return + } + + if (util.isIdStartChar(c)) { + buffer += read() + lexState = 'identifierName' + return + } + + throw invalidChar(read()) + }, + afterPropertyName: function afterPropertyName() { + if (c === ':') { + return newToken('punctuator', read()) + } + + throw invalidChar(read()) + }, + beforePropertyValue: function beforePropertyValue() { + lexState = 'value' + }, + afterPropertyValue: function afterPropertyValue() { + switch (c) { + case ',': + case '}': + return newToken('punctuator', read()) + } + + throw invalidChar(read()) + }, + beforeArrayValue: function beforeArrayValue() { + if (c === ']') { + return newToken('punctuator', read()) + } + + lexState = 'value' + }, + afterArrayValue: function afterArrayValue() { + switch (c) { + case ',': + case ']': + return newToken('punctuator', read()) + } + + throw invalidChar(read()) + }, + end: function end() { + throw invalidChar(read()) + } + } + + function newToken(type, value) { + return { + type: type, + value: value, + line: line, + column: column + } + } + + function literal(s) { + var _iterator = _createForOfIteratorHelper(s), + _step + + try { + for (_iterator.s(); !(_step = _iterator.n()).done; ) { + var _c = _step.value + var p = peek() + + if (p !== _c) { + throw invalidChar(read()) + } + + read() + } + } catch (err) { + _iterator.e(err) + } finally { + _iterator.f() + } + } + + function escape() { + var c = peek() + + switch (c) { + case 'b': + read() + return '\b' + + case 'f': + read() + return '\f' + + case 'n': + read() + return '\n' + + case 'r': + read() + return '\r' + + case 't': + read() + return '\t' + + case 'v': + read() + return '\v' + + case '0': + read() + + if (util.isDigit(peek())) { + throw invalidChar(read()) + } + + return '\0' + + case 'x': + read() + return hexEscape() + + case 'u': + read() + return unicodeEscape() + + case '\n': + case '\u2028': + case '\u2029': + read() + return '' + + case '\r': + read() + + if (peek() === '\n') { + read() + } + + return '' + + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + throw invalidChar(read()) + + case undefined: + throw invalidChar(read()) + } + + return read() + } + + function hexEscape() { + var buffer = '' + var c = peek() + + if (!util.isHexDigit(c)) { + throw invalidChar(read()) + } + + buffer += read() + c = peek() + + if (!util.isHexDigit(c)) { + throw invalidChar(read()) + } + + buffer += read() + return String.fromCodePoint(parseInt(buffer, 16)) + } + + function unicodeEscape() { + var buffer = '' + var count = 4 + + while (count-- > 0) { + var _c2 = peek() + + if (!util.isHexDigit(_c2)) { + throw invalidChar(read()) + } + + buffer += read() + } + + return String.fromCodePoint(parseInt(buffer, 16)) + } + + var parseStates = { + start: function start() { + if (token.type === 'eof') { + throw invalidEOF() + } + + push() + }, + beforePropertyName: function beforePropertyName() { + switch (token.type) { + case 'identifier': + case 'string': + key = token.value + parseState = 'afterPropertyName' + return + + case 'punctuator': + pop() + return + + case 'eof': + throw invalidEOF() + } + }, + afterPropertyName: function afterPropertyName() { + if (token.type === 'eof') { + throw invalidEOF() + } + + parseState = 'beforePropertyValue' + }, + beforePropertyValue: function beforePropertyValue() { + if (token.type === 'eof') { + throw invalidEOF() + } + + push() + }, + beforeArrayValue: function beforeArrayValue() { + if (token.type === 'eof') { + throw invalidEOF() + } + + if (token.type === 'punctuator' && token.value === ']') { + pop() + return + } + + push() + }, + afterPropertyValue: function afterPropertyValue() { + if (token.type === 'eof') { + throw invalidEOF() + } + + switch (token.value) { + case ',': + parseState = 'beforePropertyName' + return + + case '}': + pop() + } + }, + afterArrayValue: function afterArrayValue() { + if (token.type === 'eof') { + throw invalidEOF() + } + + switch (token.value) { + case ',': + parseState = 'beforeArrayValue' + return + + case ']': + pop() + } + }, + end: function end() {} + } + + function push() { + var value + + switch (token.type) { + case 'punctuator': + switch (token.value) { + case '{': + value = {} + break + + case '[': + value = [] + break + } + + break + + case 'null': + case 'boolean': + case 'numeric': + case 'string': + value = token.value + break + } + + if (root === undefined) { + root = value + } else { + var parent = stack[stack.length - 1] + + if (Array.isArray(parent)) { + parent.push(value) + } else { + parent[key] = value + } + } + + if (value !== null && _typeof(value) === 'object') { + stack.push(value) + + if (Array.isArray(value)) { + parseState = 'beforeArrayValue' + } else { + parseState = 'beforePropertyName' + } + } else { + var current = stack[stack.length - 1] + + if (current == null) { + parseState = 'end' + } else if (Array.isArray(current)) { + parseState = 'afterArrayValue' + } else { + parseState = 'afterPropertyValue' + } + } + } + + function pop() { + stack.pop() + var current = stack[stack.length - 1] + + if (current == null) { + parseState = 'end' + } else if (Array.isArray(current)) { + parseState = 'afterArrayValue' + } else { + parseState = 'afterPropertyValue' + } + } + + function invalidChar(c) { + if (c === undefined) { + return syntaxError( + 'JSON5: invalid end of input at '.concat(line, ':').concat(column) + ) + } + + return syntaxError( + "JSON5: invalid character '" + .concat(formatChar(c), "' at ") + .concat(line, ':') + .concat(column) + ) + } + + function invalidEOF() { + return syntaxError( + 'JSON5: invalid end of input at '.concat(line, ':').concat(column) + ) + } + + function invalidIdentifier() { + column -= 5 + return syntaxError( + 'JSON5: invalid identifier character at ' + .concat(line, ':') + .concat(column) + ) + } + + function separatorChar(c) { + console.warn( + "JSON5: '".concat( + formatChar(c), + "' in strings is not valid ECMAScript; consider escaping" + ) + ) + } + + function formatChar(c) { + var replacements = { + "'": "\\'", + '"': '\\"', + '\\': '\\\\', + '\b': '\\b', + '\f': '\\f', + '\n': '\\n', + '\r': '\\r', + '\t': '\\t', + '\v': '\\v', + '\0': '\\0', + '\u2028': '\\u2028', + '\u2029': '\\u2029' + } + + if (replacements[c]) { + return replacements[c] + } + + if (c < ' ') { + var hexString = c.charCodeAt(0).toString(16) + return '\\x' + ('00' + hexString).substring(hexString.length) + } + + return c + } + + function syntaxError(message) { + var err = new SyntaxError(message) + err.lineNumber = line + err.columnNumber = column + return err + } + + var stringify = function stringify(value, replacer, space) { + var stack = [] + var indent = '' + var propertyList + var replacerFunc + var gap = '' + var quote + + if ( + replacer != null && + _typeof(replacer) === 'object' && + !Array.isArray(replacer) + ) { + space = replacer.space + quote = replacer.quote + replacer = replacer.replacer + } + + if (typeof replacer === 'function') { + replacerFunc = replacer + } else if (Array.isArray(replacer)) { + propertyList = [] + + var _iterator2 = _createForOfIteratorHelper(replacer), + _step2 + + try { + for (_iterator2.s(); !(_step2 = _iterator2.n()).done; ) { + var v = _step2.value + var item = void 0 + + if (typeof v === 'string') { + item = v + } else if ( + typeof v === 'number' || + v instanceof String || + v instanceof Number + ) { + item = String(v) + } + + if (item !== undefined && propertyList.indexOf(item) < 0) { + propertyList.push(item) + } + } + } catch (err) { + _iterator2.e(err) + } finally { + _iterator2.f() + } + } + + if (space instanceof Number) { + space = Number(space) + } else if (space instanceof String) { + space = String(space) + } + + if (typeof space === 'number') { + if (space > 0) { + space = Math.min(10, Math.floor(space)) + gap = ' '.substr(0, space) + } + } else if (typeof space === 'string') { + gap = space.substr(0, 10) + } + + return serializeProperty('', { + '': value + }) + + function serializeProperty(key, holder) { + var value = holder[key] + + if (value != null) { + if (typeof value.toJSON5 === 'function') { + value = value.toJSON5(key) + } else if (typeof value.toJSON === 'function') { + value = value.toJSON(key) + } + } + + if (replacerFunc) { + value = replacerFunc.call(holder, key, value) + } + + if (value instanceof Number) { + value = Number(value) + } else if (value instanceof String) { + value = String(value) + } else if (value instanceof Boolean) { + value = value.valueOf() + } + + switch (value) { + case null: + return 'null' + + case true: + return 'true' + + case false: + return 'false' + } + + if (typeof value === 'string') { + return quoteString(value, false) + } + + if (typeof value === 'number') { + return String(value) + } + + if (_typeof(value) === 'object') { + return Array.isArray(value) + ? serializeArray(value) + : serializeObject(value) + } + + return undefined + } + + function quoteString(value) { + var quotes = { + "'": 0.1, + '"': 0.2 + } + var replacements = { + "'": "\\'", + '"': '\\"', + '\\': '\\\\', + '\b': '\\b', + '\f': '\\f', + '\n': '\\n', + '\r': '\\r', + '\t': '\\t', + '\v': '\\v', + '\0': '\\0', + '\u2028': '\\u2028', + '\u2029': '\\u2029' + } + var product = '' + + for (var i = 0; i < value.length; i++) { + var _c3 = value[i] + + switch (_c3) { + case "'": + case '"': + quotes[_c3]++ + product += _c3 + continue + + case '\0': + if (util.isDigit(value[i + 1])) { + product += '\\x00' + continue + } + } + + if (replacements[_c3]) { + product += replacements[_c3] + continue + } + + if (_c3 < ' ') { + var hexString = _c3.charCodeAt(0).toString(16) + + product += '\\x' + ('00' + hexString).substring(hexString.length) + continue + } + + product += _c3 + } + + var quoteChar = + quote || + Object.keys(quotes).reduce(function (a, b) { + return quotes[a] < quotes[b] ? a : b + }) + product = product.replace( + new RegExp(quoteChar, 'g'), + replacements[quoteChar] + ) + return quoteChar + product + quoteChar + } + + function serializeObject(value) { + if (stack.indexOf(value) >= 0) { + throw TypeError('Converting circular structure to JSON5') + } + + stack.push(value) + var stepback = indent + indent = indent + gap + var keys = propertyList || Object.keys(value) + var partial = [] + + var _iterator3 = _createForOfIteratorHelper(keys), + _step3 + + try { + for (_iterator3.s(); !(_step3 = _iterator3.n()).done; ) { + var _key2 = _step3.value + var propertyString = serializeProperty(_key2, value) + + if (propertyString !== undefined) { + var member = serializeKey(_key2) + ':' + + if (gap !== '') { + member += ' ' + } + + member += propertyString + partial.push(member) + } + } + } catch (err) { + _iterator3.e(err) + } finally { + _iterator3.f() + } + + var final + + if (partial.length === 0) { + final = '{}' + } else { + var properties + + if (gap === '') { + properties = partial.join(',') + final = '{' + properties + '}' + } else { + var separator = ',\n' + indent + properties = partial.join(separator) + final = '{\n' + indent + properties + ',\n' + stepback + '}' + } + } + + stack.pop() + indent = stepback + return final + } + + function serializeKey(key) { + if (key.length === 0) { + return quoteString(key, true) + } + + var firstChar = String.fromCodePoint(key.codePointAt(0)) + + if (!util.isIdStartChar(firstChar)) { + return quoteString(key, true) + } + + for (var i = firstChar.length; i < key.length; i++) { + if ( + !util.isIdContinueChar(String.fromCodePoint(key.codePointAt(i))) + ) { + return quoteString(key, true) + } + } + + return key + } + + function serializeArray(value) { + if (stack.indexOf(value) >= 0) { + throw TypeError('Converting circular structure to JSON5') + } + + stack.push(value) + var stepback = indent + indent = indent + gap + var partial = [] + + for (var i = 0; i < value.length; i++) { + var propertyString = serializeProperty(String(i), value) + partial.push(propertyString !== undefined ? propertyString : 'null') + } + + var final + + if (partial.length === 0) { + final = '[]' + } else { + if (gap === '') { + var properties = partial.join(',') + final = '[' + properties + ']' + } else { + var separator = ',\n' + indent + + var _properties = partial.join(separator) + + final = '[\n' + indent + _properties + ',\n' + stepback + ']' + } + } + + stack.pop() + indent = stepback + return final + } + } + + var JSON5 = { + parse: parse, + stringify: stringify + } + var lib = JSON5 + var _default2 = lib + exports.default = _default2 + module.exports = exports.default + + /***/ + }, + + /***/ 36858: /***/ (module, exports) => { + 'use strict' + + function _typeof(obj) { + '@babel/helpers - typeof' + if ( + typeof Symbol === 'function' && + typeof Symbol.iterator === 'symbol' + ) { + _typeof = function _typeof(obj) { + return typeof obj + } + } else { + _typeof = function _typeof(obj) { + return obj && + typeof Symbol === 'function' && + obj.constructor === Symbol && + obj !== Symbol.prototype + ? 'symbol' + : typeof obj + } + } + return _typeof(obj) + } + + !(function (e) { + 'object' == (false ? 0 : _typeof(exports)) && 'undefined' != 'object' + ? (module.exports = e()) + : 'function' == typeof define && define.amd + ? define([], e) + : (('undefined' != typeof window + ? window + : 'undefined' != typeof global + ? global + : 'undefined' != typeof self + ? self + : this + ).jsyaml = e()) + })(function () { + return (function o(a, s, c) { + function u(t, e) { + if (!s[t]) { + if (!a[t]) { + var n = true && require + if (!e && n) return n(t, !0) + if (l) return l(t, !0) + var i = new Error("Cannot find module '" + t + "'") + throw ((i.code = 'MODULE_NOT_FOUND'), i) + } + + var r = (s[t] = { + exports: {} + }) + a[t][0].call( + r.exports, + function (e) { + return u(a[t][1][e] || e) + }, + r, + r.exports, + o, + a, + s, + c + ) + } + + return s[t].exports + } + + for (var l = true && require, e = 0; e < c.length; e++) { + u(c[e]) + } + + return u + })( + { + 1: [ + function (e, t, n) { + 'use strict' + + var i = e('./js-yaml/loader'), + r = e('./js-yaml/dumper') + + function o(e) { + return function () { + throw new Error( + 'Function ' + e + ' is deprecated and cannot be used.' + ) + } + } + + ;(t.exports.Type = e('./js-yaml/type')), + (t.exports.Schema = e('./js-yaml/schema')), + (t.exports.FAILSAFE_SCHEMA = e('./js-yaml/schema/failsafe')), + (t.exports.JSON_SCHEMA = e('./js-yaml/schema/json')), + (t.exports.CORE_SCHEMA = e('./js-yaml/schema/core')), + (t.exports.DEFAULT_SAFE_SCHEMA = e( + './js-yaml/schema/default_safe' + )), + (t.exports.DEFAULT_FULL_SCHEMA = e( + './js-yaml/schema/default_full' + )), + (t.exports.load = i.load), + (t.exports.loadAll = i.loadAll), + (t.exports.safeLoad = i.safeLoad), + (t.exports.safeLoadAll = i.safeLoadAll), + (t.exports.dump = r.dump), + (t.exports.safeDump = r.safeDump), + (t.exports.YAMLException = e('./js-yaml/exception')), + (t.exports.MINIMAL_SCHEMA = e('./js-yaml/schema/failsafe')), + (t.exports.SAFE_SCHEMA = e('./js-yaml/schema/default_safe')), + (t.exports.DEFAULT_SCHEMA = e( + './js-yaml/schema/default_full' + )), + (t.exports.scan = o('scan')), + (t.exports.parse = o('parse')), + (t.exports.compose = o('compose')), + (t.exports.addConstructor = o('addConstructor')) + }, + { + './js-yaml/dumper': 3, + './js-yaml/exception': 4, + './js-yaml/loader': 5, + './js-yaml/schema': 7, + './js-yaml/schema/core': 8, + './js-yaml/schema/default_full': 9, + './js-yaml/schema/default_safe': 10, + './js-yaml/schema/failsafe': 11, + './js-yaml/schema/json': 12, + './js-yaml/type': 13 + } + ], + 2: [ + function (e, t, n) { + 'use strict' + + function i(e) { + return null == e + } + + ;(t.exports.isNothing = i), + (t.exports.isObject = function (e) { + return 'object' == _typeof(e) && null !== e + }), + (t.exports.toArray = function (e) { + return Array.isArray(e) ? e : i(e) ? [] : [e] + }), + (t.exports.repeat = function (e, t) { + for (var n = '', i = 0; i < t; i += 1) { + n += e + } + + return n + }), + (t.exports.isNegativeZero = function (e) { + return 0 === e && Number.NEGATIVE_INFINITY === 1 / e + }), + (t.exports.extend = function (e, t) { + var n, i, r, o + if (t) + for ( + n = 0, i = (o = Object.keys(t)).length; + n < i; + n += 1 + ) { + e[(r = o[n])] = t[r] + } + return e + }) + }, + {} + ], + 3: [ + function (e, t, n) { + 'use strict' + + var c = e('./common'), + d = e('./exception'), + i = e('./schema/default_full'), + r = e('./schema/default_safe'), + p = Object.prototype.toString, + u = Object.prototype.hasOwnProperty, + o = 9, + h = 10, + a = 13, + s = 32, + m = 33, + g = 34, + y = 35, + x = 37, + v = 38, + A = 39, + b = 42, + w = 44, + C = 45, + k = 58, + j = 61, + S = 62, + I = 63, + O = 64, + E = 91, + F = 93, + _ = 96, + N = 123, + M = 124, + T = 125, + l = { + 0: '\\0', + 7: '\\a', + 8: '\\b', + 9: '\\t', + 10: '\\n', + 11: '\\v', + 12: '\\f', + 13: '\\r', + 27: '\\e', + 34: '\\"', + 92: '\\\\', + 133: '\\N', + 160: '\\_', + 8232: '\\L', + 8233: '\\P' + }, + f = [ + 'y', + 'Y', + 'yes', + 'Yes', + 'YES', + 'on', + 'On', + 'ON', + 'n', + 'N', + 'no', + 'No', + 'NO', + 'off', + 'Off', + 'OFF' + ] + + function L(e) { + var t, + n, + i = e.toString(16).toUpperCase() + if (e <= 255) (t = 'x'), (n = 2) + else if (e <= 65535) (t = 'u'), (n = 4) + else { + if (!(e <= 4294967295)) + throw new d( + 'code point within a string may not be greater than 0xFFFFFFFF' + ) + ;(t = 'U'), (n = 8) + } + return '\\' + t + c.repeat('0', n - i.length) + i + } + + function D(e) { + ;(this.schema = e.schema || i), + (this.indent = Math.max(1, e.indent || 2)), + (this.noArrayIndent = e.noArrayIndent || !1), + (this.skipInvalid = e.skipInvalid || !1), + (this.flowLevel = c.isNothing(e.flowLevel) + ? -1 + : e.flowLevel), + (this.styleMap = (function (e, t) { + var n, i, r, o, a, s, c + if (null === t) return {} + + for ( + n = {}, r = 0, o = (i = Object.keys(t)).length; + r < o; + r += 1 + ) { + ;(a = i[r]), + (s = String(t[a])), + '!!' === a.slice(0, 2) && + (a = 'tag:yaml.org,2002:' + a.slice(2)), + (c = e.compiledTypeMap.fallback[a]) && + u.call(c.styleAliases, s) && + (s = c.styleAliases[s]), + (n[a] = s) + } + + return n + })(this.schema, e.styles || null)), + (this.sortKeys = e.sortKeys || !1), + (this.lineWidth = e.lineWidth || 80), + (this.noRefs = e.noRefs || !1), + (this.noCompatMode = e.noCompatMode || !1), + (this.condenseFlow = e.condenseFlow || !1), + (this.implicitTypes = this.schema.compiledImplicit), + (this.explicitTypes = this.schema.compiledExplicit), + (this.tag = null), + (this.result = ''), + (this.duplicates = []), + (this.usedDuplicates = null) + } + + function U(e, t) { + for ( + var n, + i = c.repeat(' ', t), + r = 0, + o = -1, + a = '', + s = e.length; + r < s; + + ) { + ;(r = + -1 === (o = e.indexOf('\n', r)) + ? ((n = e.slice(r)), s) + : ((n = e.slice(r, o + 1)), o + 1)), + n.length && '\n' !== n && (a += i), + (a += n) + } + + return a + } + + function q(e, t) { + return '\n' + c.repeat(' ', e.indent * t) + } + + function Y(e) { + return e === s || e === o + } + + function R(e) { + return ( + (32 <= e && e <= 126) || + (161 <= e && e <= 55295 && 8232 !== e && 8233 !== e) || + (57344 <= e && e <= 65533 && 65279 !== e) || + (65536 <= e && e <= 1114111) + ) + } + + function B(e, t) { + return ( + R(e) && + 65279 !== e && + e !== w && + e !== E && + e !== F && + e !== N && + e !== T && + e !== k && + (e !== y || + (t && + R((n = t)) && + !Y(n) && + 65279 !== n && + n !== a && + n !== h)) + ) + var n + } + + function P(e) { + return /^\n* /.test(e) + } + + var W = 1, + K = 2, + $ = 3, + H = 4, + G = 5 + + function V(e, t, n, i, r) { + var o, + a, + s, + c, + u = !1, + l = !1, + p = -1 !== i, + f = -1, + d = + R((c = e.charCodeAt(0))) && + 65279 !== c && + !Y(c) && + c !== C && + c !== I && + c !== k && + c !== w && + c !== E && + c !== F && + c !== N && + c !== T && + c !== y && + c !== v && + c !== b && + c !== m && + c !== M && + c !== j && + c !== S && + c !== A && + c !== g && + c !== x && + c !== O && + c !== _ && + !Y(e.charCodeAt(e.length - 1)) + if (t) + for (o = 0; o < e.length; o++) { + if (!R((a = e.charCodeAt(o)))) return G + ;(s = 0 < o ? e.charCodeAt(o - 1) : null), + (d = d && B(a, s)) + } + else { + for (o = 0; o < e.length; o++) { + if ((a = e.charCodeAt(o)) === h) + (u = !0), + p && + ((l = l || (i < o - f - 1 && ' ' !== e[f + 1])), + (f = o)) + else if (!R(a)) return G + ;(s = 0 < o ? e.charCodeAt(o - 1) : null), + (d = d && B(a, s)) + } + + l = l || (p && i < o - f - 1 && ' ' !== e[f + 1]) + } + return u || l + ? 9 < n && P(e) + ? G + : l + ? H + : $ + : d && !r(e) + ? W + : K + } + + function Z(i, r, o, a) { + i.dump = (function () { + if (0 === r.length) return "''" + if (!i.noCompatMode && -1 !== f.indexOf(r)) + return "'" + r + "'" + var e = i.indent * Math.max(1, o), + t = + -1 === i.lineWidth + ? -1 + : Math.max( + Math.min(i.lineWidth, 40), + i.lineWidth - e + ), + n = a || (-1 < i.flowLevel && o >= i.flowLevel) + + switch ( + V(r, n, i.indent, t, function (e) { + return (function (e, t) { + for ( + var n = 0, i = e.implicitTypes.length; + n < i; + n += 1 + ) { + if (e.implicitTypes[n].resolve(t)) return !0 + } + + return !1 + })(i, e) + }) + ) { + case W: + return r + + case K: + return "'" + r.replace(/'/g, "''") + "'" + + case $: + return '|' + z(r, i.indent) + J(U(r, e)) + + case H: + return ( + '>' + + z(r, i.indent) + + J( + U( + (function (t, n) { + var e, + i, + r = /(\n+)([^\n]*)/g, + o = (function () { + var e = + -1 !== (e = t.indexOf('\n')) + ? e + : t.length + return ( + (r.lastIndex = e), Q(t.slice(0, e), n) + ) + })(), + a = '\n' === t[0] || ' ' === t[0] + + for (; (i = r.exec(t)); ) { + var s = i[1], + c = i[2] + ;(e = ' ' === c[0]), + (o += + s + + (a || e || '' === c ? '' : '\n') + + Q(c, n)), + (a = e) + } + + return o + })(r, t), + e + ) + ) + ) + + case G: + return ( + '"' + + (function (e) { + for ( + var t, n, i, r = '', o = 0; + o < e.length; + o++ + ) { + 55296 <= (t = e.charCodeAt(o)) && + t <= 56319 && + 56320 <= (n = e.charCodeAt(o + 1)) && + n <= 57343 + ? ((r += L( + 1024 * (t - 55296) + n - 56320 + 65536 + )), + o++) + : ((i = l[t]), + (r += !i && R(t) ? e[o] : i || L(t))) + } + + return r + })(r) + + '"' + ) + + default: + throw new d('impossible error: invalid scalar style') + } + })() + } + + function z(e, t) { + var n = P(e) ? String(t) : '', + i = '\n' === e[e.length - 1] + return ( + n + + (i && ('\n' === e[e.length - 2] || '\n' === e) + ? '+' + : i + ? '' + : '-') + + '\n' + ) + } + + function J(e) { + return '\n' === e[e.length - 1] ? e.slice(0, -1) : e + } + + function Q(e, t) { + if ('' === e || ' ' === e[0]) return e + + for ( + var n, i, r = / [^ ]/g, o = 0, a = 0, s = 0, c = ''; + (n = r.exec(e)); + + ) { + t < (s = n.index) - o && + ((i = o < a ? a : s), + (c += '\n' + e.slice(o, i)), + (o = i + 1)), + (a = s) + } + + return ( + (c += '\n'), + e.length - o > t && o < a + ? (c += e.slice(o, a) + '\n' + e.slice(a + 1)) + : (c += e.slice(o)), + c.slice(1) + ) + } + + function X(e, t, n) { + for ( + var i, + r, + o, + a = n ? e.explicitTypes : e.implicitTypes, + s = 0, + c = a.length; + s < c; + s += 1 + ) { + if ( + ((r = a[s]).instanceOf || r.predicate) && + (!r.instanceOf || + ('object' == _typeof(t) && + t instanceof r.instanceOf)) && + (!r.predicate || r.predicate(t)) + ) { + if (((e.tag = n ? r.tag : '?'), r.represent)) { + if ( + ((o = e.styleMap[r.tag] || r.defaultStyle), + '[object Function]' === p.call(r.represent)) + ) + i = r.represent(t, o) + else { + if (!u.call(r.represent, o)) + throw new d( + '!<' + + r.tag + + '> tag resolver accepts not "' + + o + + '" style' + ) + i = r.represent[o](t, o) + } + e.dump = i + } + + return 1 + } + } + } + + function ee(e, t, n, i, r, o) { + ;(e.tag = null), (e.dump = n), X(e, n, !1) || X(e, n, !0) + var a = p.call(e.dump) + i = i && (e.flowLevel < 0 || e.flowLevel > t) + var s, + c, + u = '[object Object]' === a || '[object Array]' === a + if ( + (u && (c = -1 !== (s = e.duplicates.indexOf(n))), + ((null !== e.tag && '?' !== e.tag) || + c || + (2 !== e.indent && 0 < t)) && + (r = !1), + c && e.usedDuplicates[s]) + ) + e.dump = '*ref_' + s + else { + if ( + (u && + c && + !e.usedDuplicates[s] && + (e.usedDuplicates[s] = !0), + '[object Object]' === a) + ) + i && 0 !== Object.keys(e.dump).length + ? ((function (e, t, n, i) { + var r, + o, + a, + s, + c, + u, + l = '', + p = e.tag, + f = Object.keys(n) + if (!0 === e.sortKeys) f.sort() + else if ('function' == typeof e.sortKeys) + f.sort(e.sortKeys) + else if (e.sortKeys) + throw new d( + 'sortKeys must be a boolean or a function' + ) + + for (r = 0, o = f.length; r < o; r += 1) { + ;(u = ''), + (i && 0 === r) || (u += q(e, t)), + (s = n[(a = f[r])]), + ee(e, t + 1, a, !0, !0, !0) && + ((c = + (null !== e.tag && '?' !== e.tag) || + (e.dump && 1024 < e.dump.length)) && + (e.dump && h === e.dump.charCodeAt(0) + ? (u += '?') + : (u += '? ')), + (u += e.dump), + c && (u += q(e, t)), + ee(e, t + 1, s, !0, c) && + (e.dump && h === e.dump.charCodeAt(0) + ? (u += ':') + : (u += ': '), + (l += u += e.dump))) + } + + ;(e.tag = p), (e.dump = l || '{}') + })(e, t, e.dump, r), + c && (e.dump = '&ref_' + s + e.dump)) + : ((function (e, t, n) { + for ( + var i, + r, + o, + a = '', + s = e.tag, + c = Object.keys(n), + u = 0, + l = c.length; + u < l; + u += 1 + ) { + ;(o = ''), + 0 !== u && (o += ', '), + e.condenseFlow && (o += '"'), + (r = n[(i = c[u])]), + ee(e, t, i, !1, !1) && + (1024 < e.dump.length && (o += '? '), + (o += + e.dump + + (e.condenseFlow ? '"' : '') + + ':' + + (e.condenseFlow ? '' : ' ')), + ee(e, t, r, !1, !1) && (a += o += e.dump)) + } + + ;(e.tag = s), (e.dump = '{' + a + '}') + })(e, t, e.dump), + c && (e.dump = '&ref_' + s + ' ' + e.dump)) + else if ('[object Array]' === a) { + var l = e.noArrayIndent && 0 < t ? t - 1 : t + i && 0 !== e.dump.length + ? ((function (e, t, n, i) { + for ( + var r = '', o = e.tag, a = 0, s = n.length; + a < s; + a += 1 + ) { + ee(e, t + 1, n[a], !0, !0) && + ((i && 0 === a) || (r += q(e, t)), + e.dump && h === e.dump.charCodeAt(0) + ? (r += '-') + : (r += '- '), + (r += e.dump)) + } + + ;(e.tag = o), (e.dump = r || '[]') + })(e, l, e.dump, r), + c && (e.dump = '&ref_' + s + e.dump)) + : ((function (e, t, n) { + for ( + var i = '', r = e.tag, o = 0, a = n.length; + o < a; + o += 1 + ) { + ee(e, t, n[o], !1, !1) && + (0 !== o && + (i += ',' + (e.condenseFlow ? '' : ' ')), + (i += e.dump)) + } + + ;(e.tag = r), (e.dump = '[' + i + ']') + })(e, l, e.dump), + c && (e.dump = '&ref_' + s + ' ' + e.dump)) + } else { + if ('[object String]' !== a) { + if (e.skipInvalid) return + throw new d( + 'unacceptable kind of an object to dump ' + a + ) + } + + '?' !== e.tag && Z(e, e.dump, t, o) + } + null !== e.tag && + '?' !== e.tag && + (e.dump = '!<' + e.tag + '> ' + e.dump) + } + return 1 + } + + function te(e, t) { + var n, + i, + r = [], + o = [] + + for ( + !(function e(t, n, i) { + var r, o, a + if (null !== t && 'object' == _typeof(t)) + if (-1 !== (o = n.indexOf(t))) + -1 === i.indexOf(o) && i.push(o) + else if ((n.push(t), Array.isArray(t))) + for (o = 0, a = t.length; o < a; o += 1) { + e(t[o], n, i) + } + else + for ( + r = Object.keys(t), o = 0, a = r.length; + o < a; + o += 1 + ) { + e(t[r[o]], n, i) + } + })(e, r, o), + n = 0, + i = o.length; + n < i; + n += 1 + ) { + t.duplicates.push(r[o[n]]) + } + + t.usedDuplicates = new Array(i) + } + + function ne(e, t) { + var n = new D((t = t || {})) + return ( + n.noRefs || te(e, n), + ee(n, 0, e, !0, !0) ? n.dump + '\n' : '' + ) + } + + ;(t.exports.dump = ne), + (t.exports.safeDump = function (e, t) { + return ne( + e, + c.extend( + { + schema: r + }, + t + ) + ) + }) + }, + { + './common': 2, + './exception': 4, + './schema/default_full': 9, + './schema/default_safe': 10 + } + ], + 4: [ + function (e, t, n) { + 'use strict' + + function i(e, t) { + Error.call(this), + (this.name = 'YAMLException'), + (this.reason = e), + (this.mark = t), + (this.message = + (this.reason || '(unknown reason)') + + (this.mark ? ' ' + this.mark.toString() : '')), + Error.captureStackTrace + ? Error.captureStackTrace(this, this.constructor) + : (this.stack = new Error().stack || '') + } + + ;(((i.prototype = Object.create( + Error.prototype + )).constructor = i).prototype.toString = function (e) { + var t = this.name + ': ' + return ( + (t += this.reason || '(unknown reason)'), + !e && this.mark && (t += ' ' + this.mark.toString()), + t + ) + }), + (t.exports = i) + }, + {} + ], + 5: [ + function (e, t, n) { + 'use strict' + + var g = e('./common'), + i = e('./exception'), + r = e('./mark'), + o = e('./schema/default_safe'), + a = e('./schema/default_full'), + y = Object.prototype.hasOwnProperty, + x = 1, + v = 2, + A = 3, + b = 4, + w = 1, + C = 2, + k = 3, + c = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/, + s = /[\x85\u2028\u2029]/, + j = /[,\[\]\{\}]/, + S = /^(?:!|!!|![a-z\-]+!)$/i, + I = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i + + function l(e) { + return Object.prototype.toString.call(e) + } + + function O(e) { + return 10 === e || 13 === e + } + + function E(e) { + return 9 === e || 32 === e + } + + function F(e) { + return 9 === e || 32 === e || 10 === e || 13 === e + } + + function _(e) { + return ( + 44 === e || 91 === e || 93 === e || 123 === e || 125 === e + ) + } + + function u(e) { + return 48 === e + ? '\0' + : 97 === e + ? '' + : 98 === e + ? '\b' + : 116 === e || 9 === e + ? '\t' + : 110 === e + ? '\n' + : 118 === e + ? '\v' + : 102 === e + ? '\f' + : 114 === e + ? '\r' + : 101 === e + ? '' + : 32 === e + ? ' ' + : 34 === e + ? '"' + : 47 === e + ? '/' + : 92 === e + ? '\\' + : 78 === e + ? '…' + : 95 === e + ? ' ' + : 76 === e + ? '\u2028' + : 80 === e + ? '\u2029' + : '' + } + + for ( + var f = new Array(256), d = new Array(256), p = 0; + p < 256; + p++ + ) { + ;(f[p] = u(p) ? 1 : 0), (d[p] = u(p)) + } + + function h(e, t) { + ;(this.input = e), + (this.filename = t.filename || null), + (this.schema = t.schema || a), + (this.onWarning = t.onWarning || null), + (this.legacy = t.legacy || !1), + (this.json = t.json || !1), + (this.listener = t.listener || null), + (this.implicitTypes = this.schema.compiledImplicit), + (this.typeMap = this.schema.compiledTypeMap), + (this.length = e.length), + (this.position = 0), + (this.line = 0), + (this.lineStart = 0), + (this.lineIndent = 0), + (this.documents = []) + } + + function m(e, t) { + return new i( + t, + new r( + e.filename, + e.input, + e.position, + e.line, + e.position - e.lineStart + ) + ) + } + + function N(e, t) { + throw m(e, t) + } + + function M(e, t) { + e.onWarning && e.onWarning.call(null, m(e, t)) + } + + var T = { + YAML: function YAML(e, t, n) { + var i, r, o + null !== e.version && + N(e, 'duplication of %YAML directive'), + 1 !== n.length && + N(e, 'YAML directive accepts exactly one argument'), + null === (i = /^([0-9]+)\.([0-9]+)$/.exec(n[0])) && + N(e, 'ill-formed argument of the YAML directive'), + (r = parseInt(i[1], 10)), + (o = parseInt(i[2], 10)), + 1 !== r && + N(e, 'unacceptable YAML version of the document'), + (e.version = n[0]), + (e.checkLineBreaks = o < 2), + 1 !== o && + 2 !== o && + M(e, 'unsupported YAML version of the document') + }, + TAG: function TAG(e, t, n) { + var i, r + 2 !== n.length && + N(e, 'TAG directive accepts exactly two arguments'), + (i = n[0]), + (r = n[1]), + S.test(i) || + N( + e, + 'ill-formed tag handle (first argument) of the TAG directive' + ), + y.call(e.tagMap, i) && + N( + e, + 'there is a previously declared suffix for "' + + i + + '" tag handle' + ), + I.test(r) || + N( + e, + 'ill-formed tag prefix (second argument) of the TAG directive' + ), + (e.tagMap[i] = r) + } + } + + function L(e, t, n, i) { + var r, o, a, s + + if (t < n) { + if (((s = e.input.slice(t, n)), i)) + for (r = 0, o = s.length; r < o; r += 1) { + 9 === (a = s.charCodeAt(r)) || + (32 <= a && a <= 1114111) || + N(e, 'expected valid JSON character') + } + else + c.test(s) && + N(e, 'the stream contains non-printable characters') + e.result += s + } + } + + function D(e, t, n, i) { + var r, o, a, s + + for ( + g.isObject(n) || + N( + e, + 'cannot merge mappings; the provided source object is unacceptable' + ), + a = 0, + s = (r = Object.keys(n)).length; + a < s; + a += 1 + ) { + ;(o = r[a]), y.call(t, o) || ((t[o] = n[o]), (i[o] = !0)) + } + } + + function U(e, t, n, i, r, o, a, s) { + var c, u + if (Array.isArray(r)) + for ( + c = 0, u = (r = Array.prototype.slice.call(r)).length; + c < u; + c += 1 + ) { + Array.isArray(r[c]) && + N(e, 'nested arrays are not supported inside keys'), + 'object' == _typeof(r) && + '[object Object]' === l(r[c]) && + (r[c] = '[object Object]') + } + if ( + ('object' == _typeof(r) && + '[object Object]' === l(r) && + (r = '[object Object]'), + (r = String(r)), + null === t && (t = {}), + 'tag:yaml.org,2002:merge' === i) + ) { + if (Array.isArray(o)) + for (c = 0, u = o.length; c < u; c += 1) { + D(e, t, o[c], n) + } + else D(e, t, o, n) + } else + e.json || + y.call(n, r) || + !y.call(t, r) || + ((e.line = a || e.line), + (e.position = s || e.position), + N(e, 'duplicated mapping key')), + (t[r] = o), + delete n[r] + return t + } + + function q(e) { + var t = e.input.charCodeAt(e.position) + 10 === t + ? e.position++ + : 13 === t + ? (e.position++, + 10 === e.input.charCodeAt(e.position) && e.position++) + : N(e, 'a line break is expected'), + (e.line += 1), + (e.lineStart = e.position) + } + + function Y(e, t, n) { + for ( + var i = 0, r = e.input.charCodeAt(e.position); + 0 !== r; + + ) { + for (; E(r); ) { + r = e.input.charCodeAt(++e.position) + } + + if (t && 35 === r) + for ( + ; + 10 !== (r = e.input.charCodeAt(++e.position)) && + 13 !== r && + 0 !== r; + + ) {} + if (!O(r)) break + + for ( + q(e), + r = e.input.charCodeAt(e.position), + i++, + e.lineIndent = 0; + 32 === r; + + ) { + e.lineIndent++, (r = e.input.charCodeAt(++e.position)) + } + } + + return ( + -1 !== n && + 0 !== i && + e.lineIndent < n && + M(e, 'deficient indentation'), + i + ) + } + + function R(e) { + var t = e.position, + n = e.input.charCodeAt(t) + return (45 !== n && 46 !== n) || + n !== e.input.charCodeAt(t + 1) || + n !== e.input.charCodeAt(t + 2) || + ((t += 3), 0 !== (n = e.input.charCodeAt(t)) && !F(n)) + ? void 0 + : 1 + } + + function B(e, t) { + 1 === t + ? (e.result += ' ') + : 1 < t && (e.result += g.repeat('\n', t - 1)) + } + + function P(e, t) { + var n, + i, + r, + o, + a, + s, + c, + u, + l, + p = e.input.charCodeAt(e.position) + + if (34 === p) { + for ( + e.kind = 'scalar', + e.result = '', + e.position++, + n = i = e.position; + 0 !== (p = e.input.charCodeAt(e.position)); + + ) { + if (34 === p) + return L(e, n, e.position, !0), e.position++, 1 + + if (92 === p) { + if ( + (L(e, n, e.position, !0), + O((p = e.input.charCodeAt(++e.position)))) + ) + Y(e, !1, t) + else if (p < 256 && f[p]) + (e.result += d[p]), e.position++ + else if ( + 0 < + (a = + 120 === (l = p) + ? 2 + : 117 === l + ? 4 + : 85 === l + ? 8 + : 0) + ) { + for (r = a, o = 0; 0 < r; r--) { + ;(p = e.input.charCodeAt(++e.position)), + (u = void 0), + 0 <= + (a = + 48 <= (c = p) && c <= 57 + ? c - 48 + : 97 <= (u = 32 | c) && u <= 102 + ? u - 97 + 10 + : -1) + ? (o = (o << 4) + a) + : N(e, 'expected hexadecimal character') + } + + ;(e.result += + (s = o) <= 65535 + ? String.fromCharCode(s) + : String.fromCharCode( + 55296 + ((s - 65536) >> 10), + 56320 + ((s - 65536) & 1023) + )), + e.position++ + } else N(e, 'unknown escape sequence') + n = i = e.position + } else + O(p) + ? (L(e, n, i, !0), + B(e, Y(e, !1, t)), + (n = i = e.position)) + : e.position === e.lineStart && R(e) + ? N( + e, + 'unexpected end of the document within a double quoted scalar' + ) + : (e.position++, (i = e.position)) + } + + N( + e, + 'unexpected end of the stream within a double quoted scalar' + ) + } + } + + function W(e, t) { + var n, + i, + r = e.tag, + o = e.anchor, + a = [], + s = !1 + + for ( + null !== e.anchor && (e.anchorMap[e.anchor] = a), + i = e.input.charCodeAt(e.position); + 0 !== i && + 45 === i && + F(e.input.charCodeAt(e.position + 1)); + + ) { + if ( + ((s = !0), + e.position++, + Y(e, !0, -1) && e.lineIndent <= t) + ) + a.push(null), (i = e.input.charCodeAt(e.position)) + else if ( + ((n = e.line), + K(e, t, A, !1, !0), + a.push(e.result), + Y(e, !0, -1), + (i = e.input.charCodeAt(e.position)), + (e.line === n || e.lineIndent > t) && 0 !== i) + ) + N(e, 'bad indentation of a sequence entry') + else if (e.lineIndent < t) break + } + + return ( + !!s && + ((e.tag = r), + (e.anchor = o), + (e.kind = 'sequence'), + (e.result = a), + !0) + ) + } + + function K(e, t, n, i, r) { + var o, + a, + s, + c, + u, + l, + p, + f, + d = 1, + h = !1, + m = !1 + if ( + (null !== e.listener && e.listener('open', e), + (e.tag = null), + (e.anchor = null), + (e.kind = null), + (e.result = null), + (o = a = s = b === n || A === n), + i && + Y(e, !0, -1) && + ((h = !0), + e.lineIndent > t + ? (d = 1) + : e.lineIndent === t + ? (d = 0) + : e.lineIndent < t && (d = -1)), + 1 === d) + ) + for ( + ; + (function (e) { + var t, + n, + i, + r = !1, + o = !1, + a = e.input.charCodeAt(e.position) + + if (33 === a) { + if ( + (null !== e.tag && + N(e, 'duplication of a tag property'), + 60 === (a = e.input.charCodeAt(++e.position)) + ? ((r = !0), + (a = e.input.charCodeAt(++e.position))) + : 33 === a + ? ((o = !0), + (n = '!!'), + (a = e.input.charCodeAt(++e.position))) + : (n = '!'), + (t = e.position), + r) + ) { + for ( + ; + 0 !== (a = e.input.charCodeAt(++e.position)) && + 62 !== a; + + ) {} + + e.position < e.length + ? ((i = e.input.slice(t, e.position)), + (a = e.input.charCodeAt(++e.position))) + : N( + e, + 'unexpected end of the stream within a verbatim tag' + ) + } else { + for (; 0 !== a && !F(a); ) { + 33 === a && + (o + ? N( + e, + 'tag suffix cannot contain exclamation marks' + ) + : ((n = e.input.slice(t - 1, e.position + 1)), + S.test(n) || + N( + e, + 'named tag handle cannot contain such characters' + ), + (o = !0), + (t = e.position + 1))), + (a = e.input.charCodeAt(++e.position)) + } + + ;(i = e.input.slice(t, e.position)), + j.test(i) && + N( + e, + 'tag suffix cannot contain flow indicator characters' + ) + } + + return ( + i && + !I.test(i) && + N( + e, + 'tag name cannot contain such characters: ' + i + ), + r + ? (e.tag = i) + : y.call(e.tagMap, n) + ? (e.tag = e.tagMap[n] + i) + : '!' === n + ? (e.tag = '!' + i) + : '!!' === n + ? (e.tag = 'tag:yaml.org,2002:' + i) + : N(e, 'undeclared tag handle "' + n + '"'), + 1 + ) + } + })(e) || + (function (e) { + var t, + n = e.input.charCodeAt(e.position) + + if (38 === n) { + for ( + null !== e.anchor && + N(e, 'duplication of an anchor property'), + n = e.input.charCodeAt(++e.position), + t = e.position; + 0 !== n && !F(n) && !_(n); + + ) { + n = e.input.charCodeAt(++e.position) + } + + return ( + e.position === t && + N( + e, + 'name of an anchor node must contain at least one character' + ), + (e.anchor = e.input.slice(t, e.position)), + 1 + ) + } + })(e); + + ) { + Y(e, !0, -1) + ? ((h = !0), + (s = o), + e.lineIndent > t + ? (d = 1) + : e.lineIndent === t + ? (d = 0) + : e.lineIndent < t && (d = -1)) + : (s = !1) + } + if ( + ((s = s && (h || r)), + (1 !== d && b !== n) || + ((p = x === n || v === n ? t : t + 1), + (f = e.position - e.lineStart), + 1 === d + ? (s && + (W(e, f) || + (function (e, t, n) { + var i, + r, + o, + a, + s, + c = e.tag, + u = e.anchor, + l = {}, + p = {}, + f = null, + d = null, + h = null, + m = !1, + g = !1 + + for ( + null !== e.anchor && + (e.anchorMap[e.anchor] = l), + s = e.input.charCodeAt(e.position); + 0 !== s; + + ) { + if ( + ((i = e.input.charCodeAt(e.position + 1)), + (o = e.line), + (a = e.position), + (63 !== s && 58 !== s) || !F(i)) + ) { + if (!K(e, n, v, !1, !0)) break + + if (e.line === o) { + for ( + s = e.input.charCodeAt(e.position); + E(s); + + ) { + s = e.input.charCodeAt(++e.position) + } + + if (58 === s) + F( + (s = e.input.charCodeAt(++e.position)) + ) || + N( + e, + 'a whitespace character is expected after the key-value separator within a block mapping' + ), + m && + (U(e, l, p, f, d, null), + (f = d = h = null)), + (r = m = !(g = !0)), + (f = e.tag), + (d = e.result) + else { + if (!g) + return (e.tag = c), (e.anchor = u), 1 + N( + e, + 'can not read an implicit mapping pair; a colon is missed' + ) + } + } else { + if (!g) + return (e.tag = c), (e.anchor = u), 1 + N( + e, + 'can not read a block mapping entry; a multiline key may not be an implicit key' + ) + } + } else + 63 === s + ? (m && + (U(e, l, p, f, d, null), + (f = d = h = null)), + (r = m = g = !0)) + : m + ? (r = !(m = !1)) + : N( + e, + 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line' + ), + (e.position += 1), + (s = i) + + if ( + ((e.line === o || e.lineIndent > t) && + (K(e, t, b, !0, r) && + (m ? (d = e.result) : (h = e.result)), + m || + (U(e, l, p, f, d, h, o, a), + (f = d = h = null)), + Y(e, !0, -1), + (s = e.input.charCodeAt(e.position))), + e.lineIndent > t && 0 !== s) + ) + N(e, 'bad indentation of a mapping entry') + else if (e.lineIndent < t) break + } + + return ( + m && U(e, l, p, f, d, null), + g && + ((e.tag = c), + (e.anchor = u), + (e.kind = 'mapping'), + (e.result = l)), + g + ) + })(e, f, p))) || + (function (e, t) { + var n, + i, + r, + o, + a, + s, + c, + u, + l, + p = !0, + f = e.tag, + d = e.anchor, + h = {}, + m = e.input.charCodeAt(e.position) + if (91 === m) (s = !(r = 93)), (i = []) + else { + if (123 !== m) return + ;(r = 125), (s = !0), (i = {}) + } + + for ( + null !== e.anchor && (e.anchorMap[e.anchor] = i), + m = e.input.charCodeAt(++e.position); + 0 !== m; + + ) { + if ( + (Y(e, !0, t), + (m = e.input.charCodeAt(e.position)) === r) + ) + return ( + e.position++, + (e.tag = f), + (e.anchor = d), + (e.kind = s ? 'mapping' : 'sequence'), + (e.result = i), + 1 + ) + p || + N( + e, + 'missed comma between flow collection entries' + ), + (l = null), + (o = a = !1), + 63 === m && + F(e.input.charCodeAt(e.position + 1)) && + ((o = a = !0), e.position++, Y(e, !0, t)), + (n = e.line), + K(e, t, x, !1, !0), + (u = e.tag), + (c = e.result), + Y(e, !0, t), + (m = e.input.charCodeAt(e.position)), + (!a && e.line !== n) || + 58 !== m || + ((o = !0), + (m = e.input.charCodeAt(++e.position)), + Y(e, !0, t), + K(e, t, x, !1, !0), + (l = e.result)), + s + ? U(e, i, h, u, c, l) + : o + ? i.push(U(e, null, h, u, c, l)) + : i.push(c), + Y(e, !0, t), + 44 === (m = e.input.charCodeAt(e.position)) + ? ((p = !0), + (m = e.input.charCodeAt(++e.position))) + : (p = !1) + } + + N( + e, + 'unexpected end of the stream within a flow collection' + ) + })(e, p) + ? (m = !0) + : ((a && + (function (e, t) { + var n, + i, + r, + o, + a = w, + s = !1, + c = !1, + u = t, + l = 0, + p = !1, + f = e.input.charCodeAt(e.position) + if (124 === f) i = !1 + else { + if (62 !== f) return + i = !0 + } + + for ( + e.kind = 'scalar', e.result = ''; + 0 !== f; + + ) { + if ( + 43 === + (f = e.input.charCodeAt(++e.position)) || + 45 === f + ) + w === a + ? (a = 43 === f ? k : C) + : N( + e, + 'repeat of a chomping mode identifier' + ) + else { + if ( + !( + 0 <= + (r = + 48 <= (o = f) && o <= 57 + ? o - 48 + : -1) + ) + ) + break + 0 == r + ? N( + e, + 'bad explicit indentation width of a block scalar; it cannot be less than one' + ) + : c + ? N( + e, + 'repeat of an indentation width identifier' + ) + : ((u = t + r - 1), (c = !0)) + } + } + + if (E(f)) { + for ( + ; + E((f = e.input.charCodeAt(++e.position))); + + ) {} + + if (35 === f) + for ( + ; + !O( + (f = e.input.charCodeAt(++e.position)) + ) && 0 !== f; + + ) {} + } + + for (; 0 !== f; ) { + for ( + q(e), + e.lineIndent = 0, + f = e.input.charCodeAt(e.position); + (!c || e.lineIndent < u) && 32 === f; + + ) { + e.lineIndent++, + (f = e.input.charCodeAt(++e.position)) + } + + if ( + (!c && + e.lineIndent > u && + (u = e.lineIndent), + O(f)) + ) + l++ + else { + if (e.lineIndent < u) { + a === k + ? (e.result += g.repeat( + '\n', + s ? 1 + l : l + )) + : a === w && s && (e.result += '\n') + break + } + + for ( + i + ? E(f) + ? ((p = !0), + (e.result += g.repeat( + '\n', + s ? 1 + l : l + ))) + : p + ? ((p = !1), + (e.result += g.repeat('\n', l + 1))) + : 0 === l + ? s && (e.result += ' ') + : (e.result += g.repeat('\n', l)) + : (e.result += g.repeat( + '\n', + s ? 1 + l : l + )), + c = s = !0, + l = 0, + n = e.position; + !O(f) && 0 !== f; + + ) { + f = e.input.charCodeAt(++e.position) + } + + L(e, n, e.position, !1) + } + } + + return 1 + })(e, p)) || + (function (e, t) { + var n, + i, + r = e.input.charCodeAt(e.position) + + if (39 === r) { + for ( + e.kind = 'scalar', + e.result = '', + e.position++, + n = i = e.position; + 0 !== (r = e.input.charCodeAt(e.position)); + + ) { + if (39 === r) { + if ( + (L(e, n, e.position, !0), + 39 !== + (r = e.input.charCodeAt(++e.position))) + ) + return 1 + ;(n = e.position), + e.position++, + (i = e.position) + } else + O(r) + ? (L(e, n, i, !0), + B(e, Y(e, !1, t)), + (n = i = e.position)) + : e.position === e.lineStart && R(e) + ? N( + e, + 'unexpected end of the document within a single quoted scalar' + ) + : (e.position++, (i = e.position)) + } + + N( + e, + 'unexpected end of the stream within a single quoted scalar' + ) + } + })(e, p) || + P(e, p) + ? (m = !0) + : !(function (e) { + var t, + n, + i = e.input.charCodeAt(e.position) + + if (42 === i) { + for ( + i = e.input.charCodeAt(++e.position), + t = e.position; + 0 !== i && !F(i) && !_(i); + + ) { + i = e.input.charCodeAt(++e.position) + } + + return ( + e.position === t && + N( + e, + 'name of an alias node must contain at least one character' + ), + (n = e.input.slice(t, e.position)), + e.anchorMap.hasOwnProperty(n) || + N(e, 'unidentified alias "' + n + '"'), + (e.result = e.anchorMap[n]), + Y(e, !0, -1), + 1 + ) + } + })(e) + ? (function (e, t, n) { + var i, + r, + o, + a, + s, + c, + u, + l = e.kind, + p = e.result, + f = e.input.charCodeAt(e.position) + + if ( + !F(f) && + !_(f) && + 35 !== f && + 38 !== f && + 42 !== f && + 33 !== f && + 124 !== f && + 62 !== f && + 39 !== f && + 34 !== f && + 37 !== f && + 64 !== f && + 96 !== f && + ((63 !== f && 45 !== f) || + !( + F( + (i = e.input.charCodeAt( + e.position + 1 + )) + ) || + (n && _(i)) + )) + ) { + for ( + e.kind = 'scalar', + e.result = '', + r = o = e.position, + a = !1; + 0 !== f; + + ) { + if (58 === f) { + if ( + F( + (i = e.input.charCodeAt( + e.position + 1 + )) + ) || + (n && _(i)) + ) + break + } else if (35 === f) { + if ( + F(e.input.charCodeAt(e.position - 1)) + ) + break + } else { + if ( + (e.position === e.lineStart && + R(e)) || + (n && _(f)) + ) + break + + if (O(f)) { + if ( + ((s = e.line), + (c = e.lineStart), + (u = e.lineIndent), + Y(e, !1, -1), + e.lineIndent >= t) + ) { + ;(a = !0), + (f = e.input.charCodeAt( + e.position + )) + continue + } + + ;(e.position = o), + (e.line = s), + (e.lineStart = c), + (e.lineIndent = u) + break + } + } + + a && + (L(e, r, o, !1), + B(e, e.line - s), + (r = o = e.position), + (a = !1)), + E(f) || (o = e.position + 1), + (f = e.input.charCodeAt(++e.position)) + } + + if ((L(e, r, o, !1), e.result)) return 1 + ;(e.kind = l), (e.result = p) + } + })(e, p, x === n) && + ((m = !0), null === e.tag && (e.tag = '?')) + : ((m = !0), + (null === e.tag && null === e.anchor) || + N( + e, + 'alias node should not have any properties' + )), + null !== e.anchor && + (e.anchorMap[e.anchor] = e.result)) + : 0 === d && (m = s && W(e, f))), + null !== e.tag && '!' !== e.tag) + ) + if ('?' === e.tag) { + for ( + null !== e.result && + 'scalar' !== e.kind && + N( + e, + 'unacceptable node kind for ! tag; it should be "scalar", not "' + + e.kind + + '"' + ), + c = 0, + u = e.implicitTypes.length; + c < u; + c += 1 + ) { + if ((l = e.implicitTypes[c]).resolve(e.result)) { + ;(e.result = l.construct(e.result)), + (e.tag = l.tag), + null !== e.anchor && + (e.anchorMap[e.anchor] = e.result) + break + } + } + } else + y.call(e.typeMap[e.kind || 'fallback'], e.tag) + ? ((l = e.typeMap[e.kind || 'fallback'][e.tag]), + null !== e.result && + l.kind !== e.kind && + N( + e, + 'unacceptable node kind for !<' + + e.tag + + '> tag; it should be "' + + l.kind + + '", not "' + + e.kind + + '"' + ), + l.resolve(e.result) + ? ((e.result = l.construct(e.result)), + null !== e.anchor && + (e.anchorMap[e.anchor] = e.result)) + : N( + e, + 'cannot resolve a node with !<' + + e.tag + + '> explicit tag' + )) + : N(e, 'unknown tag !<' + e.tag + '>') + return ( + null !== e.listener && e.listener('close', e), + null !== e.tag || null !== e.anchor || m + ) + } + + function $(e, t) { + ;(t = t || {}), + 0 !== (e = String(e)).length && + (10 !== e.charCodeAt(e.length - 1) && + 13 !== e.charCodeAt(e.length - 1) && + (e += '\n'), + 65279 === e.charCodeAt(0) && (e = e.slice(1))) + var n = new h(e, t), + i = e.indexOf('\0') + + for ( + -1 !== i && + ((n.position = i), + N(n, 'null byte is not allowed in input')), + n.input += '\0'; + 32 === n.input.charCodeAt(n.position); + + ) { + ;(n.lineIndent += 1), (n.position += 1) + } + + for (; n.position < n.length - 1; ) { + !(function (e) { + var t, + n, + i, + r, + o = e.position, + a = !1 + + for ( + e.version = null, + e.checkLineBreaks = e.legacy, + e.tagMap = {}, + e.anchorMap = {}; + 0 !== (r = e.input.charCodeAt(e.position)) && + (Y(e, !0, -1), + (r = e.input.charCodeAt(e.position)), + !(0 < e.lineIndent || 37 !== r)); + + ) { + for ( + a = !0, + r = e.input.charCodeAt(++e.position), + t = e.position; + 0 !== r && !F(r); + + ) { + r = e.input.charCodeAt(++e.position) + } + + for ( + i = [], + (n = e.input.slice(t, e.position)).length < 1 && + N( + e, + 'directive name must not be less than one character in length' + ); + 0 !== r; + + ) { + for (; E(r); ) { + r = e.input.charCodeAt(++e.position) + } + + if (35 === r) { + for ( + ; + 0 !== (r = e.input.charCodeAt(++e.position)) && + !O(r); + + ) {} + + break + } + + if (O(r)) break + + for (t = e.position; 0 !== r && !F(r); ) { + r = e.input.charCodeAt(++e.position) + } + + i.push(e.input.slice(t, e.position)) + } + + 0 !== r && q(e), + y.call(T, n) + ? T[n](e, n, i) + : M(e, 'unknown document directive "' + n + '"') + } + + Y(e, !0, -1), + 0 === e.lineIndent && + 45 === e.input.charCodeAt(e.position) && + 45 === e.input.charCodeAt(e.position + 1) && + 45 === e.input.charCodeAt(e.position + 2) + ? ((e.position += 3), Y(e, !0, -1)) + : a && N(e, 'directives end mark is expected'), + K(e, e.lineIndent - 1, b, !1, !0), + Y(e, !0, -1), + e.checkLineBreaks && + s.test(e.input.slice(o, e.position)) && + M( + e, + 'non-ASCII line breaks are interpreted as content' + ), + e.documents.push(e.result), + e.position === e.lineStart && R(e) + ? 46 === e.input.charCodeAt(e.position) && + ((e.position += 3), Y(e, !0, -1)) + : e.position < e.length - 1 && + N( + e, + 'end of the stream or a document separator is expected' + ) + })(n) + } + + return n.documents + } + + function H(e, t, n) { + null !== t && + 'object' == _typeof(t) && + void 0 === n && + ((n = t), (t = null)) + var i = $(e, n) + if ('function' != typeof t) return i + + for (var r = 0, o = i.length; r < o; r += 1) { + t(i[r]) + } + } + + function G(e, t) { + var n = $(e, t) + + if (0 !== n.length) { + if (1 === n.length) return n[0] + throw new i( + 'expected a single document in the stream, but found more' + ) + } + } + + ;(t.exports.loadAll = H), + (t.exports.load = G), + (t.exports.safeLoadAll = function (e, t, n) { + return ( + 'object' == _typeof(t) && + null !== t && + void 0 === n && + ((n = t), (t = null)), + H( + e, + t, + g.extend( + { + schema: o + }, + n + ) + ) + ) + }), + (t.exports.safeLoad = function (e, t) { + return G( + e, + g.extend( + { + schema: o + }, + t + ) + ) + }) + }, + { + './common': 2, + './exception': 4, + './mark': 6, + './schema/default_full': 9, + './schema/default_safe': 10 + } + ], + 6: [ + function (e, t, n) { + 'use strict' + + var s = e('./common') + + function i(e, t, n, i, r) { + ;(this.name = e), + (this.buffer = t), + (this.position = n), + (this.line = i), + (this.column = r) + } + + ;(i.prototype.getSnippet = function (e, t) { + var n, i, r, o, a + if (!this.buffer) return null + + for ( + e = e || 4, t = t || 75, n = '', i = this.position; + 0 < i && + -1 === + '\0\r\n\x85\u2028\u2029'.indexOf( + this.buffer.charAt(i - 1) + ); + + ) { + if ((--i, this.position - i > t / 2 - 1)) { + ;(n = ' ... '), (i += 5) + break + } + } + + for ( + r = '', o = this.position; + o < this.buffer.length && + -1 === + '\0\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(o)); + + ) { + if ((o += 1) - this.position > t / 2 - 1) { + ;(r = ' ... '), (o -= 5) + break + } + } + + return ( + (a = this.buffer.slice(i, o)), + s.repeat(' ', e) + + n + + a + + r + + '\n' + + s.repeat(' ', e + this.position - i + n.length) + + '^' + ) + }), + (i.prototype.toString = function (e) { + var t, + n = '' + return ( + this.name && (n += 'in "' + this.name + '" '), + (n += + 'at line ' + + (this.line + 1) + + ', column ' + + (this.column + 1)), + e || ((t = this.getSnippet()) && (n += ':\n' + t)), + n + ) + }), + (t.exports = i) + }, + { + './common': 2 + } + ], + 7: [ + function (e, t, n) { + 'use strict' + + var r = e('./common'), + o = e('./exception'), + a = e('./type') + + function s(e, t, i) { + var r = [] + return ( + e.include.forEach(function (e) { + i = s(e, t, i) + }), + e[t].forEach(function (n) { + i.forEach(function (e, t) { + e.tag === n.tag && e.kind === n.kind && r.push(t) + }), + i.push(n) + }), + i.filter(function (e, t) { + return -1 === r.indexOf(t) + }) + ) + } + + function c(e) { + ;(this.include = e.include || []), + (this.implicit = e.implicit || []), + (this.explicit = e.explicit || []), + this.implicit.forEach(function (e) { + if (e.loadKind && 'scalar' !== e.loadKind) + throw new o( + 'There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.' + ) + }), + (this.compiledImplicit = s(this, 'implicit', [])), + (this.compiledExplicit = s(this, 'explicit', [])), + (this.compiledTypeMap = (function () { + var e, + t, + n = { + scalar: {}, + sequence: {}, + mapping: {}, + fallback: {} + } + + function i(e) { + n[e.kind][e.tag] = n.fallback[e.tag] = e + } + + for (e = 0, t = arguments.length; e < t; e += 1) { + arguments[e].forEach(i) + } + + return n + })(this.compiledImplicit, this.compiledExplicit)) + } + + ;(c.DEFAULT = null), + (c.create = function (e, t) { + var n, i + + switch (arguments.length) { + case 1: + ;(n = c.DEFAULT), (i = e) + break + + case 2: + ;(n = e), (i = t) + break + + default: + throw new o( + 'Wrong number of arguments for Schema.create function' + ) + } + + if ( + ((n = r.toArray(n)), + (i = r.toArray(i)), + !n.every(function (e) { + return e instanceof c + })) + ) + throw new o( + 'Specified list of super schemas (or a single Schema object) contains a non-Schema object.' + ) + if ( + !i.every(function (e) { + return e instanceof a + }) + ) + throw new o( + 'Specified list of YAML types (or a single Type object) contains a non-Type object.' + ) + return new c({ + include: n, + explicit: i + }) + }), + (t.exports = c) + }, + { + './common': 2, + './exception': 4, + './type': 13 + } + ], + 8: [ + function (e, t, n) { + 'use strict' + + var i = e('../schema') + t.exports = new i({ + include: [e('./json')] + }) + }, + { + '../schema': 7, + './json': 12 + } + ], + 9: [ + function (e, t, n) { + 'use strict' + + var i = e('../schema') + t.exports = i.DEFAULT = new i({ + include: [e('./default_safe')], + explicit: [ + e('../type/js/undefined'), + e('../type/js/regexp'), + e('../type/js/function') + ] + }) + }, + { + '../schema': 7, + '../type/js/function': 18, + '../type/js/regexp': 19, + '../type/js/undefined': 20, + './default_safe': 10 + } + ], + 10: [ + function (e, t, n) { + 'use strict' + + var i = e('../schema') + t.exports = new i({ + include: [e('./core')], + implicit: [e('../type/timestamp'), e('../type/merge')], + explicit: [ + e('../type/binary'), + e('../type/omap'), + e('../type/pairs'), + e('../type/set') + ] + }) + }, + { + '../schema': 7, + '../type/binary': 14, + '../type/merge': 22, + '../type/omap': 24, + '../type/pairs': 25, + '../type/set': 27, + '../type/timestamp': 29, + './core': 8 + } + ], + 11: [ + function (e, t, n) { + 'use strict' + + var i = e('../schema') + t.exports = new i({ + explicit: [ + e('../type/str'), + e('../type/seq'), + e('../type/map') + ] + }) + }, + { + '../schema': 7, + '../type/map': 21, + '../type/seq': 26, + '../type/str': 28 + } + ], + 12: [ + function (e, t, n) { + 'use strict' + + var i = e('../schema') + t.exports = new i({ + include: [e('./failsafe')], + implicit: [ + e('../type/null'), + e('../type/bool'), + e('../type/int'), + e('../type/float') + ] + }) + }, + { + '../schema': 7, + '../type/bool': 15, + '../type/float': 16, + '../type/int': 17, + '../type/null': 23, + './failsafe': 11 + } + ], + 13: [ + function (e, t, n) { + 'use strict' + + var r = e('./exception'), + o = [ + 'kind', + 'resolve', + 'construct', + 'instanceOf', + 'predicate', + 'represent', + 'defaultStyle', + 'styleAliases' + ], + a = ['scalar', 'sequence', 'mapping'] + + t.exports = function (t, e) { + var n, i + if ( + ((e = e || {}), + Object.keys(e).forEach(function (e) { + if (-1 === o.indexOf(e)) + throw new r( + 'Unknown option "' + + e + + '" is met in definition of "' + + t + + '" YAML type.' + ) + }), + (this.tag = t), + (this.kind = e.kind || null), + (this.resolve = + e.resolve || + function () { + return !0 + }), + (this.construct = + e.construct || + function (e) { + return e + }), + (this.instanceOf = e.instanceOf || null), + (this.predicate = e.predicate || null), + (this.represent = e.represent || null), + (this.defaultStyle = e.defaultStyle || null), + (this.styleAliases = + ((n = e.styleAliases || null), + (i = {}), + null !== n && + Object.keys(n).forEach(function (t) { + n[t].forEach(function (e) { + i[String(e)] = t + }) + }), + i)), + -1 === a.indexOf(this.kind)) + ) + throw new r( + 'Unknown kind "' + + this.kind + + '" is specified for "' + + t + + '" YAML type.' + ) + } + }, + { + './exception': 4 + } + ], + 14: [ + function (e, t, n) { + 'use strict' + + try { + var c = e('buffer').Buffer + } catch (e) {} + + var i = e('../type'), + u = + 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r' + t.exports = new i('tag:yaml.org,2002:binary', { + kind: 'scalar', + resolve: function resolve(e) { + if (null === e) return !1 + + for (var t, n = 0, i = e.length, r = u, o = 0; o < i; o++) { + if (!(64 < (t = r.indexOf(e.charAt(o))))) { + if (t < 0) return !1 + n += 6 + } + } + + return n % 8 == 0 + }, + construct: function construct(e) { + for ( + var t, + n = e.replace(/[\r\n=]/g, ''), + i = n.length, + r = u, + o = 0, + a = [], + s = 0; + s < i; + s++ + ) { + s % 4 == 0 && + s && + (a.push((o >> 16) & 255), + a.push((o >> 8) & 255), + a.push(255 & o)), + (o = (o << 6) | r.indexOf(n.charAt(s))) + } + + return ( + 0 == (t = (i % 4) * 6) + ? (a.push((o >> 16) & 255), + a.push((o >> 8) & 255), + a.push(255 & o)) + : 18 == t + ? (a.push((o >> 10) & 255), a.push((o >> 2) & 255)) + : 12 == t && a.push((o >> 4) & 255), + c ? (c.from ? c.from(a) : new c(a)) : a + ) + }, + predicate: function predicate(e) { + return c && c.isBuffer(e) + }, + represent: function represent(e) { + for ( + var t, n = '', i = 0, r = e.length, o = u, a = 0; + a < r; + a++ + ) { + a % 3 == 0 && + a && + ((n += o[(i >> 18) & 63]), + (n += o[(i >> 12) & 63]), + (n += o[(i >> 6) & 63]), + (n += o[63 & i])), + (i = (i << 8) + e[a]) + } + + return ( + 0 == (t = r % 3) + ? ((n += o[(i >> 18) & 63]), + (n += o[(i >> 12) & 63]), + (n += o[(i >> 6) & 63]), + (n += o[63 & i])) + : 2 == t + ? ((n += o[(i >> 10) & 63]), + (n += o[(i >> 4) & 63]), + (n += o[(i << 2) & 63]), + (n += o[64])) + : 1 == t && + ((n += o[(i >> 2) & 63]), + (n += o[(i << 4) & 63]), + (n += o[64]), + (n += o[64])), + n + ) + } + }) + }, + { + '../type': 13 + } + ], + 15: [ + function (e, t, n) { + 'use strict' + + var i = e('../type') + t.exports = new i('tag:yaml.org,2002:bool', { + kind: 'scalar', + resolve: function resolve(e) { + if (null === e) return !1 + var t = e.length + return ( + (4 === t && + ('true' === e || 'True' === e || 'TRUE' === e)) || + (5 === t && + ('false' === e || 'False' === e || 'FALSE' === e)) + ) + }, + construct: function construct(e) { + return 'true' === e || 'True' === e || 'TRUE' === e + }, + predicate: function predicate(e) { + return ( + '[object Boolean]' === Object.prototype.toString.call(e) + ) + }, + represent: { + lowercase: function lowercase(e) { + return e ? 'true' : 'false' + }, + uppercase: function uppercase(e) { + return e ? 'TRUE' : 'FALSE' + }, + camelcase: function camelcase(e) { + return e ? 'True' : 'False' + } + }, + defaultStyle: 'lowercase' + }) + }, + { + '../type': 13 + } + ], + 16: [ + function (e, t, n) { + 'use strict' + + var i = e('../common'), + r = e('../type'), + o = new RegExp( + '^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$' + ) + var a = /^[-+]?[0-9]+e/ + t.exports = new r('tag:yaml.org,2002:float', { + kind: 'scalar', + resolve: function resolve(e) { + return ( + null !== e && !(!o.test(e) || '_' === e[e.length - 1]) + ) + }, + construct: function construct(e) { + var t, + n = e.replace(/_/g, '').toLowerCase(), + i = '-' === n[0] ? -1 : 1, + r = [] + return ( + 0 <= '+-'.indexOf(n[0]) && (n = n.slice(1)), + '.inf' === n + ? 1 == i + ? Number.POSITIVE_INFINITY + : Number.NEGATIVE_INFINITY + : '.nan' === n + ? NaN + : 0 <= n.indexOf(':') + ? (n.split(':').forEach(function (e) { + r.unshift(parseFloat(e, 10)) + }), + (n = 0), + (t = 1), + r.forEach(function (e) { + ;(n += e * t), (t *= 60) + }), + i * n) + : i * parseFloat(n, 10) + ) + }, + predicate: function predicate(e) { + return ( + '[object Number]' === Object.prototype.toString.call(e) && + (e % 1 != 0 || i.isNegativeZero(e)) + ) + }, + represent: function represent(e, t) { + var n + if (isNaN(e)) + switch (t) { + case 'lowercase': + return '.nan' + + case 'uppercase': + return '.NAN' + + case 'camelcase': + return '.NaN' + } + else if (Number.POSITIVE_INFINITY === e) + switch (t) { + case 'lowercase': + return '.inf' + + case 'uppercase': + return '.INF' + + case 'camelcase': + return '.Inf' + } + else if (Number.NEGATIVE_INFINITY === e) + switch (t) { + case 'lowercase': + return '-.inf' + + case 'uppercase': + return '-.INF' + + case 'camelcase': + return '-.Inf' + } + else if (i.isNegativeZero(e)) return '-0.0' + return ( + (n = e.toString(10)), a.test(n) ? n.replace('e', '.e') : n + ) + }, + defaultStyle: 'lowercase' + }) + }, + { + '../common': 2, + '../type': 13 + } + ], + 17: [ + function (e, t, n) { + 'use strict' + + var i = e('../common'), + r = e('../type') + t.exports = new r('tag:yaml.org,2002:int', { + kind: 'scalar', + resolve: function resolve(e) { + if (null === e) return !1 + var t, + n, + i, + r, + o = e.length, + a = 0, + s = !1 + if (!o) return !1 + + if ( + (('-' !== (t = e[a]) && '+' !== t) || (t = e[++a]), + '0' === t) + ) { + if (a + 1 === o) return !0 + + if ('b' === (t = e[++a])) { + for (a++; a < o; a++) { + if ('_' !== (t = e[a])) { + if ('0' !== t && '1' !== t) return !1 + s = !0 + } + } + + return s && '_' !== t + } + + if ('x' === t) { + for (a++; a < o; a++) { + if ('_' !== (t = e[a])) { + if ( + !( + (48 <= (i = e.charCodeAt(a)) && i <= 57) || + (65 <= i && i <= 70) || + (97 <= i && i <= 102) + ) + ) + return !1 + s = !0 + } + } + + return s && '_' !== t + } + + for (; a < o; a++) { + if ('_' !== (t = e[a])) { + if (!(48 <= (n = e.charCodeAt(a)) && n <= 55)) + return !1 + s = !0 + } + } + + return s && '_' !== t + } + + if ('_' === t) return !1 + + for (; a < o; a++) { + if ('_' !== (t = e[a])) { + if (':' === t) break + if (!(48 <= (r = e.charCodeAt(a)) && r <= 57)) return !1 + s = !0 + } + } + + return ( + !(!s || '_' === t) && + (':' !== t || /^(:[0-5]?[0-9])+$/.test(e.slice(a))) + ) + }, + construct: function construct(e) { + var t, + n, + i = e, + r = 1, + o = [] + return ( + -1 !== i.indexOf('_') && (i = i.replace(/_/g, '')), + ('-' !== (t = i[0]) && '+' !== t) || + ('-' === t && (r = -1), (t = (i = i.slice(1))[0])), + '0' === i + ? 0 + : '0' === t + ? 'b' === i[1] + ? r * parseInt(i.slice(2), 2) + : 'x' === i[1] + ? r * parseInt(i, 16) + : r * parseInt(i, 8) + : -1 !== i.indexOf(':') + ? (i.split(':').forEach(function (e) { + o.unshift(parseInt(e, 10)) + }), + (i = 0), + (n = 1), + o.forEach(function (e) { + ;(i += e * n), (n *= 60) + }), + r * i) + : r * parseInt(i, 10) + ) + }, + predicate: function predicate(e) { + return ( + '[object Number]' === Object.prototype.toString.call(e) && + e % 1 == 0 && + !i.isNegativeZero(e) + ) + }, + represent: { + binary: function binary(e) { + return 0 <= e + ? '0b' + e.toString(2) + : '-0b' + e.toString(2).slice(1) + }, + octal: function octal(e) { + return 0 <= e + ? '0' + e.toString(8) + : '-0' + e.toString(8).slice(1) + }, + decimal: function decimal(e) { + return e.toString(10) + }, + hexadecimal: function hexadecimal(e) { + return 0 <= e + ? '0x' + e.toString(16).toUpperCase() + : '-0x' + e.toString(16).toUpperCase().slice(1) + } + }, + defaultStyle: 'decimal', + styleAliases: { + binary: [2, 'bin'], + octal: [8, 'oct'], + decimal: [10, 'dec'], + hexadecimal: [16, 'hex'] + } + }) + }, + { + '../common': 2, + '../type': 13 + } + ], + 18: [ + function (e, t, n) { + 'use strict' + + try { + var o = e('esprima') + } catch (e) { + 'undefined' != typeof window && (o = window.esprima) + } + + var i = e('../../type') + t.exports = new i('tag:yaml.org,2002:js/function', { + kind: 'scalar', + resolve: function resolve(e) { + if (null === e) return !1 + + try { + var t = '(' + e + ')', + n = o.parse(t, { + range: !0 + }) + return 'Program' !== n.type || + 1 !== n.body.length || + 'ExpressionStatement' !== n.body[0].type || + ('ArrowFunctionExpression' !== + n.body[0].expression.type && + 'FunctionExpression' !== n.body[0].expression.type) + ? !1 + : !0 + } catch (e) { + return !1 + } + }, + construct: function construct(e) { + var t, + n = '(' + e + ')', + i = o.parse(n, { + range: !0 + }), + r = [] + if ( + 'Program' !== i.type || + 1 !== i.body.length || + 'ExpressionStatement' !== i.body[0].type || + ('ArrowFunctionExpression' !== + i.body[0].expression.type && + 'FunctionExpression' !== i.body[0].expression.type) + ) + throw new Error('Failed to resolve function') + return ( + i.body[0].expression.params.forEach(function (e) { + r.push(e.name) + }), + (t = i.body[0].expression.body.range), + 'BlockStatement' === i.body[0].expression.body.type + ? new Function(r, n.slice(t[0] + 1, t[1] - 1)) + : new Function(r, 'return ' + n.slice(t[0], t[1])) + ) + }, + predicate: function predicate(e) { + return ( + '[object Function]' === Object.prototype.toString.call(e) + ) + }, + represent: function represent(e) { + return e.toString() + } + }) + }, + { + '../../type': 13 + } + ], + 19: [ + function (e, t, n) { + 'use strict' + + var i = e('../../type') + t.exports = new i('tag:yaml.org,2002:js/regexp', { + kind: 'scalar', + resolve: function resolve(e) { + if (null === e) return !1 + if (0 === e.length) return !1 + var t = e, + n = /\/([gim]*)$/.exec(e), + i = '' + + if ('/' === t[0]) { + if ((n && (i = n[1]), 3 < i.length)) return !1 + if ('/' !== t[t.length - i.length - 1]) return !1 + } + + return !0 + }, + construct: function construct(e) { + var t = e, + n = /\/([gim]*)$/.exec(e), + i = '' + return ( + '/' === t[0] && + (n && (i = n[1]), + (t = t.slice(1, t.length - i.length - 1))), + new RegExp(t, i) + ) + }, + predicate: function predicate(e) { + return ( + '[object RegExp]' === Object.prototype.toString.call(e) + ) + }, + represent: function represent(e) { + var t = '/' + e.source + '/' + return ( + e.global && (t += 'g'), + e.multiline && (t += 'm'), + e.ignoreCase && (t += 'i'), + t + ) + } + }) + }, + { + '../../type': 13 + } + ], + 20: [ + function (e, t, n) { + 'use strict' + + var i = e('../../type') + t.exports = new i('tag:yaml.org,2002:js/undefined', { + kind: 'scalar', + resolve: function resolve() { + return !0 + }, + construct: function construct() {}, + predicate: function predicate(e) { + return void 0 === e + }, + represent: function represent() { + return '' + } + }) + }, + { + '../../type': 13 + } + ], + 21: [ + function (e, t, n) { + 'use strict' + + var i = e('../type') + t.exports = new i('tag:yaml.org,2002:map', { + kind: 'mapping', + construct: function construct(e) { + return null !== e ? e : {} + } + }) + }, + { + '../type': 13 + } + ], + 22: [ + function (e, t, n) { + 'use strict' + + var i = e('../type') + t.exports = new i('tag:yaml.org,2002:merge', { + kind: 'scalar', + resolve: function resolve(e) { + return '<<' === e || null === e + } + }) + }, + { + '../type': 13 + } + ], + 23: [ + function (e, t, n) { + 'use strict' + + var i = e('../type') + t.exports = new i('tag:yaml.org,2002:null', { + kind: 'scalar', + resolve: function resolve(e) { + if (null === e) return !0 + var t = e.length + return ( + (1 === t && '~' === e) || + (4 === t && + ('null' === e || 'Null' === e || 'NULL' === e)) + ) + }, + construct: function construct() { + return null + }, + predicate: function predicate(e) { + return null === e + }, + represent: { + canonical: function canonical() { + return '~' + }, + lowercase: function lowercase() { + return 'null' + }, + uppercase: function uppercase() { + return 'NULL' + }, + camelcase: function camelcase() { + return 'Null' + } + }, + defaultStyle: 'lowercase' + }) + }, + { + '../type': 13 + } + ], + 24: [ + function (e, t, n) { + 'use strict' + + var i = e('../type'), + c = Object.prototype.hasOwnProperty, + u = Object.prototype.toString + t.exports = new i('tag:yaml.org,2002:omap', { + kind: 'sequence', + resolve: function resolve(e) { + if (null === e) return !0 + + for ( + var t, n, i, r = [], o = e, a = 0, s = o.length; + a < s; + a += 1 + ) { + if ( + ((t = o[a]), (i = !1), '[object Object]' !== u.call(t)) + ) + return !1 + + for (n in t) { + if (c.call(t, n)) { + if (i) return !1 + i = !0 + } + } + + if (!i) return !1 + if (-1 !== r.indexOf(n)) return !1 + r.push(n) + } + + return !0 + }, + construct: function construct(e) { + return null !== e ? e : [] + } + }) + }, + { + '../type': 13 + } + ], + 25: [ + function (e, t, n) { + 'use strict' + + var i = e('../type'), + s = Object.prototype.toString + t.exports = new i('tag:yaml.org,2002:pairs', { + kind: 'sequence', + resolve: function resolve(e) { + if (null === e) return !0 + + for ( + var t, + n, + i = e, + r = new Array(i.length), + o = 0, + a = i.length; + o < a; + o += 1 + ) { + if (((t = i[o]), '[object Object]' !== s.call(t))) + return !1 + if (1 !== (n = Object.keys(t)).length) return !1 + r[o] = [n[0], t[n[0]]] + } + + return !0 + }, + construct: function construct(e) { + if (null === e) return [] + + for ( + var t, + n, + i = e, + r = new Array(i.length), + o = 0, + a = i.length; + o < a; + o += 1 + ) { + ;(t = i[o]), + (n = Object.keys(t)), + (r[o] = [n[0], t[n[0]]]) + } + + return r + } + }) + }, + { + '../type': 13 + } + ], + 26: [ + function (e, t, n) { + 'use strict' + + var i = e('../type') + t.exports = new i('tag:yaml.org,2002:seq', { + kind: 'sequence', + construct: function construct(e) { + return null !== e ? e : [] + } + }) + }, + { + '../type': 13 + } + ], + 27: [ + function (e, t, n) { + 'use strict' + + var i = e('../type'), + r = Object.prototype.hasOwnProperty + t.exports = new i('tag:yaml.org,2002:set', { + kind: 'mapping', + resolve: function resolve(e) { + if (null === e) return !0 + var t, + n = e + + for (t in n) { + if (r.call(n, t) && null !== n[t]) return !1 + } + + return !0 + }, + construct: function construct(e) { + return null !== e ? e : {} + } + }) + }, + { + '../type': 13 + } + ], + 28: [ + function (e, t, n) { + 'use strict' + + var i = e('../type') + t.exports = new i('tag:yaml.org,2002:str', { + kind: 'scalar', + construct: function construct(e) { + return null !== e ? e : '' + } + }) + }, + { + '../type': 13 + } + ], + 29: [ + function (e, t, n) { + 'use strict' + + var i = e('../type'), + p = new RegExp( + '^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$' + ), + f = new RegExp( + '^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$' + ) + t.exports = new i('tag:yaml.org,2002:timestamp', { + kind: 'scalar', + resolve: function resolve(e) { + return ( + null !== e && (null !== p.exec(e) || null !== f.exec(e)) + ) + }, + construct: function construct(e) { + var t, + n, + i, + r, + o, + a, + s, + c = 0, + u = null, + l = p.exec(e) + if ((null === l && (l = f.exec(e)), null === l)) + throw new Error('Date resolve error') + if (((t = +l[1]), (n = l[2] - 1), (i = +l[3]), !l[4])) + return new Date(Date.UTC(t, n, i)) + + if (((r = +l[4]), (o = +l[5]), (a = +l[6]), l[7])) { + for (c = l[7].slice(0, 3); c.length < 3; ) { + c += '0' + } + + c = +c + } + + return ( + l[9] && + ((u = 6e4 * (60 * +l[10] + +(l[11] || 0))), + '-' === l[9] && (u = -u)), + (s = new Date(Date.UTC(t, n, i, r, o, a, c))), + u && s.setTime(s.getTime() - u), + s + ) + }, + instanceOf: Date, + represent: function represent(e) { + return e.toISOString() + } + }) + }, + { + '../type': 13 + } + ], + '/': [ + function (e, t, n) { + 'use strict' + + var i = e('./lib/js-yaml.js') + t.exports = i + }, + { + './lib/js-yaml.js': 1 + } + ] + }, + {}, + [] + )('/') + }) + + /***/ + }, + + /***/ 49298: /***/ (module, exports, __webpack_require__) => { + if (true) { + var f = __webpack_require__(35747) + if (f.default) f = f.default + exports.default = f + module.exports = exports.default + } + + /***/ + }, + + /***/ 82399: /***/ (module, exports, __webpack_require__) => { + 'use strict' + + Object.defineProperty(exports, '__esModule', { + value: true + }) + exports.default = void 0 + + var _utils = __webpack_require__(14497) + + var _readFile = __webpack_require__(86950) + + var _writeFile2 = __webpack_require__(61596) + + function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError('Cannot call a class as a function') + } + } + + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i] + descriptor.enumerable = descriptor.enumerable || false + descriptor.configurable = true + if ('value' in descriptor) descriptor.writable = true + Object.defineProperty(target, descriptor.key, descriptor) + } + } + + function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps) + if (staticProps) _defineProperties(Constructor, staticProps) + return Constructor + } + + var getDefaults = function getDefaults() { + return { + loadPath: '/locales/{{lng}}/{{ns}}.json', + addPath: '/locales/{{lng}}/{{ns}}.missing.json', + ident: 2, + parse: JSON.parse, + stringify: JSON.stringify + } + } + + var Backend = (function () { + function Backend(services) { + var options = + arguments.length > 1 && arguments[1] !== undefined + ? arguments[1] + : {} + var allOptions = + arguments.length > 2 && arguments[2] !== undefined + ? arguments[2] + : {} + + _classCallCheck(this, Backend) + + this.services = services + this.options = options + this.allOptions = allOptions + this.type = 'backend' + this.init(services, options, allOptions) + } + + _createClass(Backend, [ + { + key: 'init', + value: function init(services) { + var options = + arguments.length > 1 && arguments[1] !== undefined + ? arguments[1] + : {} + var allOptions = + arguments.length > 2 && arguments[2] !== undefined + ? arguments[2] + : {} + this.services = services + this.options = (0, _utils.defaults)( + options, + this.options || {}, + getDefaults() + ) + this.allOptions = allOptions + this.queuedWrites = {} + this.debouncedWrite = (0, _utils.debounce)(this.write, 250) + } + }, + { + key: 'read', + value: function read(language, namespace, callback) { + var loadPath = this.options.loadPath + + if (typeof this.options.loadPath === 'function') { + loadPath = this.options.loadPath(language, namespace) + } + + var filename = this.services.interpolator.interpolate(loadPath, { + lng: language, + ns: namespace + }) + + if (this.allOptions.initImmediate === false) { + try { + var resources = (0, _readFile.readFileSync)( + filename, + this.options + ) + callback(null, resources) + } catch (err) { + callback(err, false) + } + + return + } + + ;(0, _readFile.readFile)(filename, this.options) + .then(function (resources) { + return callback(null, resources) + }) + .catch(function (err) { + return callback(err, false) + }) + } + }, + { + key: 'create', + value: function create( + languages, + namespace, + key, + fallbackValue, + callback + ) { + var _this = this + + if (!callback) callback = function callback() {} + if (typeof languages === 'string') languages = [languages] + var todo = languages.length + + var done = function done() { + if (!--todo) callback() + } + + languages.forEach(function (lng) { + _this.queue.call( + _this, + lng, + namespace, + key, + fallbackValue, + done + ) + }) + } + }, + { + key: 'write', + value: function write() { + for (var lng in this.queuedWrites) { + var namespaces = this.queuedWrites[lng] + + if (lng !== 'locks') { + for (var ns in namespaces) { + this.writeFile(lng, ns) + } + } + } + } + }, + { + key: 'writeFile', + value: function writeFile(lng, namespace) { + var _this2 = this + + var lock = (0, _utils.getPath)(this.queuedWrites, [ + 'locks', + lng, + namespace + ]) + if (lock) return + var addPath = this.options.addPath + + if (typeof this.options.addPath === 'function') { + addPath = this.options.addPath(lng, namespace) + } + + var filename = this.services.interpolator.interpolate(addPath, { + lng: lng, + ns: namespace + }) + var missings = (0, _utils.getPath)(this.queuedWrites, [ + lng, + namespace + ]) + ;(0, _utils.setPath)(this.queuedWrites, [lng, namespace], []) + + if (missings.length) { + ;(0, _utils.setPath)( + this.queuedWrites, + ['locks', lng, namespace], + true + ) + + var proceed = function proceed(resources) { + missings.forEach(function (missing) { + var path = + _this2.allOptions.keySeparator === false + ? [missing.key] + : missing.key.split( + _this2.allOptions.keySeparator || '.' + ) + ;(0, _utils.setPath)(resources, path, missing.fallbackValue) + }) + + var proceedWrite = function proceedWrite() { + ;(0, _utils.setPath)( + _this2.queuedWrites, + ['locks', lng, namespace], + false + ) + missings.forEach(function (missing) { + if (missing.callback) missing.callback() + }) + + _this2.debouncedWrite() + } + + ;(0, _writeFile2.writeFile)( + filename, + resources, + _this2.options + ) + .then(proceedWrite) + .catch(proceedWrite) + } + + ;(0, _readFile.readFile)(filename, this.options) + .then(proceed) + .catch(function () { + return proceed({}) + }) + } + } + }, + { + key: 'queue', + value: function queue( + lng, + namespace, + key, + fallbackValue, + callback + ) { + ;(0, _utils.pushPath)(this.queuedWrites, [lng, namespace], { + key: key, + fallbackValue: fallbackValue || '', + callback: callback + }) + this.debouncedWrite() + } + } + ]) + + return Backend + })() + + Backend.type = 'backend' + var _default = Backend + exports.default = _default + module.exports = exports.default + + /***/ + }, + + /***/ 86950: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + function _typeof(obj) { + '@babel/helpers - typeof' + if ( + typeof Symbol === 'function' && + typeof Symbol.iterator === 'symbol' + ) { + _typeof = function _typeof(obj) { + return typeof obj + } + } else { + _typeof = function _typeof(obj) { + return obj && + typeof Symbol === 'function' && + obj.constructor === Symbol && + obj !== Symbol.prototype + ? 'symbol' + : typeof obj + } + } + return _typeof(obj) + } + + Object.defineProperty(exports, '__esModule', { + value: true + }) + exports.readFileSync = readFileSync + exports.readFile = readFile + + var _json = _interopRequireDefault(__webpack_require__(61006)) + + var YAMLDummy = _interopRequireWildcard(__webpack_require__(36858)) + + var fsMod = _interopRequireWildcard(__webpack_require__(49298)) + + var _extname = _interopRequireDefault(__webpack_require__(61852)) + + function _getRequireWildcardCache() { + if (typeof WeakMap !== 'function') return null + var cache = new WeakMap() + _getRequireWildcardCache = function _getRequireWildcardCache() { + return cache + } + return cache + } + + function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj + } + if ( + obj === null || + (_typeof(obj) !== 'object' && typeof obj !== 'function') + ) { + return { default: obj } + } + var cache = _getRequireWildcardCache() + if (cache && cache.has(obj)) { + return cache.get(obj) + } + var newObj = {} + var hasPropertyDescriptor = + Object.defineProperty && Object.getOwnPropertyDescriptor + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor + ? Object.getOwnPropertyDescriptor(obj, key) + : null + if (desc && (desc.get || desc.set)) { + Object.defineProperty(newObj, key, desc) + } else { + newObj[key] = obj[key] + } + } + } + newObj.default = obj + if (cache) { + cache.set(obj, newObj) + } + return newObj + } + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj } + } + + var isDeno = typeof Deno !== 'undefined' + var YAML = + typeof YAMLDummy !== 'undefined' && YAMLDummy.safeLoad + ? YAMLDummy + : typeof global !== 'undefined' + ? global.jsyaml + : typeof window !== 'undefined' + ? window.jsyaml + : undefined + var fs = fsMod ? fsMod.default || fsMod : undefined + + var readFileInNodeSync = function readFileInNodeSync(filename) { + return fs.readFileSync(filename, 'utf8') + } + + var readFileInNode = function readFileInNode(filename) { + return new Promise(function (resolve, reject) { + return fs.readFile(filename, 'utf8', function (err, data) { + return err ? reject(err) : resolve(data) + }) + }) + } + + var readFileInDenoSync = function readFileInDenoSync(filename) { + var decoder = new TextDecoder('utf-8') + var data = Deno.readFileSync(filename) + return decoder.decode(data) + } + + var readFileInDeno = function readFileInDeno(filename) { + return new Promise(function (resolve, reject) { + var decoder = new TextDecoder('utf-8') + Deno.readFile(filename) + .then(function (data) { + resolve(decoder.decode(data)) + }) + .catch(reject) + }) + } + + var parseData = function parseData(extension, data, options) { + data = data.replace(/^\uFEFF/, '') + var result = {} + + switch (extension) { + case '.js': + case '.ts': + if (false) { + } + + result = eval(data) + break + + case '.json5': + result = _json.default.parse(data) + break + + case '.yml': + case '.yaml': + result = YAML.safeLoad(data) + break + + default: + result = options.parse(data) + } + + return result + } + + function readFileSync(filename, options) { + var ext = (0, _extname.default)(filename) + + if (['.js', '.ts'].indexOf(ext) > -1 && 'function' !== 'undefined') { + return require(!filename.startsWith('/') && + typeof process !== 'undefined' && + process.cwd + ? ''.concat(process.cwd(), '/').concat(filename) + : filename) + } + + var data + + if (isDeno) { + data = readFileInDenoSync(filename) + } else { + data = readFileInNodeSync(filename) + } + + return parseData(ext, data, options) + } + + function readFile(filename) { + var options = + arguments.length > 1 && arguments[1] !== undefined + ? arguments[1] + : { + parse: JSON.parse + } + var ext = (0, _extname.default)(filename) + + if (['.js', '.ts'].indexOf(ext) > -1 && 'function' !== 'undefined') { + return new Promise(function (resolve, reject) { + try { + resolve( + require(!filename.startsWith('/') && + typeof process !== 'undefined' && + process.cwd + ? ''.concat(process.cwd(), '/').concat(filename) + : filename) + ) + } catch (err) { + reject(err) + } + }) + } + + var fn = isDeno ? readFileInDeno : readFileInNode + return new Promise(function (resolve, reject) { + fn(filename) + .then(function (data) { + try { + var ret = parseData(ext, data, options) + resolve(ret) + } catch (err) { + err.message = 'error parsing ' + filename + ': ' + err.message + reject(err) + } + }) + .catch(reject) + }) + } + + /***/ + }, + + /***/ 14497: /***/ (__unused_webpack_module, exports) => { + 'use strict' + + Object.defineProperty(exports, '__esModule', { + value: true + }) + exports.defaults = defaults + exports.debounce = debounce + exports.setPath = setPath + exports.pushPath = pushPath + exports.getPath = getPath + var arr = [] + var each = arr.forEach + var slice = arr.slice + + function defaults(obj) { + each.call(slice.call(arguments, 1), function (source) { + if (source) { + for (var prop in source) { + if (obj[prop] === undefined) obj[prop] = source[prop] + } + } + }) + return obj + } + + function debounce(func, wait, immediate) { + var timeout + return function () { + var context = this + var args = arguments + + var later = function later() { + timeout = null + if (!immediate) func.apply(context, args) + } + + var callNow = immediate && !timeout + clearTimeout(timeout) + timeout = setTimeout(later, wait) + if (callNow) func.apply(context, args) + } + } + + function getLastOfPath(object, path, Empty) { + function cleanKey(key) { + return key && key.indexOf('###') > -1 ? key.replace(/###/g, '.') : key + } + + var stack = typeof path !== 'string' ? [].concat(path) : path.split('.') + + while (stack.length > 1) { + if (!object) return {} + var key = cleanKey(stack.shift()) + if (!object[key] && Empty) object[key] = new Empty() + object = object[key] + } + + if (!object) return {} + return { + obj: object, + k: cleanKey(stack.shift()) + } + } + + function setPath(object, path, newValue) { + var _getLastOfPath = getLastOfPath(object, path, Object), + obj = _getLastOfPath.obj, + k = _getLastOfPath.k + + obj[k] = newValue + } + + function pushPath(object, path, newValue, concat) { + var _getLastOfPath2 = getLastOfPath(object, path, Object), + obj = _getLastOfPath2.obj, + k = _getLastOfPath2.k + + obj[k] = obj[k] || [] + if (concat) obj[k] = obj[k].concat(newValue) + if (!concat) obj[k].push(newValue) + } + + function getPath(object, path) { + var _getLastOfPath3 = getLastOfPath(object, path), + obj = _getLastOfPath3.obj, + k = _getLastOfPath3.k + + if (!obj) return undefined + return obj[k] + } + + /***/ + }, + + /***/ 61596: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + 'use strict' + + function _typeof(obj) { + '@babel/helpers - typeof' + if ( + typeof Symbol === 'function' && + typeof Symbol.iterator === 'symbol' + ) { + _typeof = function _typeof(obj) { + return typeof obj + } + } else { + _typeof = function _typeof(obj) { + return obj && + typeof Symbol === 'function' && + obj.constructor === Symbol && + obj !== Symbol.prototype + ? 'symbol' + : typeof obj + } + } + return _typeof(obj) + } + + Object.defineProperty(exports, '__esModule', { + value: true + }) + exports.writeFileSync = writeFileSync + exports.writeFile = writeFile + + var _json = _interopRequireDefault(__webpack_require__(61006)) + + var YAMLDummy = _interopRequireWildcard(__webpack_require__(36858)) + + var fsMod = _interopRequireWildcard(__webpack_require__(49298)) + + var _extname = _interopRequireDefault(__webpack_require__(61852)) + + function _getRequireWildcardCache() { + if (typeof WeakMap !== 'function') return null + var cache = new WeakMap() + _getRequireWildcardCache = function _getRequireWildcardCache() { + return cache + } + return cache + } + + function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj + } + if ( + obj === null || + (_typeof(obj) !== 'object' && typeof obj !== 'function') + ) { + return { default: obj } + } + var cache = _getRequireWildcardCache() + if (cache && cache.has(obj)) { + return cache.get(obj) + } + var newObj = {} + var hasPropertyDescriptor = + Object.defineProperty && Object.getOwnPropertyDescriptor + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor + ? Object.getOwnPropertyDescriptor(obj, key) + : null + if (desc && (desc.get || desc.set)) { + Object.defineProperty(newObj, key, desc) + } else { + newObj[key] = obj[key] + } + } + } + newObj.default = obj + if (cache) { + cache.set(obj, newObj) + } + return newObj + } + + function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj } + } + + var isDeno = typeof Deno !== 'undefined' + var YAML = + typeof YAMLDummy !== 'undefined' && YAMLDummy.safeLoad + ? YAMLDummy + : typeof global !== 'undefined' + ? global.jsyaml + : typeof window !== 'undefined' + ? window.jsyaml + : undefined + var fs = fsMod ? fsMod.default || fsMod : undefined + + var writeFileInNodeSync = function writeFileInNodeSync( + filename, + payload + ) { + return fs.writeFileSync(filename, payload, 'utf8') + } + + var writeFileInNode = function writeFileInNode(filename, payload) { + return new Promise(function (resolve, reject) { + return fs.writeFile(filename, payload, 'utf8', function (err, data) { + return err ? reject(err) : resolve(data) + }) + }) + } + + var writeFileInDenoSync = function writeFileInDenoSync( + filename, + payload + ) { + var encoder = new TextEncoder() + var data = encoder.encode(payload) + Deno.writeFileSync(filename, data) + } + + var writeFileInDeno = function writeFileInDeno(filename, payload) { + var encoder = new TextEncoder() + var data = encoder.encode(payload) + return Deno.writeFile(filename, data) + } + + var stringifyData = function stringifyData(extension, data, options) { + var result = '' + + switch (extension) { + case '.js': + case '.ts': + if (false) { + } else { + result = 'module.exports = '.concat( + options.stringify(data, null, options.ident) + ) + } + + break + + case '.json5': + result = _json.default.stringify(data, null, options.ident) + break + + case '.yml': + case '.yaml': + result = YAML.safeDump(data, { + ident: options.indent + }) + break + + default: + result = options.stringify(data, null, options.ident) + } + + return result + } + + function writeFileSync(filename, payload, options) { + var ext = (0, _extname.default)(filename) + var data + + try { + data = stringifyData(ext, payload, options) + } catch (err) { + err.message = 'error stringifying ' + filename + ': ' + err.message + throw err + } + + if (isDeno) { + return writeFileInDenoSync(filename, data) + } else { + return writeFileInNodeSync(filename, data) + } + } + + function writeFile(filename, payload) { + var options = + arguments.length > 2 && arguments[2] !== undefined + ? arguments[2] + : { + stringify: JSON.stringify, + ident: 2 + } + var ext = (0, _extname.default)(filename) + var data + + try { + data = stringifyData(ext, payload, options) + } catch (err) { + err.message = 'error stringifying ' + filename + ': ' + err.message + throw err + } + + var fn = isDeno ? writeFileInDeno : writeFileInNode + return fn(filename, data) + } + + /***/ + }, + + /***/ 8813: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + 'use strict' + + function _interopDefault(ex) { + return ex && typeof ex === 'object' && 'default' in ex + ? ex['default'] + : ex + } + + var _typeof = _interopDefault(__webpack_require__(31042)) + var _objectSpread = _interopDefault(__webpack_require__(27107)) + var _classCallCheck = _interopDefault(__webpack_require__(49346)) + var _createClass = _interopDefault(__webpack_require__(72158)) + var _possibleConstructorReturn = _interopDefault( + __webpack_require__(68104) + ) + var _getPrototypeOf = _interopDefault(__webpack_require__(2030)) + var _assertThisInitialized = _interopDefault(__webpack_require__(53808)) + var _inherits = _interopDefault(__webpack_require__(35937)) + + var consoleLogger = { + type: 'logger', + log: function log(args) { + this.output('log', args) + }, + warn: function warn(args) { + this.output('warn', args) + }, + error: function error(args) { + this.output('error', args) + }, + output: function output(type, args) { + if (console && console[type]) console[type].apply(console, args) + } + } + + var Logger = (function () { + function Logger(concreteLogger) { + var options = + arguments.length > 1 && arguments[1] !== undefined + ? arguments[1] + : {} + + _classCallCheck(this, Logger) + + this.init(concreteLogger, options) + } + + _createClass(Logger, [ + { + key: 'init', + value: function init(concreteLogger) { + var options = + arguments.length > 1 && arguments[1] !== undefined + ? arguments[1] + : {} + this.prefix = options.prefix || 'i18next:' + this.logger = concreteLogger || consoleLogger + this.options = options + this.debug = options.debug + } + }, + { + key: 'setDebug', + value: function setDebug(bool) { + this.debug = bool + } + }, + { + key: 'log', + value: function log() { + for ( + var _len = arguments.length, args = new Array(_len), _key = 0; + _key < _len; + _key++ + ) { + args[_key] = arguments[_key] + } + + return this.forward(args, 'log', '', true) + } + }, + { + key: 'warn', + value: function warn() { + for ( + var _len2 = arguments.length, + args = new Array(_len2), + _key2 = 0; + _key2 < _len2; + _key2++ + ) { + args[_key2] = arguments[_key2] + } + + return this.forward(args, 'warn', '', true) + } + }, + { + key: 'error', + value: function error() { + for ( + var _len3 = arguments.length, + args = new Array(_len3), + _key3 = 0; + _key3 < _len3; + _key3++ + ) { + args[_key3] = arguments[_key3] + } + + return this.forward(args, 'error', '') + } + }, + { + key: 'deprecate', + value: function deprecate() { + for ( + var _len4 = arguments.length, + args = new Array(_len4), + _key4 = 0; + _key4 < _len4; + _key4++ + ) { + args[_key4] = arguments[_key4] + } + + return this.forward(args, 'warn', 'WARNING DEPRECATED: ', true) + } + }, + { + key: 'forward', + value: function forward(args, lvl, prefix, debugOnly) { + if (debugOnly && !this.debug) return null + if (typeof args[0] === 'string') + args[0] = '' + .concat(prefix) + .concat(this.prefix, ' ') + .concat(args[0]) + return this.logger[lvl](args) + } + }, + { + key: 'create', + value: function create(moduleName) { + return new Logger( + this.logger, + _objectSpread( + {}, + { + prefix: ''.concat(this.prefix, ':').concat(moduleName, ':') + }, + this.options + ) + ) + } + } + ]) + + return Logger + })() + + var baseLogger = new Logger() + + var EventEmitter = (function () { + function EventEmitter() { + _classCallCheck(this, EventEmitter) + + this.observers = {} + } + + _createClass(EventEmitter, [ + { + key: 'on', + value: function on(events, listener) { + var _this = this + + events.split(' ').forEach(function (event) { + _this.observers[event] = _this.observers[event] || [] + + _this.observers[event].push(listener) + }) + return this + } + }, + { + key: 'off', + value: function off(event, listener) { + if (!this.observers[event]) return + + if (!listener) { + delete this.observers[event] + return + } + + this.observers[event] = this.observers[event].filter(function ( + l + ) { + return l !== listener + }) + } + }, + { + key: 'emit', + value: function emit(event) { + for ( + var _len = arguments.length, + args = new Array(_len > 1 ? _len - 1 : 0), + _key = 1; + _key < _len; + _key++ + ) { + args[_key - 1] = arguments[_key] + } + + if (this.observers[event]) { + var cloned = [].concat(this.observers[event]) + cloned.forEach(function (observer) { + observer.apply(void 0, args) + }) + } + + if (this.observers['*']) { + var _cloned = [].concat(this.observers['*']) + + _cloned.forEach(function (observer) { + observer.apply(observer, [event].concat(args)) + }) + } + } + } + ]) + + return EventEmitter + })() + + function defer() { + var res + var rej + var promise = new Promise(function (resolve, reject) { + res = resolve + rej = reject + }) + promise.resolve = res + promise.reject = rej + return promise + } + function makeString(object) { + if (object == null) return '' + return '' + object + } + function copy(a, s, t) { + a.forEach(function (m) { + if (s[m]) t[m] = s[m] + }) + } + + function getLastOfPath(object, path, Empty) { + function cleanKey(key) { + return key && key.indexOf('###') > -1 ? key.replace(/###/g, '.') : key + } + + function canNotTraverseDeeper() { + return !object || typeof object === 'string' + } + + var stack = typeof path !== 'string' ? [].concat(path) : path.split('.') + + while (stack.length > 1) { + if (canNotTraverseDeeper()) return {} + var key = cleanKey(stack.shift()) + if (!object[key] && Empty) object[key] = new Empty() + object = object[key] + } + + if (canNotTraverseDeeper()) return {} + return { + obj: object, + k: cleanKey(stack.shift()) + } + } + + function setPath(object, path, newValue) { + var _getLastOfPath = getLastOfPath(object, path, Object), + obj = _getLastOfPath.obj, + k = _getLastOfPath.k + + obj[k] = newValue + } + function pushPath(object, path, newValue, concat) { + var _getLastOfPath2 = getLastOfPath(object, path, Object), + obj = _getLastOfPath2.obj, + k = _getLastOfPath2.k + + obj[k] = obj[k] || [] + if (concat) obj[k] = obj[k].concat(newValue) + if (!concat) obj[k].push(newValue) + } + function getPath(object, path) { + var _getLastOfPath3 = getLastOfPath(object, path), + obj = _getLastOfPath3.obj, + k = _getLastOfPath3.k + + if (!obj) return undefined + return obj[k] + } + function getPathWithDefaults(data, defaultData, key) { + var value = getPath(data, key) + + if (value !== undefined) { + return value + } + + return getPath(defaultData, key) + } + function deepExtend(target, source, overwrite) { + for (var prop in source) { + if (prop !== '__proto__' && prop !== 'constructor') { + if (prop in target) { + if ( + typeof target[prop] === 'string' || + target[prop] instanceof String || + typeof source[prop] === 'string' || + source[prop] instanceof String + ) { + if (overwrite) target[prop] = source[prop] + } else { + deepExtend(target[prop], source[prop], overwrite) + } + } else { + target[prop] = source[prop] + } + } + } + + return target + } + function regexEscape(str) { + return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&') + } + var _entityMap = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''', + '/': '/' + } + function escape(data) { + if (typeof data === 'string') { + return data.replace(/[&<>"'\/]/g, function (s) { + return _entityMap[s] + }) + } + + return data + } + var isIE10 = + typeof window !== 'undefined' && + window.navigator && + window.navigator.userAgent && + window.navigator.userAgent.indexOf('MSIE') > -1 + + var ResourceStore = (function (_EventEmitter) { + _inherits(ResourceStore, _EventEmitter) + + function ResourceStore(data) { + var _this + + var options = + arguments.length > 1 && arguments[1] !== undefined + ? arguments[1] + : { + ns: ['translation'], + defaultNS: 'translation' + } + + _classCallCheck(this, ResourceStore) + + _this = _possibleConstructorReturn( + this, + _getPrototypeOf(ResourceStore).call(this) + ) + + if (isIE10) { + EventEmitter.call(_assertThisInitialized(_this)) + } + + _this.data = data || {} + _this.options = options + + if (_this.options.keySeparator === undefined) { + _this.options.keySeparator = '.' + } + + return _this + } + + _createClass(ResourceStore, [ + { + key: 'addNamespaces', + value: function addNamespaces(ns) { + if (this.options.ns.indexOf(ns) < 0) { + this.options.ns.push(ns) + } + } + }, + { + key: 'removeNamespaces', + value: function removeNamespaces(ns) { + var index = this.options.ns.indexOf(ns) + + if (index > -1) { + this.options.ns.splice(index, 1) + } + } + }, + { + key: 'getResource', + value: function getResource(lng, ns, key) { + var options = + arguments.length > 3 && arguments[3] !== undefined + ? arguments[3] + : {} + var keySeparator = + options.keySeparator !== undefined + ? options.keySeparator + : this.options.keySeparator + var path = [lng, ns] + if (key && typeof key !== 'string') path = path.concat(key) + if (key && typeof key === 'string') + path = path.concat(keySeparator ? key.split(keySeparator) : key) + + if (lng.indexOf('.') > -1) { + path = lng.split('.') + } + + return getPath(this.data, path) + } + }, + { + key: 'addResource', + value: function addResource(lng, ns, key, value) { + var options = + arguments.length > 4 && arguments[4] !== undefined + ? arguments[4] + : { + silent: false + } + var keySeparator = this.options.keySeparator + if (keySeparator === undefined) keySeparator = '.' + var path = [lng, ns] + if (key) + path = path.concat(keySeparator ? key.split(keySeparator) : key) + + if (lng.indexOf('.') > -1) { + path = lng.split('.') + value = ns + ns = path[1] + } + + this.addNamespaces(ns) + setPath(this.data, path, value) + if (!options.silent) this.emit('added', lng, ns, key, value) + } + }, + { + key: 'addResources', + value: function addResources(lng, ns, resources) { + var options = + arguments.length > 3 && arguments[3] !== undefined + ? arguments[3] + : { + silent: false + } + + for (var m in resources) { + if ( + typeof resources[m] === 'string' || + Object.prototype.toString.apply(resources[m]) === + '[object Array]' + ) + this.addResource(lng, ns, m, resources[m], { + silent: true + }) + } + + if (!options.silent) this.emit('added', lng, ns, resources) + } + }, + { + key: 'addResourceBundle', + value: function addResourceBundle( + lng, + ns, + resources, + deep, + overwrite + ) { + var options = + arguments.length > 5 && arguments[5] !== undefined + ? arguments[5] + : { + silent: false + } + var path = [lng, ns] + + if (lng.indexOf('.') > -1) { + path = lng.split('.') + deep = resources + resources = ns + ns = path[1] + } + + this.addNamespaces(ns) + var pack = getPath(this.data, path) || {} + + if (deep) { + deepExtend(pack, resources, overwrite) + } else { + pack = _objectSpread({}, pack, resources) + } + + setPath(this.data, path, pack) + if (!options.silent) this.emit('added', lng, ns, resources) + } + }, + { + key: 'removeResourceBundle', + value: function removeResourceBundle(lng, ns) { + if (this.hasResourceBundle(lng, ns)) { + delete this.data[lng][ns] + } + + this.removeNamespaces(ns) + this.emit('removed', lng, ns) + } + }, + { + key: 'hasResourceBundle', + value: function hasResourceBundle(lng, ns) { + return this.getResource(lng, ns) !== undefined + } + }, + { + key: 'getResourceBundle', + value: function getResourceBundle(lng, ns) { + if (!ns) ns = this.options.defaultNS + if (this.options.compatibilityAPI === 'v1') + return _objectSpread({}, {}, this.getResource(lng, ns)) + return this.getResource(lng, ns) + } + }, + { + key: 'getDataByLanguage', + value: function getDataByLanguage(lng) { + return this.data[lng] + } + }, + { + key: 'toJSON', + value: function toJSON() { + return this.data + } + } + ]) + + return ResourceStore + })(EventEmitter) + + var postProcessor = { + processors: {}, + addPostProcessor: function addPostProcessor(module) { + this.processors[module.name] = module + }, + handle: function handle(processors, value, key, options, translator) { + var _this = this + + processors.forEach(function (processor) { + if (_this.processors[processor]) + value = _this.processors[processor].process( + value, + key, + options, + translator + ) + }) + return value + } + } + + var checkedLoadedFor = {} + + var Translator = (function (_EventEmitter) { + _inherits(Translator, _EventEmitter) + + function Translator(services) { + var _this + + var options = + arguments.length > 1 && arguments[1] !== undefined + ? arguments[1] + : {} + + _classCallCheck(this, Translator) + + _this = _possibleConstructorReturn( + this, + _getPrototypeOf(Translator).call(this) + ) + + if (isIE10) { + EventEmitter.call(_assertThisInitialized(_this)) + } + + copy( + [ + 'resourceStore', + 'languageUtils', + 'pluralResolver', + 'interpolator', + 'backendConnector', + 'i18nFormat', + 'utils' + ], + services, + _assertThisInitialized(_this) + ) + _this.options = options + + if (_this.options.keySeparator === undefined) { + _this.options.keySeparator = '.' + } + + _this.logger = baseLogger.create('translator') + return _this + } + + _createClass(Translator, [ + { + key: 'changeLanguage', + value: function changeLanguage(lng) { + if (lng) this.language = lng + } + }, + { + key: 'exists', + value: function exists(key) { + var options = + arguments.length > 1 && arguments[1] !== undefined + ? arguments[1] + : { + interpolation: {} + } + var resolved = this.resolve(key, options) + return resolved && resolved.res !== undefined + } + }, + { + key: 'extractFromKey', + value: function extractFromKey(key, options) { + var nsSeparator = + options.nsSeparator !== undefined + ? options.nsSeparator + : this.options.nsSeparator + if (nsSeparator === undefined) nsSeparator = ':' + var keySeparator = + options.keySeparator !== undefined + ? options.keySeparator + : this.options.keySeparator + var namespaces = options.ns || this.options.defaultNS + + if (nsSeparator && key.indexOf(nsSeparator) > -1) { + var m = key.match(this.interpolator.nestingRegexp) + + if (m && m.length > 0) { + return { + key: key, + namespaces: namespaces + } + } + + var parts = key.split(nsSeparator) + if ( + nsSeparator !== keySeparator || + (nsSeparator === keySeparator && + this.options.ns.indexOf(parts[0]) > -1) + ) + namespaces = parts.shift() + key = parts.join(keySeparator) + } + + if (typeof namespaces === 'string') namespaces = [namespaces] + return { + key: key, + namespaces: namespaces + } + } + }, + { + key: 'translate', + value: function translate(keys, options, lastKey) { + var _this2 = this + + if ( + _typeof(options) !== 'object' && + this.options.overloadTranslationOptionHandler + ) { + options = this.options.overloadTranslationOptionHandler( + arguments + ) + } + + if (!options) options = {} + if (keys === undefined || keys === null) return '' + if (!Array.isArray(keys)) keys = [String(keys)] + var keySeparator = + options.keySeparator !== undefined + ? options.keySeparator + : this.options.keySeparator + + var _this$extractFromKey = this.extractFromKey( + keys[keys.length - 1], + options + ), + key = _this$extractFromKey.key, + namespaces = _this$extractFromKey.namespaces + + var namespace = namespaces[namespaces.length - 1] + var lng = options.lng || this.language + var appendNamespaceToCIMode = + options.appendNamespaceToCIMode || + this.options.appendNamespaceToCIMode + + if (lng && lng.toLowerCase() === 'cimode') { + if (appendNamespaceToCIMode) { + var nsSeparator = + options.nsSeparator || this.options.nsSeparator + return namespace + nsSeparator + key + } + + return key + } + + var resolved = this.resolve(keys, options) + var res = resolved && resolved.res + var resUsedKey = (resolved && resolved.usedKey) || key + var resExactUsedKey = (resolved && resolved.exactUsedKey) || key + var resType = Object.prototype.toString.apply(res) + var noObject = [ + '[object Number]', + '[object Function]', + '[object RegExp]' + ] + var joinArrays = + options.joinArrays !== undefined + ? options.joinArrays + : this.options.joinArrays + var handleAsObjectInI18nFormat = + !this.i18nFormat || this.i18nFormat.handleAsObject + var handleAsObject = + typeof res !== 'string' && + typeof res !== 'boolean' && + typeof res !== 'number' + + if ( + handleAsObjectInI18nFormat && + res && + handleAsObject && + noObject.indexOf(resType) < 0 && + !( + typeof joinArrays === 'string' && resType === '[object Array]' + ) + ) { + if (!options.returnObjects && !this.options.returnObjects) { + this.logger.warn( + 'accessing an object - but returnObjects options is not enabled!' + ) + return this.options.returnedObjectHandler + ? this.options.returnedObjectHandler( + resUsedKey, + res, + options + ) + : "key '" + .concat(key, ' (') + .concat( + this.language, + ")' returned an object instead of string." + ) + } + + if (keySeparator) { + var resTypeIsArray = resType === '[object Array]' + var copy$$1 = resTypeIsArray ? [] : {} + var newKeyToUse = resTypeIsArray + ? resExactUsedKey + : resUsedKey + + for (var m in res) { + if (Object.prototype.hasOwnProperty.call(res, m)) { + var deepKey = '' + .concat(newKeyToUse) + .concat(keySeparator) + .concat(m) + copy$$1[m] = this.translate( + deepKey, + _objectSpread({}, options, { + joinArrays: false, + ns: namespaces + }) + ) + if (copy$$1[m] === deepKey) copy$$1[m] = res[m] + } + } + + res = copy$$1 + } + } else if ( + handleAsObjectInI18nFormat && + typeof joinArrays === 'string' && + resType === '[object Array]' + ) { + res = res.join(joinArrays) + if (res) + res = this.extendTranslation(res, keys, options, lastKey) + } else { + var usedDefault = false + var usedKey = false + + if ( + !this.isValidLookup(res) && + options.defaultValue !== undefined + ) { + usedDefault = true + + if (options.count !== undefined) { + var suffix = this.pluralResolver.getSuffix( + lng, + options.count + ) + res = options['defaultValue'.concat(suffix)] + } + + if (!res) res = options.defaultValue + } + + if (!this.isValidLookup(res)) { + usedKey = true + res = key + } + + var updateMissing = + options.defaultValue && + options.defaultValue !== res && + this.options.updateMissing + + if (usedKey || usedDefault || updateMissing) { + this.logger.log( + updateMissing ? 'updateKey' : 'missingKey', + lng, + namespace, + key, + updateMissing ? options.defaultValue : res + ) + + if (keySeparator) { + var fk = this.resolve( + key, + _objectSpread({}, options, { + keySeparator: false + }) + ) + if (fk && fk.res) + this.logger.warn( + 'Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.' + ) + } + + var lngs = [] + var fallbackLngs = this.languageUtils.getFallbackCodes( + this.options.fallbackLng, + options.lng || this.language + ) + + if ( + this.options.saveMissingTo === 'fallback' && + fallbackLngs && + fallbackLngs[0] + ) { + for (var i = 0; i < fallbackLngs.length; i++) { + lngs.push(fallbackLngs[i]) + } + } else if (this.options.saveMissingTo === 'all') { + lngs = this.languageUtils.toResolveHierarchy( + options.lng || this.language + ) + } else { + lngs.push(options.lng || this.language) + } + + var send = function send(l, k) { + if (_this2.options.missingKeyHandler) { + _this2.options.missingKeyHandler( + l, + namespace, + k, + updateMissing ? options.defaultValue : res, + updateMissing, + options + ) + } else if ( + _this2.backendConnector && + _this2.backendConnector.saveMissing + ) { + _this2.backendConnector.saveMissing( + l, + namespace, + k, + updateMissing ? options.defaultValue : res, + updateMissing, + options + ) + } + + _this2.emit('missingKey', l, namespace, k, res) + } + + if (this.options.saveMissing) { + var needsPluralHandling = + options.count !== undefined && + typeof options.count !== 'string' + + if ( + this.options.saveMissingPlurals && + needsPluralHandling + ) { + lngs.forEach(function (l) { + var plurals = _this2.pluralResolver.getPluralFormsOfKey( + l, + key + ) + + plurals.forEach(function (p) { + return send([l], p) + }) + }) + } else { + send(lngs, key) + } + } + } + + res = this.extendTranslation( + res, + keys, + options, + resolved, + lastKey + ) + if ( + usedKey && + res === key && + this.options.appendNamespaceToMissingKey + ) + res = ''.concat(namespace, ':').concat(key) + if (usedKey && this.options.parseMissingKeyHandler) + res = this.options.parseMissingKeyHandler(res) + } + + return res + } + }, + { + key: 'extendTranslation', + value: function extendTranslation( + res, + key, + options, + resolved, + lastKey + ) { + var _this3 = this + + if (this.i18nFormat && this.i18nFormat.parse) { + res = this.i18nFormat.parse( + res, + options, + resolved.usedLng, + resolved.usedNS, + resolved.usedKey, + { + resolved: resolved + } + ) + } else if (!options.skipInterpolation) { + if (options.interpolation) + this.interpolator.init( + _objectSpread({}, options, { + interpolation: _objectSpread( + {}, + this.options.interpolation, + options.interpolation + ) + }) + ) + var skipOnVariables = + (options.interpolation && + options.interpolation.skipOnVariables) || + this.options.interpolation.skipOnVariables + var nestBef + + if (skipOnVariables) { + var nb = res.match(this.interpolator.nestingRegexp) + nestBef = nb && nb.length + } + + var data = + options.replace && typeof options.replace !== 'string' + ? options.replace + : options + if (this.options.interpolation.defaultVariables) + data = _objectSpread( + {}, + this.options.interpolation.defaultVariables, + data + ) + res = this.interpolator.interpolate( + res, + data, + options.lng || this.language, + options + ) + + if (skipOnVariables) { + var na = res.match(this.interpolator.nestingRegexp) + var nestAft = na && na.length + if (nestBef < nestAft) options.nest = false + } + + if (options.nest !== false) + res = this.interpolator.nest( + res, + function () { + for ( + var _len = arguments.length, + args = new Array(_len), + _key = 0; + _key < _len; + _key++ + ) { + args[_key] = arguments[_key] + } + + if ( + lastKey && + lastKey[0] === args[0] && + !options.context + ) { + _this3.logger.warn( + 'It seems you are nesting recursively key: ' + .concat(args[0], ' in key: ') + .concat(key[0]) + ) + + return null + } + + return _this3.translate.apply(_this3, args.concat([key])) + }, + options + ) + if (options.interpolation) this.interpolator.reset() + } + + var postProcess = options.postProcess || this.options.postProcess + var postProcessorNames = + typeof postProcess === 'string' ? [postProcess] : postProcess + + if ( + res !== undefined && + res !== null && + postProcessorNames && + postProcessorNames.length && + options.applyPostProcessor !== false + ) { + res = postProcessor.handle( + postProcessorNames, + res, + key, + this.options && this.options.postProcessPassResolved + ? _objectSpread( + { + i18nResolved: resolved + }, + options + ) + : options, + this + ) + } + + return res + } + }, + { + key: 'resolve', + value: function resolve(keys) { + var _this4 = this + + var options = + arguments.length > 1 && arguments[1] !== undefined + ? arguments[1] + : {} + var found + var usedKey + var exactUsedKey + var usedLng + var usedNS + if (typeof keys === 'string') keys = [keys] + keys.forEach(function (k) { + if (_this4.isValidLookup(found)) return + + var extracted = _this4.extractFromKey(k, options) + + var key = extracted.key + usedKey = key + var namespaces = extracted.namespaces + if (_this4.options.fallbackNS) + namespaces = namespaces.concat(_this4.options.fallbackNS) + var needsPluralHandling = + options.count !== undefined && + typeof options.count !== 'string' + var needsContextHandling = + options.context !== undefined && + typeof options.context === 'string' && + options.context !== '' + var codes = options.lngs + ? options.lngs + : _this4.languageUtils.toResolveHierarchy( + options.lng || _this4.language, + options.fallbackLng + ) + namespaces.forEach(function (ns) { + if (_this4.isValidLookup(found)) return + usedNS = ns + + if ( + !checkedLoadedFor[''.concat(codes[0], '-').concat(ns)] && + _this4.utils && + _this4.utils.hasLoadedNamespace && + !_this4.utils.hasLoadedNamespace(usedNS) + ) { + checkedLoadedFor[''.concat(codes[0], '-').concat(ns)] = true + + _this4.logger.warn( + 'key "' + .concat(usedKey, '" for languages "') + .concat( + codes.join(', '), + '" won\'t get resolved as namespace "' + ) + .concat(usedNS, '" was not yet loaded'), + 'This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!' + ) + } + + codes.forEach(function (code) { + if (_this4.isValidLookup(found)) return + usedLng = code + var finalKey = key + var finalKeys = [finalKey] + + if (_this4.i18nFormat && _this4.i18nFormat.addLookupKeys) { + _this4.i18nFormat.addLookupKeys( + finalKeys, + key, + code, + ns, + options + ) + } else { + var pluralSuffix + if (needsPluralHandling) + pluralSuffix = _this4.pluralResolver.getSuffix( + code, + options.count + ) + if (needsPluralHandling && needsContextHandling) + finalKeys.push(finalKey + pluralSuffix) + if (needsContextHandling) + finalKeys.push( + (finalKey += '' + .concat(_this4.options.contextSeparator) + .concat(options.context)) + ) + if (needsPluralHandling) + finalKeys.push((finalKey += pluralSuffix)) + } + + var possibleKey + + while ((possibleKey = finalKeys.pop())) { + if (!_this4.isValidLookup(found)) { + exactUsedKey = possibleKey + found = _this4.getResource( + code, + ns, + possibleKey, + options + ) + } + } + }) + }) + }) + return { + res: found, + usedKey: usedKey, + exactUsedKey: exactUsedKey, + usedLng: usedLng, + usedNS: usedNS + } + } + }, + { + key: 'isValidLookup', + value: function isValidLookup(res) { + return ( + res !== undefined && + !(!this.options.returnNull && res === null) && + !(!this.options.returnEmptyString && res === '') + ) + } + }, + { + key: 'getResource', + value: function getResource(code, ns, key) { + var options = + arguments.length > 3 && arguments[3] !== undefined + ? arguments[3] + : {} + if (this.i18nFormat && this.i18nFormat.getResource) + return this.i18nFormat.getResource(code, ns, key, options) + return this.resourceStore.getResource(code, ns, key, options) + } + } + ]) + + return Translator + })(EventEmitter) + + function capitalize(string) { + return string.charAt(0).toUpperCase() + string.slice(1) + } + + var LanguageUtil = (function () { + function LanguageUtil(options) { + _classCallCheck(this, LanguageUtil) + + this.options = options + this.whitelist = this.options.supportedLngs || false + this.supportedLngs = this.options.supportedLngs || false + this.logger = baseLogger.create('languageUtils') + } + + _createClass(LanguageUtil, [ + { + key: 'getScriptPartFromCode', + value: function getScriptPartFromCode(code) { + if (!code || code.indexOf('-') < 0) return null + var p = code.split('-') + if (p.length === 2) return null + p.pop() + if (p[p.length - 1].toLowerCase() === 'x') return null + return this.formatLanguageCode(p.join('-')) + } + }, + { + key: 'getLanguagePartFromCode', + value: function getLanguagePartFromCode(code) { + if (!code || code.indexOf('-') < 0) return code + var p = code.split('-') + return this.formatLanguageCode(p[0]) + } + }, + { + key: 'formatLanguageCode', + value: function formatLanguageCode(code) { + if (typeof code === 'string' && code.indexOf('-') > -1) { + var specialCases = [ + 'hans', + 'hant', + 'latn', + 'cyrl', + 'cans', + 'mong', + 'arab' + ] + var p = code.split('-') + + if (this.options.lowerCaseLng) { + p = p.map(function (part) { + return part.toLowerCase() + }) + } else if (p.length === 2) { + p[0] = p[0].toLowerCase() + p[1] = p[1].toUpperCase() + if (specialCases.indexOf(p[1].toLowerCase()) > -1) + p[1] = capitalize(p[1].toLowerCase()) + } else if (p.length === 3) { + p[0] = p[0].toLowerCase() + if (p[1].length === 2) p[1] = p[1].toUpperCase() + if (p[0] !== 'sgn' && p[2].length === 2) + p[2] = p[2].toUpperCase() + if (specialCases.indexOf(p[1].toLowerCase()) > -1) + p[1] = capitalize(p[1].toLowerCase()) + if (specialCases.indexOf(p[2].toLowerCase()) > -1) + p[2] = capitalize(p[2].toLowerCase()) + } + + return p.join('-') + } + + return this.options.cleanCode || this.options.lowerCaseLng + ? code.toLowerCase() + : code + } + }, + { + key: 'isWhitelisted', + value: function isWhitelisted(code) { + this.logger.deprecate( + 'languageUtils.isWhitelisted', + 'function "isWhitelisted" will be renamed to "isSupportedCode" in the next major - please make sure to rename it\'s usage asap.' + ) + return this.isSupportedCode(code) + } + }, + { + key: 'isSupportedCode', + value: function isSupportedCode(code) { + if ( + this.options.load === 'languageOnly' || + this.options.nonExplicitSupportedLngs + ) { + code = this.getLanguagePartFromCode(code) + } + + return ( + !this.supportedLngs || + !this.supportedLngs.length || + this.supportedLngs.indexOf(code) > -1 + ) + } + }, + { + key: 'getBestMatchFromCodes', + value: function getBestMatchFromCodes(codes) { + var _this = this + + if (!codes) return null + var found + codes.forEach(function (code) { + if (found) return + + var cleanedLng = _this.formatLanguageCode(code) + + if ( + !_this.options.supportedLngs || + _this.isSupportedCode(cleanedLng) + ) + found = cleanedLng + }) + + if (!found && this.options.supportedLngs) { + codes.forEach(function (code) { + if (found) return + + var lngOnly = _this.getLanguagePartFromCode(code) + + if (_this.isSupportedCode(lngOnly)) return (found = lngOnly) + found = _this.options.supportedLngs.find(function ( + supportedLng + ) { + if (supportedLng.indexOf(lngOnly) === 0) return supportedLng + }) + }) + } + + if (!found) + found = this.getFallbackCodes(this.options.fallbackLng)[0] + return found + } + }, + { + key: 'getFallbackCodes', + value: function getFallbackCodes(fallbacks, code) { + if (!fallbacks) return [] + if (typeof fallbacks === 'function') fallbacks = fallbacks(code) + if (typeof fallbacks === 'string') fallbacks = [fallbacks] + if ( + Object.prototype.toString.apply(fallbacks) === '[object Array]' + ) + return fallbacks + if (!code) return fallbacks['default'] || [] + var found = fallbacks[code] + if (!found) found = fallbacks[this.getScriptPartFromCode(code)] + if (!found) found = fallbacks[this.formatLanguageCode(code)] + if (!found) found = fallbacks[this.getLanguagePartFromCode(code)] + if (!found) found = fallbacks['default'] + return found || [] + } + }, + { + key: 'toResolveHierarchy', + value: function toResolveHierarchy(code, fallbackCode) { + var _this2 = this + + var fallbackCodes = this.getFallbackCodes( + fallbackCode || this.options.fallbackLng || [], + code + ) + var codes = [] + + var addCode = function addCode(c) { + if (!c) return + + if (_this2.isSupportedCode(c)) { + codes.push(c) + } else { + _this2.logger.warn( + 'rejecting language code not found in supportedLngs: '.concat( + c + ) + ) + } + } + + if (typeof code === 'string' && code.indexOf('-') > -1) { + if (this.options.load !== 'languageOnly') + addCode(this.formatLanguageCode(code)) + if ( + this.options.load !== 'languageOnly' && + this.options.load !== 'currentOnly' + ) + addCode(this.getScriptPartFromCode(code)) + if (this.options.load !== 'currentOnly') + addCode(this.getLanguagePartFromCode(code)) + } else if (typeof code === 'string') { + addCode(this.formatLanguageCode(code)) + } + + fallbackCodes.forEach(function (fc) { + if (codes.indexOf(fc) < 0) + addCode(_this2.formatLanguageCode(fc)) + }) + return codes + } + } + ]) + + return LanguageUtil + })() + + var sets = [ + { + lngs: [ + 'ach', + 'ak', + 'am', + 'arn', + 'br', + 'fil', + 'gun', + 'ln', + 'mfe', + 'mg', + 'mi', + 'oc', + 'pt', + 'pt-BR', + 'tg', + 'ti', + 'tr', + 'uz', + 'wa' + ], + nr: [1, 2], + fc: 1 + }, + { + lngs: [ + 'af', + 'an', + 'ast', + 'az', + 'bg', + 'bn', + 'ca', + 'da', + 'de', + 'dev', + 'el', + 'en', + 'eo', + 'es', + 'et', + 'eu', + 'fi', + 'fo', + 'fur', + 'fy', + 'gl', + 'gu', + 'ha', + 'hi', + 'hu', + 'hy', + 'ia', + 'it', + 'kn', + 'ku', + 'lb', + 'mai', + 'ml', + 'mn', + 'mr', + 'nah', + 'nap', + 'nb', + 'ne', + 'nl', + 'nn', + 'no', + 'nso', + 'pa', + 'pap', + 'pms', + 'ps', + 'pt-PT', + 'rm', + 'sco', + 'se', + 'si', + 'so', + 'son', + 'sq', + 'sv', + 'sw', + 'ta', + 'te', + 'tk', + 'ur', + 'yo' + ], + nr: [1, 2], + fc: 2 + }, + { + lngs: [ + 'ay', + 'bo', + 'cgg', + 'fa', + 'ht', + 'id', + 'ja', + 'jbo', + 'ka', + 'kk', + 'km', + 'ko', + 'ky', + 'lo', + 'ms', + 'sah', + 'su', + 'th', + 'tt', + 'ug', + 'vi', + 'wo', + 'zh' + ], + nr: [1], + fc: 3 + }, + { + lngs: ['be', 'bs', 'cnr', 'dz', 'hr', 'ru', 'sr', 'uk'], + nr: [1, 2, 5], + fc: 4 + }, + { + lngs: ['ar'], + nr: [0, 1, 2, 3, 11, 100], + fc: 5 + }, + { + lngs: ['cs', 'sk'], + nr: [1, 2, 5], + fc: 6 + }, + { + lngs: ['csb', 'pl'], + nr: [1, 2, 5], + fc: 7 + }, + { + lngs: ['cy'], + nr: [1, 2, 3, 8], + fc: 8 + }, + { + lngs: ['fr'], + nr: [1, 2], + fc: 9 + }, + { + lngs: ['ga'], + nr: [1, 2, 3, 7, 11], + fc: 10 + }, + { + lngs: ['gd'], + nr: [1, 2, 3, 20], + fc: 11 + }, + { + lngs: ['is'], + nr: [1, 2], + fc: 12 + }, + { + lngs: ['jv'], + nr: [0, 1], + fc: 13 + }, + { + lngs: ['kw'], + nr: [1, 2, 3, 4], + fc: 14 + }, + { + lngs: ['lt'], + nr: [1, 2, 10], + fc: 15 + }, + { + lngs: ['lv'], + nr: [1, 2, 0], + fc: 16 + }, + { + lngs: ['mk'], + nr: [1, 2], + fc: 17 + }, + { + lngs: ['mnk'], + nr: [0, 1, 2], + fc: 18 + }, + { + lngs: ['mt'], + nr: [1, 2, 11, 20], + fc: 19 + }, + { + lngs: ['or'], + nr: [2, 1], + fc: 2 + }, + { + lngs: ['ro'], + nr: [1, 2, 20], + fc: 20 + }, + { + lngs: ['sl'], + nr: [5, 1, 2, 3], + fc: 21 + }, + { + lngs: ['he', 'iw'], + nr: [1, 2, 20, 21], + fc: 22 + } + ] + var _rulesPluralsTypes = { + 1: function _(n) { + return Number(n > 1) + }, + 2: function _(n) { + return Number(n != 1) + }, + 3: function _(n) { + return 0 + }, + 4: function _(n) { + return Number( + n % 10 == 1 && n % 100 != 11 + ? 0 + : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) + ? 1 + : 2 + ) + }, + 5: function _(n) { + return Number( + n == 0 + ? 0 + : n == 1 + ? 1 + : n == 2 + ? 2 + : n % 100 >= 3 && n % 100 <= 10 + ? 3 + : n % 100 >= 11 + ? 4 + : 5 + ) + }, + 6: function _(n) { + return Number(n == 1 ? 0 : n >= 2 && n <= 4 ? 1 : 2) + }, + 7: function _(n) { + return Number( + n == 1 + ? 0 + : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) + ? 1 + : 2 + ) + }, + 8: function _(n) { + return Number(n == 1 ? 0 : n == 2 ? 1 : n != 8 && n != 11 ? 2 : 3) + }, + 9: function _(n) { + return Number(n >= 2) + }, + 10: function _(n) { + return Number(n == 1 ? 0 : n == 2 ? 1 : n < 7 ? 2 : n < 11 ? 3 : 4) + }, + 11: function _(n) { + return Number( + n == 1 || n == 11 + ? 0 + : n == 2 || n == 12 + ? 1 + : n > 2 && n < 20 + ? 2 + : 3 + ) + }, + 12: function _(n) { + return Number(n % 10 != 1 || n % 100 == 11) + }, + 13: function _(n) { + return Number(n !== 0) + }, + 14: function _(n) { + return Number(n == 1 ? 0 : n == 2 ? 1 : n == 3 ? 2 : 3) + }, + 15: function _(n) { + return Number( + n % 10 == 1 && n % 100 != 11 + ? 0 + : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) + ? 1 + : 2 + ) + }, + 16: function _(n) { + return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n !== 0 ? 1 : 2) + }, + 17: function _(n) { + return Number(n == 1 || (n % 10 == 1 && n % 100 != 11) ? 0 : 1) + }, + 18: function _(n) { + return Number(n == 0 ? 0 : n == 1 ? 1 : 2) + }, + 19: function _(n) { + return Number( + n == 1 + ? 0 + : n == 0 || (n % 100 > 1 && n % 100 < 11) + ? 1 + : n % 100 > 10 && n % 100 < 20 + ? 2 + : 3 + ) + }, + 20: function _(n) { + return Number( + n == 1 ? 0 : n == 0 || (n % 100 > 0 && n % 100 < 20) ? 1 : 2 + ) + }, + 21: function _(n) { + return Number( + n % 100 == 1 + ? 1 + : n % 100 == 2 + ? 2 + : n % 100 == 3 || n % 100 == 4 + ? 3 + : 0 + ) + }, + 22: function _(n) { + return Number( + n == 1 ? 0 : n == 2 ? 1 : (n < 0 || n > 10) && n % 10 == 0 ? 2 : 3 + ) + } + } + + function createRules() { + var rules = {} + sets.forEach(function (set) { + set.lngs.forEach(function (l) { + rules[l] = { + numbers: set.nr, + plurals: _rulesPluralsTypes[set.fc] + } + }) + }) + return rules + } + + var PluralResolver = (function () { + function PluralResolver(languageUtils) { + var options = + arguments.length > 1 && arguments[1] !== undefined + ? arguments[1] + : {} + + _classCallCheck(this, PluralResolver) + + this.languageUtils = languageUtils + this.options = options + this.logger = baseLogger.create('pluralResolver') + this.rules = createRules() + } + + _createClass(PluralResolver, [ + { + key: 'addRule', + value: function addRule(lng, obj) { + this.rules[lng] = obj + } + }, + { + key: 'getRule', + value: function getRule(code) { + return ( + this.rules[code] || + this.rules[this.languageUtils.getLanguagePartFromCode(code)] + ) + } + }, + { + key: 'needsPlural', + value: function needsPlural(code) { + var rule = this.getRule(code) + return rule && rule.numbers.length > 1 + } + }, + { + key: 'getPluralFormsOfKey', + value: function getPluralFormsOfKey(code, key) { + var _this = this + + var ret = [] + var rule = this.getRule(code) + if (!rule) return ret + rule.numbers.forEach(function (n) { + var suffix = _this.getSuffix(code, n) + + ret.push(''.concat(key).concat(suffix)) + }) + return ret + } + }, + { + key: 'getSuffix', + value: function getSuffix(code, count) { + var _this2 = this + + var rule = this.getRule(code) + + if (rule) { + var idx = rule.noAbs + ? rule.plurals(count) + : rule.plurals(Math.abs(count)) + var suffix = rule.numbers[idx] + + if ( + this.options.simplifyPluralSuffix && + rule.numbers.length === 2 && + rule.numbers[0] === 1 + ) { + if (suffix === 2) { + suffix = 'plural' + } else if (suffix === 1) { + suffix = '' + } + } + + var returnSuffix = function returnSuffix() { + return _this2.options.prepend && suffix.toString() + ? _this2.options.prepend + suffix.toString() + : suffix.toString() + } + + if (this.options.compatibilityJSON === 'v1') { + if (suffix === 1) return '' + if (typeof suffix === 'number') + return '_plural_'.concat(suffix.toString()) + return returnSuffix() + } else if (this.options.compatibilityJSON === 'v2') { + return returnSuffix() + } else if ( + this.options.simplifyPluralSuffix && + rule.numbers.length === 2 && + rule.numbers[0] === 1 + ) { + return returnSuffix() + } + + return this.options.prepend && idx.toString() + ? this.options.prepend + idx.toString() + : idx.toString() + } + + this.logger.warn('no plural rule found for: '.concat(code)) + return '' + } + } + ]) + + return PluralResolver + })() + + var Interpolator = (function () { + function Interpolator() { + var options = + arguments.length > 0 && arguments[0] !== undefined + ? arguments[0] + : {} + + _classCallCheck(this, Interpolator) + + this.logger = baseLogger.create('interpolator') + this.options = options + + this.format = + (options.interpolation && options.interpolation.format) || + function (value) { + return value + } + + this.init(options) + } + + _createClass(Interpolator, [ + { + key: 'init', + value: function init() { + var options = + arguments.length > 0 && arguments[0] !== undefined + ? arguments[0] + : {} + if (!options.interpolation) + options.interpolation = { + escapeValue: true + } + var iOpts = options.interpolation + this.escape = iOpts.escape !== undefined ? iOpts.escape : escape + this.escapeValue = + iOpts.escapeValue !== undefined ? iOpts.escapeValue : true + this.useRawValueToEscape = + iOpts.useRawValueToEscape !== undefined + ? iOpts.useRawValueToEscape + : false + this.prefix = iOpts.prefix + ? regexEscape(iOpts.prefix) + : iOpts.prefixEscaped || '{{' + this.suffix = iOpts.suffix + ? regexEscape(iOpts.suffix) + : iOpts.suffixEscaped || '}}' + this.formatSeparator = iOpts.formatSeparator + ? iOpts.formatSeparator + : iOpts.formatSeparator || ',' + this.unescapePrefix = iOpts.unescapeSuffix + ? '' + : iOpts.unescapePrefix || '-' + this.unescapeSuffix = this.unescapePrefix + ? '' + : iOpts.unescapeSuffix || '' + this.nestingPrefix = iOpts.nestingPrefix + ? regexEscape(iOpts.nestingPrefix) + : iOpts.nestingPrefixEscaped || regexEscape('$t(') + this.nestingSuffix = iOpts.nestingSuffix + ? regexEscape(iOpts.nestingSuffix) + : iOpts.nestingSuffixEscaped || regexEscape(')') + this.nestingOptionsSeparator = iOpts.nestingOptionsSeparator + ? iOpts.nestingOptionsSeparator + : iOpts.nestingOptionsSeparator || ',' + this.maxReplaces = iOpts.maxReplaces ? iOpts.maxReplaces : 1000 + this.alwaysFormat = + iOpts.alwaysFormat !== undefined ? iOpts.alwaysFormat : false + this.resetRegExp() + } + }, + { + key: 'reset', + value: function reset() { + if (this.options) this.init(this.options) + } + }, + { + key: 'resetRegExp', + value: function resetRegExp() { + var regexpStr = '' + .concat(this.prefix, '(.+?)') + .concat(this.suffix) + this.regexp = new RegExp(regexpStr, 'g') + var regexpUnescapeStr = '' + .concat(this.prefix) + .concat(this.unescapePrefix, '(.+?)') + .concat(this.unescapeSuffix) + .concat(this.suffix) + this.regexpUnescape = new RegExp(regexpUnescapeStr, 'g') + var nestingRegexpStr = '' + .concat(this.nestingPrefix, '(.+?)') + .concat(this.nestingSuffix) + this.nestingRegexp = new RegExp(nestingRegexpStr, 'g') + } + }, + { + key: 'interpolate', + value: function interpolate(str, data, lng, options) { + var _this = this + + var match + var value + var replaces + var defaultData = + (this.options && + this.options.interpolation && + this.options.interpolation.defaultVariables) || + {} + + function regexSafe(val) { + return val.replace(/\$/g, '$$$$') + } + + var handleFormat = function handleFormat(key) { + if (key.indexOf(_this.formatSeparator) < 0) { + var path = getPathWithDefaults(data, defaultData, key) + return _this.alwaysFormat + ? _this.format(path, undefined, lng) + : path + } + + var p = key.split(_this.formatSeparator) + var k = p.shift().trim() + var f = p.join(_this.formatSeparator).trim() + return _this.format( + getPathWithDefaults(data, defaultData, k), + f, + lng, + options + ) + } + + this.resetRegExp() + var missingInterpolationHandler = + (options && options.missingInterpolationHandler) || + this.options.missingInterpolationHandler + var skipOnVariables = + (options && + options.interpolation && + options.interpolation.skipOnVariables) || + this.options.interpolation.skipOnVariables + var todos = [ + { + regex: this.regexpUnescape, + safeValue: function safeValue(val) { + return regexSafe(val) + } + }, + { + regex: this.regexp, + safeValue: function safeValue(val) { + return _this.escapeValue + ? regexSafe(_this.escape(val)) + : regexSafe(val) + } + } + ] + todos.forEach(function (todo) { + replaces = 0 + + while ((match = todo.regex.exec(str))) { + value = handleFormat(match[1].trim()) + + if (value === undefined) { + if (typeof missingInterpolationHandler === 'function') { + var temp = missingInterpolationHandler( + str, + match, + options + ) + value = typeof temp === 'string' ? temp : '' + } else if (skipOnVariables) { + value = match[0] + continue + } else { + _this.logger.warn( + 'missed to pass in variable ' + .concat(match[1], ' for interpolating ') + .concat(str) + ) + + value = '' + } + } else if ( + typeof value !== 'string' && + !_this.useRawValueToEscape + ) { + value = makeString(value) + } + + str = str.replace(match[0], todo.safeValue(value)) + todo.regex.lastIndex = 0 + replaces++ + + if (replaces >= _this.maxReplaces) { + break + } + } + }) + return str + } + }, + { + key: 'nest', + value: function nest(str, fc) { + var _this2 = this + + var options = + arguments.length > 2 && arguments[2] !== undefined + ? arguments[2] + : {} + var match + var value + + var clonedOptions = _objectSpread({}, options) + + clonedOptions.applyPostProcessor = false + delete clonedOptions.defaultValue + + function handleHasOptions(key, inheritedOptions) { + var sep = this.nestingOptionsSeparator + if (key.indexOf(sep) < 0) return key + var c = key.split(new RegExp(''.concat(sep, '[ ]*{'))) + var optionsString = '{'.concat(c[1]) + key = c[0] + optionsString = this.interpolate(optionsString, clonedOptions) + optionsString = optionsString.replace(/'/g, '"') + + try { + clonedOptions = JSON.parse(optionsString) + if (inheritedOptions) + clonedOptions = _objectSpread( + {}, + inheritedOptions, + clonedOptions + ) + } catch (e) { + this.logger.warn( + 'failed parsing options string in nesting for key '.concat( + key + ), + e + ) + return ''.concat(key).concat(sep).concat(optionsString) + } + + delete clonedOptions.defaultValue + return key + } + + while ((match = this.nestingRegexp.exec(str))) { + var formatters = [] + var doReduce = false + + if ( + match[0].includes(this.formatSeparator) && + !/{.*}/.test(match[1]) + ) { + var r = match[1] + .split(this.formatSeparator) + .map(function (elem) { + return elem.trim() + }) + match[1] = r.shift() + formatters = r + doReduce = true + } + + value = fc( + handleHasOptions.call(this, match[1].trim(), clonedOptions), + clonedOptions + ) + if (value && match[0] === str && typeof value !== 'string') + return value + if (typeof value !== 'string') value = makeString(value) + + if (!value) { + this.logger.warn( + 'missed to resolve ' + .concat(match[1], ' for nesting ') + .concat(str) + ) + value = '' + } + + if (doReduce) { + value = formatters.reduce(function (v, f) { + return _this2.format(v, f, options.lng, options) + }, value.trim()) + } + + str = str.replace(match[0], value) + this.regexp.lastIndex = 0 + } + + return str + } + } + ]) + + return Interpolator + })() + + function remove(arr, what) { + var found = arr.indexOf(what) + + while (found !== -1) { + arr.splice(found, 1) + found = arr.indexOf(what) + } + } + + var Connector = (function (_EventEmitter) { + _inherits(Connector, _EventEmitter) + + function Connector(backend, store, services) { + var _this + + var options = + arguments.length > 3 && arguments[3] !== undefined + ? arguments[3] + : {} + + _classCallCheck(this, Connector) + + _this = _possibleConstructorReturn( + this, + _getPrototypeOf(Connector).call(this) + ) + + if (isIE10) { + EventEmitter.call(_assertThisInitialized(_this)) + } + + _this.backend = backend + _this.store = store + _this.services = services + _this.languageUtils = services.languageUtils + _this.options = options + _this.logger = baseLogger.create('backendConnector') + _this.state = {} + _this.queue = [] + + if (_this.backend && _this.backend.init) { + _this.backend.init(services, options.backend, options) + } + + return _this + } + + _createClass(Connector, [ + { + key: 'queueLoad', + value: function queueLoad( + languages, + namespaces, + options, + callback + ) { + var _this2 = this + + var toLoad = [] + var pending = [] + var toLoadLanguages = [] + var toLoadNamespaces = [] + languages.forEach(function (lng) { + var hasAllNamespaces = true + namespaces.forEach(function (ns) { + var name = ''.concat(lng, '|').concat(ns) + + if ( + !options.reload && + _this2.store.hasResourceBundle(lng, ns) + ) { + _this2.state[name] = 2 + } else if (_this2.state[name] < 0); + else if (_this2.state[name] === 1) { + if (pending.indexOf(name) < 0) pending.push(name) + } else { + _this2.state[name] = 1 + hasAllNamespaces = false + if (pending.indexOf(name) < 0) pending.push(name) + if (toLoad.indexOf(name) < 0) toLoad.push(name) + if (toLoadNamespaces.indexOf(ns) < 0) + toLoadNamespaces.push(ns) + } + }) + if (!hasAllNamespaces) toLoadLanguages.push(lng) + }) + + if (toLoad.length || pending.length) { + this.queue.push({ + pending: pending, + loaded: {}, + errors: [], + callback: callback + }) + } + + return { + toLoad: toLoad, + pending: pending, + toLoadLanguages: toLoadLanguages, + toLoadNamespaces: toLoadNamespaces + } + } + }, + { + key: 'loaded', + value: function loaded(name, err, data) { + var s = name.split('|') + var lng = s[0] + var ns = s[1] + if (err) this.emit('failedLoading', lng, ns, err) + + if (data) { + this.store.addResourceBundle(lng, ns, data) + } + + this.state[name] = err ? -1 : 2 + var loaded = {} + this.queue.forEach(function (q) { + pushPath(q.loaded, [lng], ns) + remove(q.pending, name) + if (err) q.errors.push(err) + + if (q.pending.length === 0 && !q.done) { + Object.keys(q.loaded).forEach(function (l) { + if (!loaded[l]) loaded[l] = [] + + if (q.loaded[l].length) { + q.loaded[l].forEach(function (ns) { + if (loaded[l].indexOf(ns) < 0) loaded[l].push(ns) + }) + } + }) + q.done = true + + if (q.errors.length) { + q.callback(q.errors) + } else { + q.callback() + } + } + }) + this.emit('loaded', loaded) + this.queue = this.queue.filter(function (q) { + return !q.done + }) + } + }, + { + key: 'read', + value: function read(lng, ns, fcName) { + var _this3 = this + + var tried = + arguments.length > 3 && arguments[3] !== undefined + ? arguments[3] + : 0 + var wait = + arguments.length > 4 && arguments[4] !== undefined + ? arguments[4] + : 350 + var callback = arguments.length > 5 ? arguments[5] : undefined + if (!lng.length) return callback(null, {}) + return this.backend[fcName](lng, ns, function (err, data) { + if (err && data && tried < 5) { + setTimeout(function () { + _this3.read.call( + _this3, + lng, + ns, + fcName, + tried + 1, + wait * 2, + callback + ) + }, wait) + return + } + + callback(err, data) + }) + } + }, + { + key: 'prepareLoading', + value: function prepareLoading(languages, namespaces) { + var _this4 = this + + var options = + arguments.length > 2 && arguments[2] !== undefined + ? arguments[2] + : {} + var callback = arguments.length > 3 ? arguments[3] : undefined + + if (!this.backend) { + this.logger.warn( + 'No backend was added via i18next.use. Will not load resources.' + ) + return callback && callback() + } + + if (typeof languages === 'string') + languages = this.languageUtils.toResolveHierarchy(languages) + if (typeof namespaces === 'string') namespaces = [namespaces] + var toLoad = this.queueLoad( + languages, + namespaces, + options, + callback + ) + + if (!toLoad.toLoad.length) { + if (!toLoad.pending.length) callback() + return null + } + + toLoad.toLoad.forEach(function (name) { + _this4.loadOne(name) + }) + } + }, + { + key: 'load', + value: function load(languages, namespaces, callback) { + this.prepareLoading(languages, namespaces, {}, callback) + } + }, + { + key: 'reload', + value: function reload(languages, namespaces, callback) { + this.prepareLoading( + languages, + namespaces, + { + reload: true + }, + callback + ) + } + }, + { + key: 'loadOne', + value: function loadOne(name) { + var _this5 = this + + var prefix = + arguments.length > 1 && arguments[1] !== undefined + ? arguments[1] + : '' + var s = name.split('|') + var lng = s[0] + var ns = s[1] + this.read(lng, ns, 'read', undefined, undefined, function ( + err, + data + ) { + if (err) + _this5.logger.warn( + '' + .concat(prefix, 'loading namespace ') + .concat(ns, ' for language ') + .concat(lng, ' failed'), + err + ) + if (!err && data) + _this5.logger.log( + '' + .concat(prefix, 'loaded namespace ') + .concat(ns, ' for language ') + .concat(lng), + data + ) + + _this5.loaded(name, err, data) + }) + } + }, + { + key: 'saveMissing', + value: function saveMissing( + languages, + namespace, + key, + fallbackValue, + isUpdate + ) { + var options = + arguments.length > 5 && arguments[5] !== undefined + ? arguments[5] + : {} + + if ( + this.services.utils && + this.services.utils.hasLoadedNamespace && + !this.services.utils.hasLoadedNamespace(namespace) + ) { + this.logger.warn( + 'did not save key "' + .concat(key, '" as the namespace "') + .concat(namespace, '" was not yet loaded'), + 'This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!' + ) + return + } + + if (key === undefined || key === null || key === '') return + + if (this.backend && this.backend.create) { + this.backend.create( + languages, + namespace, + key, + fallbackValue, + null, + _objectSpread({}, options, { + isUpdate: isUpdate + }) + ) + } + + if (!languages || !languages[0]) return + this.store.addResource( + languages[0], + namespace, + key, + fallbackValue + ) + } + } + ]) + + return Connector + })(EventEmitter) + + function get() { + return { + debug: false, + initImmediate: true, + ns: ['translation'], + defaultNS: ['translation'], + fallbackLng: ['dev'], + fallbackNS: false, + whitelist: false, + nonExplicitWhitelist: false, + supportedLngs: false, + nonExplicitSupportedLngs: false, + load: 'all', + preload: false, + simplifyPluralSuffix: true, + keySeparator: '.', + nsSeparator: ':', + pluralSeparator: '_', + contextSeparator: '_', + partialBundledLanguages: false, + saveMissing: false, + updateMissing: false, + saveMissingTo: 'fallback', + saveMissingPlurals: true, + missingKeyHandler: false, + missingInterpolationHandler: false, + postProcess: false, + postProcessPassResolved: false, + returnNull: true, + returnEmptyString: true, + returnObjects: false, + joinArrays: false, + returnedObjectHandler: false, + parseMissingKeyHandler: false, + appendNamespaceToMissingKey: false, + appendNamespaceToCIMode: false, + overloadTranslationOptionHandler: function handle(args) { + var ret = {} + if (_typeof(args[1]) === 'object') ret = args[1] + if (typeof args[1] === 'string') ret.defaultValue = args[1] + if (typeof args[2] === 'string') ret.tDescription = args[2] + + if ( + _typeof(args[2]) === 'object' || + _typeof(args[3]) === 'object' + ) { + var options = args[3] || args[2] + Object.keys(options).forEach(function (key) { + ret[key] = options[key] + }) + } + + return ret + }, + interpolation: { + escapeValue: true, + format: function format(value, _format, lng, options) { + return value + }, + prefix: '{{', + suffix: '}}', + formatSeparator: ',', + unescapePrefix: '-', + nestingPrefix: '$t(', + nestingSuffix: ')', + nestingOptionsSeparator: ',', + maxReplaces: 1000, + skipOnVariables: false + } + } + } + function transformOptions(options) { + if (typeof options.ns === 'string') options.ns = [options.ns] + if (typeof options.fallbackLng === 'string') + options.fallbackLng = [options.fallbackLng] + if (typeof options.fallbackNS === 'string') + options.fallbackNS = [options.fallbackNS] + + if (options.whitelist) { + if (options.whitelist && options.whitelist.indexOf('cimode') < 0) { + options.whitelist = options.whitelist.concat(['cimode']) + } + + options.supportedLngs = options.whitelist + } + + if (options.nonExplicitWhitelist) { + options.nonExplicitSupportedLngs = options.nonExplicitWhitelist + } + + if ( + options.supportedLngs && + options.supportedLngs.indexOf('cimode') < 0 + ) { + options.supportedLngs = options.supportedLngs.concat(['cimode']) + } + + return options + } + + function noop() {} + + var I18n = (function (_EventEmitter) { + _inherits(I18n, _EventEmitter) + + function I18n() { + var _this + + var options = + arguments.length > 0 && arguments[0] !== undefined + ? arguments[0] + : {} + var callback = arguments.length > 1 ? arguments[1] : undefined + + _classCallCheck(this, I18n) + + _this = _possibleConstructorReturn( + this, + _getPrototypeOf(I18n).call(this) + ) + + if (isIE10) { + EventEmitter.call(_assertThisInitialized(_this)) + } + + _this.options = transformOptions(options) + _this.services = {} + _this.logger = baseLogger + _this.modules = { + external: [] + } + + if (callback && !_this.isInitialized && !options.isClone) { + if (!_this.options.initImmediate) { + _this.init(options, callback) + + return _possibleConstructorReturn( + _this, + _assertThisInitialized(_this) + ) + } + + setTimeout(function () { + _this.init(options, callback) + }, 0) + } + + return _this + } + + _createClass(I18n, [ + { + key: 'init', + value: function init() { + var _this2 = this + + var options = + arguments.length > 0 && arguments[0] !== undefined + ? arguments[0] + : {} + var callback = arguments.length > 1 ? arguments[1] : undefined + + if (typeof options === 'function') { + callback = options + options = {} + } + + if (options.whitelist && !options.supportedLngs) { + this.logger.deprecate( + 'whitelist', + 'option "whitelist" will be renamed to "supportedLngs" in the next major - please make sure to rename this option asap.' + ) + } + + if ( + options.nonExplicitWhitelist && + !options.nonExplicitSupportedLngs + ) { + this.logger.deprecate( + 'whitelist', + 'options "nonExplicitWhitelist" will be renamed to "nonExplicitSupportedLngs" in the next major - please make sure to rename this option asap.' + ) + } + + this.options = _objectSpread( + {}, + get(), + this.options, + transformOptions(options) + ) + this.format = this.options.interpolation.format + if (!callback) callback = noop + + function createClassOnDemand(ClassOrObject) { + if (!ClassOrObject) return null + if (typeof ClassOrObject === 'function') + return new ClassOrObject() + return ClassOrObject + } + + if (!this.options.isClone) { + if (this.modules.logger) { + baseLogger.init( + createClassOnDemand(this.modules.logger), + this.options + ) + } else { + baseLogger.init(null, this.options) + } + + var lu = new LanguageUtil(this.options) + this.store = new ResourceStore( + this.options.resources, + this.options + ) + var s = this.services + s.logger = baseLogger + s.resourceStore = this.store + s.languageUtils = lu + s.pluralResolver = new PluralResolver(lu, { + prepend: this.options.pluralSeparator, + compatibilityJSON: this.options.compatibilityJSON, + simplifyPluralSuffix: this.options.simplifyPluralSuffix + }) + s.interpolator = new Interpolator(this.options) + s.utils = { + hasLoadedNamespace: this.hasLoadedNamespace.bind(this) + } + s.backendConnector = new Connector( + createClassOnDemand(this.modules.backend), + s.resourceStore, + s, + this.options + ) + s.backendConnector.on('*', function (event) { + for ( + var _len = arguments.length, + args = new Array(_len > 1 ? _len - 1 : 0), + _key = 1; + _key < _len; + _key++ + ) { + args[_key - 1] = arguments[_key] + } + + _this2.emit.apply(_this2, [event].concat(args)) + }) + + if (this.modules.languageDetector) { + s.languageDetector = createClassOnDemand( + this.modules.languageDetector + ) + s.languageDetector.init( + s, + this.options.detection, + this.options + ) + } + + if (this.modules.i18nFormat) { + s.i18nFormat = createClassOnDemand(this.modules.i18nFormat) + if (s.i18nFormat.init) s.i18nFormat.init(this) + } + + this.translator = new Translator(this.services, this.options) + this.translator.on('*', function (event) { + for ( + var _len2 = arguments.length, + args = new Array(_len2 > 1 ? _len2 - 1 : 0), + _key2 = 1; + _key2 < _len2; + _key2++ + ) { + args[_key2 - 1] = arguments[_key2] + } + + _this2.emit.apply(_this2, [event].concat(args)) + }) + this.modules.external.forEach(function (m) { + if (m.init) m.init(_this2) + }) + } + + if (!this.services.languageDetector && !this.options.lng) { + this.logger.warn( + 'init: no languageDetector is used and no lng is defined' + ) + } + + var storeApi = [ + 'getResource', + 'hasResourceBundle', + 'getResourceBundle', + 'getDataByLanguage' + ] + storeApi.forEach(function (fcName) { + _this2[fcName] = function () { + var _this2$store + + return (_this2$store = _this2.store)[fcName].apply( + _this2$store, + arguments + ) + } + }) + var storeApiChained = [ + 'addResource', + 'addResources', + 'addResourceBundle', + 'removeResourceBundle' + ] + storeApiChained.forEach(function (fcName) { + _this2[fcName] = function () { + var _this2$store2 + + ;(_this2$store2 = _this2.store)[fcName].apply( + _this2$store2, + arguments + ) + + return _this2 + } + }) + var deferred = defer() + + var load = function load() { + _this2.changeLanguage(_this2.options.lng, function (err, t) { + _this2.isInitialized = true + if (!_this2.options.isClone) + _this2.logger.log('initialized', _this2.options) + + _this2.emit('initialized', _this2.options) + + deferred.resolve(t) + callback(err, t) + }) + } + + if (this.options.resources || !this.options.initImmediate) { + load() + } else { + setTimeout(load, 0) + } + + return deferred + } + }, + { + key: 'loadResources', + value: function loadResources(language) { + var _this3 = this + + var callback = + arguments.length > 1 && arguments[1] !== undefined + ? arguments[1] + : noop + var usedCallback = callback + var usedLng = + typeof language === 'string' ? language : this.language + if (typeof language === 'function') usedCallback = language + + if ( + !this.options.resources || + this.options.partialBundledLanguages + ) { + if (usedLng && usedLng.toLowerCase() === 'cimode') + return usedCallback() + var toLoad = [] + + var append = function append(lng) { + if (!lng) return + + var lngs = _this3.services.languageUtils.toResolveHierarchy( + lng + ) + + lngs.forEach(function (l) { + if (toLoad.indexOf(l) < 0) toLoad.push(l) + }) + } + + if (!usedLng) { + var fallbacks = this.services.languageUtils.getFallbackCodes( + this.options.fallbackLng + ) + fallbacks.forEach(function (l) { + return append(l) + }) + } else { + append(usedLng) + } + + if (this.options.preload) { + this.options.preload.forEach(function (l) { + return append(l) + }) + } + + this.services.backendConnector.load( + toLoad, + this.options.ns, + usedCallback + ) + } else { + usedCallback(null) + } + } + }, + { + key: 'reloadResources', + value: function reloadResources(lngs, ns, callback) { + var deferred = defer() + if (!lngs) lngs = this.languages + if (!ns) ns = this.options.ns + if (!callback) callback = noop + this.services.backendConnector.reload(lngs, ns, function (err) { + deferred.resolve() + callback(err) + }) + return deferred + } + }, + { + key: 'use', + value: function use(module) { + if (!module) + throw new Error( + 'You are passing an undefined module! Please check the object you are passing to i18next.use()' + ) + if (!module.type) + throw new Error( + 'You are passing a wrong module! Please check the object you are passing to i18next.use()' + ) + + if (module.type === 'backend') { + this.modules.backend = module + } + + if ( + module.type === 'logger' || + (module.log && module.warn && module.error) + ) { + this.modules.logger = module + } + + if (module.type === 'languageDetector') { + this.modules.languageDetector = module + } + + if (module.type === 'i18nFormat') { + this.modules.i18nFormat = module + } + + if (module.type === 'postProcessor') { + postProcessor.addPostProcessor(module) + } + + if (module.type === '3rdParty') { + this.modules.external.push(module) + } + + return this + } + }, + { + key: 'changeLanguage', + value: function changeLanguage(lng, callback) { + var _this4 = this + + this.isLanguageChangingTo = lng + var deferred = defer() + this.emit('languageChanging', lng) + + var done = function done(err, l) { + if (l) { + _this4.language = l + _this4.languages = _this4.services.languageUtils.toResolveHierarchy( + l + ) + + _this4.translator.changeLanguage(l) + + _this4.isLanguageChangingTo = undefined + + _this4.emit('languageChanged', l) + + _this4.logger.log('languageChanged', l) + } else { + _this4.isLanguageChangingTo = undefined + } + + deferred.resolve(function () { + return _this4.t.apply(_this4, arguments) + }) + if (callback) + callback(err, function () { + return _this4.t.apply(_this4, arguments) + }) + } + + var setLng = function setLng(lngs) { + var l = + typeof lngs === 'string' + ? lngs + : _this4.services.languageUtils.getBestMatchFromCodes(lngs) + + if (l) { + if (!_this4.language) { + _this4.language = l + _this4.languages = _this4.services.languageUtils.toResolveHierarchy( + l + ) + } + + if (!_this4.translator.language) + _this4.translator.changeLanguage(l) + if (_this4.services.languageDetector) + _this4.services.languageDetector.cacheUserLanguage(l) + } + + _this4.loadResources(l, function (err) { + done(err, l) + }) + } + + if ( + !lng && + this.services.languageDetector && + !this.services.languageDetector.async + ) { + setLng(this.services.languageDetector.detect()) + } else if ( + !lng && + this.services.languageDetector && + this.services.languageDetector.async + ) { + this.services.languageDetector.detect(setLng) + } else { + setLng(lng) + } + + return deferred + } + }, + { + key: 'getFixedT', + value: function getFixedT(lng, ns) { + var _this5 = this + + var fixedT = function fixedT(key, opts) { + var options + + if (_typeof(opts) !== 'object') { + for ( + var _len3 = arguments.length, + rest = new Array(_len3 > 2 ? _len3 - 2 : 0), + _key3 = 2; + _key3 < _len3; + _key3++ + ) { + rest[_key3 - 2] = arguments[_key3] + } + + options = _this5.options.overloadTranslationOptionHandler( + [key, opts].concat(rest) + ) + } else { + options = _objectSpread({}, opts) + } + + options.lng = options.lng || fixedT.lng + options.lngs = options.lngs || fixedT.lngs + options.ns = options.ns || fixedT.ns + return _this5.t(key, options) + } + + if (typeof lng === 'string') { + fixedT.lng = lng + } else { + fixedT.lngs = lng + } + + fixedT.ns = ns + return fixedT + } + }, + { + key: 't', + value: function t() { + var _this$translator + + return ( + this.translator && + (_this$translator = this.translator).translate.apply( + _this$translator, + arguments + ) + ) + } + }, + { + key: 'exists', + value: function exists() { + var _this$translator2 + + return ( + this.translator && + (_this$translator2 = this.translator).exists.apply( + _this$translator2, + arguments + ) + ) + } + }, + { + key: 'setDefaultNamespace', + value: function setDefaultNamespace(ns) { + this.options.defaultNS = ns + } + }, + { + key: 'hasLoadedNamespace', + value: function hasLoadedNamespace(ns) { + var _this6 = this + + var options = + arguments.length > 1 && arguments[1] !== undefined + ? arguments[1] + : {} + + if (!this.isInitialized) { + this.logger.warn( + 'hasLoadedNamespace: i18next was not initialized', + this.languages + ) + return false + } + + if (!this.languages || !this.languages.length) { + this.logger.warn( + 'hasLoadedNamespace: i18n.languages were undefined or empty', + this.languages + ) + return false + } + + var lng = this.languages[0] + var fallbackLng = this.options ? this.options.fallbackLng : false + var lastLng = this.languages[this.languages.length - 1] + if (lng.toLowerCase() === 'cimode') return true + + var loadNotPending = function loadNotPending(l, n) { + var loadState = + _this6.services.backendConnector.state[ + ''.concat(l, '|').concat(n) + ] + + return loadState === -1 || loadState === 2 + } + + if (options.precheck) { + var preResult = options.precheck(this, loadNotPending) + if (preResult !== undefined) return preResult + } + + if (this.hasResourceBundle(lng, ns)) return true + if (!this.services.backendConnector.backend) return true + if ( + loadNotPending(lng, ns) && + (!fallbackLng || loadNotPending(lastLng, ns)) + ) + return true + return false + } + }, + { + key: 'loadNamespaces', + value: function loadNamespaces(ns, callback) { + var _this7 = this + + var deferred = defer() + + if (!this.options.ns) { + callback && callback() + return Promise.resolve() + } + + if (typeof ns === 'string') ns = [ns] + ns.forEach(function (n) { + if (_this7.options.ns.indexOf(n) < 0) _this7.options.ns.push(n) + }) + this.loadResources(function (err) { + deferred.resolve() + if (callback) callback(err) + }) + return deferred + } + }, + { + key: 'loadLanguages', + value: function loadLanguages(lngs, callback) { + var deferred = defer() + if (typeof lngs === 'string') lngs = [lngs] + var preloaded = this.options.preload || [] + var newLngs = lngs.filter(function (lng) { + return preloaded.indexOf(lng) < 0 + }) + + if (!newLngs.length) { + if (callback) callback() + return Promise.resolve() + } + + this.options.preload = preloaded.concat(newLngs) + this.loadResources(function (err) { + deferred.resolve() + if (callback) callback(err) + }) + return deferred + } + }, + { + key: 'dir', + value: function dir(lng) { + if (!lng) + lng = + this.languages && this.languages.length > 0 + ? this.languages[0] + : this.language + if (!lng) return 'rtl' + var rtlLngs = [ + 'ar', + 'shu', + 'sqr', + 'ssh', + 'xaa', + 'yhd', + 'yud', + 'aao', + 'abh', + 'abv', + 'acm', + 'acq', + 'acw', + 'acx', + 'acy', + 'adf', + 'ads', + 'aeb', + 'aec', + 'afb', + 'ajp', + 'apc', + 'apd', + 'arb', + 'arq', + 'ars', + 'ary', + 'arz', + 'auz', + 'avl', + 'ayh', + 'ayl', + 'ayn', + 'ayp', + 'bbz', + 'pga', + 'he', + 'iw', + 'ps', + 'pbt', + 'pbu', + 'pst', + 'prp', + 'prd', + 'ug', + 'ur', + 'ydd', + 'yds', + 'yih', + 'ji', + 'yi', + 'hbo', + 'men', + 'xmn', + 'fa', + 'jpr', + 'peo', + 'pes', + 'prs', + 'dv', + 'sam' + ] + return rtlLngs.indexOf( + this.services.languageUtils.getLanguagePartFromCode(lng) + ) >= 0 + ? 'rtl' + : 'ltr' + } + }, + { + key: 'createInstance', + value: function createInstance() { + var options = + arguments.length > 0 && arguments[0] !== undefined + ? arguments[0] + : {} + var callback = arguments.length > 1 ? arguments[1] : undefined + return new I18n(options, callback) + } + }, + { + key: 'cloneInstance', + value: function cloneInstance() { + var _this8 = this + + var options = + arguments.length > 0 && arguments[0] !== undefined + ? arguments[0] + : {} + var callback = + arguments.length > 1 && arguments[1] !== undefined + ? arguments[1] + : noop + + var mergedOptions = _objectSpread({}, this.options, options, { + isClone: true + }) + + var clone = new I18n(mergedOptions) + var membersToCopy = ['store', 'services', 'language'] + membersToCopy.forEach(function (m) { + clone[m] = _this8[m] + }) + clone.services = _objectSpread({}, this.services) + clone.services.utils = { + hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone) + } + clone.translator = new Translator(clone.services, clone.options) + clone.translator.on('*', function (event) { + for ( + var _len4 = arguments.length, + args = new Array(_len4 > 1 ? _len4 - 1 : 0), + _key4 = 1; + _key4 < _len4; + _key4++ + ) { + args[_key4 - 1] = arguments[_key4] + } + + clone.emit.apply(clone, [event].concat(args)) + }) + clone.init(mergedOptions, callback) + clone.translator.options = clone.options + clone.translator.backendConnector.services.utils = { + hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone) + } + return clone + } + } + ]) + + return I18n + })(EventEmitter) + + var i18next = new I18n() + + module.exports = i18next + + /***/ + }, + + /***/ 44124: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + try { + var util = __webpack_require__(31669) + /* istanbul ignore next */ + if (typeof util.inherits !== 'function') throw '' + module.exports = util.inherits + } catch (e) { + /* istanbul ignore next */ + module.exports = __webpack_require__(8544) + } + + /***/ + }, + + /***/ 8544: /***/ module => { + if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + module.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }) + } + } + } else { + // old school shim for old browsers + module.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor + var TempCtor = function () {} + TempCtor.prototype = superCtor.prototype + ctor.prototype = new TempCtor() + ctor.prototype.constructor = ctor + } + } + } + + /***/ + }, + + /***/ 51389: /***/ module => { + 'use strict' + + module.exports = value => { + const type = typeof value + return value !== null && (type === 'object' || type === 'function') + } + + /***/ + }, + + /***/ 66634: /***/ module => { + 'use strict' + + module.exports = function (stream) { + var ended + + if (typeof stream.ended !== 'undefined') { + ended = stream.ended + } else { + ended = stream._readableState.ended + } + + return Boolean(ended).valueOf() + } + + /***/ + }, + + /***/ 41554: /***/ module => { + 'use strict' + + var isStream = (module.exports = function (stream) { + return ( + stream !== null && + typeof stream === 'object' && + typeof stream.pipe === 'function' + ) + }) + + isStream.writable = function (stream) { + return ( + isStream(stream) && + stream.writable !== false && + typeof stream._write === 'function' && + typeof stream._writableState === 'object' + ) + } + + isStream.readable = function (stream) { + return ( + isStream(stream) && + stream.readable !== false && + typeof stream._read === 'function' && + typeof stream._readableState === 'object' + ) + } + + isStream.duplex = function (stream) { + return isStream.writable(stream) && isStream.readable(stream) + } + + isStream.transform = function (stream) { + return ( + isStream.duplex(stream) && + typeof stream._transform === 'function' && + typeof stream._transformState === 'object' + ) + } + + /***/ + }, + + /***/ 10657: /***/ module => { + module.exports = isTypedArray + isTypedArray.strict = isStrictTypedArray + isTypedArray.loose = isLooseTypedArray + + var toString = Object.prototype.toString + var names = { + '[object Int8Array]': true, + '[object Int16Array]': true, + '[object Int32Array]': true, + '[object Uint8Array]': true, + '[object Uint8ClampedArray]': true, + '[object Uint16Array]': true, + '[object Uint32Array]': true, + '[object Float32Array]': true, + '[object Float64Array]': true + } + + function isTypedArray(arr) { + return isStrictTypedArray(arr) || isLooseTypedArray(arr) + } + + function isStrictTypedArray(arr) { + return ( + arr instanceof Int8Array || + arr instanceof Int16Array || + arr instanceof Int32Array || + arr instanceof Uint8Array || + arr instanceof Uint8ClampedArray || + arr instanceof Uint16Array || + arr instanceof Uint32Array || + arr instanceof Float32Array || + arr instanceof Float64Array + ) + } + + function isLooseTypedArray(arr) { + return names[toString.call(arr)] + } + + /***/ + }, + + /***/ 98941: /***/ module => { + 'use strict' + /* globals window, HTMLElement */ + + /**! + * is + * the definitive JavaScript type testing library + * + * @copyright 2013-2014 Enrico Marino / Jordan Harband + * @license MIT + */ + + var objProto = Object.prototype + var owns = objProto.hasOwnProperty + var toStr = objProto.toString + var symbolValueOf + if (typeof Symbol === 'function') { + symbolValueOf = Symbol.prototype.valueOf + } + var bigIntValueOf + if (typeof BigInt === 'function') { + bigIntValueOf = BigInt.prototype.valueOf + } + var isActualNaN = function (value) { + return value !== value + } + var NON_HOST_TYPES = { + boolean: 1, + number: 1, + string: 1, + undefined: 1 + } + + var base64Regex = /^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$/ + var hexRegex = /^[A-Fa-f0-9]+$/ + + /** + * Expose `is` + */ + + var is = {} + + /** + * Test general. + */ + + /** + * is.type + * Test if `value` is a type of `type`. + * + * @param {*} value value to test + * @param {String} type type + * @return {Boolean} true if `value` is a type of `type`, false otherwise + * @api public + */ + + is.a = is.type = function (value, type) { + return typeof value === type + } + + /** + * is.defined + * Test if `value` is defined. + * + * @param {*} value value to test + * @return {Boolean} true if 'value' is defined, false otherwise + * @api public + */ + + is.defined = function (value) { + return typeof value !== 'undefined' + } + + /** + * is.empty + * Test if `value` is empty. + * + * @param {*} value value to test + * @return {Boolean} true if `value` is empty, false otherwise + * @api public + */ + + is.empty = function (value) { + var type = toStr.call(value) + var key + + if ( + type === '[object Array]' || + type === '[object Arguments]' || + type === '[object String]' + ) { + return value.length === 0 + } + + if (type === '[object Object]') { + for (key in value) { + if (owns.call(value, key)) { + return false + } + } + return true + } + + return !value + } + + /** + * is.equal + * Test if `value` is equal to `other`. + * + * @param {*} value value to test + * @param {*} other value to compare with + * @return {Boolean} true if `value` is equal to `other`, false otherwise + */ + + is.equal = function equal(value, other) { + if (value === other) { + return true + } + + var type = toStr.call(value) + var key + + if (type !== toStr.call(other)) { + return false + } + + if (type === '[object Object]') { + for (key in value) { + if (!is.equal(value[key], other[key]) || !(key in other)) { + return false + } + } + for (key in other) { + if (!is.equal(value[key], other[key]) || !(key in value)) { + return false + } + } + return true + } + + if (type === '[object Array]') { + key = value.length + if (key !== other.length) { + return false + } + while (key--) { + if (!is.equal(value[key], other[key])) { + return false + } + } + return true + } + + if (type === '[object Function]') { + return value.prototype === other.prototype + } + + if (type === '[object Date]') { + return value.getTime() === other.getTime() + } + + return false + } + + /** + * is.hosted + * Test if `value` is hosted by `host`. + * + * @param {*} value to test + * @param {*} host host to test with + * @return {Boolean} true if `value` is hosted by `host`, false otherwise + * @api public + */ + + is.hosted = function (value, host) { + var type = typeof host[value] + return type === 'object' ? !!host[value] : !NON_HOST_TYPES[type] + } + + /** + * is.instance + * Test if `value` is an instance of `constructor`. + * + * @param {*} value value to test + * @return {Boolean} true if `value` is an instance of `constructor` + * @api public + */ + + is.instance = is['instanceof'] = function (value, constructor) { + return value instanceof constructor + } + + /** + * is.nil / is.null + * Test if `value` is null. + * + * @param {*} value value to test + * @return {Boolean} true if `value` is null, false otherwise + * @api public + */ + + is.nil = is['null'] = function (value) { + return value === null + } + + /** + * is.undef / is.undefined + * Test if `value` is undefined. + * + * @param {*} value value to test + * @return {Boolean} true if `value` is undefined, false otherwise + * @api public + */ + + is.undef = is.undefined = function (value) { + return typeof value === 'undefined' + } + + /** + * Test arguments. + */ + + /** + * is.args + * Test if `value` is an arguments object. + * + * @param {*} value value to test + * @return {Boolean} true if `value` is an arguments object, false otherwise + * @api public + */ + + is.args = is.arguments = function (value) { + var isStandardArguments = toStr.call(value) === '[object Arguments]' + var isOldArguments = + !is.array(value) && + is.arraylike(value) && + is.object(value) && + is.fn(value.callee) + return isStandardArguments || isOldArguments + } + + /** + * Test array. + */ + + /** + * is.array + * Test if 'value' is an array. + * + * @param {*} value value to test + * @return {Boolean} true if `value` is an array, false otherwise + * @api public + */ + + is.array = + Array.isArray || + function (value) { + return toStr.call(value) === '[object Array]' + } + + /** + * is.arguments.empty + * Test if `value` is an empty arguments object. + * + * @param {*} value value to test + * @return {Boolean} true if `value` is an empty arguments object, false otherwise + * @api public + */ + is.args.empty = function (value) { + return is.args(value) && value.length === 0 + } + + /** + * is.array.empty + * Test if `value` is an empty array. + * + * @param {*} value value to test + * @return {Boolean} true if `value` is an empty array, false otherwise + * @api public + */ + is.array.empty = function (value) { + return is.array(value) && value.length === 0 + } + + /** + * is.arraylike + * Test if `value` is an arraylike object. + * + * @param {*} value value to test + * @return {Boolean} true if `value` is an arguments object, false otherwise + * @api public + */ + + is.arraylike = function (value) { + return ( + !!value && + !is.bool(value) && + owns.call(value, 'length') && + isFinite(value.length) && + is.number(value.length) && + value.length >= 0 + ) + } + + /** + * Test boolean. + */ + + /** + * is.bool + * Test if `value` is a boolean. + * + * @param {*} value value to test + * @return {Boolean} true if `value` is a boolean, false otherwise + * @api public + */ + + is.bool = is['boolean'] = function (value) { + return toStr.call(value) === '[object Boolean]' + } + + /** + * is.false + * Test if `value` is false. + * + * @param {*} value value to test + * @return {Boolean} true if `value` is false, false otherwise + * @api public + */ + + is['false'] = function (value) { + return is.bool(value) && Boolean(Number(value)) === false + } + + /** + * is.true + * Test if `value` is true. + * + * @param {*} value value to test + * @return {Boolean} true if `value` is true, false otherwise + * @api public + */ + + is['true'] = function (value) { + return is.bool(value) && Boolean(Number(value)) === true + } + + /** + * Test date. + */ + + /** + * is.date + * Test if `value` is a date. + * + * @param {*} value value to test + * @return {Boolean} true if `value` is a date, false otherwise + * @api public + */ + + is.date = function (value) { + return toStr.call(value) === '[object Date]' + } + + /** + * is.date.valid + * Test if `value` is a valid date. + * + * @param {*} value value to test + * @returns {Boolean} true if `value` is a valid date, false otherwise + */ + is.date.valid = function (value) { + return is.date(value) && !isNaN(Number(value)) + } + + /** + * Test element. + */ + + /** + * is.element + * Test if `value` is an html element. + * + * @param {*} value value to test + * @return {Boolean} true if `value` is an HTML Element, false otherwise + * @api public + */ + + is.element = function (value) { + return ( + value !== undefined && + typeof HTMLElement !== 'undefined' && + value instanceof HTMLElement && + value.nodeType === 1 + ) + } + + /** + * Test error. + */ + + /** + * is.error + * Test if `value` is an error object. + * + * @param {*} value value to test + * @return {Boolean} true if `value` is an error object, false otherwise + * @api public + */ + + is.error = function (value) { + return toStr.call(value) === '[object Error]' + } + + /** + * Test function. + */ + + /** + * is.fn / is.function (deprecated) + * Test if `value` is a function. + * + * @param {*} value value to test + * @return {Boolean} true if `value` is a function, false otherwise + * @api public + */ + + is.fn = is['function'] = function (value) { + var isAlert = typeof window !== 'undefined' && value === window.alert + if (isAlert) { + return true + } + var str = toStr.call(value) + return ( + str === '[object Function]' || + str === '[object GeneratorFunction]' || + str === '[object AsyncFunction]' + ) + } + + /** + * Test number. + */ + + /** + * is.number + * Test if `value` is a number. + * + * @param {*} value value to test + * @return {Boolean} true if `value` is a number, false otherwise + * @api public + */ + + is.number = function (value) { + return toStr.call(value) === '[object Number]' + } + + /** + * is.infinite + * Test if `value` is positive or negative infinity. + * + * @param {*} value value to test + * @return {Boolean} true if `value` is positive or negative Infinity, false otherwise + * @api public + */ + is.infinite = function (value) { + return value === Infinity || value === -Infinity + } + + /** + * is.decimal + * Test if `value` is a decimal number. + * + * @param {*} value value to test + * @return {Boolean} true if `value` is a decimal number, false otherwise + * @api public + */ + + is.decimal = function (value) { + return ( + is.number(value) && + !isActualNaN(value) && + !is.infinite(value) && + value % 1 !== 0 + ) + } + + /** + * is.divisibleBy + * Test if `value` is divisible by `n`. + * + * @param {Number} value value to test + * @param {Number} n dividend + * @return {Boolean} true if `value` is divisible by `n`, false otherwise + * @api public + */ + + is.divisibleBy = function (value, n) { + var isDividendInfinite = is.infinite(value) + var isDivisorInfinite = is.infinite(n) + var isNonZeroNumber = + is.number(value) && + !isActualNaN(value) && + is.number(n) && + !isActualNaN(n) && + n !== 0 + return ( + isDividendInfinite || + isDivisorInfinite || + (isNonZeroNumber && value % n === 0) + ) + } + + /** + * is.integer + * Test if `value` is an integer. + * + * @param value to test + * @return {Boolean} true if `value` is an integer, false otherwise + * @api public + */ + + is.integer = is['int'] = function (value) { + return is.number(value) && !isActualNaN(value) && value % 1 === 0 + } + + /** + * is.maximum + * Test if `value` is greater than 'others' values. + * + * @param {Number} value value to test + * @param {Array} others values to compare with + * @return {Boolean} true if `value` is greater than `others` values + * @api public + */ + + is.maximum = function (value, others) { + if (isActualNaN(value)) { + throw new TypeError('NaN is not a valid value') + } else if (!is.arraylike(others)) { + throw new TypeError('second argument must be array-like') + } + var len = others.length + + while (--len >= 0) { + if (value < others[len]) { + return false + } + } + + return true + } + + /** + * is.minimum + * Test if `value` is less than `others` values. + * + * @param {Number} value value to test + * @param {Array} others values to compare with + * @return {Boolean} true if `value` is less than `others` values + * @api public + */ + + is.minimum = function (value, others) { + if (isActualNaN(value)) { + throw new TypeError('NaN is not a valid value') + } else if (!is.arraylike(others)) { + throw new TypeError('second argument must be array-like') + } + var len = others.length + + while (--len >= 0) { + if (value > others[len]) { + return false + } + } + + return true + } + + /** + * is.nan + * Test if `value` is not a number. + * + * @param {*} value value to test + * @return {Boolean} true if `value` is not a number, false otherwise + * @api public + */ + + is.nan = function (value) { + return !is.number(value) || value !== value + } + + /** + * is.even + * Test if `value` is an even number. + * + * @param {Number} value value to test + * @return {Boolean} true if `value` is an even number, false otherwise + * @api public + */ + + is.even = function (value) { + return ( + is.infinite(value) || + (is.number(value) && value === value && value % 2 === 0) + ) + } + + /** + * is.odd + * Test if `value` is an odd number. + * + * @param {Number} value value to test + * @return {Boolean} true if `value` is an odd number, false otherwise + * @api public + */ + + is.odd = function (value) { + return ( + is.infinite(value) || + (is.number(value) && value === value && value % 2 !== 0) + ) + } + + /** + * is.ge + * Test if `value` is greater than or equal to `other`. + * + * @param {Number} value value to test + * @param {Number} other value to compare with + * @return {Boolean} + * @api public + */ + + is.ge = function (value, other) { + if (isActualNaN(value) || isActualNaN(other)) { + throw new TypeError('NaN is not a valid value') + } + return !is.infinite(value) && !is.infinite(other) && value >= other + } + + /** + * is.gt + * Test if `value` is greater than `other`. + * + * @param {Number} value value to test + * @param {Number} other value to compare with + * @return {Boolean} + * @api public + */ + + is.gt = function (value, other) { + if (isActualNaN(value) || isActualNaN(other)) { + throw new TypeError('NaN is not a valid value') + } + return !is.infinite(value) && !is.infinite(other) && value > other + } + + /** + * is.le + * Test if `value` is less than or equal to `other`. + * + * @param {Number} value value to test + * @param {Number} other value to compare with + * @return {Boolean} if 'value' is less than or equal to 'other' + * @api public + */ + + is.le = function (value, other) { + if (isActualNaN(value) || isActualNaN(other)) { + throw new TypeError('NaN is not a valid value') + } + return !is.infinite(value) && !is.infinite(other) && value <= other + } + + /** + * is.lt + * Test if `value` is less than `other`. + * + * @param {Number} value value to test + * @param {Number} other value to compare with + * @return {Boolean} if `value` is less than `other` + * @api public + */ + + is.lt = function (value, other) { + if (isActualNaN(value) || isActualNaN(other)) { + throw new TypeError('NaN is not a valid value') + } + return !is.infinite(value) && !is.infinite(other) && value < other + } + + /** + * is.within + * Test if `value` is within `start` and `finish`. + * + * @param {Number} value value to test + * @param {Number} start lower bound + * @param {Number} finish upper bound + * @return {Boolean} true if 'value' is is within 'start' and 'finish' + * @api public + */ + is.within = function (value, start, finish) { + if (isActualNaN(value) || isActualNaN(start) || isActualNaN(finish)) { + throw new TypeError('NaN is not a valid value') + } else if ( + !is.number(value) || + !is.number(start) || + !is.number(finish) + ) { + throw new TypeError('all arguments must be numbers') + } + var isAnyInfinite = + is.infinite(value) || is.infinite(start) || is.infinite(finish) + return isAnyInfinite || (value >= start && value <= finish) + } + + /** + * Test object. + */ + + /** + * is.object + * Test if `value` is an object. + * + * @param {*} value value to test + * @return {Boolean} true if `value` is an object, false otherwise + * @api public + */ + is.object = function (value) { + return toStr.call(value) === '[object Object]' + } + + /** + * is.primitive + * Test if `value` is a primitive. + * + * @param {*} value value to test + * @return {Boolean} true if `value` is a primitive, false otherwise + * @api public + */ + is.primitive = function isPrimitive(value) { + if (!value) { + return true + } + if ( + typeof value === 'object' || + is.object(value) || + is.fn(value) || + is.array(value) + ) { + return false + } + return true + } + + /** + * is.hash + * Test if `value` is a hash - a plain object literal. + * + * @param {*} value value to test + * @return {Boolean} true if `value` is a hash, false otherwise + * @api public + */ + + is.hash = function (value) { + return ( + is.object(value) && + value.constructor === Object && + !value.nodeType && + !value.setInterval + ) + } + + /** + * Test regexp. + */ + + /** + * is.regexp + * Test if `value` is a regular expression. + * + * @param {*} value value to test + * @return {Boolean} true if `value` is a regexp, false otherwise + * @api public + */ + + is.regexp = function (value) { + return toStr.call(value) === '[object RegExp]' + } + + /** + * Test string. + */ + + /** + * is.string + * Test if `value` is a string. + * + * @param {*} value value to test + * @return {Boolean} true if 'value' is a string, false otherwise + * @api public + */ + + is.string = function (value) { + return toStr.call(value) === '[object String]' + } + + /** + * Test base64 string. + */ + + /** + * is.base64 + * Test if `value` is a valid base64 encoded string. + * + * @param {*} value value to test + * @return {Boolean} true if 'value' is a base64 encoded string, false otherwise + * @api public + */ + + is.base64 = function (value) { + return is.string(value) && (!value.length || base64Regex.test(value)) + } + + /** + * Test base64 string. + */ + + /** + * is.hex + * Test if `value` is a valid hex encoded string. + * + * @param {*} value value to test + * @return {Boolean} true if 'value' is a hex encoded string, false otherwise + * @api public + */ + + is.hex = function (value) { + return is.string(value) && (!value.length || hexRegex.test(value)) + } + + /** + * is.symbol + * Test if `value` is an ES6 Symbol + * + * @param {*} value value to test + * @return {Boolean} true if `value` is a Symbol, false otherise + * @api public + */ + + is.symbol = function (value) { + return ( + typeof Symbol === 'function' && + toStr.call(value) === '[object Symbol]' && + typeof symbolValueOf.call(value) === 'symbol' + ) + } + + /** + * is.bigint + * Test if `value` is an ES-proposed BigInt + * + * @param {*} value value to test + * @return {Boolean} true if `value` is a BigInt, false otherise + * @api public + */ + + is.bigint = function (value) { + // eslint-disable-next-line valid-typeof + return ( + typeof BigInt === 'function' && + toStr.call(value) === '[object BigInt]' && + typeof bigIntValueOf.call(value) === 'bigint' + ) + } + + module.exports = is + + /***/ + }, + + /***/ 97126: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + var fs = __webpack_require__(35747) + var core + if (process.platform === 'win32' || global.TESTING_WINDOWS) { + core = __webpack_require__(42001) + } else { + core = __webpack_require__(9728) + } + + module.exports = isexe + isexe.sync = sync + + function isexe(path, options, cb) { + if (typeof options === 'function') { + cb = options + options = {} + } + + if (!cb) { + if (typeof Promise !== 'function') { + throw new TypeError('callback not provided') + } + + return new Promise(function (resolve, reject) { + isexe(path, options || {}, function (er, is) { + if (er) { + reject(er) + } else { + resolve(is) + } + }) + }) + } + + core(path, options || {}, function (er, is) { + // ignore EACCES because that just means we aren't allowed to run it + if (er) { + if (er.code === 'EACCES' || (options && options.ignoreErrors)) { + er = null + is = false + } + } + cb(er, is) + }) + } + + function sync(path, options) { + // my kingdom for a filtered catch + try { + return core.sync(path, options || {}) + } catch (er) { + if ((options && options.ignoreErrors) || er.code === 'EACCES') { + return false + } else { + throw er + } + } + } + + /***/ + }, + + /***/ 9728: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + module.exports = isexe + isexe.sync = sync + + var fs = __webpack_require__(35747) + + function isexe(path, options, cb) { + fs.stat(path, function (er, stat) { + cb(er, er ? false : checkStat(stat, options)) + }) + } + + function sync(path, options) { + return checkStat(fs.statSync(path), options) + } + + function checkStat(stat, options) { + return stat.isFile() && checkMode(stat, options) + } + + function checkMode(stat, options) { + var mod = stat.mode + var uid = stat.uid + var gid = stat.gid + + var myUid = + options.uid !== undefined + ? options.uid + : process.getuid && process.getuid() + var myGid = + options.gid !== undefined + ? options.gid + : process.getgid && process.getgid() + + var u = parseInt('100', 8) + var g = parseInt('010', 8) + var o = parseInt('001', 8) + var ug = u | g + + var ret = + mod & o || + (mod & g && gid === myGid) || + (mod & u && uid === myUid) || + (mod & ug && myUid === 0) + + return ret + } + + /***/ + }, + + /***/ 42001: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + module.exports = isexe + isexe.sync = sync + + var fs = __webpack_require__(35747) + + function checkPathExt(path, options) { + var pathext = + options.pathExt !== undefined ? options.pathExt : process.env.PATHEXT + + if (!pathext) { + return true + } + + pathext = pathext.split(';') + if (pathext.indexOf('') !== -1) { + return true + } + for (var i = 0; i < pathext.length; i++) { + var p = pathext[i].toLowerCase() + if (p && path.substr(-p.length).toLowerCase() === p) { + return true + } + } + return false + } + + function checkStat(stat, path, options) { + if (!stat.isSymbolicLink() && !stat.isFile()) { + return false + } + return checkPathExt(path, options) + } + + function isexe(path, options, cb) { + fs.stat(path, function (er, stat) { + cb(er, er ? false : checkStat(stat, path, options)) + }) + } + + function sync(path, options) { + return checkStat(fs.statSync(path), path, options) + } + + /***/ + }, + + /***/ 83362: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + var stream = __webpack_require__(92413) + + function isStream(obj) { + return obj instanceof stream.Stream + } + + function isReadable(obj) { + return ( + isStream(obj) && + typeof obj._read == 'function' && + typeof obj._readableState == 'object' + ) + } + + function isWritable(obj) { + return ( + isStream(obj) && + typeof obj._write == 'function' && + typeof obj._writableState == 'object' + ) + } + + function isDuplex(obj) { + return isReadable(obj) && isWritable(obj) + } + + module.exports = isStream + module.exports.isReadable = isReadable + module.exports.isWritable = isWritable + module.exports.isDuplex = isDuplex + + /***/ + }, + + /***/ 85587: /***/ function (module, exports) { + ;(function () { + // Copyright (c) 2005 Tom Wu + // All Rights Reserved. + // See "LICENSE" for details. + + // Basic JavaScript BN library - subset useful for RSA encryption. + + // Bits per digit + var dbits + + // JavaScript engine analysis + var canary = 0xdeadbeefcafe + var j_lm = (canary & 0xffffff) == 0xefcafe + + // (public) Constructor + function BigInteger(a, b, c) { + if (a != null) + if ('number' == typeof a) this.fromNumber(a, b, c) + else if (b == null && 'string' != typeof a) this.fromString(a, 256) + else this.fromString(a, b) + } + + // return new, unset BigInteger + function nbi() { + return new BigInteger(null) + } + + // am: Compute w_j += (x*this_i), propagate carries, + // c is initial carry, returns final carry. + // c < 3*dvalue, x < 2*dvalue, this_i < dvalue + // We need to select the fastest one that works in this environment. + + // am1: use a single mult and divide to get the high bits, + // max digit bits should be 26 because + // max internal value = 2*dvalue^2-2*dvalue (< 2^53) + function am1(i, x, w, j, c, n) { + while (--n >= 0) { + var v = x * this[i++] + w[j] + c + c = Math.floor(v / 0x4000000) + w[j++] = v & 0x3ffffff + } + return c + } + // am2 avoids a big mult-and-extract completely. + // Max digit bits should be <= 30 because we do bitwise ops + // on values up to 2*hdvalue^2-hdvalue-1 (< 2^31) + function am2(i, x, w, j, c, n) { + var xl = x & 0x7fff, + xh = x >> 15 + while (--n >= 0) { + var l = this[i] & 0x7fff + var h = this[i++] >> 15 + var m = xh * l + h * xl + l = xl * l + ((m & 0x7fff) << 15) + w[j] + (c & 0x3fffffff) + c = (l >>> 30) + (m >>> 15) + xh * h + (c >>> 30) + w[j++] = l & 0x3fffffff + } + return c + } + // Alternately, set max digit bits to 28 since some + // browsers slow down when dealing with 32-bit numbers. + function am3(i, x, w, j, c, n) { + var xl = x & 0x3fff, + xh = x >> 14 + while (--n >= 0) { + var l = this[i] & 0x3fff + var h = this[i++] >> 14 + var m = xh * l + h * xl + l = xl * l + ((m & 0x3fff) << 14) + w[j] + c + c = (l >> 28) + (m >> 14) + xh * h + w[j++] = l & 0xfffffff + } + return c + } + var inBrowser = typeof navigator !== 'undefined' + if ( + inBrowser && + j_lm && + navigator.appName == 'Microsoft Internet Explorer' + ) { + BigInteger.prototype.am = am2 + dbits = 30 + } else if (inBrowser && j_lm && navigator.appName != 'Netscape') { + BigInteger.prototype.am = am1 + dbits = 26 + } else { + // Mozilla/Netscape seems to prefer am3 + BigInteger.prototype.am = am3 + dbits = 28 + } + + BigInteger.prototype.DB = dbits + BigInteger.prototype.DM = (1 << dbits) - 1 + BigInteger.prototype.DV = 1 << dbits + + var BI_FP = 52 + BigInteger.prototype.FV = Math.pow(2, BI_FP) + BigInteger.prototype.F1 = BI_FP - dbits + BigInteger.prototype.F2 = 2 * dbits - BI_FP + + // Digit conversions + var BI_RM = '0123456789abcdefghijklmnopqrstuvwxyz' + var BI_RC = new Array() + var rr, vv + rr = '0'.charCodeAt(0) + for (vv = 0; vv <= 9; ++vv) BI_RC[rr++] = vv + rr = 'a'.charCodeAt(0) + for (vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv + rr = 'A'.charCodeAt(0) + for (vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv + + function int2char(n) { + return BI_RM.charAt(n) + } + function intAt(s, i) { + var c = BI_RC[s.charCodeAt(i)] + return c == null ? -1 : c + } + + // (protected) copy this to r + function bnpCopyTo(r) { + for (var i = this.t - 1; i >= 0; --i) r[i] = this[i] + r.t = this.t + r.s = this.s + } + + // (protected) set from integer value x, -DV <= x < DV + function bnpFromInt(x) { + this.t = 1 + this.s = x < 0 ? -1 : 0 + if (x > 0) this[0] = x + else if (x < -1) this[0] = x + this.DV + else this.t = 0 + } + + // return bigint initialized to value + function nbv(i) { + var r = nbi() + r.fromInt(i) + return r + } + + // (protected) set from string and radix + function bnpFromString(s, b) { + var k + if (b == 16) k = 4 + else if (b == 8) k = 3 + else if (b == 256) k = 8 + // byte array + else if (b == 2) k = 1 + else if (b == 32) k = 5 + else if (b == 4) k = 2 + else { + this.fromRadix(s, b) + return + } + this.t = 0 + this.s = 0 + var i = s.length, + mi = false, + sh = 0 + while (--i >= 0) { + var x = k == 8 ? s[i] & 0xff : intAt(s, i) + if (x < 0) { + if (s.charAt(i) == '-') mi = true + continue + } + mi = false + if (sh == 0) this[this.t++] = x + else if (sh + k > this.DB) { + this[this.t - 1] |= (x & ((1 << (this.DB - sh)) - 1)) << sh + this[this.t++] = x >> (this.DB - sh) + } else this[this.t - 1] |= x << sh + sh += k + if (sh >= this.DB) sh -= this.DB + } + if (k == 8 && (s[0] & 0x80) != 0) { + this.s = -1 + if (sh > 0) this[this.t - 1] |= ((1 << (this.DB - sh)) - 1) << sh + } + this.clamp() + if (mi) BigInteger.ZERO.subTo(this, this) + } + + // (protected) clamp off excess high words + function bnpClamp() { + var c = this.s & this.DM + while (this.t > 0 && this[this.t - 1] == c) --this.t + } + + // (public) return string representation in given radix + function bnToString(b) { + if (this.s < 0) return '-' + this.negate().toString(b) + var k + if (b == 16) k = 4 + else if (b == 8) k = 3 + else if (b == 2) k = 1 + else if (b == 32) k = 5 + else if (b == 4) k = 2 + else return this.toRadix(b) + var km = (1 << k) - 1, + d, + m = false, + r = '', + i = this.t + var p = this.DB - ((i * this.DB) % k) + if (i-- > 0) { + if (p < this.DB && (d = this[i] >> p) > 0) { + m = true + r = int2char(d) + } + while (i >= 0) { + if (p < k) { + d = (this[i] & ((1 << p) - 1)) << (k - p) + d |= this[--i] >> (p += this.DB - k) + } else { + d = (this[i] >> (p -= k)) & km + if (p <= 0) { + p += this.DB + --i + } + } + if (d > 0) m = true + if (m) r += int2char(d) + } + } + return m ? r : '0' + } + + // (public) -this + function bnNegate() { + var r = nbi() + BigInteger.ZERO.subTo(this, r) + return r + } + + // (public) |this| + function bnAbs() { + return this.s < 0 ? this.negate() : this + } + + // (public) return + if this > a, - if this < a, 0 if equal + function bnCompareTo(a) { + var r = this.s - a.s + if (r != 0) return r + var i = this.t + r = i - a.t + if (r != 0) return this.s < 0 ? -r : r + while (--i >= 0) if ((r = this[i] - a[i]) != 0) return r + return 0 + } + + // returns bit length of the integer x + function nbits(x) { + var r = 1, + t + if ((t = x >>> 16) != 0) { + x = t + r += 16 + } + if ((t = x >> 8) != 0) { + x = t + r += 8 + } + if ((t = x >> 4) != 0) { + x = t + r += 4 + } + if ((t = x >> 2) != 0) { + x = t + r += 2 + } + if ((t = x >> 1) != 0) { + x = t + r += 1 + } + return r + } + + // (public) return the number of bits in "this" + function bnBitLength() { + if (this.t <= 0) return 0 + return ( + this.DB * (this.t - 1) + + nbits(this[this.t - 1] ^ (this.s & this.DM)) + ) + } + + // (protected) r = this << n*DB + function bnpDLShiftTo(n, r) { + var i + for (i = this.t - 1; i >= 0; --i) r[i + n] = this[i] + for (i = n - 1; i >= 0; --i) r[i] = 0 + r.t = this.t + n + r.s = this.s + } + + // (protected) r = this >> n*DB + function bnpDRShiftTo(n, r) { + for (var i = n; i < this.t; ++i) r[i - n] = this[i] + r.t = Math.max(this.t - n, 0) + r.s = this.s + } + + // (protected) r = this << n + function bnpLShiftTo(n, r) { + var bs = n % this.DB + var cbs = this.DB - bs + var bm = (1 << cbs) - 1 + var ds = Math.floor(n / this.DB), + c = (this.s << bs) & this.DM, + i + for (i = this.t - 1; i >= 0; --i) { + r[i + ds + 1] = (this[i] >> cbs) | c + c = (this[i] & bm) << bs + } + for (i = ds - 1; i >= 0; --i) r[i] = 0 + r[ds] = c + r.t = this.t + ds + 1 + r.s = this.s + r.clamp() + } + + // (protected) r = this >> n + function bnpRShiftTo(n, r) { + r.s = this.s + var ds = Math.floor(n / this.DB) + if (ds >= this.t) { + r.t = 0 + return + } + var bs = n % this.DB + var cbs = this.DB - bs + var bm = (1 << bs) - 1 + r[0] = this[ds] >> bs + for (var i = ds + 1; i < this.t; ++i) { + r[i - ds - 1] |= (this[i] & bm) << cbs + r[i - ds] = this[i] >> bs + } + if (bs > 0) r[this.t - ds - 1] |= (this.s & bm) << cbs + r.t = this.t - ds + r.clamp() + } + + // (protected) r = this - a + function bnpSubTo(a, r) { + var i = 0, + c = 0, + m = Math.min(a.t, this.t) + while (i < m) { + c += this[i] - a[i] + r[i++] = c & this.DM + c >>= this.DB + } + if (a.t < this.t) { + c -= a.s + while (i < this.t) { + c += this[i] + r[i++] = c & this.DM + c >>= this.DB + } + c += this.s + } else { + c += this.s + while (i < a.t) { + c -= a[i] + r[i++] = c & this.DM + c >>= this.DB + } + c -= a.s + } + r.s = c < 0 ? -1 : 0 + if (c < -1) r[i++] = this.DV + c + else if (c > 0) r[i++] = c + r.t = i + r.clamp() + } + + // (protected) r = this * a, r != this,a (HAC 14.12) + // "this" should be the larger one if appropriate. + function bnpMultiplyTo(a, r) { + var x = this.abs(), + y = a.abs() + var i = x.t + r.t = i + y.t + while (--i >= 0) r[i] = 0 + for (i = 0; i < y.t; ++i) r[i + x.t] = x.am(0, y[i], r, i, 0, x.t) + r.s = 0 + r.clamp() + if (this.s != a.s) BigInteger.ZERO.subTo(r, r) + } + + // (protected) r = this^2, r != this (HAC 14.16) + function bnpSquareTo(r) { + var x = this.abs() + var i = (r.t = 2 * x.t) + while (--i >= 0) r[i] = 0 + for (i = 0; i < x.t - 1; ++i) { + var c = x.am(i, x[i], r, 2 * i, 0, 1) + if ( + (r[i + x.t] += x.am( + i + 1, + 2 * x[i], + r, + 2 * i + 1, + c, + x.t - i - 1 + )) >= x.DV + ) { + r[i + x.t] -= x.DV + r[i + x.t + 1] = 1 + } + } + if (r.t > 0) r[r.t - 1] += x.am(i, x[i], r, 2 * i, 0, 1) + r.s = 0 + r.clamp() + } + + // (protected) divide this by m, quotient and remainder to q, r (HAC 14.20) + // r != q, this != m. q or r may be null. + function bnpDivRemTo(m, q, r) { + var pm = m.abs() + if (pm.t <= 0) return + var pt = this.abs() + if (pt.t < pm.t) { + if (q != null) q.fromInt(0) + if (r != null) this.copyTo(r) + return + } + if (r == null) r = nbi() + var y = nbi(), + ts = this.s, + ms = m.s + var nsh = this.DB - nbits(pm[pm.t - 1]) // normalize modulus + if (nsh > 0) { + pm.lShiftTo(nsh, y) + pt.lShiftTo(nsh, r) + } else { + pm.copyTo(y) + pt.copyTo(r) + } + var ys = y.t + var y0 = y[ys - 1] + if (y0 == 0) return + var yt = y0 * (1 << this.F1) + (ys > 1 ? y[ys - 2] >> this.F2 : 0) + var d1 = this.FV / yt, + d2 = (1 << this.F1) / yt, + e = 1 << this.F2 + var i = r.t, + j = i - ys, + t = q == null ? nbi() : q + y.dlShiftTo(j, t) + if (r.compareTo(t) >= 0) { + r[r.t++] = 1 + r.subTo(t, r) + } + BigInteger.ONE.dlShiftTo(ys, t) + t.subTo(y, y) // "negative" y so we can replace sub with am later + while (y.t < ys) y[y.t++] = 0 + while (--j >= 0) { + // Estimate quotient digit + var qd = + r[--i] == y0 + ? this.DM + : Math.floor(r[i] * d1 + (r[i - 1] + e) * d2) + if ((r[i] += y.am(0, qd, r, j, 0, ys)) < qd) { + // Try it out + y.dlShiftTo(j, t) + r.subTo(t, r) + while (r[i] < --qd) r.subTo(t, r) + } + } + if (q != null) { + r.drShiftTo(ys, q) + if (ts != ms) BigInteger.ZERO.subTo(q, q) + } + r.t = ys + r.clamp() + if (nsh > 0) r.rShiftTo(nsh, r) // Denormalize remainder + if (ts < 0) BigInteger.ZERO.subTo(r, r) + } + + // (public) this mod a + function bnMod(a) { + var r = nbi() + this.abs().divRemTo(a, null, r) + if (this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r, r) + return r + } + + // Modular reduction using "classic" algorithm + function Classic(m) { + this.m = m + } + function cConvert(x) { + if (x.s < 0 || x.compareTo(this.m) >= 0) return x.mod(this.m) + else return x + } + function cRevert(x) { + return x + } + function cReduce(x) { + x.divRemTo(this.m, null, x) + } + function cMulTo(x, y, r) { + x.multiplyTo(y, r) + this.reduce(r) + } + function cSqrTo(x, r) { + x.squareTo(r) + this.reduce(r) + } + + Classic.prototype.convert = cConvert + Classic.prototype.revert = cRevert + Classic.prototype.reduce = cReduce + Classic.prototype.mulTo = cMulTo + Classic.prototype.sqrTo = cSqrTo + + // (protected) return "-1/this % 2^DB"; useful for Mont. reduction + // justification: + // xy == 1 (mod m) + // xy = 1+km + // xy(2-xy) = (1+km)(1-km) + // x[y(2-xy)] = 1-k^2m^2 + // x[y(2-xy)] == 1 (mod m^2) + // if y is 1/x mod m, then y(2-xy) is 1/x mod m^2 + // should reduce x and y(2-xy) by m^2 at each step to keep size bounded. + // JS multiply "overflows" differently from C/C++, so care is needed here. + function bnpInvDigit() { + if (this.t < 1) return 0 + var x = this[0] + if ((x & 1) == 0) return 0 + var y = x & 3 // y == 1/x mod 2^2 + y = (y * (2 - (x & 0xf) * y)) & 0xf // y == 1/x mod 2^4 + y = (y * (2 - (x & 0xff) * y)) & 0xff // y == 1/x mod 2^8 + y = (y * (2 - (((x & 0xffff) * y) & 0xffff))) & 0xffff // y == 1/x mod 2^16 + // last step - calculate inverse mod DV directly; + // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints + y = (y * (2 - ((x * y) % this.DV))) % this.DV // y == 1/x mod 2^dbits + // we really want the negative inverse, and -DV < y < DV + return y > 0 ? this.DV - y : -y + } + + // Montgomery reduction + function Montgomery(m) { + this.m = m + this.mp = m.invDigit() + this.mpl = this.mp & 0x7fff + this.mph = this.mp >> 15 + this.um = (1 << (m.DB - 15)) - 1 + this.mt2 = 2 * m.t + } + + // xR mod m + function montConvert(x) { + var r = nbi() + x.abs().dlShiftTo(this.m.t, r) + r.divRemTo(this.m, null, r) + if (x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r, r) + return r + } + + // x/R mod m + function montRevert(x) { + var r = nbi() + x.copyTo(r) + this.reduce(r) + return r + } + + // x = x/R mod m (HAC 14.32) + function montReduce(x) { + while ( + x.t <= this.mt2 // pad x so am has enough room later + ) + x[x.t++] = 0 + for (var i = 0; i < this.m.t; ++i) { + // faster way of calculating u0 = x[i]*mp mod DV + var j = x[i] & 0x7fff + var u0 = + (j * this.mpl + + (((j * this.mph + (x[i] >> 15) * this.mpl) & this.um) << 15)) & + x.DM + // use am to combine the multiply-shift-add into one call + j = i + this.m.t + x[j] += this.m.am(0, u0, x, i, 0, this.m.t) + // propagate carry + while (x[j] >= x.DV) { + x[j] -= x.DV + x[++j]++ + } + } + x.clamp() + x.drShiftTo(this.m.t, x) + if (x.compareTo(this.m) >= 0) x.subTo(this.m, x) + } + + // r = "x^2/R mod m"; x != r + function montSqrTo(x, r) { + x.squareTo(r) + this.reduce(r) + } + + // r = "xy/R mod m"; x,y != r + function montMulTo(x, y, r) { + x.multiplyTo(y, r) + this.reduce(r) + } + + Montgomery.prototype.convert = montConvert + Montgomery.prototype.revert = montRevert + Montgomery.prototype.reduce = montReduce + Montgomery.prototype.mulTo = montMulTo + Montgomery.prototype.sqrTo = montSqrTo + + // (protected) true iff this is even + function bnpIsEven() { + return (this.t > 0 ? this[0] & 1 : this.s) == 0 + } + + // (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79) + function bnpExp(e, z) { + if (e > 0xffffffff || e < 1) return BigInteger.ONE + var r = nbi(), + r2 = nbi(), + g = z.convert(this), + i = nbits(e) - 1 + g.copyTo(r) + while (--i >= 0) { + z.sqrTo(r, r2) + if ((e & (1 << i)) > 0) z.mulTo(r2, g, r) + else { + var t = r + r = r2 + r2 = t + } + } + return z.revert(r) + } + + // (public) this^e % m, 0 <= e < 2^32 + function bnModPowInt(e, m) { + var z + if (e < 256 || m.isEven()) z = new Classic(m) + else z = new Montgomery(m) + return this.exp(e, z) + } + + // protected + BigInteger.prototype.copyTo = bnpCopyTo + BigInteger.prototype.fromInt = bnpFromInt + BigInteger.prototype.fromString = bnpFromString + BigInteger.prototype.clamp = bnpClamp + BigInteger.prototype.dlShiftTo = bnpDLShiftTo + BigInteger.prototype.drShiftTo = bnpDRShiftTo + BigInteger.prototype.lShiftTo = bnpLShiftTo + BigInteger.prototype.rShiftTo = bnpRShiftTo + BigInteger.prototype.subTo = bnpSubTo + BigInteger.prototype.multiplyTo = bnpMultiplyTo + BigInteger.prototype.squareTo = bnpSquareTo + BigInteger.prototype.divRemTo = bnpDivRemTo + BigInteger.prototype.invDigit = bnpInvDigit + BigInteger.prototype.isEven = bnpIsEven + BigInteger.prototype.exp = bnpExp + + // public + BigInteger.prototype.toString = bnToString + BigInteger.prototype.negate = bnNegate + BigInteger.prototype.abs = bnAbs + BigInteger.prototype.compareTo = bnCompareTo + BigInteger.prototype.bitLength = bnBitLength + BigInteger.prototype.mod = bnMod + BigInteger.prototype.modPowInt = bnModPowInt + + // "constants" + BigInteger.ZERO = nbv(0) + BigInteger.ONE = nbv(1) + + // Copyright (c) 2005-2009 Tom Wu + // All Rights Reserved. + // See "LICENSE" for details. + + // Extended JavaScript BN functions, required for RSA private ops. + + // Version 1.1: new BigInteger("0", 10) returns "proper" zero + // Version 1.2: square() API, isProbablePrime fix + + // (public) + function bnClone() { + var r = nbi() + this.copyTo(r) + return r + } + + // (public) return value as integer + function bnIntValue() { + if (this.s < 0) { + if (this.t == 1) return this[0] - this.DV + else if (this.t == 0) return -1 + } else if (this.t == 1) return this[0] + else if (this.t == 0) return 0 + // assumes 16 < DB < 32 + return ((this[1] & ((1 << (32 - this.DB)) - 1)) << this.DB) | this[0] + } + + // (public) return value as byte + function bnByteValue() { + return this.t == 0 ? this.s : (this[0] << 24) >> 24 + } + + // (public) return value as short (assumes DB>=16) + function bnShortValue() { + return this.t == 0 ? this.s : (this[0] << 16) >> 16 + } + + // (protected) return x s.t. r^x < DV + function bnpChunkSize(r) { + return Math.floor((Math.LN2 * this.DB) / Math.log(r)) + } + + // (public) 0 if this == 0, 1 if this > 0 + function bnSigNum() { + if (this.s < 0) return -1 + else if (this.t <= 0 || (this.t == 1 && this[0] <= 0)) return 0 + else return 1 + } + + // (protected) convert to radix string + function bnpToRadix(b) { + if (b == null) b = 10 + if (this.signum() == 0 || b < 2 || b > 36) return '0' + var cs = this.chunkSize(b) + var a = Math.pow(b, cs) + var d = nbv(a), + y = nbi(), + z = nbi(), + r = '' + this.divRemTo(d, y, z) + while (y.signum() > 0) { + r = (a + z.intValue()).toString(b).substr(1) + r + y.divRemTo(d, y, z) + } + return z.intValue().toString(b) + r + } + + // (protected) convert from radix string + function bnpFromRadix(s, b) { + this.fromInt(0) + if (b == null) b = 10 + var cs = this.chunkSize(b) + var d = Math.pow(b, cs), + mi = false, + j = 0, + w = 0 + for (var i = 0; i < s.length; ++i) { + var x = intAt(s, i) + if (x < 0) { + if (s.charAt(i) == '-' && this.signum() == 0) mi = true + continue + } + w = b * w + x + if (++j >= cs) { + this.dMultiply(d) + this.dAddOffset(w, 0) + j = 0 + w = 0 + } + } + if (j > 0) { + this.dMultiply(Math.pow(b, j)) + this.dAddOffset(w, 0) + } + if (mi) BigInteger.ZERO.subTo(this, this) + } + + // (protected) alternate constructor + function bnpFromNumber(a, b, c) { + if ('number' == typeof b) { + // new BigInteger(int,int,RNG) + if (a < 2) this.fromInt(1) + else { + this.fromNumber(a, c) + if (!this.testBit(a - 1)) + // force MSB set + this.bitwiseTo(BigInteger.ONE.shiftLeft(a - 1), op_or, this) + if (this.isEven()) this.dAddOffset(1, 0) // force odd + while (!this.isProbablePrime(b)) { + this.dAddOffset(2, 0) + if (this.bitLength() > a) + this.subTo(BigInteger.ONE.shiftLeft(a - 1), this) + } + } + } else { + // new BigInteger(int,RNG) + var x = new Array(), + t = a & 7 + x.length = (a >> 3) + 1 + b.nextBytes(x) + if (t > 0) x[0] &= (1 << t) - 1 + else x[0] = 0 + this.fromString(x, 256) + } + } + + // (public) convert to bigendian byte array + function bnToByteArray() { + var i = this.t, + r = new Array() + r[0] = this.s + var p = this.DB - ((i * this.DB) % 8), + d, + k = 0 + if (i-- > 0) { + if (p < this.DB && (d = this[i] >> p) != (this.s & this.DM) >> p) + r[k++] = d | (this.s << (this.DB - p)) + while (i >= 0) { + if (p < 8) { + d = (this[i] & ((1 << p) - 1)) << (8 - p) + d |= this[--i] >> (p += this.DB - 8) + } else { + d = (this[i] >> (p -= 8)) & 0xff + if (p <= 0) { + p += this.DB + --i + } + } + if ((d & 0x80) != 0) d |= -256 + if (k == 0 && (this.s & 0x80) != (d & 0x80)) ++k + if (k > 0 || d != this.s) r[k++] = d + } + } + return r + } + + function bnEquals(a) { + return this.compareTo(a) == 0 + } + function bnMin(a) { + return this.compareTo(a) < 0 ? this : a + } + function bnMax(a) { + return this.compareTo(a) > 0 ? this : a + } + + // (protected) r = this op a (bitwise) + function bnpBitwiseTo(a, op, r) { + var i, + f, + m = Math.min(a.t, this.t) + for (i = 0; i < m; ++i) r[i] = op(this[i], a[i]) + if (a.t < this.t) { + f = a.s & this.DM + for (i = m; i < this.t; ++i) r[i] = op(this[i], f) + r.t = this.t + } else { + f = this.s & this.DM + for (i = m; i < a.t; ++i) r[i] = op(f, a[i]) + r.t = a.t + } + r.s = op(this.s, a.s) + r.clamp() + } + + // (public) this & a + function op_and(x, y) { + return x & y + } + function bnAnd(a) { + var r = nbi() + this.bitwiseTo(a, op_and, r) + return r + } + + // (public) this | a + function op_or(x, y) { + return x | y + } + function bnOr(a) { + var r = nbi() + this.bitwiseTo(a, op_or, r) + return r + } + + // (public) this ^ a + function op_xor(x, y) { + return x ^ y + } + function bnXor(a) { + var r = nbi() + this.bitwiseTo(a, op_xor, r) + return r + } + + // (public) this & ~a + function op_andnot(x, y) { + return x & ~y + } + function bnAndNot(a) { + var r = nbi() + this.bitwiseTo(a, op_andnot, r) + return r + } + + // (public) ~this + function bnNot() { + var r = nbi() + for (var i = 0; i < this.t; ++i) r[i] = this.DM & ~this[i] + r.t = this.t + r.s = ~this.s + return r + } + + // (public) this << n + function bnShiftLeft(n) { + var r = nbi() + if (n < 0) this.rShiftTo(-n, r) + else this.lShiftTo(n, r) + return r + } + + // (public) this >> n + function bnShiftRight(n) { + var r = nbi() + if (n < 0) this.lShiftTo(-n, r) + else this.rShiftTo(n, r) + return r + } + + // return index of lowest 1-bit in x, x < 2^31 + function lbit(x) { + if (x == 0) return -1 + var r = 0 + if ((x & 0xffff) == 0) { + x >>= 16 + r += 16 + } + if ((x & 0xff) == 0) { + x >>= 8 + r += 8 + } + if ((x & 0xf) == 0) { + x >>= 4 + r += 4 + } + if ((x & 3) == 0) { + x >>= 2 + r += 2 + } + if ((x & 1) == 0) ++r + return r + } + + // (public) returns index of lowest 1-bit (or -1 if none) + function bnGetLowestSetBit() { + for (var i = 0; i < this.t; ++i) + if (this[i] != 0) return i * this.DB + lbit(this[i]) + if (this.s < 0) return this.t * this.DB + return -1 + } + + // return number of 1 bits in x + function cbit(x) { + var r = 0 + while (x != 0) { + x &= x - 1 + ++r + } + return r + } + + // (public) return number of set bits + function bnBitCount() { + var r = 0, + x = this.s & this.DM + for (var i = 0; i < this.t; ++i) r += cbit(this[i] ^ x) + return r + } + + // (public) true iff nth bit is set + function bnTestBit(n) { + var j = Math.floor(n / this.DB) + if (j >= this.t) return this.s != 0 + return (this[j] & (1 << n % this.DB)) != 0 + } + + // (protected) this op (1<>= this.DB + } + if (a.t < this.t) { + c += a.s + while (i < this.t) { + c += this[i] + r[i++] = c & this.DM + c >>= this.DB + } + c += this.s + } else { + c += this.s + while (i < a.t) { + c += a[i] + r[i++] = c & this.DM + c >>= this.DB + } + c += a.s + } + r.s = c < 0 ? -1 : 0 + if (c > 0) r[i++] = c + else if (c < -1) r[i++] = this.DV + c + r.t = i + r.clamp() + } + + // (public) this + a + function bnAdd(a) { + var r = nbi() + this.addTo(a, r) + return r + } + + // (public) this - a + function bnSubtract(a) { + var r = nbi() + this.subTo(a, r) + return r + } + + // (public) this * a + function bnMultiply(a) { + var r = nbi() + this.multiplyTo(a, r) + return r + } + + // (public) this^2 + function bnSquare() { + var r = nbi() + this.squareTo(r) + return r + } + + // (public) this / a + function bnDivide(a) { + var r = nbi() + this.divRemTo(a, r, null) + return r + } + + // (public) this % a + function bnRemainder(a) { + var r = nbi() + this.divRemTo(a, null, r) + return r + } + + // (public) [this/a,this%a] + function bnDivideAndRemainder(a) { + var q = nbi(), + r = nbi() + this.divRemTo(a, q, r) + return new Array(q, r) + } + + // (protected) this *= n, this >= 0, 1 < n < DV + function bnpDMultiply(n) { + this[this.t] = this.am(0, n - 1, this, 0, 0, this.t) + ++this.t + this.clamp() + } + + // (protected) this += n << w words, this >= 0 + function bnpDAddOffset(n, w) { + if (n == 0) return + while (this.t <= w) this[this.t++] = 0 + this[w] += n + while (this[w] >= this.DV) { + this[w] -= this.DV + if (++w >= this.t) this[this.t++] = 0 + ++this[w] + } + } + + // A "null" reducer + function NullExp() {} + function nNop(x) { + return x + } + function nMulTo(x, y, r) { + x.multiplyTo(y, r) + } + function nSqrTo(x, r) { + x.squareTo(r) + } + + NullExp.prototype.convert = nNop + NullExp.prototype.revert = nNop + NullExp.prototype.mulTo = nMulTo + NullExp.prototype.sqrTo = nSqrTo + + // (public) this^e + function bnPow(e) { + return this.exp(e, new NullExp()) + } + + // (protected) r = lower n words of "this * a", a.t <= n + // "this" should be the larger one if appropriate. + function bnpMultiplyLowerTo(a, n, r) { + var i = Math.min(this.t + a.t, n) + r.s = 0 // assumes a,this >= 0 + r.t = i + while (i > 0) r[--i] = 0 + var j + for (j = r.t - this.t; i < j; ++i) + r[i + this.t] = this.am(0, a[i], r, i, 0, this.t) + for (j = Math.min(a.t, n); i < j; ++i) + this.am(0, a[i], r, i, 0, n - i) + r.clamp() + } + + // (protected) r = "this * a" without lower n words, n > 0 + // "this" should be the larger one if appropriate. + function bnpMultiplyUpperTo(a, n, r) { + --n + var i = (r.t = this.t + a.t - n) + r.s = 0 // assumes a,this >= 0 + while (--i >= 0) r[i] = 0 + for (i = Math.max(n - this.t, 0); i < a.t; ++i) + r[this.t + i - n] = this.am(n - i, a[i], r, 0, 0, this.t + i - n) + r.clamp() + r.drShiftTo(1, r) + } + + // Barrett modular reduction + function Barrett(m) { + // setup Barrett + this.r2 = nbi() + this.q3 = nbi() + BigInteger.ONE.dlShiftTo(2 * m.t, this.r2) + this.mu = this.r2.divide(m) + this.m = m + } + + function barrettConvert(x) { + if (x.s < 0 || x.t > 2 * this.m.t) return x.mod(this.m) + else if (x.compareTo(this.m) < 0) return x + else { + var r = nbi() + x.copyTo(r) + this.reduce(r) + return r + } + } + + function barrettRevert(x) { + return x + } + + // x = x mod m (HAC 14.42) + function barrettReduce(x) { + x.drShiftTo(this.m.t - 1, this.r2) + if (x.t > this.m.t + 1) { + x.t = this.m.t + 1 + x.clamp() + } + this.mu.multiplyUpperTo(this.r2, this.m.t + 1, this.q3) + this.m.multiplyLowerTo(this.q3, this.m.t + 1, this.r2) + while (x.compareTo(this.r2) < 0) x.dAddOffset(1, this.m.t + 1) + x.subTo(this.r2, x) + while (x.compareTo(this.m) >= 0) x.subTo(this.m, x) + } + + // r = x^2 mod m; x != r + function barrettSqrTo(x, r) { + x.squareTo(r) + this.reduce(r) + } + + // r = x*y mod m; x,y != r + function barrettMulTo(x, y, r) { + x.multiplyTo(y, r) + this.reduce(r) + } + + Barrett.prototype.convert = barrettConvert + Barrett.prototype.revert = barrettRevert + Barrett.prototype.reduce = barrettReduce + Barrett.prototype.mulTo = barrettMulTo + Barrett.prototype.sqrTo = barrettSqrTo + + // (public) this^e % m (HAC 14.85) + function bnModPow(e, m) { + var i = e.bitLength(), + k, + r = nbv(1), + z + if (i <= 0) return r + else if (i < 18) k = 1 + else if (i < 48) k = 3 + else if (i < 144) k = 4 + else if (i < 768) k = 5 + else k = 6 + if (i < 8) z = new Classic(m) + else if (m.isEven()) z = new Barrett(m) + else z = new Montgomery(m) + + // precomputation + var g = new Array(), + n = 3, + k1 = k - 1, + km = (1 << k) - 1 + g[1] = z.convert(this) + if (k > 1) { + var g2 = nbi() + z.sqrTo(g[1], g2) + while (n <= km) { + g[n] = nbi() + z.mulTo(g2, g[n - 2], g[n]) + n += 2 + } + } + + var j = e.t - 1, + w, + is1 = true, + r2 = nbi(), + t + i = nbits(e[j]) - 1 + while (j >= 0) { + if (i >= k1) w = (e[j] >> (i - k1)) & km + else { + w = (e[j] & ((1 << (i + 1)) - 1)) << (k1 - i) + if (j > 0) w |= e[j - 1] >> (this.DB + i - k1) + } + + n = k + while ((w & 1) == 0) { + w >>= 1 + --n + } + if ((i -= n) < 0) { + i += this.DB + --j + } + if (is1) { + // ret == 1, don't bother squaring or multiplying it + g[w].copyTo(r) + is1 = false + } else { + while (n > 1) { + z.sqrTo(r, r2) + z.sqrTo(r2, r) + n -= 2 + } + if (n > 0) z.sqrTo(r, r2) + else { + t = r + r = r2 + r2 = t + } + z.mulTo(r2, g[w], r) + } + + while (j >= 0 && (e[j] & (1 << i)) == 0) { + z.sqrTo(r, r2) + t = r + r = r2 + r2 = t + if (--i < 0) { + i = this.DB - 1 + --j + } + } + } + return z.revert(r) + } + + // (public) gcd(this,a) (HAC 14.54) + function bnGCD(a) { + var x = this.s < 0 ? this.negate() : this.clone() + var y = a.s < 0 ? a.negate() : a.clone() + if (x.compareTo(y) < 0) { + var t = x + x = y + y = t + } + var i = x.getLowestSetBit(), + g = y.getLowestSetBit() + if (g < 0) return x + if (i < g) g = i + if (g > 0) { + x.rShiftTo(g, x) + y.rShiftTo(g, y) + } + while (x.signum() > 0) { + if ((i = x.getLowestSetBit()) > 0) x.rShiftTo(i, x) + if ((i = y.getLowestSetBit()) > 0) y.rShiftTo(i, y) + if (x.compareTo(y) >= 0) { + x.subTo(y, x) + x.rShiftTo(1, x) + } else { + y.subTo(x, y) + y.rShiftTo(1, y) + } + } + if (g > 0) y.lShiftTo(g, y) + return y + } + + // (protected) this % n, n < 2^26 + function bnpModInt(n) { + if (n <= 0) return 0 + var d = this.DV % n, + r = this.s < 0 ? n - 1 : 0 + if (this.t > 0) + if (d == 0) r = this[0] % n + else for (var i = this.t - 1; i >= 0; --i) r = (d * r + this[i]) % n + return r + } + + // (public) 1/this % m (HAC 14.61) + function bnModInverse(m) { + var ac = m.isEven() + if ((this.isEven() && ac) || m.signum() == 0) return BigInteger.ZERO + var u = m.clone(), + v = this.clone() + var a = nbv(1), + b = nbv(0), + c = nbv(0), + d = nbv(1) + while (u.signum() != 0) { + while (u.isEven()) { + u.rShiftTo(1, u) + if (ac) { + if (!a.isEven() || !b.isEven()) { + a.addTo(this, a) + b.subTo(m, b) + } + a.rShiftTo(1, a) + } else if (!b.isEven()) b.subTo(m, b) + b.rShiftTo(1, b) + } + while (v.isEven()) { + v.rShiftTo(1, v) + if (ac) { + if (!c.isEven() || !d.isEven()) { + c.addTo(this, c) + d.subTo(m, d) + } + c.rShiftTo(1, c) + } else if (!d.isEven()) d.subTo(m, d) + d.rShiftTo(1, d) + } + if (u.compareTo(v) >= 0) { + u.subTo(v, u) + if (ac) a.subTo(c, a) + b.subTo(d, b) + } else { + v.subTo(u, v) + if (ac) c.subTo(a, c) + d.subTo(b, d) + } + } + if (v.compareTo(BigInteger.ONE) != 0) return BigInteger.ZERO + if (d.compareTo(m) >= 0) return d.subtract(m) + if (d.signum() < 0) d.addTo(m, d) + else return d + if (d.signum() < 0) return d.add(m) + else return d + } + + var lowprimes = [ + 2, + 3, + 5, + 7, + 11, + 13, + 17, + 19, + 23, + 29, + 31, + 37, + 41, + 43, + 47, + 53, + 59, + 61, + 67, + 71, + 73, + 79, + 83, + 89, + 97, + 101, + 103, + 107, + 109, + 113, + 127, + 131, + 137, + 139, + 149, + 151, + 157, + 163, + 167, + 173, + 179, + 181, + 191, + 193, + 197, + 199, + 211, + 223, + 227, + 229, + 233, + 239, + 241, + 251, + 257, + 263, + 269, + 271, + 277, + 281, + 283, + 293, + 307, + 311, + 313, + 317, + 331, + 337, + 347, + 349, + 353, + 359, + 367, + 373, + 379, + 383, + 389, + 397, + 401, + 409, + 419, + 421, + 431, + 433, + 439, + 443, + 449, + 457, + 461, + 463, + 467, + 479, + 487, + 491, + 499, + 503, + 509, + 521, + 523, + 541, + 547, + 557, + 563, + 569, + 571, + 577, + 587, + 593, + 599, + 601, + 607, + 613, + 617, + 619, + 631, + 641, + 643, + 647, + 653, + 659, + 661, + 673, + 677, + 683, + 691, + 701, + 709, + 719, + 727, + 733, + 739, + 743, + 751, + 757, + 761, + 769, + 773, + 787, + 797, + 809, + 811, + 821, + 823, + 827, + 829, + 839, + 853, + 857, + 859, + 863, + 877, + 881, + 883, + 887, + 907, + 911, + 919, + 929, + 937, + 941, + 947, + 953, + 967, + 971, + 977, + 983, + 991, + 997 + ] + var lplim = (1 << 26) / lowprimes[lowprimes.length - 1] + + // (public) test primality with certainty >= 1-.5^t + function bnIsProbablePrime(t) { + var i, + x = this.abs() + if (x.t == 1 && x[0] <= lowprimes[lowprimes.length - 1]) { + for (i = 0; i < lowprimes.length; ++i) + if (x[0] == lowprimes[i]) return true + return false + } + if (x.isEven()) return false + i = 1 + while (i < lowprimes.length) { + var m = lowprimes[i], + j = i + 1 + while (j < lowprimes.length && m < lplim) m *= lowprimes[j++] + m = x.modInt(m) + while (i < j) if (m % lowprimes[i++] == 0) return false + } + return x.millerRabin(t) + } + + // (protected) true if probably prime (HAC 4.24, Miller-Rabin) + function bnpMillerRabin(t) { + var n1 = this.subtract(BigInteger.ONE) + var k = n1.getLowestSetBit() + if (k <= 0) return false + var r = n1.shiftRight(k) + t = (t + 1) >> 1 + if (t > lowprimes.length) t = lowprimes.length + var a = nbi() + for (var i = 0; i < t; ++i) { + //Pick bases at random, instead of starting at 2 + a.fromInt(lowprimes[Math.floor(Math.random() * lowprimes.length)]) + var y = a.modPow(r, this) + if (y.compareTo(BigInteger.ONE) != 0 && y.compareTo(n1) != 0) { + var j = 1 + while (j++ < k && y.compareTo(n1) != 0) { + y = y.modPowInt(2, this) + if (y.compareTo(BigInteger.ONE) == 0) return false + } + if (y.compareTo(n1) != 0) return false + } + } + return true + } + + // protected + BigInteger.prototype.chunkSize = bnpChunkSize + BigInteger.prototype.toRadix = bnpToRadix + BigInteger.prototype.fromRadix = bnpFromRadix + BigInteger.prototype.fromNumber = bnpFromNumber + BigInteger.prototype.bitwiseTo = bnpBitwiseTo + BigInteger.prototype.changeBit = bnpChangeBit + BigInteger.prototype.addTo = bnpAddTo + BigInteger.prototype.dMultiply = bnpDMultiply + BigInteger.prototype.dAddOffset = bnpDAddOffset + BigInteger.prototype.multiplyLowerTo = bnpMultiplyLowerTo + BigInteger.prototype.multiplyUpperTo = bnpMultiplyUpperTo + BigInteger.prototype.modInt = bnpModInt + BigInteger.prototype.millerRabin = bnpMillerRabin + + // public + BigInteger.prototype.clone = bnClone + BigInteger.prototype.intValue = bnIntValue + BigInteger.prototype.byteValue = bnByteValue + BigInteger.prototype.shortValue = bnShortValue + BigInteger.prototype.signum = bnSigNum + BigInteger.prototype.toByteArray = bnToByteArray + BigInteger.prototype.equals = bnEquals + BigInteger.prototype.min = bnMin + BigInteger.prototype.max = bnMax + BigInteger.prototype.and = bnAnd + BigInteger.prototype.or = bnOr + BigInteger.prototype.xor = bnXor + BigInteger.prototype.andNot = bnAndNot + BigInteger.prototype.not = bnNot + BigInteger.prototype.shiftLeft = bnShiftLeft + BigInteger.prototype.shiftRight = bnShiftRight + BigInteger.prototype.getLowestSetBit = bnGetLowestSetBit + BigInteger.prototype.bitCount = bnBitCount + BigInteger.prototype.testBit = bnTestBit + BigInteger.prototype.setBit = bnSetBit + BigInteger.prototype.clearBit = bnClearBit + BigInteger.prototype.flipBit = bnFlipBit + BigInteger.prototype.add = bnAdd + BigInteger.prototype.subtract = bnSubtract + BigInteger.prototype.multiply = bnMultiply + BigInteger.prototype.divide = bnDivide + BigInteger.prototype.remainder = bnRemainder + BigInteger.prototype.divideAndRemainder = bnDivideAndRemainder + BigInteger.prototype.modPow = bnModPow + BigInteger.prototype.modInverse = bnModInverse + BigInteger.prototype.pow = bnPow + BigInteger.prototype.gcd = bnGCD + BigInteger.prototype.isProbablePrime = bnIsProbablePrime + + // JSBN-specific extension + BigInteger.prototype.square = bnSquare + + // Expose the Barrett function + BigInteger.prototype.Barrett = Barrett + + // BigInteger interfaces not implemented in jsbn: + + // BigInteger(int signum, byte[] magnitude) + // double doubleValue() + // float floatValue() + // int hashCode() + // long longValue() + // static BigInteger valueOf(long val) + + // Random number generator - requires a PRNG backend, e.g. prng4.js + + // For best results, put code like + // + // in your main HTML document. + + var rng_state + var rng_pool + var rng_pptr + + // Mix in a 32-bit integer into the pool + function rng_seed_int(x) { + rng_pool[rng_pptr++] ^= x & 255 + rng_pool[rng_pptr++] ^= (x >> 8) & 255 + rng_pool[rng_pptr++] ^= (x >> 16) & 255 + rng_pool[rng_pptr++] ^= (x >> 24) & 255 + if (rng_pptr >= rng_psize) rng_pptr -= rng_psize + } + + // Mix in the current time (w/milliseconds) into the pool + function rng_seed_time() { + rng_seed_int(new Date().getTime()) + } + + // Initialize the pool with junk if needed. + if (rng_pool == null) { + rng_pool = new Array() + rng_pptr = 0 + var t + if (typeof window !== 'undefined' && window.crypto) { + if (window.crypto.getRandomValues) { + // Use webcrypto if available + var ua = new Uint8Array(32) + window.crypto.getRandomValues(ua) + for (t = 0; t < 32; ++t) rng_pool[rng_pptr++] = ua[t] + } else if ( + navigator.appName == 'Netscape' && + navigator.appVersion < '5' + ) { + // Extract entropy (256 bits) from NS4 RNG if available + var z = window.crypto.random(32) + for (t = 0; t < z.length; ++t) + rng_pool[rng_pptr++] = z.charCodeAt(t) & 255 + } + } + while (rng_pptr < rng_psize) { + // extract some randomness from Math.random() + t = Math.floor(65536 * Math.random()) + rng_pool[rng_pptr++] = t >>> 8 + rng_pool[rng_pptr++] = t & 255 + } + rng_pptr = 0 + rng_seed_time() + //rng_seed_int(window.screenX); + //rng_seed_int(window.screenY); + } + + function rng_get_byte() { + if (rng_state == null) { + rng_seed_time() + rng_state = prng_newstate() + rng_state.init(rng_pool) + for (rng_pptr = 0; rng_pptr < rng_pool.length; ++rng_pptr) + rng_pool[rng_pptr] = 0 + rng_pptr = 0 + //rng_pool = null; + } + // TODO: allow reseeding after first request + return rng_state.next() + } + + function rng_get_bytes(ba) { + var i + for (i = 0; i < ba.length; ++i) ba[i] = rng_get_byte() + } + + function SecureRandom() {} + + SecureRandom.prototype.nextBytes = rng_get_bytes + + // prng4.js - uses Arcfour as a PRNG + + function Arcfour() { + this.i = 0 + this.j = 0 + this.S = new Array() + } + + // Initialize arcfour context from key, an array of ints, each from [0..255] + function ARC4init(key) { + var i, j, t + for (i = 0; i < 256; ++i) this.S[i] = i + j = 0 + for (i = 0; i < 256; ++i) { + j = (j + this.S[i] + key[i % key.length]) & 255 + t = this.S[i] + this.S[i] = this.S[j] + this.S[j] = t + } + this.i = 0 + this.j = 0 + } + + function ARC4next() { + var t + this.i = (this.i + 1) & 255 + this.j = (this.j + this.S[this.i]) & 255 + t = this.S[this.i] + this.S[this.i] = this.S[this.j] + this.S[this.j] = t + return this.S[(t + this.S[this.i]) & 255] + } + + Arcfour.prototype.init = ARC4init + Arcfour.prototype.next = ARC4next + + // Plug in your RNG constructor here + function prng_newstate() { + return new Arcfour() + } + + // Pool size must be a multiple of 4 and greater than 32. + // An array of bytes the size of the pool will be passed to init() + var rng_psize = 256 + + BigInteger.SecureRandom = SecureRandom + BigInteger.BigInteger = BigInteger + if (true) { + exports = module.exports = BigInteger + } else { + } + }.call(this)) + + /***/ + }, + + /***/ 55031: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + var json_stringify = __webpack_require__(78574).stringify + var json_parse = __webpack_require__(89099) + + module.exports = function (options) { + return { + parse: json_parse(options), + stringify: json_stringify + } + } + //create the default method members with no options applied for backwards compatibility + module.exports.parse = json_parse() + module.exports.stringify = json_stringify + + /***/ + }, + + /***/ 89099: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + var BigNumber = null + + // regexpxs extracted from + // (c) BSD-3-Clause + // https://github.com/fastify/secure-json-parse/graphs/contributors and https://github.com/hapijs/bourne/graphs/contributors + + const suspectProtoRx = /(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])/ + const suspectConstructorRx = /(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)/ + + /* + json_parse.js + 2012-06-20 + + Public Domain. + + NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. + + This file creates a json_parse function. + During create you can (optionally) specify some behavioural switches + + require('json-bigint')(options) + + The optional options parameter holds switches that drive certain + aspects of the parsing process: + * options.strict = true will warn about duplicate-key usage in the json. + The default (strict = false) will silently ignore those and overwrite + values for keys that are in duplicate use. + + The resulting function follows this signature: + json_parse(text, reviver) + This method parses a JSON text to produce an object or array. + It can throw a SyntaxError exception. + + The optional reviver parameter is a function that can filter and + transform the results. It receives each of the keys and values, + and its return value is used instead of the original value. + If it returns what it received, then the structure is not modified. + If it returns undefined then the member is deleted. + + Example: + + // Parse the text. Values that look like ISO date strings will + // be converted to Date objects. + + myData = json_parse(text, function (key, value) { + var a; + if (typeof value === 'string') { + a = +/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value); + if (a) { + return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], + +a[5], +a[6])); + } + } + return value; + }); + + This is a reference implementation. You are free to copy, modify, or + redistribute. + + This code should be minified before deployment. + See http://javascript.crockford.com/jsmin.html + + USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO + NOT CONTROL. +*/ + + /*members "", "\"", "\/", "\\", at, b, call, charAt, f, fromCharCode, + hasOwnProperty, message, n, name, prototype, push, r, t, text +*/ + + var json_parse = function (options) { + 'use strict' + + // This is a function that can parse a JSON text, producing a JavaScript + // data structure. It is a simple, recursive descent parser. It does not use + // eval or regular expressions, so it can be used as a model for implementing + // a JSON parser in other languages. + + // We are defining the function inside of another function to avoid creating + // global variables. + + // Default options one can override by passing options to the parse() + var _options = { + strict: false, // not being strict means do not generate syntax errors for "duplicate key" + storeAsString: false, // toggles whether the values should be stored as BigNumber (default) or a string + alwaysParseAsBig: false, // toggles whether all numbers should be Big + useNativeBigInt: false, // toggles whether to use native BigInt instead of bignumber.js + protoAction: 'error', + constructorAction: 'error' + } + + // If there are options, then use them to override the default _options + if (options !== undefined && options !== null) { + if (options.strict === true) { + _options.strict = true + } + if (options.storeAsString === true) { + _options.storeAsString = true + } + _options.alwaysParseAsBig = + options.alwaysParseAsBig === true ? options.alwaysParseAsBig : false + _options.useNativeBigInt = + options.useNativeBigInt === true ? options.useNativeBigInt : false + + if (typeof options.constructorAction !== 'undefined') { + if ( + options.constructorAction === 'error' || + options.constructorAction === 'ignore' || + options.constructorAction === 'preserve' + ) { + _options.constructorAction = options.constructorAction + } else { + throw new Error( + `Incorrect value for constructorAction option, must be "error", "ignore" or undefined but passed ${options.constructorAction}` + ) + } + } + + if (typeof options.protoAction !== 'undefined') { + if ( + options.protoAction === 'error' || + options.protoAction === 'ignore' || + options.protoAction === 'preserve' + ) { + _options.protoAction = options.protoAction + } else { + throw new Error( + `Incorrect value for protoAction option, must be "error", "ignore" or undefined but passed ${options.protoAction}` + ) + } + } + } + + var at, // The index of the current character + ch, // The current character + escapee = { + '"': '"', + '\\': '\\', + '/': '/', + b: '\b', + f: '\f', + n: '\n', + r: '\r', + t: '\t' + }, + text, + error = function (m) { + // Call error when something is wrong. + + throw { + name: 'SyntaxError', + message: m, + at: at, + text: text + } + }, + next = function (c) { + // If a c parameter is provided, verify that it matches the current character. + + if (c && c !== ch) { + error("Expected '" + c + "' instead of '" + ch + "'") + } + + // Get the next character. When there are no more characters, + // return the empty string. + + ch = text.charAt(at) + at += 1 + return ch + }, + number = function () { + // Parse a number value. + + var number, + string = '' + + if (ch === '-') { + string = '-' + next('-') + } + while (ch >= '0' && ch <= '9') { + string += ch + next() + } + if (ch === '.') { + string += '.' + while (next() && ch >= '0' && ch <= '9') { + string += ch + } + } + if (ch === 'e' || ch === 'E') { + string += ch + next() + if (ch === '-' || ch === '+') { + string += ch + next() + } + while (ch >= '0' && ch <= '9') { + string += ch + next() + } + } + number = +string + if (!isFinite(number)) { + error('Bad number') + } else { + if (BigNumber == null) BigNumber = __webpack_require__(87558) + //if (number > 9007199254740992 || number < -9007199254740992) + // Bignumber has stricter check: everything with length > 15 digits disallowed + if (string.length > 15) + return _options.storeAsString + ? string + : _options.useNativeBigInt + ? BigInt(string) + : new BigNumber(string) + else + return !_options.alwaysParseAsBig + ? number + : _options.useNativeBigInt + ? BigInt(number) + : new BigNumber(number) + } + }, + string = function () { + // Parse a string value. + + var hex, + i, + string = '', + uffff + + // When parsing for string values, we must look for " and \ characters. + + if (ch === '"') { + var startAt = at + while (next()) { + if (ch === '"') { + if (at - 1 > startAt) + string += text.substring(startAt, at - 1) + next() + return string + } + if (ch === '\\') { + if (at - 1 > startAt) + string += text.substring(startAt, at - 1) + next() + if (ch === 'u') { + uffff = 0 + for (i = 0; i < 4; i += 1) { + hex = parseInt(next(), 16) + if (!isFinite(hex)) { + break + } + uffff = uffff * 16 + hex + } + string += String.fromCharCode(uffff) + } else if (typeof escapee[ch] === 'string') { + string += escapee[ch] + } else { + break + } + startAt = at + } + } + } + error('Bad string') + }, + white = function () { + // Skip whitespace. + + while (ch && ch <= ' ') { + next() + } + }, + word = function () { + // true, false, or null. + + switch (ch) { + case 't': + next('t') + next('r') + next('u') + next('e') + return true + case 'f': + next('f') + next('a') + next('l') + next('s') + next('e') + return false + case 'n': + next('n') + next('u') + next('l') + next('l') + return null + } + error("Unexpected '" + ch + "'") + }, + value, // Place holder for the value function. + array = function () { + // Parse an array value. + + var array = [] + + if (ch === '[') { + next('[') + white() + if (ch === ']') { + next(']') + return array // empty array + } + while (ch) { + array.push(value()) + white() + if (ch === ']') { + next(']') + return array + } + next(',') + white() + } + } + error('Bad array') + }, + object = function () { + // Parse an object value. + + var key, + object = Object.create(null) + + if (ch === '{') { + next('{') + white() + if (ch === '}') { + next('}') + return object // empty object + } + while (ch) { + key = string() + white() + next(':') + if ( + _options.strict === true && + Object.hasOwnProperty.call(object, key) + ) { + error('Duplicate key "' + key + '"') + } + + if (suspectProtoRx.test(key) === true) { + if (_options.protoAction === 'error') { + error('Object contains forbidden prototype property') + } else if (_options.protoAction === 'ignore') { + value() + } else { + object[key] = value() + } + } else if (suspectConstructorRx.test(key) === true) { + if (_options.constructorAction === 'error') { + error('Object contains forbidden constructor property') + } else if (_options.constructorAction === 'ignore') { + value() + } else { + object[key] = value() + } + } else { + object[key] = value() + } + + white() + if (ch === '}') { + next('}') + return object + } + next(',') + white() + } + } + error('Bad object') + } + + value = function () { + // Parse a JSON value. It could be an object, an array, a string, a number, + // or a word. + + white() + switch (ch) { + case '{': + return object() + case '[': + return array() + case '"': + return string() + case '-': + return number() + default: + return ch >= '0' && ch <= '9' ? number() : word() + } + } + + // Return the json_parse function. It will have access to all of the above + // functions and variables. + + return function (source, reviver) { + var result + + text = source + '' + at = 0 + ch = ' ' + result = value() + white() + if (ch) { + error('Syntax error') + } + + // If there is a reviver function, we recursively walk the new structure, + // passing each name/value pair to the reviver function for possible + // transformation, starting with a temporary root object that holds the result + // in an empty key. If there is not a reviver function, we simply return the + // result. + + return typeof reviver === 'function' + ? (function walk(holder, key) { + var k, + v, + value = holder[key] + if (value && typeof value === 'object') { + Object.keys(value).forEach(function (k) { + v = walk(value, k) + if (v !== undefined) { + value[k] = v + } else { + delete value[k] + } + }) + } + return reviver.call(holder, key, value) + })({ '': result }, '') + : result + } + } + + module.exports = json_parse + + /***/ + }, + + /***/ 78574: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + var BigNumber = __webpack_require__(87558) + + /* + json2.js + 2013-05-26 + + Public Domain. + + NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. + + See http://www.JSON.org/js.html + + + This code should be minified before deployment. + See http://javascript.crockford.com/jsmin.html + + USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO + NOT CONTROL. + + + This file creates a global JSON object containing two methods: stringify + and parse. + + JSON.stringify(value, replacer, space) + value any JavaScript value, usually an object or array. + + replacer an optional parameter that determines how object + values are stringified for objects. It can be a + function or an array of strings. + + space an optional parameter that specifies the indentation + of nested structures. If it is omitted, the text will + be packed without extra whitespace. If it is a number, + it will specify the number of spaces to indent at each + level. If it is a string (such as '\t' or ' '), + it contains the characters used to indent at each level. + + This method produces a JSON text from a JavaScript value. + + When an object value is found, if the object contains a toJSON + method, its toJSON method will be called and the result will be + stringified. A toJSON method does not serialize: it returns the + value represented by the name/value pair that should be serialized, + or undefined if nothing should be serialized. The toJSON method + will be passed the key associated with the value, and this will be + bound to the value + + For example, this would serialize Dates as ISO strings. + + Date.prototype.toJSON = function (key) { + function f(n) { + // Format integers to have at least two digits. + return n < 10 ? '0' + n : n; + } + + return this.getUTCFullYear() + '-' + + f(this.getUTCMonth() + 1) + '-' + + f(this.getUTCDate()) + 'T' + + f(this.getUTCHours()) + ':' + + f(this.getUTCMinutes()) + ':' + + f(this.getUTCSeconds()) + 'Z'; + }; + + You can provide an optional replacer method. It will be passed the + key and value of each member, with this bound to the containing + object. The value that is returned from your method will be + serialized. If your method returns undefined, then the member will + be excluded from the serialization. + + If the replacer parameter is an array of strings, then it will be + used to select the members to be serialized. It filters the results + such that only members with keys listed in the replacer array are + stringified. + + Values that do not have JSON representations, such as undefined or + functions, will not be serialized. Such values in objects will be + dropped; in arrays they will be replaced with null. You can use + a replacer function to replace those with JSON values. + JSON.stringify(undefined) returns undefined. + + The optional space parameter produces a stringification of the + value that is filled with line breaks and indentation to make it + easier to read. + + If the space parameter is a non-empty string, then that string will + be used for indentation. If the space parameter is a number, then + the indentation will be that many spaces. + + Example: + + text = JSON.stringify(['e', {pluribus: 'unum'}]); + // text is '["e",{"pluribus":"unum"}]' + + + text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t'); + // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]' + + text = JSON.stringify([new Date()], function (key, value) { + return this[key] instanceof Date ? + 'Date(' + this[key] + ')' : value; + }); + // text is '["Date(---current time---)"]' + + + JSON.parse(text, reviver) + This method parses a JSON text to produce an object or array. + It can throw a SyntaxError exception. + + The optional reviver parameter is a function that can filter and + transform the results. It receives each of the keys and values, + and its return value is used instead of the original value. + If it returns what it received, then the structure is not modified. + If it returns undefined then the member is deleted. + + Example: + + // Parse the text. Values that look like ISO date strings will + // be converted to Date objects. + + myData = JSON.parse(text, function (key, value) { + var a; + if (typeof value === 'string') { + a = +/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value); + if (a) { + return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], + +a[5], +a[6])); + } + } + return value; + }); + + myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) { + var d; + if (typeof value === 'string' && + value.slice(0, 5) === 'Date(' && + value.slice(-1) === ')') { + d = new Date(value.slice(5, -1)); + if (d) { + return d; + } + } + return value; + }); + + + This is a reference implementation. You are free to copy, modify, or + redistribute. +*/ + + /*jslint evil: true, regexp: true */ + + /*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply, + call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours, + getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join, + lastIndex, length, parse, prototype, push, replace, slice, stringify, + test, toJSON, toString, valueOf +*/ + + // Create a JSON object only if one does not already exist. We create the + // methods in a closure to avoid creating global variables. + + var JSON = module.exports + + ;(function () { + 'use strict' + + function f(n) { + // Format integers to have at least two digits. + return n < 10 ? '0' + n : n + } + + var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, + escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, + gap, + indent, + meta = { + // table of character substitutions + '\b': '\\b', + '\t': '\\t', + '\n': '\\n', + '\f': '\\f', + '\r': '\\r', + '"': '\\"', + '\\': '\\\\' + }, + rep + + function quote(string) { + // If the string contains no control characters, no quote characters, and no + // backslash characters, then we can safely slap some quotes around it. + // Otherwise we must also replace the offending characters with safe escape + // sequences. + + escapable.lastIndex = 0 + return escapable.test(string) + ? '"' + + string.replace(escapable, function (a) { + var c = meta[a] + return typeof c === 'string' + ? c + : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4) + }) + + '"' + : '"' + string + '"' + } + + function str(key, holder) { + // Produce a string from holder[key]. + + var i, // The loop counter. + k, // The member key. + v, // The member value. + length, + mind = gap, + partial, + value = holder[key], + isBigNumber = + value != null && + (value instanceof BigNumber || BigNumber.isBigNumber(value)) + + // If the value has a toJSON method, call it to obtain a replacement value. + + if ( + value && + typeof value === 'object' && + typeof value.toJSON === 'function' + ) { + value = value.toJSON(key) + } + + // If we were called with a replacer function, then call the replacer to + // obtain a replacement value. + + if (typeof rep === 'function') { + value = rep.call(holder, key, value) + } + + // What happens next depends on the value's type. + + switch (typeof value) { + case 'string': + if (isBigNumber) { + return value + } else { + return quote(value) + } + + case 'number': + // JSON numbers must be finite. Encode non-finite numbers as null. + + return isFinite(value) ? String(value) : 'null' + + case 'boolean': + case 'null': + case 'bigint': + // If the value is a boolean or null, convert it to a string. Note: + // typeof null does not produce 'null'. The case is included here in + // the remote chance that this gets fixed someday. + + return String(value) + + // If the type is 'object', we might be dealing with an object or an array or + // null. + + case 'object': + // Due to a specification blunder in ECMAScript, typeof null is 'object', + // so watch out for that case. + + if (!value) { + return 'null' + } + + // Make an array to hold the partial results of stringifying this object value. + + gap += indent + partial = [] + + // Is the value an array? + + if (Object.prototype.toString.apply(value) === '[object Array]') { + // The value is an array. Stringify every element. Use null as a placeholder + // for non-JSON values. + + length = value.length + for (i = 0; i < length; i += 1) { + partial[i] = str(i, value) || 'null' + } + + // Join all of the elements together, separated with commas, and wrap them in + // brackets. + + v = + partial.length === 0 + ? '[]' + : gap + ? '[\n' + + gap + + partial.join(',\n' + gap) + + '\n' + + mind + + ']' + : '[' + partial.join(',') + ']' + gap = mind + return v + } + + // If the replacer is an array, use it to select the members to be stringified. + + if (rep && typeof rep === 'object') { + length = rep.length + for (i = 0; i < length; i += 1) { + if (typeof rep[i] === 'string') { + k = rep[i] + v = str(k, value) + if (v) { + partial.push(quote(k) + (gap ? ': ' : ':') + v) + } + } + } + } else { + // Otherwise, iterate through all of the keys in the object. + + Object.keys(value).forEach(function (k) { + var v = str(k, value) + if (v) { + partial.push(quote(k) + (gap ? ': ' : ':') + v) + } + }) + } + + // Join all of the member texts together, separated with commas, + // and wrap them in braces. + + v = + partial.length === 0 + ? '{}' + : gap + ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' + : '{' + partial.join(',') + '}' + gap = mind + return v + } + } + + // If the JSON object does not yet have a stringify method, give it one. + + if (typeof JSON.stringify !== 'function') { + JSON.stringify = function (value, replacer, space) { + // The stringify method takes a value and an optional replacer, and an optional + // space parameter, and returns a JSON text. The replacer can be a function + // that can replace values, or an array of strings that will select the keys. + // A default replacer method can be provided. Use of the space parameter can + // produce text that is more easily readable. + + var i + gap = '' + indent = '' + + // If the space parameter is a number, make an indent string containing that + // many spaces. + + if (typeof space === 'number') { + for (i = 0; i < space; i += 1) { + indent += ' ' + } + + // If the space parameter is a string, it will be used as the indent string. + } else if (typeof space === 'string') { + indent = space + } + + // If there is a replacer, it must be a function or an array. + // Otherwise, throw an error. + + rep = replacer + if ( + replacer && + typeof replacer !== 'function' && + (typeof replacer !== 'object' || + typeof replacer.length !== 'number') + ) { + throw new Error('JSON.stringify') + } + + // Make a fake root object containing our value under the key of ''. + // Return the result of stringifying the value. + + return str('', { '': value }) + } + } + })() + + /***/ + }, + + /***/ 52533: /***/ module => { + 'use strict' + + var traverse = (module.exports = function (schema, opts, cb) { + // Legacy support for v0.3.1 and earlier. + if (typeof opts == 'function') { + cb = opts + opts = {} + } + + cb = opts.cb || cb + var pre = typeof cb == 'function' ? cb : cb.pre || function () {} + var post = cb.post || function () {} + + _traverse(opts, pre, post, schema, '', schema) + }) + + traverse.keywords = { + additionalItems: true, + items: true, + contains: true, + additionalProperties: true, + propertyNames: true, + not: true + } + + traverse.arrayKeywords = { + items: true, + allOf: true, + anyOf: true, + oneOf: true + } + + traverse.propsKeywords = { + definitions: true, + properties: true, + patternProperties: true, + dependencies: true + } + + traverse.skipKeywords = { + default: true, + enum: true, + const: true, + required: true, + maximum: true, + minimum: true, + exclusiveMaximum: true, + exclusiveMinimum: true, + multipleOf: true, + maxLength: true, + minLength: true, + pattern: true, + format: true, + maxItems: true, + minItems: true, + uniqueItems: true, + maxProperties: true, + minProperties: true + } + + function _traverse( + opts, + pre, + post, + schema, + jsonPtr, + rootSchema, + parentJsonPtr, + parentKeyword, + parentSchema, + keyIndex + ) { + if (schema && typeof schema == 'object' && !Array.isArray(schema)) { + pre( + schema, + jsonPtr, + rootSchema, + parentJsonPtr, + parentKeyword, + parentSchema, + keyIndex + ) + for (var key in schema) { + var sch = schema[key] + if (Array.isArray(sch)) { + if (key in traverse.arrayKeywords) { + for (var i = 0; i < sch.length; i++) + _traverse( + opts, + pre, + post, + sch[i], + jsonPtr + '/' + key + '/' + i, + rootSchema, + jsonPtr, + key, + schema, + i + ) + } + } else if (key in traverse.propsKeywords) { + if (sch && typeof sch == 'object') { + for (var prop in sch) + _traverse( + opts, + pre, + post, + sch[prop], + jsonPtr + '/' + key + '/' + escapeJsonPtr(prop), + rootSchema, + jsonPtr, + key, + schema, + prop + ) + } + } else if ( + key in traverse.keywords || + (opts.allKeys && !(key in traverse.skipKeywords)) + ) { + _traverse( + opts, + pre, + post, + sch, + jsonPtr + '/' + key, + rootSchema, + jsonPtr, + key, + schema + ) + } + } + post( + schema, + jsonPtr, + rootSchema, + parentJsonPtr, + parentKeyword, + parentSchema, + keyIndex + ) + } + } + + function escapeJsonPtr(str) { + return str.replace(/~/g, '~0').replace(/\//g, '~1') + } + + /***/ + }, + + /***/ 21328: /***/ function (module) { + /** + * JSONSchema Validator - Validates JavaScript objects using JSON Schemas + * (http://www.json.com/json-schema-proposal/) + * + * Copyright (c) 2007 Kris Zyp SitePen (www.sitepen.com) + * Licensed under the MIT (MIT-LICENSE.txt) license. +To use the validator call the validate function with an instance object and an optional schema object. +If a schema is provided, it will be used to validate. If the instance object refers to a schema (self-validating), +that schema will be used to validate and the schema parameter is not necessary (if both exist, +both validations will occur). +The validate method will return an array of validation errors. If there are no errors, then an +empty list will be returned. A validation error will have two properties: +"property" which indicates which property had the error +"message" which indicates what the error was + */ + ;(function (root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define([], function () { + return factory() + }) + } else if (true && module.exports) { + // Node. Does not work with strict CommonJS, but + // only CommonJS-like environments that support module.exports, + // like Node. + module.exports = factory() + } else { + // Browser globals + root.jsonSchema = factory() + } + })(this, function () { + // setup primitive classes to be JSON Schema types + var exports = validate + exports.Integer = { type: 'integer' } + var primitiveConstructors = { + String: String, + Boolean: Boolean, + Number: Number, + Object: Object, + Array: Array, + Date: Date + } + exports.validate = validate + function validate(/*Any*/ instance, /*Object*/ schema) { + // Summary: + // To use the validator call JSONSchema.validate with an instance object and an optional schema object. + // If a schema is provided, it will be used to validate. If the instance object refers to a schema (self-validating), + // that schema will be used to validate and the schema parameter is not necessary (if both exist, + // both validations will occur). + // The validate method will return an object with two properties: + // valid: A boolean indicating if the instance is valid by the schema + // errors: An array of validation errors. If there are no errors, then an + // empty list will be returned. A validation error will have two properties: + // property: which indicates which property had the error + // message: which indicates what the error was + // + return validate(instance, schema, { changing: false }) //, coerce: false, existingOnly: false}); + } + exports.checkPropertyChange = function ( + /*Any*/ value, + /*Object*/ schema, + /*String*/ property + ) { + // Summary: + // The checkPropertyChange method will check to see if an value can legally be in property with the given schema + // This is slightly different than the validate method in that it will fail if the schema is readonly and it will + // not check for self-validation, it is assumed that the passed in value is already internally valid. + // The checkPropertyChange method will return the same object type as validate, see JSONSchema.validate for + // information. + // + return validate(value, schema, { changing: property || 'property' }) + } + var validate = (exports._validate = function ( + /*Any*/ instance, + /*Object*/ schema, + /*Object*/ options + ) { + if (!options) options = {} + var _changing = options.changing + + function getType(schema) { + return ( + schema.type || + (primitiveConstructors[schema.name] == schema && + schema.name.toLowerCase()) + ) + } + var errors = [] + // validate a value against a property definition + function checkProp(value, schema, path, i) { + var l + path += path + ? typeof i == 'number' + ? '[' + i + ']' + : typeof i == 'undefined' + ? '' + : '.' + i + : i + function addError(message) { + errors.push({ property: path, message: message }) + } + + if ( + (typeof schema != 'object' || schema instanceof Array) && + (path || typeof schema != 'function') && + !(schema && getType(schema)) + ) { + if (typeof schema == 'function') { + if (!(value instanceof schema)) { + addError( + 'is not an instance of the class/constructor ' + schema.name + ) + } + } else if (schema) { + addError('Invalid schema/property definition ' + schema) + } + return null + } + if (_changing && schema.readonly) { + addError('is a readonly field, it can not be changed') + } + if (schema['extends']) { + // if it extends another schema, it must pass that schema as well + checkProp(value, schema['extends'], path, i) + } + // validate a value against a type definition + function checkType(type, value) { + if (type) { + if ( + typeof type == 'string' && + type != 'any' && + (type == 'null' ? value !== null : typeof value != type) && + !(value instanceof Array && type == 'array') && + !(value instanceof Date && type == 'date') && + !(type == 'integer' && value % 1 === 0) + ) { + return [ + { + property: path, + message: + typeof value + + ' value found, but a ' + + type + + ' is required' + } + ] + } + if (type instanceof Array) { + var unionErrors = [] + for (var j = 0; j < type.length; j++) { + // a union type + if (!(unionErrors = checkType(type[j], value)).length) { + break + } + } + if (unionErrors.length) { + return unionErrors + } + } else if (typeof type == 'object') { + var priorErrors = errors + errors = [] + checkProp(value, type, path) + var theseErrors = errors + errors = priorErrors + return theseErrors + } + } + return [] + } + if (value === undefined) { + if (schema.required) { + addError('is missing and it is required') + } + } else { + errors = errors.concat(checkType(getType(schema), value)) + if ( + schema.disallow && + !checkType(schema.disallow, value).length + ) { + addError(' disallowed value was matched') + } + if (value !== null) { + if (value instanceof Array) { + if (schema.items) { + var itemsIsArray = schema.items instanceof Array + var propDef = schema.items + for (i = 0, l = value.length; i < l; i += 1) { + if (itemsIsArray) propDef = schema.items[i] + if (options.coerce) + value[i] = options.coerce(value[i], propDef) + errors.concat(checkProp(value[i], propDef, path, i)) + } + } + if (schema.minItems && value.length < schema.minItems) { + addError( + 'There must be a minimum of ' + + schema.minItems + + ' in the array' + ) + } + if (schema.maxItems && value.length > schema.maxItems) { + addError( + 'There must be a maximum of ' + + schema.maxItems + + ' in the array' + ) + } + } else if (schema.properties || schema.additionalProperties) { + errors.concat( + checkObj( + value, + schema.properties, + path, + schema.additionalProperties + ) + ) + } + if ( + schema.pattern && + typeof value == 'string' && + !value.match(schema.pattern) + ) { + addError('does not match the regex pattern ' + schema.pattern) + } + if ( + schema.maxLength && + typeof value == 'string' && + value.length > schema.maxLength + ) { + addError( + 'may only be ' + schema.maxLength + ' characters long' + ) + } + if ( + schema.minLength && + typeof value == 'string' && + value.length < schema.minLength + ) { + addError( + 'must be at least ' + schema.minLength + ' characters long' + ) + } + if ( + typeof schema.minimum !== undefined && + typeof value == typeof schema.minimum && + schema.minimum > value + ) { + addError('must have a minimum value of ' + schema.minimum) + } + if ( + typeof schema.maximum !== undefined && + typeof value == typeof schema.maximum && + schema.maximum < value + ) { + addError('must have a maximum value of ' + schema.maximum) + } + if (schema['enum']) { + var enumer = schema['enum'] + l = enumer.length + var found + for (var j = 0; j < l; j++) { + if (enumer[j] === value) { + found = 1 + break + } + } + if (!found) { + addError( + 'does not have a value in the enumeration ' + + enumer.join(', ') + ) + } + } + if ( + typeof schema.maxDecimal == 'number' && + value + .toString() + .match( + new RegExp('\\.[0-9]{' + (schema.maxDecimal + 1) + ',}') + ) + ) { + addError( + 'may only have ' + + schema.maxDecimal + + ' digits of decimal places' + ) + } + } + } + return null + } + // validate an object against a schema + function checkObj(instance, objTypeDef, path, additionalProp) { + if (typeof objTypeDef == 'object') { + if (typeof instance != 'object' || instance instanceof Array) { + errors.push({ + property: path, + message: 'an object is required' + }) + } + + for (var i in objTypeDef) { + if (objTypeDef.hasOwnProperty(i)) { + var value = instance[i] + // skip _not_ specified properties + if (value === undefined && options.existingOnly) continue + var propDef = objTypeDef[i] + // set default + if (value === undefined && propDef['default']) { + value = instance[i] = propDef['default'] + } + if (options.coerce && i in instance) { + value = instance[i] = options.coerce(value, propDef) + } + checkProp(value, propDef, path, i) + } + } + } + for (i in instance) { + if ( + instance.hasOwnProperty(i) && + !(i.charAt(0) == '_' && i.charAt(1) == '_') && + objTypeDef && + !objTypeDef[i] && + additionalProp === false + ) { + if (options.filter) { + delete instance[i] + continue + } else { + errors.push({ + property: path, + message: + typeof value + + 'The property ' + + i + + ' is not defined in the schema and the schema does not allow additional properties' + }) + } + } + var requires = + objTypeDef && objTypeDef[i] && objTypeDef[i].requires + if (requires && !(requires in instance)) { + errors.push({ + property: path, + message: + 'the presence of the property ' + + i + + ' requires that ' + + requires + + ' also be present' + }) + } + value = instance[i] + if ( + additionalProp && + (!(objTypeDef && typeof objTypeDef == 'object') || + !(i in objTypeDef)) + ) { + if (options.coerce) { + value = instance[i] = options.coerce(value, additionalProp) + } + checkProp(value, additionalProp, path, i) + } + if (!_changing && value && value.$schema) { + errors = errors.concat(checkProp(value, value.$schema, path, i)) + } + } + return errors + } + if (schema) { + checkProp(instance, schema, '', _changing || '') + } + if (!_changing && instance && instance.$schema) { + checkProp(instance, instance.$schema, '', '') + } + return { valid: !errors.length, errors: errors } + }) + exports.mustBeValid = function (result) { + // summary: + // This checks to ensure that the result is valid and will throw an appropriate error message if it is not + // result: the result returned from checkPropertyChange or validate + if (!result.valid) { + throw new TypeError( + result.errors + .map(function (error) { + return 'for property ' + error.property + ': ' + error.message + }) + .join(', \n') + ) + } + } + + return exports + }) + + /***/ + }, + + /***/ 57073: /***/ (module, exports) => { + exports = module.exports = stringify + exports.getSerialize = serializer + + function stringify(obj, replacer, spaces, cycleReplacer) { + return JSON.stringify(obj, serializer(replacer, cycleReplacer), spaces) + } + + function serializer(replacer, cycleReplacer) { + var stack = [], + keys = [] + + if (cycleReplacer == null) + cycleReplacer = function (key, value) { + if (stack[0] === value) return '[Circular ~]' + return ( + '[Circular ~.' + + keys.slice(0, stack.indexOf(value)).join('.') + + ']' + ) + } + + return function (key, value) { + if (stack.length > 0) { + var thisPos = stack.indexOf(this) + ~thisPos ? stack.splice(thisPos + 1) : stack.push(this) + ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key) + if (~stack.indexOf(value)) + value = cycleReplacer.call(this, key, value) + } else stack.push(value) + + return replacer == null ? value : replacer.call(this, key, value) + } + } + + /***/ + }, + + /***/ 6287: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + /* + * lib/jsprim.js: utilities for primitive JavaScript types + */ + + var mod_assert = __webpack_require__(66631) + var mod_util = __webpack_require__(31669) + + var mod_extsprintf = __webpack_require__(87264) + var mod_verror = __webpack_require__(81692) + var mod_jsonschema = __webpack_require__(21328) + + /* + * Public interface + */ + exports.deepCopy = deepCopy + exports.deepEqual = deepEqual + exports.isEmpty = isEmpty + exports.hasKey = hasKey + exports.forEachKey = forEachKey + exports.pluck = pluck + exports.flattenObject = flattenObject + exports.flattenIter = flattenIter + exports.validateJsonObject = validateJsonObjectJS + exports.validateJsonObjectJS = validateJsonObjectJS + exports.randElt = randElt + exports.extraProperties = extraProperties + exports.mergeObjects = mergeObjects + + exports.startsWith = startsWith + exports.endsWith = endsWith + + exports.parseInteger = parseInteger + + exports.iso8601 = iso8601 + exports.rfc1123 = rfc1123 + exports.parseDateTime = parseDateTime + + exports.hrtimediff = hrtimeDiff + exports.hrtimeDiff = hrtimeDiff + exports.hrtimeAccum = hrtimeAccum + exports.hrtimeAdd = hrtimeAdd + exports.hrtimeNanosec = hrtimeNanosec + exports.hrtimeMicrosec = hrtimeMicrosec + exports.hrtimeMillisec = hrtimeMillisec + + /* + * Deep copy an acyclic *basic* Javascript object. This only handles basic + * scalars (strings, numbers, booleans) and arbitrarily deep arrays and objects + * containing these. This does *not* handle instances of other classes. + */ + function deepCopy(obj) { + var ret, key + var marker = '__deepCopy' + + if (obj && obj[marker]) + throw new Error('attempted deep copy of cyclic object') + + if (obj && obj.constructor == Object) { + ret = {} + obj[marker] = true + + for (key in obj) { + if (key == marker) continue + + ret[key] = deepCopy(obj[key]) + } + + delete obj[marker] + return ret + } + + if (obj && obj.constructor == Array) { + ret = [] + obj[marker] = true + + for (key = 0; key < obj.length; key++) ret.push(deepCopy(obj[key])) + + delete obj[marker] + return ret + } + + /* + * It must be a primitive type -- just return it. + */ + return obj + } + + function deepEqual(obj1, obj2) { + if (typeof obj1 != typeof obj2) return false + + if (obj1 === null || obj2 === null || typeof obj1 != 'object') + return obj1 === obj2 + + if (obj1.constructor != obj2.constructor) return false + + var k + for (k in obj1) { + if (!obj2.hasOwnProperty(k)) return false + + if (!deepEqual(obj1[k], obj2[k])) return false + } + + for (k in obj2) { + if (!obj1.hasOwnProperty(k)) return false + } + + return true + } + + function isEmpty(obj) { + var key + for (key in obj) return false + return true + } + + function hasKey(obj, key) { + mod_assert.equal(typeof key, 'string') + return Object.prototype.hasOwnProperty.call(obj, key) + } + + function forEachKey(obj, callback) { + for (var key in obj) { + if (hasKey(obj, key)) { + callback(key, obj[key]) + } + } + } + + function pluck(obj, key) { + mod_assert.equal(typeof key, 'string') + return pluckv(obj, key) + } + + function pluckv(obj, key) { + if (obj === null || typeof obj !== 'object') return undefined + + if (obj.hasOwnProperty(key)) return obj[key] + + var i = key.indexOf('.') + if (i == -1) return undefined + + var key1 = key.substr(0, i) + if (!obj.hasOwnProperty(key1)) return undefined + + return pluckv(obj[key1], key.substr(i + 1)) + } + + /* + * Invoke callback(row) for each entry in the array that would be returned by + * flattenObject(data, depth). This is just like flattenObject(data, + * depth).forEach(callback), except that the intermediate array is never + * created. + */ + function flattenIter(data, depth, callback) { + doFlattenIter(data, depth, [], callback) + } + + function doFlattenIter(data, depth, accum, callback) { + var each + var key + + if (depth === 0) { + each = accum.slice(0) + each.push(data) + callback(each) + return + } + + mod_assert.ok(data !== null) + mod_assert.equal(typeof data, 'object') + mod_assert.equal(typeof depth, 'number') + mod_assert.ok(depth >= 0) + + for (key in data) { + each = accum.slice(0) + each.push(key) + doFlattenIter(data[key], depth - 1, each, callback) + } + } + + function flattenObject(data, depth) { + if (depth === 0) return [data] + + mod_assert.ok(data !== null) + mod_assert.equal(typeof data, 'object') + mod_assert.equal(typeof depth, 'number') + mod_assert.ok(depth >= 0) + + var rv = [] + var key + + for (key in data) { + flattenObject(data[key], depth - 1).forEach(function (p) { + rv.push([key].concat(p)) + }) + } + + return rv + } + + function startsWith(str, prefix) { + return str.substr(0, prefix.length) == prefix + } + + function endsWith(str, suffix) { + return str.substr(str.length - suffix.length, suffix.length) == suffix + } + + function iso8601(d) { + if (typeof d == 'number') d = new Date(d) + mod_assert.ok(d.constructor === Date) + return mod_extsprintf.sprintf( + '%4d-%02d-%02dT%02d:%02d:%02d.%03dZ', + d.getUTCFullYear(), + d.getUTCMonth() + 1, + d.getUTCDate(), + d.getUTCHours(), + d.getUTCMinutes(), + d.getUTCSeconds(), + d.getUTCMilliseconds() + ) + } + + var RFC1123_MONTHS = [ + 'Jan', + 'Feb', + 'Mar', + 'Apr', + 'May', + 'Jun', + 'Jul', + 'Aug', + 'Sep', + 'Oct', + 'Nov', + 'Dec' + ] + var RFC1123_DAYS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'] + + function rfc1123(date) { + return mod_extsprintf.sprintf( + '%s, %02d %s %04d %02d:%02d:%02d GMT', + RFC1123_DAYS[date.getUTCDay()], + date.getUTCDate(), + RFC1123_MONTHS[date.getUTCMonth()], + date.getUTCFullYear(), + date.getUTCHours(), + date.getUTCMinutes(), + date.getUTCSeconds() + ) + } + + /* + * Parses a date expressed as a string, as either a number of milliseconds since + * the epoch or any string format that Date accepts, giving preference to the + * former where these two sets overlap (e.g., small numbers). + */ + function parseDateTime(str) { + /* + * This is irritatingly implicit, but significantly more concise than + * alternatives. The "+str" will convert a string containing only a + * number directly to a Number, or NaN for other strings. Thus, if the + * conversion succeeds, we use it (this is the milliseconds-since-epoch + * case). Otherwise, we pass the string directly to the Date + * constructor to parse. + */ + var numeric = +str + if (!isNaN(numeric)) { + return new Date(numeric) + } else { + return new Date(str) + } + } + + /* + * Number.*_SAFE_INTEGER isn't present before node v0.12, so we hardcode + * the ES6 definitions here, while allowing for them to someday be higher. + */ + var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991 + var MIN_SAFE_INTEGER = Number.MIN_SAFE_INTEGER || -9007199254740991 + + /* + * Default options for parseInteger(). + */ + var PI_DEFAULTS = { + base: 10, + allowSign: true, + allowPrefix: false, + allowTrailing: false, + allowImprecise: false, + trimWhitespace: false, + leadingZeroIsOctal: false + } + + var CP_0 = 0x30 + var CP_9 = 0x39 + + var CP_A = 0x41 + var CP_B = 0x42 + var CP_O = 0x4f + var CP_T = 0x54 + var CP_X = 0x58 + var CP_Z = 0x5a + + var CP_a = 0x61 + var CP_b = 0x62 + var CP_o = 0x6f + var CP_t = 0x74 + var CP_x = 0x78 + var CP_z = 0x7a + + var PI_CONV_DEC = 0x30 + var PI_CONV_UC = 0x37 + var PI_CONV_LC = 0x57 + + /* + * A stricter version of parseInt() that provides options for changing what + * is an acceptable string (for example, disallowing trailing characters). + */ + function parseInteger(str, uopts) { + mod_assert.string(str, 'str') + mod_assert.optionalObject(uopts, 'options') + + var baseOverride = false + var options = PI_DEFAULTS + + if (uopts) { + baseOverride = hasKey(uopts, 'base') + options = mergeObjects(options, uopts) + mod_assert.number(options.base, 'options.base') + mod_assert.ok(options.base >= 2, 'options.base >= 2') + mod_assert.ok(options.base <= 36, 'options.base <= 36') + mod_assert.bool(options.allowSign, 'options.allowSign') + mod_assert.bool(options.allowPrefix, 'options.allowPrefix') + mod_assert.bool(options.allowTrailing, 'options.allowTrailing') + mod_assert.bool(options.allowImprecise, 'options.allowImprecise') + mod_assert.bool(options.trimWhitespace, 'options.trimWhitespace') + mod_assert.bool( + options.leadingZeroIsOctal, + 'options.leadingZeroIsOctal' + ) + + if (options.leadingZeroIsOctal) { + mod_assert.ok( + !baseOverride, + '"base" and "leadingZeroIsOctal" are ' + 'mutually exclusive' + ) + } + } + + var c + var pbase = -1 + var base = options.base + var start + var mult = 1 + var value = 0 + var idx = 0 + var len = str.length + + /* Trim any whitespace on the left side. */ + if (options.trimWhitespace) { + while (idx < len && isSpace(str.charCodeAt(idx))) { + ++idx + } + } + + /* Check the number for a leading sign. */ + if (options.allowSign) { + if (str[idx] === '-') { + idx += 1 + mult = -1 + } else if (str[idx] === '+') { + idx += 1 + } + } + + /* Parse the base-indicating prefix if there is one. */ + if (str[idx] === '0') { + if (options.allowPrefix) { + pbase = prefixToBase(str.charCodeAt(idx + 1)) + if (pbase !== -1 && (!baseOverride || pbase === base)) { + base = pbase + idx += 2 + } + } + + if (pbase === -1 && options.leadingZeroIsOctal) { + base = 8 + } + } + + /* Parse the actual digits. */ + for (start = idx; idx < len; ++idx) { + c = translateDigit(str.charCodeAt(idx)) + if (c !== -1 && c < base) { + value *= base + value += c + } else { + break + } + } + + /* If we didn't parse any digits, we have an invalid number. */ + if (start === idx) { + return new Error('invalid number: ' + JSON.stringify(str)) + } + + /* Trim any whitespace on the right side. */ + if (options.trimWhitespace) { + while (idx < len && isSpace(str.charCodeAt(idx))) { + ++idx + } + } + + /* Check for trailing characters. */ + if (idx < len && !options.allowTrailing) { + return new Error( + 'trailing characters after number: ' + + JSON.stringify(str.slice(idx)) + ) + } + + /* If our value is 0, we return now, to avoid returning -0. */ + if (value === 0) { + return 0 + } + + /* Calculate our final value. */ + var result = value * mult + + /* + * If the string represents a value that cannot be precisely represented + * by JavaScript, then we want to check that: + * + * - We never increased the value past MAX_SAFE_INTEGER + * - We don't make the result negative and below MIN_SAFE_INTEGER + * + * Because we only ever increment the value during parsing, there's no + * chance of moving past MAX_SAFE_INTEGER and then dropping below it + * again, losing precision in the process. This means that we only need + * to do our checks here, at the end. + */ + if ( + !options.allowImprecise && + (value > MAX_SAFE_INTEGER || result < MIN_SAFE_INTEGER) + ) { + return new Error( + 'number is outside of the supported range: ' + + JSON.stringify(str.slice(start, idx)) + ) + } + + return result + } + + /* + * Interpret a character code as a base-36 digit. + */ + function translateDigit(d) { + if (d >= CP_0 && d <= CP_9) { + /* '0' to '9' -> 0 to 9 */ + return d - PI_CONV_DEC + } else if (d >= CP_A && d <= CP_Z) { + /* 'A' - 'Z' -> 10 to 35 */ + return d - PI_CONV_UC + } else if (d >= CP_a && d <= CP_z) { + /* 'a' - 'z' -> 10 to 35 */ + return d - PI_CONV_LC + } else { + /* Invalid character code */ + return -1 + } + } + + /* + * Test if a value matches the ECMAScript definition of trimmable whitespace. + */ + function isSpace(c) { + return ( + c === 0x20 || + (c >= 0x0009 && c <= 0x000d) || + c === 0x00a0 || + c === 0x1680 || + c === 0x180e || + (c >= 0x2000 && c <= 0x200a) || + c === 0x2028 || + c === 0x2029 || + c === 0x202f || + c === 0x205f || + c === 0x3000 || + c === 0xfeff + ) + } + + /* + * Determine which base a character indicates (e.g., 'x' indicates hex). + */ + function prefixToBase(c) { + if (c === CP_b || c === CP_B) { + /* 0b/0B (binary) */ + return 2 + } else if (c === CP_o || c === CP_O) { + /* 0o/0O (octal) */ + return 8 + } else if (c === CP_t || c === CP_T) { + /* 0t/0T (decimal) */ + return 10 + } else if (c === CP_x || c === CP_X) { + /* 0x/0X (hexadecimal) */ + return 16 + } else { + /* Not a meaningful character */ + return -1 + } + } + + function validateJsonObjectJS(schema, input) { + var report = mod_jsonschema.validate(input, schema) + + if (report.errors.length === 0) return null + + /* Currently, we only do anything useful with the first error. */ + var error = report.errors[0] + + /* The failed property is given by a URI with an irrelevant prefix. */ + var propname = error['property'] + var reason = error['message'].toLowerCase() + var i, j + + /* + * There's at least one case where the property error message is + * confusing at best. We work around this here. + */ + if ( + (i = reason.indexOf('the property ')) != -1 && + (j = reason.indexOf( + ' is not defined in the schema and the ' + + 'schema does not allow additional properties' + )) != -1 + ) { + i += 'the property '.length + if (propname === '') propname = reason.substr(i, j - i) + else propname = propname + '.' + reason.substr(i, j - i) + + reason = 'unsupported property' + } + + var rv = new mod_verror.VError('property "%s": %s', propname, reason) + rv.jsv_details = error + return rv + } + + function randElt(arr) { + mod_assert.ok( + Array.isArray(arr) && arr.length > 0, + 'randElt argument must be a non-empty array' + ) + + return arr[Math.floor(Math.random() * arr.length)] + } + + function assertHrtime(a) { + mod_assert.ok( + a[0] >= 0 && a[1] >= 0, + 'negative numbers not allowed in hrtimes' + ) + mod_assert.ok(a[1] < 1e9, 'nanoseconds column overflow') + } + + /* + * Compute the time elapsed between hrtime readings A and B, where A is later + * than B. hrtime readings come from Node's process.hrtime(). There is no + * defined way to represent negative deltas, so it's illegal to diff B from A + * where the time denoted by B is later than the time denoted by A. If this + * becomes valuable, we can define a representation and extend the + * implementation to support it. + */ + function hrtimeDiff(a, b) { + assertHrtime(a) + assertHrtime(b) + mod_assert.ok( + a[0] > b[0] || (a[0] == b[0] && a[1] >= b[1]), + 'negative differences not allowed' + ) + + var rv = [a[0] - b[0], 0] + + if (a[1] >= b[1]) { + rv[1] = a[1] - b[1] + } else { + rv[0]-- + rv[1] = 1e9 - (b[1] - a[1]) + } + + return rv + } + + /* + * Convert a hrtime reading from the array format returned by Node's + * process.hrtime() into a scalar number of nanoseconds. + */ + function hrtimeNanosec(a) { + assertHrtime(a) + + return Math.floor(a[0] * 1e9 + a[1]) + } + + /* + * Convert a hrtime reading from the array format returned by Node's + * process.hrtime() into a scalar number of microseconds. + */ + function hrtimeMicrosec(a) { + assertHrtime(a) + + return Math.floor(a[0] * 1e6 + a[1] / 1e3) + } + + /* + * Convert a hrtime reading from the array format returned by Node's + * process.hrtime() into a scalar number of milliseconds. + */ + function hrtimeMillisec(a) { + assertHrtime(a) + + return Math.floor(a[0] * 1e3 + a[1] / 1e6) + } + + /* + * Add two hrtime readings A and B, overwriting A with the result of the + * addition. This function is useful for accumulating several hrtime intervals + * into a counter. Returns A. + */ + function hrtimeAccum(a, b) { + assertHrtime(a) + assertHrtime(b) + + /* + * Accumulate the nanosecond component. + */ + a[1] += b[1] + if (a[1] >= 1e9) { + /* + * The nanosecond component overflowed, so carry to the seconds + * field. + */ + a[0]++ + a[1] -= 1e9 + } + + /* + * Accumulate the seconds component. + */ + a[0] += b[0] + + return a + } + + /* + * Add two hrtime readings A and B, returning the result as a new hrtime array. + * Does not modify either input argument. + */ + function hrtimeAdd(a, b) { + assertHrtime(a) + + var rv = [a[0], a[1]] + + return hrtimeAccum(rv, b) + } + + /* + * Check an object for unexpected properties. Accepts the object to check, and + * an array of allowed property names (strings). Returns an array of key names + * that were found on the object, but did not appear in the list of allowed + * properties. If no properties were found, the returned array will be of + * zero length. + */ + function extraProperties(obj, allowed) { + mod_assert.ok( + typeof obj === 'object' && obj !== null, + 'obj argument must be a non-null object' + ) + mod_assert.ok( + Array.isArray(allowed), + 'allowed argument must be an array of strings' + ) + for (var i = 0; i < allowed.length; i++) { + mod_assert.ok( + typeof allowed[i] === 'string', + 'allowed argument must be an array of strings' + ) + } + + return Object.keys(obj).filter(function (key) { + return allowed.indexOf(key) === -1 + }) + } + + /* + * Given three sets of properties "provided" (may be undefined), "overrides" + * (required), and "defaults" (may be undefined), construct an object containing + * the union of these sets with "overrides" overriding "provided", and + * "provided" overriding "defaults". None of the input objects are modified. + */ + function mergeObjects(provided, overrides, defaults) { + var rv, k + + rv = {} + if (defaults) { + for (k in defaults) rv[k] = defaults[k] + } + + if (provided) { + for (k in provided) rv[k] = provided[k] + } + + if (overrides) { + for (k in overrides) rv[k] = overrides[k] + } + + return rv + } + + /***/ + }, + + /***/ 96010: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + var bufferEqual = __webpack_require__(9239) + var Buffer = __webpack_require__(21867).Buffer + var crypto = __webpack_require__(76417) + var formatEcdsa = __webpack_require__(11728) + var util = __webpack_require__(31669) + + var MSG_INVALID_ALGORITHM = + '"%s" is not a valid algorithm.\n Supported algorithms are:\n "HS256", "HS384", "HS512", "RS256", "RS384", "RS512", "PS256", "PS384", "PS512", "ES256", "ES384", "ES512" and "none".' + var MSG_INVALID_SECRET = 'secret must be a string or buffer' + var MSG_INVALID_VERIFIER_KEY = 'key must be a string or a buffer' + var MSG_INVALID_SIGNER_KEY = 'key must be a string, a buffer or an object' + + var supportsKeyObjects = typeof crypto.createPublicKey === 'function' + if (supportsKeyObjects) { + MSG_INVALID_VERIFIER_KEY += ' or a KeyObject' + MSG_INVALID_SECRET += 'or a KeyObject' + } + + function checkIsPublicKey(key) { + if (Buffer.isBuffer(key)) { + return + } + + if (typeof key === 'string') { + return + } + + if (!supportsKeyObjects) { + throw typeError(MSG_INVALID_VERIFIER_KEY) + } + + if (typeof key !== 'object') { + throw typeError(MSG_INVALID_VERIFIER_KEY) + } + + if (typeof key.type !== 'string') { + throw typeError(MSG_INVALID_VERIFIER_KEY) + } + + if (typeof key.asymmetricKeyType !== 'string') { + throw typeError(MSG_INVALID_VERIFIER_KEY) + } + + if (typeof key.export !== 'function') { + throw typeError(MSG_INVALID_VERIFIER_KEY) + } + } + + function checkIsPrivateKey(key) { + if (Buffer.isBuffer(key)) { + return + } + + if (typeof key === 'string') { + return + } + + if (typeof key === 'object') { + return + } + + throw typeError(MSG_INVALID_SIGNER_KEY) + } + + function checkIsSecretKey(key) { + if (Buffer.isBuffer(key)) { + return + } + + if (typeof key === 'string') { + return key + } + + if (!supportsKeyObjects) { + throw typeError(MSG_INVALID_SECRET) + } + + if (typeof key !== 'object') { + throw typeError(MSG_INVALID_SECRET) + } + + if (key.type !== 'secret') { + throw typeError(MSG_INVALID_SECRET) + } + + if (typeof key.export !== 'function') { + throw typeError(MSG_INVALID_SECRET) + } + } + + function fromBase64(base64) { + return base64.replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_') + } + + function toBase64(base64url) { + base64url = base64url.toString() + + var padding = 4 - (base64url.length % 4) + if (padding !== 4) { + for (var i = 0; i < padding; ++i) { + base64url += '=' + } + } + + return base64url.replace(/\-/g, '+').replace(/_/g, '/') + } + + function typeError(template) { + var args = [].slice.call(arguments, 1) + var errMsg = util.format.bind(util, template).apply(null, args) + return new TypeError(errMsg) + } + + function bufferOrString(obj) { + return Buffer.isBuffer(obj) || typeof obj === 'string' + } + + function normalizeInput(thing) { + if (!bufferOrString(thing)) thing = JSON.stringify(thing) + return thing + } + + function createHmacSigner(bits) { + return function sign(thing, secret) { + checkIsSecretKey(secret) + thing = normalizeInput(thing) + var hmac = crypto.createHmac('sha' + bits, secret) + var sig = (hmac.update(thing), hmac.digest('base64')) + return fromBase64(sig) + } + } + + function createHmacVerifier(bits) { + return function verify(thing, signature, secret) { + var computedSig = createHmacSigner(bits)(thing, secret) + return bufferEqual(Buffer.from(signature), Buffer.from(computedSig)) + } + } + + function createKeySigner(bits) { + return function sign(thing, privateKey) { + checkIsPrivateKey(privateKey) + thing = normalizeInput(thing) + // Even though we are specifying "RSA" here, this works with ECDSA + // keys as well. + var signer = crypto.createSign('RSA-SHA' + bits) + var sig = (signer.update(thing), signer.sign(privateKey, 'base64')) + return fromBase64(sig) + } + } + + function createKeyVerifier(bits) { + return function verify(thing, signature, publicKey) { + checkIsPublicKey(publicKey) + thing = normalizeInput(thing) + signature = toBase64(signature) + var verifier = crypto.createVerify('RSA-SHA' + bits) + verifier.update(thing) + return verifier.verify(publicKey, signature, 'base64') + } + } + + function createPSSKeySigner(bits) { + return function sign(thing, privateKey) { + checkIsPrivateKey(privateKey) + thing = normalizeInput(thing) + var signer = crypto.createSign('RSA-SHA' + bits) + var sig = + (signer.update(thing), + signer.sign( + { + key: privateKey, + padding: crypto.constants.RSA_PKCS1_PSS_PADDING, + saltLength: crypto.constants.RSA_PSS_SALTLEN_DIGEST + }, + 'base64' + )) + return fromBase64(sig) + } + } + + function createPSSKeyVerifier(bits) { + return function verify(thing, signature, publicKey) { + checkIsPublicKey(publicKey) + thing = normalizeInput(thing) + signature = toBase64(signature) + var verifier = crypto.createVerify('RSA-SHA' + bits) + verifier.update(thing) + return verifier.verify( + { + key: publicKey, + padding: crypto.constants.RSA_PKCS1_PSS_PADDING, + saltLength: crypto.constants.RSA_PSS_SALTLEN_DIGEST + }, + signature, + 'base64' + ) + } + } + + function createECDSASigner(bits) { + var inner = createKeySigner(bits) + return function sign() { + var signature = inner.apply(null, arguments) + signature = formatEcdsa.derToJose(signature, 'ES' + bits) + return signature + } + } + + function createECDSAVerifer(bits) { + var inner = createKeyVerifier(bits) + return function verify(thing, signature, publicKey) { + signature = formatEcdsa + .joseToDer(signature, 'ES' + bits) + .toString('base64') + var result = inner(thing, signature, publicKey) + return result + } + } + + function createNoneSigner() { + return function sign() { + return '' + } + } + + function createNoneVerifier() { + return function verify(thing, signature) { + return signature === '' + } + } + + module.exports = function jwa(algorithm) { + var signerFactories = { + hs: createHmacSigner, + rs: createKeySigner, + ps: createPSSKeySigner, + es: createECDSASigner, + none: createNoneSigner + } + var verifierFactories = { + hs: createHmacVerifier, + rs: createKeyVerifier, + ps: createPSSKeyVerifier, + es: createECDSAVerifer, + none: createNoneVerifier + } + var match = algorithm.match(/^(RS|PS|ES|HS)(256|384|512)$|^(none)$/) + if (!match) throw typeError(MSG_INVALID_ALGORITHM, algorithm) + var algo = (match[1] || match[3]).toLowerCase() + var bits = match[2] + + return { + sign: signerFactories[algo](bits), + verify: verifierFactories[algo](bits) + } + } + + /***/ + }, + + /***/ 4636: /***/ ( + __unused_webpack_module, + exports, + __webpack_require__ + ) => { + /*global exports*/ + var SignStream = __webpack_require__(73334) + var VerifyStream = __webpack_require__(5522) + + var ALGORITHMS = [ + 'HS256', + 'HS384', + 'HS512', + 'RS256', + 'RS384', + 'RS512', + 'PS256', + 'PS384', + 'PS512', + 'ES256', + 'ES384', + 'ES512' + ] + + exports.ALGORITHMS = ALGORITHMS + exports.sign = SignStream.sign + exports.verify = VerifyStream.verify + exports.decode = VerifyStream.decode + exports.isValid = VerifyStream.isValid + exports.createSign = function createSign(opts) { + return new SignStream(opts) + } + exports.createVerify = function createVerify(opts) { + return new VerifyStream(opts) + } + + /***/ + }, + + /***/ 61868: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + /*global module, process*/ + var Buffer = __webpack_require__(21867).Buffer + var Stream = __webpack_require__(92413) + var util = __webpack_require__(31669) + + function DataStream(data) { + this.buffer = null + this.writable = true + this.readable = true + + // No input + if (!data) { + this.buffer = Buffer.alloc(0) + return this + } + + // Stream + if (typeof data.pipe === 'function') { + this.buffer = Buffer.alloc(0) + data.pipe(this) + return this + } + + // Buffer or String + // or Object (assumedly a passworded key) + if (data.length || typeof data === 'object') { + this.buffer = data + this.writable = false + process.nextTick( + function () { + this.emit('end', data) + this.readable = false + this.emit('close') + }.bind(this) + ) + return this + } + + throw new TypeError('Unexpected data type (' + typeof data + ')') + } + util.inherits(DataStream, Stream) + + DataStream.prototype.write = function write(data) { + this.buffer = Buffer.concat([this.buffer, Buffer.from(data)]) + this.emit('data', data) + } + + DataStream.prototype.end = function end(data) { + if (data) this.write(data) + this.emit('end', data) + this.emit('close') + this.writable = false + this.readable = false + } + + module.exports = DataStream + + /***/ + }, + + /***/ 73334: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + /*global module*/ + var Buffer = __webpack_require__(21867).Buffer + var DataStream = __webpack_require__(61868) + var jwa = __webpack_require__(96010) + var Stream = __webpack_require__(92413) + var toString = __webpack_require__(65292) + var util = __webpack_require__(31669) + + function base64url(string, encoding) { + return Buffer.from(string, encoding) + .toString('base64') + .replace(/=/g, '') + .replace(/\+/g, '-') + .replace(/\//g, '_') + } + + function jwsSecuredInput(header, payload, encoding) { + encoding = encoding || 'utf8' + var encodedHeader = base64url(toString(header), 'binary') + var encodedPayload = base64url(toString(payload), encoding) + return util.format('%s.%s', encodedHeader, encodedPayload) + } + + function jwsSign(opts) { + var header = opts.header + var payload = opts.payload + var secretOrKey = opts.secret || opts.privateKey + var encoding = opts.encoding + var algo = jwa(header.alg) + var securedInput = jwsSecuredInput(header, payload, encoding) + var signature = algo.sign(securedInput, secretOrKey) + return util.format('%s.%s', securedInput, signature) + } + + function SignStream(opts) { + var secret = opts.secret || opts.privateKey || opts.key + var secretStream = new DataStream(secret) + this.readable = true + this.header = opts.header + this.encoding = opts.encoding + this.secret = this.privateKey = this.key = secretStream + this.payload = new DataStream(opts.payload) + this.secret.once( + 'close', + function () { + if (!this.payload.writable && this.readable) this.sign() + }.bind(this) + ) + + this.payload.once( + 'close', + function () { + if (!this.secret.writable && this.readable) this.sign() + }.bind(this) + ) + } + util.inherits(SignStream, Stream) + + SignStream.prototype.sign = function sign() { + try { + var signature = jwsSign({ + header: this.header, + payload: this.payload.buffer, + secret: this.secret.buffer, + encoding: this.encoding + }) + this.emit('done', signature) + this.emit('data', signature) + this.emit('end') + this.readable = false + return signature + } catch (e) { + this.readable = false + this.emit('error', e) + this.emit('close') + } + } + + SignStream.sign = jwsSign + + module.exports = SignStream + + /***/ + }, + + /***/ 65292: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + /*global module*/ + var Buffer = __webpack_require__(64293).Buffer + + module.exports = function toString(obj) { + if (typeof obj === 'string') return obj + if (typeof obj === 'number' || Buffer.isBuffer(obj)) + return obj.toString() + return JSON.stringify(obj) + } + + /***/ + }, + + /***/ 5522: /***/ ( + module, + __unused_webpack_exports, + __webpack_require__ + ) => { + /*global module*/ + var Buffer = __webpack_require__(21867).Buffer + var DataStream = __webpack_require__(61868) + var jwa = __webpack_require__(96010) + var Stream = __webpack_require__(92413) + var toString = __webpack_require__(65292) + var util = __webpack_require__(31669) + var JWS_REGEX = /^[a-zA-Z0-9\-_]+?\.[a-zA-Z0-9\-_]+?\.([a-zA-Z0-9\-_]+)?$/ + + function isObject(thing) { + return Object.prototype.toString.call(thing) === '[object Object]' + } + + function safeJsonParse(thing) { + if (isObject(thing)) return thing + try { + return JSON.parse(thing) + } catch (e) { + return undefined + } + } + + function headerFromJWS(jwsSig) { + var encodedHeader = jwsSig.split('.', 1)[0] + return safeJsonParse( + Buffer.from(encodedHeader, 'base64').toString('binary') + ) + } + + function securedInputFromJWS(jwsSig) { + return jwsSig.split('.', 2).join('.') + } + + function signatureFromJWS(jwsSig) { + return jwsSig.split('.')[2] + } + + function payloadFromJWS(jwsSig, encoding) { + encoding = encoding || 'utf8' + var payload = jwsSig.split('.')[1] + return Buffer.from(payload, 'base64').toString(encoding) + } + + function isValidJws(string) { + return JWS_REGEX.test(string) && !!headerFromJWS(string) + } + + function jwsVerify(jwsSig, algorithm, secretOrKey) { + if (!algorithm) { + var err = new Error('Missing algorithm parameter for jws.verify') + err.code = 'MISSING_ALGORITHM' + throw err + } + jwsSig = toString(jwsSig) + var signature = signatureFromJWS(jwsSig) + var securedInput = securedInputFromJWS(jwsSig) + var algo = jwa(algorithm) + return algo.verify(securedInput, signature, secretOrKey) + } + + function jwsDecode(jwsSig, opts) { + opts = opts || {} + jwsSig = toString(jwsSig) + + if (!isValidJws(jwsSig)) return null + + var header = headerFromJWS(jwsSig) + + if (!header) return null + + var payload = payloadFromJWS(jwsSig) + if (header.typ === 'JWT' || opts.json) + payload = JSON.parse(payload, opts.encoding) + + return { + header: header, + payload: payload, + signature: signatureFromJWS(jwsSig) + } + } + + function VerifyStream(opts) { + opts = opts || {} + var secretOrKey = opts.secret || opts.publicKey || opts.key + var secretStream = new DataStream(secretOrKey) + this.readable = true + this.algorithm = opts.algorithm + this.encoding = opts.encoding + this.secret = this.publicKey = this.key = secretStream + this.signature = new DataStream(opts.signature) + this.secret.once( + 'close', + function () { + if (!this.signature.writable && this.readable) this.verify() + }.bind(this) + ) + + this.signature.once( + 'close', + function () { + if (!this.secret.writable && this.readable) this.verify() + }.bind(this) + ) + } + util.inherits(VerifyStream, Stream) + VerifyStream.prototype.verify = function verify() { + try { + var valid = jwsVerify( + this.signature.buffer, + this.algorithm, + this.key.buffer + ) + var obj = jwsDecode(this.signature.buffer, this.encoding) + this.emit('done', valid, obj) + this.emit('data', valid) + this.emit('end') + this.readable = false + return valid + } catch (e) { + this.readable = false + this.emit('error', e) + this.emit('close') + } + } + + VerifyStream.decode = jwsDecode + VerifyStream.isValid = isValidJws + VerifyStream.verify = jwsVerify + + module.exports = VerifyStream + + /***/ + }, + + /***/ 71345: /***/ module => { + /*! + localForage -- Offline Storage, Improved + Version 1.8.1 + https://localforage.github.io/localForage + (c) 2013-2017 Mozilla, Apache License 2.0 +*/ + ;(function (f) { + if (true) { + module.exports = f() + } else { + var g + } + })(function () { + var define, module, exports + return (function e(t, n, r) { + function s(o, u) { + if (!n[o]) { + if (!t[o]) { + var a = true && require + if (!u && a) return a(o, !0) + if (i) return i(o, !0) + var f = new Error("Cannot find module '" + o + "'") + throw ((f.code = 'MODULE_NOT_FOUND'), f) + } + var l = (n[o] = { exports: {} }) + t[o][0].call( + l.exports, + function (e) { + var n = t[o][1][e] + return s(n ? n : e) + }, + l, + l.exports, + e, + t, + n, + r + ) + } + return n[o].exports + } + var i = true && require + for (var o = 0; o < r.length; o++) s(r[o]) + return s + })( + { + 1: [ + function (_dereq_, module, exports) { + ;(function (global) { + 'use strict' + var Mutation = + global.MutationObserver || global.WebKitMutationObserver + + var scheduleDrain + + { + if (Mutation) { + var called = 0 + var observer = new Mutation(nextTick) + var element = global.document.createTextNode('') + observer.observe(element, { + characterData: true + }) + scheduleDrain = function () { + element.data = called = ++called % 2 + } + } else if ( + !global.setImmediate && + typeof global.MessageChannel !== 'undefined' + ) { + var channel = new global.MessageChannel() + channel.port1.onmessage = nextTick + scheduleDrain = function () { + channel.port2.postMessage(0) + } + } else if ( + 'document' in global && + 'onreadystatechange' in + global.document.createElement('script') + ) { + scheduleDrain = function () { + // Create a