Skip to content

Commit e27e5d2

Browse files
committed
created an example test file that allows the unencrypted_cc_client_test to run
1 parent df1da55 commit e27e5d2

15 files changed

Lines changed: 443 additions & 329 deletions

File tree

client/src/client.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,21 @@ import { InnerClient } from "./core.js";
44
import { SecretsApi, Secrets } from "./secrets.js";
55
import { ItemsApi, Items } from "./items.js";
66
import { VaultsApi, Vaults } from "./vaults.js";
7+
import { EnvironmentsApi, Environments } from "./environments.js";
78
import { GroupsApi, Groups } from "./groups.js";
89

910
export class Client {
1011
public secrets: SecretsApi;
1112
public items: ItemsApi;
1213
public vaults: VaultsApi;
14+
public environments: EnvironmentsApi;
1315
public groups: GroupsApi;
1416

1517
public constructor(innerClient: InnerClient) {
1618
this.secrets = new Secrets(innerClient);
1719
this.items = new Items(innerClient);
1820
this.vaults = new Vaults(innerClient);
21+
this.environments = new Environments(innerClient);
1922
this.groups = new Groups(innerClient);
2023
}
2124
}

client/src/environments.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Code generated by op-codegen - DO NOT EDIT MANUALLY
2+
3+
import { InvokeConfig, InnerClient, SharedCore } from "./core.js";
4+
import { GetVariablesResponse, ReviverFunc } from "./types.js";
5+
6+
/**
7+
* The Environments API holds all the operations the SDK client can perform on 1Password Environments.
8+
*/
9+
export interface EnvironmentsApi {
10+
/**
11+
* Get environment variables belonging to an Environment.
12+
*/
13+
getVariables(environmentId: string): Promise<GetVariablesResponse>;
14+
}
15+
16+
export class Environments implements EnvironmentsApi {
17+
#inner: InnerClient;
18+
19+
public constructor(inner: InnerClient) {
20+
this.#inner = inner;
21+
}
22+
23+
/**
24+
* Get environment variables belonging to an Environment.
25+
*/
26+
public async getVariables(
27+
environmentId: string,
28+
): Promise<GetVariablesResponse> {
29+
const invocationConfig: InvokeConfig = {
30+
invocation: {
31+
clientId: this.#inner.id,
32+
parameters: {
33+
name: "EnvironmentsGetVariables",
34+
parameters: {
35+
environment_id: environmentId,
36+
},
37+
},
38+
},
39+
};
40+
return JSON.parse(
41+
await this.#inner.invoke(invocationConfig),
42+
ReviverFunc,
43+
) as GetVariablesResponse;
44+
}
45+
}

client/src/errors.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ export class RateLimitExceededError extends Error {
1818
}
1919
}
2020

21+
export class AuthExpiredError extends Error {
22+
public message: string;
23+
24+
public constructor(message: string) {
25+
super();
26+
this.message = message;
27+
}
28+
}
29+
2130
export const throwError = (errString: string) => {
2231
interface TypedError {
2332
name: string;
@@ -36,6 +45,8 @@ export const throwError = (errString: string) => {
3645
throw new DesktopSessionExpiredError(err.message);
3746
case "RateLimitExceeded":
3847
throw new RateLimitExceededError(err.message);
48+
case "AuthExpired":
49+
throw new AuthExpiredError(err.message);
3950
default:
4051
throw new Error(err.message);
4152
}

client/src/groups.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Code generated by op-codegen - DO NOT EDIT MANUALLY
22

3-
import { InvokeConfig, InnerClient } from "./core.js";
3+
import { InvokeConfig, InnerClient, SharedCore } from "./core.js";
44
import { Group, GroupGetParams, ReviverFunc } from "./types.js";
55

66
/**

client/src/items.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Code generated by op-codegen - DO NOT EDIT MANUALLY
22

3-
import { InvokeConfig, InnerClient } from "./core.js";
3+
import { InvokeConfig, InnerClient, SharedCore } from "./core.js";
44
import {
55
Item,
66
ItemCreateParams,

client/src/items_files.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Code generated by op-codegen - DO NOT EDIT MANUALLY
22

3-
import { InvokeConfig, InnerClient } from "./core.js";
3+
import { InvokeConfig, InnerClient, SharedCore } from "./core.js";
44
import {
55
DocumentCreateParams,
66
FileAttributes,

client/src/items_shares.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Code generated by op-codegen - DO NOT EDIT MANUALLY
22

3-
import { InvokeConfig, InnerClient } from "./core.js";
3+
import { InvokeConfig, InnerClient, SharedCore } from "./core.js";
44
import {
55
Item,
66
ItemShareAccountPolicy,

client/src/types.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Generated by typeshare 1.13.2
2+
Generated by typeshare 1.13.4
33
*/
44

55
export type ErrorMessage = string;
@@ -25,6 +25,16 @@ export interface DocumentCreateParams {
2525
content: Uint8Array;
2626
}
2727

28+
/** Represents an environment variable (name:value pair) and its masked state */
29+
export interface EnvironmentVariable {
30+
/** An environment variable's name */
31+
name: string;
32+
/** An environment variable's value */
33+
value: string;
34+
/** An environment variable's masked state */
35+
masked: boolean;
36+
}
37+
2838
export interface FileAttributes {
2939
/** The name of the file */
3040
name: string;
@@ -54,6 +64,12 @@ export interface GeneratePasswordResponse {
5464
password: string;
5565
}
5666

67+
/** Response containing the full set of environment variables from an Environment. */
68+
export interface GetVariablesResponse {
69+
/** List of environment variables. */
70+
variables: EnvironmentVariable[];
71+
}
72+
5773
export enum GroupType {
5874
/**
5975
* The owners group, which gives the following permissions:
@@ -578,7 +594,7 @@ export interface Vault {
578594
activeItemCount: number;
579595
/** The content version number of the vault. It gets incremented whenever the state of the vault's contents changes (e.g. items from within the vault get created or updated). */
580596
contentVersion: number;
581-
/** The attribute version number of the vault. It gets incremented whenever vault presentation information changes, such as its title or icon. */
597+
/** The attribute version number of the vault. It gets incremented whenever vault presentation information changes, such as its name or icon. */
582598
attributeVersion: number;
583599
/** The access information associated with the vault. */
584600
access?: VaultAccess[];
@@ -614,7 +630,7 @@ export interface VaultOverview {
614630
activeItemCount: number;
615631
/** The content version number of the vault. It gets incremented whenever the state of the vault's contents changes (e.g. items from within the vault get created or updated). */
616632
contentVersion: number;
617-
/** The attribute version number of the vault. It gets incremented whenever vault presentation information changes, such as its title or icon. */
633+
/** The attribute version number of the vault. It gets incremented whenever vault presentation information changes, such as its name or icon. */
618634
attributeVersion: number;
619635
/** The time the vault was created at */
620636
createdAt: Date;

client/src/vaults.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Code generated by op-codegen - DO NOT EDIT MANUALLY
22

3-
import { InvokeConfig, InnerClient } from "./core.js";
3+
import { InvokeConfig, InnerClient, SharedCore } from "./core.js";
44
import {
55
GroupAccess,
66
GroupVaultAccess,

0 commit comments

Comments
 (0)