@zodiac-os/sdk 1.0.1 → 1.2.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/package.json CHANGED
@@ -1,40 +1,53 @@
1
1
  {
2
2
  "name": "@zodiac-os/sdk",
3
- "version": "1.0.1",
3
+ "version": "1.2.0",
4
4
  "author": "Gnosis Guild",
5
5
  "license": "LGPL-3.0-only",
6
6
  "homepage": "https://github.com/gnosisguild/zodiac-os-sdk",
7
7
  "packageManager": "bun@1.1.12",
8
- "main": "dist/index.js",
8
+ "repository": {
9
+ "url": "https://github.com/gnosisguild/zodiac-os-sdk"
10
+ },
11
+ "type": "module",
9
12
  "module": "dist/index.mjs",
10
- "types": "dist/index.d.ts",
13
+ "types": "dist/index.d.mts",
11
14
  "exports": {
12
- "types": "./dist/index.d.ts",
13
- "import": "./dist/index.mjs",
14
- "require": "./dist/index.js"
15
+ "types": "./dist/index.d.mts",
16
+ "import": "./dist/index.mjs"
15
17
  },
16
18
  "files": [
17
19
  "dist",
18
20
  "README.md",
19
21
  "LICENSE"
20
22
  ],
23
+ "bin": {
24
+ "zodiac-os": "./dist/cli.mjs"
25
+ },
21
26
  "scripts": {
22
- "build": "tsup --format esm,cjs",
27
+ "clean": "rimraf dist",
28
+ "prebuild": "bun clean",
29
+ "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",
23
30
  "prepublishOnly": "bun run build",
24
31
  "check:format": "prettier --list-different .",
25
32
  "check:types": "tsc -p tsconfig.json",
26
33
  "fix:format": "prettier --write .",
27
- "test": "bun test"
34
+ "test": "bun test",
35
+ "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"
28
36
  },
29
37
  "devDependencies": {
30
38
  "@types/bun": "^1.2.21",
31
39
  "prettier": "^3.6.2",
32
- "tsup": "^8.5.0",
40
+ "rimraf": "^6.1.0",
41
+ "tsdown": "^0.21.4",
33
42
  "typescript": "^5.9.2"
34
43
  },
35
44
  "dependencies": {
36
45
  "@epic-web/invariant": "1.0.0",
37
- "@zodiac-os/api-types": "^1.3.0",
38
- "zodiac-roles-sdk": "^3.3.2"
46
+ "@gnosis-guild/eth-sdk": "^0.4.0",
47
+ "@gnosis-guild/eth-sdk-client": "^0.1.6",
48
+ "@zodiac-os/api-types": "1.5.1",
49
+ "commander": "^14.0.3",
50
+ "ts-morph": "^27.0.2",
51
+ "zodiac-roles-sdk": "^3.4.7"
39
52
  }
40
53
  }
package/dist/index.d.ts DELETED
@@ -1,27 +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(opts: Options);
16
- private postJson;
17
- /**
18
- * Applies an accounts specification to Zodiac OS.
19
- */
20
- applyConstellation(payload: ApplyConstellationPayload): Promise<ApplyConstellationResult>;
21
- /**
22
- * Resolves an accounts specification to Zodiac OS.
23
- */
24
- resolveConstellation(payload: ResolveConstellationPayload): Promise<ResolveConstellationResult>;
25
- }
26
-
27
- export { ApiClient };
package/dist/index.js DELETED
@@ -1,144 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
21
-
22
- // src/index.ts
23
- var index_exports = {};
24
- __export(index_exports, {
25
- ApiClient: () => ApiClient
26
- });
27
- module.exports = __toCommonJS(index_exports);
28
-
29
- // src/api.ts
30
- var DEFAULT_BASE_URL = "https://app.pilot.gnosisguild.org/api/v1";
31
- var ApiClient = class {
32
- constructor(opts) {
33
- __publicField(this, "apiKey");
34
- __publicField(this, "baseUrl");
35
- __publicField(this, "_fetch");
36
- __publicField(this, "headers");
37
- this.baseUrl = (opts.baseUrl ?? DEFAULT_BASE_URL).replace(/\/$/, "") + "/workspace/" + opts.workspace;
38
- this._fetch = opts.fetch ?? fetch;
39
- this.headers = opts.headers ?? {};
40
- this.apiKey = opts.apiKey;
41
- }
42
- async postJson(endpoint, payload) {
43
- const res = await this._fetch(`${this.baseUrl}/${endpoint}`, {
44
- method: "POST",
45
- headers: {
46
- ...this.headers,
47
- "content-type": "application/json",
48
- authorization: `Bearer ${this.apiKey}`
49
- },
50
- body: jsonStringify(payload)
51
- });
52
- if (!res.ok) {
53
- await handleApiError(res);
54
- }
55
- return await res.json();
56
- }
57
- /**
58
- * Applies an accounts specification to Zodiac OS.
59
- */
60
- async applyConstellation(payload) {
61
- return await this.postJson("constellation/apply", payload);
62
- }
63
- /**
64
- * Resolves an accounts specification to Zodiac OS.
65
- */
66
- async resolveConstellation(payload) {
67
- return await this.postJson("constellation/resolve", payload);
68
- }
69
- };
70
- var ApiRequestError = class _ApiRequestError extends Error {
71
- constructor(message, opts) {
72
- super(_ApiRequestError.composeMessage(message, opts.details));
73
- __publicField(this, "status");
74
- __publicField(this, "statusText");
75
- __publicField(this, "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
- // Annotate the CommonJS export names for ESM import in node:
141
- 0 && (module.exports = {
142
- ApiClient
143
- });
144
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/index.ts","../src/api.ts"],"sourcesContent":["export { ApiClient } from './api'\n","import type {\n ApplyConstellationPayload,\n ApplyConstellationResult,\n ResolveConstellationPayload,\n ResolveConstellationResult,\n ApiError as ApiErrorResponse,\n} from '@zodiac-os/api-types'\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 DEFAULT_BASE_URL = 'https://app.pilot.gnosisguild.org/api/v1'\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(opts: Options) {\n this.baseUrl =\n (opts.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/$/, '') +\n '/workspace/' +\n opts.workspace\n\n this._fetch = opts.fetch ?? fetch\n this.headers = opts.headers ?? {}\n this.apiKey = opts.apiKey\n }\n\n private 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 await res.json()\n }\n\n /**\n * Applies an accounts specification to Zodiac OS.\n */\n async applyConstellation(\n payload: ApplyConstellationPayload\n ): Promise<ApplyConstellationResult> {\n return await this.postJson('constellation/apply', payload)\n }\n\n /**\n * Resolves an accounts specification to Zodiac OS.\n */\n async resolveConstellation(\n payload: ResolveConstellationPayload\n ): Promise<ResolveConstellationResult> {\n return await 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":";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACgBA,IAAM,mBAAmB;AAElB,IAAM,YAAN,MAAgB;AAAA,EAMrB,YAAY,MAAe;AAL3B,wBAAQ;AACR,wBAAQ;AACR,wBAAQ;AACR,wBAAQ;AAGN,SAAK,WACF,KAAK,WAAW,kBAAkB,QAAQ,OAAO,EAAE,IACpD,gBACA,KAAK;AAEP,SAAK,SAAS,KAAK,SAAS;AAC5B,SAAK,UAAU,KAAK,WAAW,CAAC;AAChC,SAAK,SAAS,KAAK;AAAA,EACrB;AAAA,EAEA,MAAc,SAAS,UAAkB,SAAkB;AACzD,UAAM,MAAM,MAAM,KAAK,OAAO,GAAG,KAAK,OAA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