listen

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 17, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

SPDX-License-Identifier: Apache-2.0

Copyright © 2023 The listen.dev team <engineering@garnet.ai>

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.

SPDX-License-Identifier: Apache-2.0

Copyright © 2023 The listen.dev team <engineering@garnet.ai>

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.

SPDX-License-Identifier: Apache-2.0

Copyright © 2023 The listen.dev team <engineering@garnet.ai>

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.

SPDX-License-Identifier: Apache-2.0

Copyright © 2023 The listen.dev team <engineering@garnet.ai>

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.

SPDX-License-Identifier: Apache-2.0

Copyright © 2023 The listen.dev team <engineering@garnet.ai>

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.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithBaseURL

func WithBaseURL(input string) func(*options)

func WithContext

func WithContext(input context.Context) func(*options)

func WithJSONOptions

func WithJSONOptions(input flags.JSONFlags) func(*options)

Types

type AnalysisRequest

type AnalysisRequest struct {
	PackageLockJSON npm.PackageLockJSON `json:"package-lock" name:"package lock" validate:"mandatory"`
	Context         *Context            `json:"context,omitempty"`
}

func NewAnalysisRequest

func NewAnalysisRequest(packageLockJSON npm.PackageLockJSON) (*AnalysisRequest, error)

func (AnalysisRequest) IsRequest

func (req AnalysisRequest) IsRequest() bool

func (AnalysisRequest) MarshalJSON

func (req AnalysisRequest) MarshalJSON() ([]byte, error)

MarshalJSON is a custom marshaler that encodes the content of the package lock in the receiving AnalysisRequest.

func (*AnalysisRequest) Ok

func (req *AnalysisRequest) Ok() (bool, error)

type Context

type Context struct {
	ID      uuid.UUID         `json:"id"`
	Version version.Version   `json:"version"`
	Git     *git.Context      `json:"git,omitempty"`
	OS      *lstnos.Info      `json:"os,omitempty"`
	PMs     map[string]string `json:"packagemanagers,omitempty"`
}

func NewContext

func NewContext(funcs ...git.GetDirFunc) *Context

type Package

type Package struct {
	Name     string    `json:"name"`
	Version  string    `json:"version"`
	Shasum   string    `json:"shasum"`
	Verdicts []Verdict `json:"verdicts"`
	Problems []Problem `json:"problems,omitempty"`
}

type Problem

type Problem struct {
	Type   string `json:"type"`
	Title  string `json:"title"`
	Detail string `json:"detail"`
}

type Request

type Request interface {
	IsRequest() bool
	Ok() (bool, error)
}

type Response

type Response []Package

func BulkPackages added in v0.3.0

func BulkPackages(requests []*VerdictsRequest, opts ...func(*options)) (*Response, []byte, error)

func Packages

func Packages[T Request](r T, opts ...func(*options)) (*Response, []byte, error)

type Verdict

type Verdict struct {
	Message  string                 `json:"message"`
	Priority string                 `json:"priority"`
	Metadata map[string]interface{} `json:"metadata,omitempty"`
}

type VerdictsRequest

type VerdictsRequest struct {
	Name    string   `json:"name" name:"name" validate:"mandatory"`
	Version string   `json:"version,omitempty" validate:"omitempty,semver"`
	Shasum  string   `json:"shasum,omitempty" validate:"omitempty,shasum"`
	Context *Context `json:"context,omitempty"`
}

VerdictsRequest represents the payload for the verdicts listen.dev endpoint.

func NewBulkVerdictsRequests added in v0.3.0

func NewBulkVerdictsRequests(names []string, versions semver.Collection) ([]*VerdictsRequest, error)

func NewBulkVerdictsRequestsFromMap added in v0.3.0

func NewBulkVerdictsRequestsFromMap(deps map[string]*semver.Version) ([]*VerdictsRequest, error)

func NewVerdictsRequest

func NewVerdictsRequest(args []string) (*VerdictsRequest, error)

func NewVerdictsRequestWithContext added in v0.3.0

func NewVerdictsRequestWithContext(args []string, c *Context) (*VerdictsRequest, error)

func (VerdictsRequest) IsRequest

func (req VerdictsRequest) IsRequest() bool

func (VerdictsRequest) MarshalJSON

func (req VerdictsRequest) MarshalJSON() ([]byte, error)

func (*VerdictsRequest) Ok

func (req *VerdictsRequest) Ok() (bool, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL