Skip to content

Commit b2d88af

Browse files
feat: move API to typescript code generation (googleapis#135)
* remove docs/ * move to ts * update synthtool * run synthtool * remove unneeded grafeas client * update synthtool * remove grafeas client * cap class name * broken link * make it work * lint * debug * sample test work * test * test * retry 10 times * finalize synth.py * clean a little bit * replace once, add to excludes * fix doc * feedback * import os * feedback * fix * remove file properly * make it work * linkinator * Update linkinator configure * rerun synthtool for resources reorder * remove google/api proto in list * remove unneeded proto files in list * format * new line in proto list * run synthtool
1 parent 78e5c78 commit b2d88af

File tree

73 files changed

+56173
-30980
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+56173
-30980
lines changed

Diff for: .gitignore

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
**/*.log
22
**/node_modules
33
.coverage
4+
coverage
45
.nyc_output
56
docs/
67
out/
7-
./build/
8+
build/
89
system-test/secrets.js
910
system-test/*key.json
1011
*.lock
1112
.DS_Store
12-
__pycache__
1313
package-lock.json
14+
__pycache__

Diff for: .jsdoc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module.exports = {
3131
source: {
3232
excludePattern: '(^|\\/|\\\\)[._]',
3333
include: [
34-
'src'
34+
'build/src'
3535
],
3636
includePattern: '\\.js$'
3737
},

Diff for: package.json

+26-12
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
"version": "1.7.1",
55
"author": "Google LLC",
66
"description": "Container Analysis API client for Node.js",
7-
"main": "src/index.js",
7+
"main": "build/src/index.js",
88
"files": [
9-
"protos",
10-
"src"
9+
"build/protos",
10+
"build/src"
1111
],
1212
"keywords": [
1313
"google apis client",
@@ -24,30 +24,44 @@
2424
],
2525
"dependencies": {
2626
"@google-cloud/grafeas": "^2.0.0",
27-
"google-gax": "^1.7.5"
27+
"google-gax": "^1.9.0"
2828
},
2929
"devDependencies": {
30+
"@types/mocha": "^5.2.5",
31+
"@types/node": "^12.0.0",
3032
"c8": "^7.0.0",
3133
"eslint": "^6.0.0",
3234
"eslint-config-prettier": "^6.0.0",
3335
"eslint-plugin-node": "^11.0.0",
3436
"eslint-plugin-prettier": "^3.1.0",
37+
"gts": "^1.0.0",
3538
"jsdoc": "^3.6.2",
3639
"jsdoc-fresh": "^1.0.1",
3740
"jsdoc-region-tag": "^1.0.2",
3841
"linkinator": "^1.5.0",
39-
"mocha": "^7.0.0",
40-
"prettier": "^1.17.1"
42+
"mocha": "^6.1.4",
43+
"null-loader": "^3.0.0",
44+
"pack-n-play": "^1.0.0-2",
45+
"power-assert": "^1.6.1",
46+
"prettier": "^1.11.1",
47+
"ts-loader": "^6.2.1",
48+
"typescript": "^3.7.0",
49+
"webpack": "^4.41.2",
50+
"webpack-cli": "^3.3.10"
4151
},
4252
"scripts": {
43-
"samples-test": "cd samples/ && npm link ../ && npm test && cd ../",
44-
"test": "c8 mocha",
45-
"lint": "eslint '**/*.js'",
53+
"test": "c8 mocha build/test",
54+
"samples-test": "cd samples/ && npm link ../ && npm install && npm test && cd ../",
55+
"system-test": "mocha build/system-test",
4656
"docs": "jsdoc -c .jsdoc.js",
47-
"system-test": "mocha system-test/ --timeout 600000",
48-
"fix": "eslint '**/*.js' --fix",
57+
"lint": "gts fix && eslint --fix samples/*.js",
58+
"fix": "gts fix",
4959
"docs-test": "linkinator docs",
50-
"predocs-test": "npm run docs"
60+
"clean": "gts clean",
61+
"compile": "tsc -p . && cp -r protos build/",
62+
"compile-protos": "compileProtos src",
63+
"predocs-test": "npm run docs",
64+
"prepare": "npm run compile"
5165
},
5266
"license": "Apache-2.0",
5367
"engines": {

Diff for: protos/google/cloud/common_resources.proto

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Copyright 2019 Google LLC.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// This file contains stub messages for common resources in GCP.
16+
// It is not intended to be directly generated, and is instead used by
17+
// other tooling to be able to match common resource patterns.
18+
syntax = "proto3";
19+
20+
package google.cloud;
21+
22+
import "google/api/resource.proto";
23+
24+
25+
option (google.api.resource_definition) = {
26+
type: "cloudresourcemanager.googleapis.com/Project"
27+
pattern: "projects/{project}"
28+
};
29+
30+
31+
option (google.api.resource_definition) = {
32+
type: "cloudresourcemanager.googleapis.com/Organization"
33+
pattern: "organizations/{organization}"
34+
};
35+
36+
37+
option (google.api.resource_definition) = {
38+
type: "cloudresourcemanager.googleapis.com/Folder"
39+
pattern: "folders/{folder}"
40+
};
41+
42+
43+
option (google.api.resource_definition) = {
44+
type: "cloudbilling.googleapis.com/BillingAccount"
45+
pattern: "billingAccounts/{billing_account}"
46+
};
47+
48+
option (google.api.resource_definition) = {
49+
type: "locations.googleapis.com/Location"
50+
pattern: "projects/{project}/locations/{location}"
51+
};
52+

Diff for: protos/grafeas/v1/attestation.proto

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// Copyright 2019 The Grafeas Authors. All rights reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
syntax = "proto3";
16+
17+
package grafeas.v1;
18+
19+
import "grafeas/v1/common.proto";
20+
21+
option go_package = "google.golang.org/genproto/googleapis/grafeas/v1;grafeas";
22+
option java_multiple_files = true;
23+
option java_package = "io.grafeas.v1";
24+
option objc_class_prefix = "GRA";
25+
26+
// An attestation wrapper with a PGP-compatible signature. This message only
27+
// supports `ATTACHED` signatures, where the payload that is signed is included
28+
// alongside the signature itself in the same file.
29+
30+
// Note kind that represents a logical attestation "role" or "authority". For
31+
// example, an organization might have one `Authority` for "QA" and one for
32+
// "build". This note is intended to act strictly as a grouping mechanism for
33+
// the attached occurrences (Attestations). This grouping mechanism also
34+
// provides a security boundary, since IAM ACLs gate the ability for a principle
35+
// to attach an occurrence to a given note. It also provides a single point of
36+
// lookup to find all attached attestation occurrences, even if they don't all
37+
// live in the same project.
38+
message AttestationNote {
39+
// This submessage provides human-readable hints about the purpose of the
40+
// authority. Because the name of a note acts as its resource reference, it is
41+
// important to disambiguate the canonical name of the Note (which might be a
42+
// UUID for security purposes) from "readable" names more suitable for debug
43+
// output. Note that these hints should not be used to look up authorities in
44+
// security sensitive contexts, such as when looking up attestations to
45+
// verify.
46+
message Hint {
47+
// Required. The human readable name of this attestation authority, for
48+
// example "qa".
49+
string human_readable_name = 1;
50+
}
51+
52+
// Hint hints at the purpose of the attestation authority.
53+
Hint hint = 1;
54+
}
55+
56+
// Occurrence that represents a single "attestation". The authenticity of an
57+
// attestation can be verified using the attached signature. If the verifier
58+
// trusts the public key of the signer, then verifying the signature is
59+
// sufficient to establish trust. In this circumstance, the authority to which
60+
// this attestation is attached is primarily useful for lookup (how to find
61+
// this attestation if you already know the authority and artifact to be
62+
// verified) and intent (for which authority this attestation was intended to
63+
// sign.
64+
message AttestationOccurrence {
65+
// Required. The serialized payload that is verified by one or more
66+
// `signatures`.
67+
bytes serialized_payload = 1;
68+
// One or more signatures over `serialized_payload`. Verifier implementations
69+
// should consider this attestation message verified if at least one
70+
// `signature` verifies `serialized_payload`. See `Signature` in common.proto
71+
// for more details on signature structure and verification.
72+
repeated Signature signatures = 2;
73+
}

Diff for: protos/grafeas/v1/build.proto

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// Copyright 2019 The Grafeas Authors. All rights reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
syntax = "proto3";
16+
17+
package grafeas.v1;
18+
19+
import "grafeas/v1/provenance.proto";
20+
21+
option go_package = "google.golang.org/genproto/googleapis/grafeas/v1;grafeas";
22+
option java_multiple_files = true;
23+
option java_package = "io.grafeas.v1";
24+
option objc_class_prefix = "GRA";
25+
26+
// Note holding the version of the provider's builder and the signature of the
27+
// provenance message in the build details occurrence.
28+
message BuildNote {
29+
// Required. Immutable. Version of the builder which produced this build.
30+
string builder_version = 1;
31+
}
32+
33+
// Details of a build occurrence.
34+
message BuildOccurrence {
35+
// Required. The actual provenance for the build.
36+
grafeas.v1.BuildProvenance provenance = 1;
37+
38+
// Serialized JSON representation of the provenance, used in generating the
39+
// build signature in the corresponding build note. After verifying the
40+
// signature, `provenance_bytes` can be unmarshalled and compared to the
41+
// provenance to confirm that it is unchanged. A base64-encoded string
42+
// representation of the provenance bytes is used for the signature in order
43+
// to interoperate with openssl which expects this format for signature
44+
// verification.
45+
//
46+
// The serialized form is captured both to avoid ambiguity in how the
47+
// provenance is marshalled to json as well to prevent incompatibilities with
48+
// future changes.
49+
string provenance_bytes = 2;
50+
}

Diff for: protos/grafeas/v1/common.proto

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
// Copyright 2019 The Grafeas Authors. All rights reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
syntax = "proto3";
16+
17+
package grafeas.v1;
18+
19+
option go_package = "google.golang.org/genproto/googleapis/grafeas/v1;grafeas";
20+
option java_multiple_files = true;
21+
option java_package = "io.grafeas.v1";
22+
option objc_class_prefix = "GRA";
23+
24+
// Kind represents the kinds of notes supported.
25+
enum NoteKind {
26+
// Unknown.
27+
NOTE_KIND_UNSPECIFIED = 0;
28+
// The note and occurrence represent a package vulnerability.
29+
VULNERABILITY = 1;
30+
// The note and occurrence assert build provenance.
31+
BUILD = 2;
32+
// This represents an image basis relationship.
33+
IMAGE = 3;
34+
// This represents a package installed via a package manager.
35+
PACKAGE = 4;
36+
// The note and occurrence track deployment events.
37+
DEPLOYMENT = 5;
38+
// The note and occurrence track the initial discovery status of a resource.
39+
DISCOVERY = 6;
40+
// This represents a logical "role" that can attest to artifacts.
41+
ATTESTATION = 7;
42+
// This represents an available package upgrade.
43+
UPGRADE = 8;
44+
}
45+
46+
// Metadata for any related URL information.
47+
message RelatedUrl {
48+
// Specific URL associated with the resource.
49+
string url = 1;
50+
// Label to describe usage of the URL.
51+
string label = 2;
52+
}
53+
54+
// Verifiers (e.g. Kritis implementations) MUST verify signatures
55+
// with respect to the trust anchors defined in policy (e.g. a Kritis policy).
56+
// Typically this means that the verifier has been configured with a map from
57+
// `public_key_id` to public key material (and any required parameters, e.g.
58+
// signing algorithm).
59+
//
60+
// In particular, verification implementations MUST NOT treat the signature
61+
// `public_key_id` as anything more than a key lookup hint. The `public_key_id`
62+
// DOES NOT validate or authenticate a public key; it only provides a mechanism
63+
// for quickly selecting a public key ALREADY CONFIGURED on the verifier through
64+
// a trusted channel. Verification implementations MUST reject signatures in any
65+
// of the following circumstances:
66+
// * The `public_key_id` is not recognized by the verifier.
67+
// * The public key that `public_key_id` refers to does not verify the
68+
// signature with respect to the payload.
69+
//
70+
// The `signature` contents SHOULD NOT be "attached" (where the payload is
71+
// included with the serialized `signature` bytes). Verifiers MUST ignore any
72+
// "attached" payload and only verify signatures with respect to explicitly
73+
// provided payload (e.g. a `payload` field on the proto message that holds
74+
// this Signature, or the canonical serialization of the proto message that
75+
// holds this signature).
76+
message Signature {
77+
// The content of the signature, an opaque bytestring.
78+
// The payload that this signature verifies MUST be unambiguously provided
79+
// with the Signature during verification. A wrapper message might provide
80+
// the payload explicitly. Alternatively, a message might have a canonical
81+
// serialization that can always be unambiguously computed to derive the
82+
// payload.
83+
bytes signature = 1;
84+
85+
// The identifier for the public key that verifies this signature.
86+
// * The `public_key_id` is required.
87+
// * The `public_key_id` MUST be an RFC3986 conformant URI.
88+
// * When possible, the `public_key_id` SHOULD be an immutable reference,
89+
// such as a cryptographic digest.
90+
//
91+
// Examples of valid `public_key_id`s:
92+
//
93+
// OpenPGP V4 public key fingerprint:
94+
// * "openpgp4fpr:74FAF3B861BDA0870C7B6DEF607E48D2A663AEEA"
95+
// See https://www.iana.org/assignments/uri-schemes/prov/openpgp4fpr for more
96+
// details on this scheme.
97+
//
98+
// RFC6920 digest-named SubjectPublicKeyInfo (digest of the DER
99+
// serialization):
100+
// * "ni:///sha-256;cD9o9Cq6LG3jD0iKXqEi_vdjJGecm_iXkbqVoScViaU"
101+
// * "nih:///sha-256;703f68f42aba2c6de30f488a5ea122fef76324679c9bf89791ba95a1271589a5"
102+
string public_key_id = 2;
103+
}

0 commit comments

Comments
 (0)