@zodiac-os/sdk 1.1.1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +171 -10
- package/dist/allow/index.d.mts +2 -0
- package/dist/allow/index.mjs +3 -0
- package/dist/allow-Dzh6t_l8.mjs +122 -0
- package/dist/allow-Dzh6t_l8.mjs.map +1 -0
- package/dist/api-D6ee2Q2b.mjs +113 -0
- package/dist/api-D6ee2Q2b.mjs.map +1 -0
- package/dist/cli/config.d.mts +35 -0
- package/dist/cli/config.mjs +31 -0
- package/dist/cli/config.mjs.map +1 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +370 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/index-DTBaxN7b.d.mts +63 -0
- package/dist/index.d.mts +212 -0
- package/dist/index.mjs +208 -0
- package/dist/index.mjs.map +1 -0
- package/dist/networks-BTW1qAAa.mjs +77 -0
- package/dist/networks-BTW1qAAa.mjs.map +1 -0
- package/dist/zodiac-os-codegen.d.ts +52 -0
- package/package.json +32 -19
- package/dist/index.d.ts +0 -28
- package/dist/index.js +0 -143
- package/dist/index.js.map +0 -1
- package/lib/index.cjs +0 -228
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zodiac-os/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"author": "Gnosis Guild",
|
|
5
5
|
"license": "LGPL-3.0-only",
|
|
6
6
|
"homepage": "https://github.com/gnosisguild/zodiac-os-sdk",
|
|
@@ -10,44 +10,57 @@
|
|
|
10
10
|
},
|
|
11
11
|
"type": "module",
|
|
12
12
|
"module": "dist/index.mjs",
|
|
13
|
-
"types": "dist/index.d.
|
|
13
|
+
"types": "dist/index.d.mts",
|
|
14
14
|
"exports": {
|
|
15
|
-
"
|
|
16
|
-
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.mts",
|
|
17
|
+
"import": "./dist/index.mjs"
|
|
18
|
+
},
|
|
19
|
+
"./allow": {
|
|
20
|
+
"types": "./dist/allow/index.d.mts",
|
|
21
|
+
"import": "./dist/allow/index.mjs"
|
|
22
|
+
},
|
|
23
|
+
"./cli/config": {
|
|
24
|
+
"types": "./dist/cli/config.d.mts",
|
|
25
|
+
"import": "./dist/cli/config.mjs"
|
|
26
|
+
}
|
|
17
27
|
},
|
|
18
28
|
"files": [
|
|
19
29
|
"dist",
|
|
20
|
-
"lib",
|
|
21
30
|
"README.md",
|
|
22
31
|
"LICENSE"
|
|
23
32
|
],
|
|
24
33
|
"bin": {
|
|
25
|
-
"zodiac-os": "./
|
|
34
|
+
"zodiac-os": "./dist/cli.mjs"
|
|
26
35
|
},
|
|
27
36
|
"scripts": {
|
|
28
|
-
"clean": "rimraf dist
|
|
37
|
+
"clean": "rimraf dist",
|
|
29
38
|
"prebuild": "bun clean",
|
|
30
|
-
"build": "
|
|
39
|
+
"build": "tsdown && cp src/zodiac-os-codegen.d.ts dist/ && printf '/// <reference path=\"./zodiac-os-codegen.d.ts\" />\\n' | cat - dist/index.d.mts > dist/index.d.mts.tmp && mv dist/index.d.mts.tmp dist/index.d.mts",
|
|
31
40
|
"prepublishOnly": "bun run build",
|
|
32
41
|
"check:format": "prettier --list-different .",
|
|
33
42
|
"check:types": "tsc -p tsconfig.json",
|
|
34
43
|
"fix:format": "prettier --write .",
|
|
35
|
-
"test": "bun test"
|
|
44
|
+
"test": "bun test",
|
|
45
|
+
"install-local-api-types": "cd ../zodiac-os/public-packages/api-types && pnpm pack-tmp && cd ../../../zodiac-os-sdk && tar -xzf /tmp/zodiac-os-api-types.tgz --strip-components=1 -C node_modules/@zodiac-os/api-types"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@epic-web/invariant": "1.0.0",
|
|
49
|
+
"@zodiac-os/api-types": "1.5.1",
|
|
50
|
+
"commander": "^14.0.3",
|
|
51
|
+
"ts-morph": "^27.0.2",
|
|
52
|
+
"zodiac-roles-deployments": "^3.2.0",
|
|
53
|
+
"zodiac-roles-sdk": "^3.4.7"
|
|
54
|
+
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"ethers": "^6.13.0"
|
|
36
57
|
},
|
|
37
58
|
"devDependencies": {
|
|
38
|
-
"@types/babel__generator": "^7.27.0",
|
|
39
59
|
"@types/bun": "^1.2.21",
|
|
60
|
+
"ethers": "^6.13.0",
|
|
40
61
|
"prettier": "^3.6.2",
|
|
41
62
|
"rimraf": "^6.1.0",
|
|
42
|
-
"
|
|
63
|
+
"tsdown": "^0.21.4",
|
|
43
64
|
"typescript": "^5.9.2"
|
|
44
|
-
},
|
|
45
|
-
"dependencies": {
|
|
46
|
-
"@babel/generator": "^7.28.5",
|
|
47
|
-
"@babel/types": "^7.28.5",
|
|
48
|
-
"@epic-web/invariant": "1.0.0",
|
|
49
|
-
"@zodiac-os/api-types": "1.4.0",
|
|
50
|
-
"arg": "^5.0.2",
|
|
51
|
-
"zodiac-roles-sdk": "^3.3.2"
|
|
52
65
|
}
|
|
53
66
|
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { ApplyConstellationPayload, ApplyConstellationResult, ResolveConstellationPayload, ResolveConstellationResult } from '@zodiac-os/api-types';
|
|
2
|
-
|
|
3
|
-
type Options = {
|
|
4
|
-
workspace?: string;
|
|
5
|
-
apiKey?: string;
|
|
6
|
-
baseUrl?: string;
|
|
7
|
-
fetch?: typeof globalThis.fetch;
|
|
8
|
-
headers?: Record<string, string>;
|
|
9
|
-
};
|
|
10
|
-
declare class ApiClient {
|
|
11
|
-
private apiKey;
|
|
12
|
-
private baseUrl;
|
|
13
|
-
private _fetch;
|
|
14
|
-
private headers;
|
|
15
|
-
constructor({ baseUrl, workspace, fetch: customFetch, headers, apiKey, }?: Options);
|
|
16
|
-
protected postJson(endpoint: string, payload: unknown): Promise<any>;
|
|
17
|
-
protected get(endpoint: string): Promise<any>;
|
|
18
|
-
/**
|
|
19
|
-
* Applies an accounts specification to Zodiac OS.
|
|
20
|
-
*/
|
|
21
|
-
applyConstellation(payload: ApplyConstellationPayload): Promise<ApplyConstellationResult>;
|
|
22
|
-
/**
|
|
23
|
-
* Resolves an accounts specification to Zodiac OS.
|
|
24
|
-
*/
|
|
25
|
-
resolveConstellation(payload: ResolveConstellationPayload): Promise<ResolveConstellationResult>;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export { ApiClient };
|
package/dist/index.js
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
// src/api.ts
|
|
2
|
-
import assert from "assert";
|
|
3
|
-
var {
|
|
4
|
-
ZODIAC_OS_API_KEY,
|
|
5
|
-
ZODIAC_OS_WORKSPACE,
|
|
6
|
-
ZODIAC_OS_API_URL = "https://app.pilot.gnosisguild.org/api/v1"
|
|
7
|
-
} = process.env;
|
|
8
|
-
var ApiClient = class {
|
|
9
|
-
apiKey;
|
|
10
|
-
baseUrl;
|
|
11
|
-
_fetch;
|
|
12
|
-
headers;
|
|
13
|
-
constructor({
|
|
14
|
-
baseUrl = ZODIAC_OS_API_URL,
|
|
15
|
-
workspace = ZODIAC_OS_WORKSPACE,
|
|
16
|
-
fetch: customFetch = fetch,
|
|
17
|
-
headers = {},
|
|
18
|
-
apiKey = ZODIAC_OS_API_KEY
|
|
19
|
-
} = {}) {
|
|
20
|
-
assert(
|
|
21
|
-
workspace,
|
|
22
|
-
'No workspace provided to the API client. Either pass it as the "workspace" option or set the ZODIAC_OS_WORKSPACE environment variable.'
|
|
23
|
-
);
|
|
24
|
-
this.baseUrl = baseUrl.replace(/\/$/, "") + "/workspace/" + workspace;
|
|
25
|
-
this._fetch = customFetch;
|
|
26
|
-
this.headers = headers;
|
|
27
|
-
assert(
|
|
28
|
-
apiKey,
|
|
29
|
-
'No API key provided to the API client. Either pass it as the "apiKey" option or set the ZODIAC_OS_API_KEY environment variable.'
|
|
30
|
-
);
|
|
31
|
-
this.apiKey = apiKey;
|
|
32
|
-
}
|
|
33
|
-
async postJson(endpoint, payload) {
|
|
34
|
-
const res = await this._fetch(`${this.baseUrl}/${endpoint}`, {
|
|
35
|
-
method: "POST",
|
|
36
|
-
headers: {
|
|
37
|
-
...this.headers,
|
|
38
|
-
"content-type": "application/json",
|
|
39
|
-
authorization: `Bearer ${this.apiKey}`
|
|
40
|
-
},
|
|
41
|
-
body: jsonStringify(payload)
|
|
42
|
-
});
|
|
43
|
-
if (!res.ok) {
|
|
44
|
-
await handleApiError(res);
|
|
45
|
-
}
|
|
46
|
-
return res.json();
|
|
47
|
-
}
|
|
48
|
-
async get(endpoint) {
|
|
49
|
-
const res = await this._fetch(`${this.baseUrl}/${endpoint}`, {
|
|
50
|
-
headers: { ...this.headers, authorization: `Bearer ${this.apiKey}` }
|
|
51
|
-
});
|
|
52
|
-
if (!res.ok) {
|
|
53
|
-
await handleApiError(res);
|
|
54
|
-
}
|
|
55
|
-
return res.json();
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Applies an accounts specification to Zodiac OS.
|
|
59
|
-
*/
|
|
60
|
-
applyConstellation(payload) {
|
|
61
|
-
return this.postJson("constellation/apply", payload);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Resolves an accounts specification to Zodiac OS.
|
|
65
|
-
*/
|
|
66
|
-
resolveConstellation(payload) {
|
|
67
|
-
return this.postJson("constellation/resolve", payload);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
var ApiRequestError = class _ApiRequestError extends Error {
|
|
71
|
-
status;
|
|
72
|
-
statusText;
|
|
73
|
-
details;
|
|
74
|
-
constructor(message, opts) {
|
|
75
|
-
super(_ApiRequestError.composeMessage(message, opts.details));
|
|
76
|
-
this.name = "ApiRequestError";
|
|
77
|
-
this.status = opts.status;
|
|
78
|
-
this.statusText = opts.statusText;
|
|
79
|
-
this.details = opts.details;
|
|
80
|
-
if (opts.cause !== void 0) {
|
|
81
|
-
;
|
|
82
|
-
this.cause = opts.cause;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
static composeMessage(message, details) {
|
|
86
|
-
if (details == null) return message;
|
|
87
|
-
let detailsString;
|
|
88
|
-
try {
|
|
89
|
-
detailsString = typeof details === "string" ? details : jsonStringify(details, 2);
|
|
90
|
-
} catch (_err) {
|
|
91
|
-
detailsString = String(details);
|
|
92
|
-
}
|
|
93
|
-
return `${message}
|
|
94
|
-
Details: ${detailsString}`;
|
|
95
|
-
}
|
|
96
|
-
toString() {
|
|
97
|
-
return `${this.name}: ${this.message}`;
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
async function handleApiError(response) {
|
|
101
|
-
const contentType = response.headers.get("content-type");
|
|
102
|
-
if (contentType?.includes("application/json")) {
|
|
103
|
-
const errorData = await response.json();
|
|
104
|
-
let error;
|
|
105
|
-
try {
|
|
106
|
-
error = new ApiRequestError(errorData.error.message, {
|
|
107
|
-
status: response.status,
|
|
108
|
-
statusText: response.statusText,
|
|
109
|
-
details: errorData.error.details
|
|
110
|
-
});
|
|
111
|
-
} catch (jsonShapeError) {
|
|
112
|
-
error = new ApiRequestError(
|
|
113
|
-
`Failed parsing error response: ${jsonShapeError}`,
|
|
114
|
-
{
|
|
115
|
-
status: response.status,
|
|
116
|
-
statusText: response.statusText,
|
|
117
|
-
details: errorData
|
|
118
|
-
}
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
throw error;
|
|
122
|
-
} else {
|
|
123
|
-
const text = await response.text();
|
|
124
|
-
throw new ApiRequestError(`Unexpected error: ${text}`, {
|
|
125
|
-
status: response.status,
|
|
126
|
-
statusText: response.statusText
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
var jsonStringify = (value, indent) => JSON.stringify(
|
|
131
|
-
value,
|
|
132
|
-
(_, value2) => {
|
|
133
|
-
if (typeof value2 === "bigint") {
|
|
134
|
-
return value2.toString();
|
|
135
|
-
}
|
|
136
|
-
return value2;
|
|
137
|
-
},
|
|
138
|
-
indent
|
|
139
|
-
);
|
|
140
|
-
export {
|
|
141
|
-
ApiClient
|
|
142
|
-
};
|
|
143
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api.ts"],"sourcesContent":["import type {\n ApplyConstellationPayload,\n ApplyConstellationResult,\n ResolveConstellationPayload,\n ResolveConstellationResult,\n ApiError as ApiErrorResponse,\n} from '@zodiac-os/api-types'\nimport assert from 'assert'\n\nexport type Options = {\n workspace?: string\n apiKey?: string\n baseUrl?: string\n fetch?: typeof globalThis.fetch\n headers?: Record<string, string>\n}\n\nconst {\n ZODIAC_OS_API_KEY,\n ZODIAC_OS_WORKSPACE,\n ZODIAC_OS_API_URL = 'https://app.pilot.gnosisguild.org/api/v1',\n} = process.env\n\nexport class ApiClient {\n private apiKey: string\n private baseUrl: string\n private _fetch: typeof fetch\n private headers: Record<string, string>\n\n constructor({\n baseUrl = ZODIAC_OS_API_URL,\n workspace = ZODIAC_OS_WORKSPACE,\n fetch: customFetch = fetch,\n headers = {},\n apiKey = ZODIAC_OS_API_KEY,\n }: Options = {}) {\n assert(\n workspace,\n 'No workspace provided to the API client. Either pass it as the \"workspace\" option or set the ZODIAC_OS_WORKSPACE environment variable.'\n )\n\n this.baseUrl = baseUrl.replace(/\\/$/, '') + '/workspace/' + workspace\n\n this._fetch = customFetch\n this.headers = headers\n\n assert(\n apiKey,\n 'No API key provided to the API client. Either pass it as the \"apiKey\" option or set the ZODIAC_OS_API_KEY environment variable.'\n )\n\n this.apiKey = apiKey\n }\n\n protected async postJson(endpoint: string, payload: unknown) {\n const res = await this._fetch(`${this.baseUrl}/${endpoint}`, {\n method: 'POST',\n headers: {\n ...this.headers,\n 'content-type': 'application/json',\n authorization: `Bearer ${this.apiKey}`,\n },\n body: jsonStringify(payload),\n })\n if (!res.ok) {\n await handleApiError(res)\n }\n\n return res.json()\n }\n\n protected async get(endpoint: string) {\n const res = await this._fetch(`${this.baseUrl}/${endpoint}`, {\n headers: { ...this.headers, authorization: `Bearer ${this.apiKey}` },\n })\n\n if (!res.ok) {\n await handleApiError(res)\n }\n\n return res.json()\n }\n\n /**\n * Applies an accounts specification to Zodiac OS.\n */\n applyConstellation(\n payload: ApplyConstellationPayload\n ): Promise<ApplyConstellationResult> {\n return this.postJson('constellation/apply', payload)\n }\n\n /**\n * Resolves an accounts specification to Zodiac OS.\n */\n resolveConstellation(\n payload: ResolveConstellationPayload\n ): Promise<ResolveConstellationResult> {\n return this.postJson('constellation/resolve', payload)\n }\n}\n\nexport class ApiRequestError extends Error {\n public readonly status: number\n public readonly statusText: string\n public readonly details?: unknown\n\n constructor(\n message: string,\n opts: {\n status: number\n statusText: string\n details?: unknown\n cause?: unknown\n }\n ) {\n super(ApiRequestError.composeMessage(message, opts.details))\n this.name = 'ApiRequestError'\n this.status = opts.status\n this.statusText = opts.statusText\n this.details = opts.details\n if (opts.cause !== undefined) {\n ;(this as any).cause = opts.cause\n }\n }\n\n private static composeMessage(message: string, details?: unknown) {\n if (details == null) return message\n let detailsString: string\n try {\n detailsString =\n typeof details === 'string' ? details : jsonStringify(details, 2)\n } catch (_err) {\n detailsString = String(details)\n }\n return `${message}\\nDetails: ${detailsString}`\n }\n\n toString() {\n return `${this.name}: ${this.message}`\n }\n}\n\nasync function handleApiError(response: Response): Promise<never> {\n const contentType = response.headers.get('content-type')\n if (contentType?.includes('application/json')) {\n const errorData = (await response.json()) as ApiErrorResponse\n let error: ApiRequestError\n try {\n error = new ApiRequestError(errorData.error.message, {\n status: response.status,\n statusText: response.statusText,\n details: errorData.error.details,\n })\n } catch (jsonShapeError) {\n error = new ApiRequestError(\n `Failed parsing error response: ${jsonShapeError}`,\n {\n status: response.status,\n statusText: response.statusText,\n details: errorData,\n }\n )\n }\n throw error\n } else {\n // Not JSON, read as text directly\n const text = await response.text()\n throw new ApiRequestError(`Unexpected error: ${text}`, {\n status: response.status,\n statusText: response.statusText,\n })\n }\n}\n\n/** JSON.stringify with bigint support */\nconst jsonStringify = (value: unknown, indent?: number) =>\n JSON.stringify(\n value,\n (_, value) => {\n if (typeof value === 'bigint') {\n return value.toString()\n }\n\n return value\n },\n indent\n )\n"],"mappings":"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","names":["value"]}
|
package/lib/index.cjs
DELETED
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __create = Object.create;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
-
mod
|
|
24
|
-
));
|
|
25
|
-
|
|
26
|
-
// cli/run.ts
|
|
27
|
-
var import_arg = __toESM(require("arg"), 1);
|
|
28
|
-
|
|
29
|
-
// src/api.ts
|
|
30
|
-
var import_assert = __toESM(require("assert"), 1);
|
|
31
|
-
var {
|
|
32
|
-
ZODIAC_OS_API_KEY,
|
|
33
|
-
ZODIAC_OS_WORKSPACE,
|
|
34
|
-
ZODIAC_OS_API_URL = "https://app.pilot.gnosisguild.org/api/v1"
|
|
35
|
-
} = process.env;
|
|
36
|
-
var ApiClient = class {
|
|
37
|
-
apiKey;
|
|
38
|
-
baseUrl;
|
|
39
|
-
_fetch;
|
|
40
|
-
headers;
|
|
41
|
-
constructor({
|
|
42
|
-
baseUrl = ZODIAC_OS_API_URL,
|
|
43
|
-
workspace = ZODIAC_OS_WORKSPACE,
|
|
44
|
-
fetch: customFetch = fetch,
|
|
45
|
-
headers = {},
|
|
46
|
-
apiKey = ZODIAC_OS_API_KEY
|
|
47
|
-
} = {}) {
|
|
48
|
-
(0, import_assert.default)(
|
|
49
|
-
workspace,
|
|
50
|
-
'No workspace provided to the API client. Either pass it as the "workspace" option or set the ZODIAC_OS_WORKSPACE environment variable.'
|
|
51
|
-
);
|
|
52
|
-
this.baseUrl = baseUrl.replace(/\/$/, "") + "/workspace/" + workspace;
|
|
53
|
-
this._fetch = customFetch;
|
|
54
|
-
this.headers = headers;
|
|
55
|
-
(0, import_assert.default)(
|
|
56
|
-
apiKey,
|
|
57
|
-
'No API key provided to the API client. Either pass it as the "apiKey" option or set the ZODIAC_OS_API_KEY environment variable.'
|
|
58
|
-
);
|
|
59
|
-
this.apiKey = apiKey;
|
|
60
|
-
}
|
|
61
|
-
async postJson(endpoint, payload) {
|
|
62
|
-
const res = await this._fetch(`${this.baseUrl}/${endpoint}`, {
|
|
63
|
-
method: "POST",
|
|
64
|
-
headers: {
|
|
65
|
-
...this.headers,
|
|
66
|
-
"content-type": "application/json",
|
|
67
|
-
authorization: `Bearer ${this.apiKey}`
|
|
68
|
-
},
|
|
69
|
-
body: jsonStringify(payload)
|
|
70
|
-
});
|
|
71
|
-
if (!res.ok) {
|
|
72
|
-
await handleApiError(res);
|
|
73
|
-
}
|
|
74
|
-
return res.json();
|
|
75
|
-
}
|
|
76
|
-
async get(endpoint) {
|
|
77
|
-
const res = await this._fetch(`${this.baseUrl}/${endpoint}`, {
|
|
78
|
-
headers: { ...this.headers, authorization: `Bearer ${this.apiKey}` }
|
|
79
|
-
});
|
|
80
|
-
if (!res.ok) {
|
|
81
|
-
await handleApiError(res);
|
|
82
|
-
}
|
|
83
|
-
return res.json();
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Applies an accounts specification to Zodiac OS.
|
|
87
|
-
*/
|
|
88
|
-
applyConstellation(payload) {
|
|
89
|
-
return this.postJson("constellation/apply", payload);
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Resolves an accounts specification to Zodiac OS.
|
|
93
|
-
*/
|
|
94
|
-
resolveConstellation(payload) {
|
|
95
|
-
return this.postJson("constellation/resolve", payload);
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
var ApiRequestError = class _ApiRequestError extends Error {
|
|
99
|
-
status;
|
|
100
|
-
statusText;
|
|
101
|
-
details;
|
|
102
|
-
constructor(message, opts) {
|
|
103
|
-
super(_ApiRequestError.composeMessage(message, opts.details));
|
|
104
|
-
this.name = "ApiRequestError";
|
|
105
|
-
this.status = opts.status;
|
|
106
|
-
this.statusText = opts.statusText;
|
|
107
|
-
this.details = opts.details;
|
|
108
|
-
if (opts.cause !== void 0) {
|
|
109
|
-
;
|
|
110
|
-
this.cause = opts.cause;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
static composeMessage(message, details) {
|
|
114
|
-
if (details == null) return message;
|
|
115
|
-
let detailsString;
|
|
116
|
-
try {
|
|
117
|
-
detailsString = typeof details === "string" ? details : jsonStringify(details, 2);
|
|
118
|
-
} catch (_err) {
|
|
119
|
-
detailsString = String(details);
|
|
120
|
-
}
|
|
121
|
-
return `${message}
|
|
122
|
-
Details: ${detailsString}`;
|
|
123
|
-
}
|
|
124
|
-
toString() {
|
|
125
|
-
return `${this.name}: ${this.message}`;
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
async function handleApiError(response) {
|
|
129
|
-
const contentType = response.headers.get("content-type");
|
|
130
|
-
if (contentType?.includes("application/json")) {
|
|
131
|
-
const errorData = await response.json();
|
|
132
|
-
let error;
|
|
133
|
-
try {
|
|
134
|
-
error = new ApiRequestError(errorData.error.message, {
|
|
135
|
-
status: response.status,
|
|
136
|
-
statusText: response.statusText,
|
|
137
|
-
details: errorData.error.details
|
|
138
|
-
});
|
|
139
|
-
} catch (jsonShapeError) {
|
|
140
|
-
error = new ApiRequestError(
|
|
141
|
-
`Failed parsing error response: ${jsonShapeError}`,
|
|
142
|
-
{
|
|
143
|
-
status: response.status,
|
|
144
|
-
statusText: response.statusText,
|
|
145
|
-
details: errorData
|
|
146
|
-
}
|
|
147
|
-
);
|
|
148
|
-
}
|
|
149
|
-
throw error;
|
|
150
|
-
} else {
|
|
151
|
-
const text = await response.text();
|
|
152
|
-
throw new ApiRequestError(`Unexpected error: ${text}`, {
|
|
153
|
-
status: response.status,
|
|
154
|
-
statusText: response.statusText
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
var jsonStringify = (value, indent) => JSON.stringify(
|
|
159
|
-
value,
|
|
160
|
-
(_, value2) => {
|
|
161
|
-
if (typeof value2 === "bigint") {
|
|
162
|
-
return value2.toString();
|
|
163
|
-
}
|
|
164
|
-
return value2;
|
|
165
|
-
},
|
|
166
|
-
indent
|
|
167
|
-
);
|
|
168
|
-
|
|
169
|
-
// cli/internalApi.ts
|
|
170
|
-
var InternalApiClient = class extends ApiClient {
|
|
171
|
-
listVaults() {
|
|
172
|
-
return this.get("vaults");
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
// cli/commands/typegen.ts
|
|
177
|
-
var t = __toESM(require("@babel/types"), 1);
|
|
178
|
-
var import_generator = require("@babel/generator");
|
|
179
|
-
var import_fs = require("fs");
|
|
180
|
-
var typegen = async () => {
|
|
181
|
-
const client = new InternalApiClient();
|
|
182
|
-
const vaults = await client.listVaults();
|
|
183
|
-
const vaultsEnum = (0, import_generator.generate)(
|
|
184
|
-
t.exportNamedDeclaration(
|
|
185
|
-
t.enumDeclaration(
|
|
186
|
-
t.identifier("Vault"),
|
|
187
|
-
t.enumStringBody(
|
|
188
|
-
vaults.map(
|
|
189
|
-
(vault) => t.enumStringMember(
|
|
190
|
-
t.identifier(vault.label.replaceAll(/ /g, "_")),
|
|
191
|
-
t.stringLiteral(vault.id)
|
|
192
|
-
)
|
|
193
|
-
)
|
|
194
|
-
)
|
|
195
|
-
)
|
|
196
|
-
)
|
|
197
|
-
);
|
|
198
|
-
const cwd = process.cwd();
|
|
199
|
-
(0, import_fs.mkdirSync)(`${cwd}/.zodiac-os/types`, { recursive: true });
|
|
200
|
-
(0, import_fs.writeFileSync)(`${cwd}/.zodiac-os/types/index.ts`, vaultsEnum.code);
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
// cli/run.ts
|
|
204
|
-
var run = async (argv = process.argv.slice(2)) => {
|
|
205
|
-
const args = (0, import_arg.default)({}, { argv });
|
|
206
|
-
const input = args._;
|
|
207
|
-
const [command] = input;
|
|
208
|
-
switch (command) {
|
|
209
|
-
case "typegen": {
|
|
210
|
-
await typegen();
|
|
211
|
-
break;
|
|
212
|
-
}
|
|
213
|
-
default: {
|
|
214
|
-
throw new Error(`Unknown command "${command}"`);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
// cli/index.ts
|
|
220
|
-
run().then(
|
|
221
|
-
() => {
|
|
222
|
-
process.exit(0);
|
|
223
|
-
},
|
|
224
|
-
(error) => {
|
|
225
|
-
if (error) console.error(error);
|
|
226
|
-
process.exit(1);
|
|
227
|
-
}
|
|
228
|
-
);
|