@statelyai/sdk 0.14.2 → 0.15.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 +48 -3
- package/dist/auth.d.mts +1 -1
- package/dist/embed.d.mts +1 -1
- package/dist/{graph-3oSqiY4N.d.mts → graph-DuOeLGvh.d.mts} +1 -1
- package/dist/graph.d.mts +1 -1
- package/dist/{index-CcgKzQ-C.d.mts → index-ag6K2iAS.d.mts} +1 -1
- package/dist/index.d.mts +6 -6
- package/dist/index.mjs +3 -3
- package/dist/inspect.d.mts +1 -1
- package/dist/patchTypes.d.mts +1 -1
- package/dist/protocol.d.mts +1 -1
- package/dist/{dist-Ci5I7Rjq.mjs → statelyPragma-Bm9O4XV6.mjs} +112 -4432
- package/dist/studio-Da5pyxv6.d.mts +303 -0
- package/dist/studio-txdyJHD7.mjs +4725 -0
- package/dist/studio.d.mts +2 -125
- package/dist/studio.mjs +2 -171
- package/dist/sync.d.mts +2 -2
- package/dist/sync.mjs +13 -24
- package/package.json +4 -3
- package/dist/dist-CO36Ks-i.mjs +0 -9400
- /package/dist/{auth-D9-iLi-S.d.mts → auth-2Thaw42j.d.mts} +0 -0
- /package/dist/{inspect-DQ_7I7eH.d.mts → inspect-DenVP7IE.d.mts} +0 -0
package/dist/studio.d.mts
CHANGED
|
@@ -1,125 +1,2 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
|
|
3
|
-
//#region src/studio.d.ts
|
|
4
|
-
interface StudioClientOptions {
|
|
5
|
-
baseUrl?: string;
|
|
6
|
-
credential?: StatelyCredential;
|
|
7
|
-
/** @deprecated Use credential: { type: 'api_key', token }. */
|
|
8
|
-
apiKey?: string;
|
|
9
|
-
authMode?: StatelyAuthMode;
|
|
10
|
-
fetch?: typeof fetch;
|
|
11
|
-
}
|
|
12
|
-
interface VerifyApiKeyResponse {
|
|
13
|
-
valid: boolean;
|
|
14
|
-
}
|
|
15
|
-
type ProjectVisibility = 'Public' | 'Private' | 'Unlisted';
|
|
16
|
-
type RepoType = 'GITHUB';
|
|
17
|
-
interface ConnectedRepo {
|
|
18
|
-
id?: string;
|
|
19
|
-
type?: RepoType;
|
|
20
|
-
url: string;
|
|
21
|
-
owner: string;
|
|
22
|
-
repo: string;
|
|
23
|
-
branch: string;
|
|
24
|
-
treeSha: string;
|
|
25
|
-
autoSync?: boolean;
|
|
26
|
-
pathForNewFiles?: string;
|
|
27
|
-
selectedPaths?: string[];
|
|
28
|
-
lastSyncedAt?: string;
|
|
29
|
-
}
|
|
30
|
-
interface ProjectMachine {
|
|
31
|
-
machineId: string;
|
|
32
|
-
name: string;
|
|
33
|
-
}
|
|
34
|
-
interface ProjectData {
|
|
35
|
-
projectId: string;
|
|
36
|
-
machines: ProjectMachine[];
|
|
37
|
-
id?: string;
|
|
38
|
-
name?: string;
|
|
39
|
-
description?: string | null;
|
|
40
|
-
keywords?: string[];
|
|
41
|
-
visibility?: ProjectVisibility;
|
|
42
|
-
projectVersionId?: string;
|
|
43
|
-
connectedRepo?: ConnectedRepo | null;
|
|
44
|
-
}
|
|
45
|
-
interface ExtractedMachine {
|
|
46
|
-
id?: string;
|
|
47
|
-
config: Record<string, unknown>;
|
|
48
|
-
setupConfig?: Record<string, unknown>;
|
|
49
|
-
implementations?: Record<string, unknown>;
|
|
50
|
-
_type: 'setup.createMachine' | 'createMachine';
|
|
51
|
-
}
|
|
52
|
-
interface ExtractMachinesResponse {
|
|
53
|
-
machines: ExtractedMachine[];
|
|
54
|
-
error?: string;
|
|
55
|
-
}
|
|
56
|
-
interface GetMachineOptions {
|
|
57
|
-
version?: string;
|
|
58
|
-
}
|
|
59
|
-
interface CreateProjectInput {
|
|
60
|
-
name: string;
|
|
61
|
-
visibility: ProjectVisibility;
|
|
62
|
-
description?: string;
|
|
63
|
-
keywords?: string[];
|
|
64
|
-
repo?: ConnectedRepo;
|
|
65
|
-
}
|
|
66
|
-
interface EnsureProjectInput extends CreateProjectInput {
|
|
67
|
-
matchConnectedRepo?: boolean;
|
|
68
|
-
}
|
|
69
|
-
type XStateVersion = 4 | 5;
|
|
70
|
-
type CreateMachineTemplate = 'blank' | 'starter';
|
|
71
|
-
interface CreateMachineFromDefinitionInput<TDefinition = Record<string, unknown>> {
|
|
72
|
-
projectVersionId: string;
|
|
73
|
-
definition: TDefinition;
|
|
74
|
-
xstateVersion?: XStateVersion;
|
|
75
|
-
}
|
|
76
|
-
interface CreateMachineFromTemplateInput {
|
|
77
|
-
projectVersionId: string;
|
|
78
|
-
name: string;
|
|
79
|
-
template: CreateMachineTemplate;
|
|
80
|
-
xstateVersion?: XStateVersion;
|
|
81
|
-
}
|
|
82
|
-
type CreateMachineInput<TDefinition = Record<string, unknown>> = CreateMachineFromDefinitionInput<TDefinition> | CreateMachineFromTemplateInput;
|
|
83
|
-
interface UpdateMachineInput<TDefinition = Record<string, unknown>> {
|
|
84
|
-
id: string;
|
|
85
|
-
name?: string;
|
|
86
|
-
definition?: TDefinition;
|
|
87
|
-
}
|
|
88
|
-
interface StudioMachineRecord<TDefinition = Record<string, unknown>> {
|
|
89
|
-
id: string;
|
|
90
|
-
name: string;
|
|
91
|
-
definition: TDefinition;
|
|
92
|
-
projectVersionId?: string;
|
|
93
|
-
[key: string]: unknown;
|
|
94
|
-
}
|
|
95
|
-
declare class StudioApiError extends Error {
|
|
96
|
-
readonly status: number;
|
|
97
|
-
constructor(message: string, status: number);
|
|
98
|
-
}
|
|
99
|
-
interface StudioClient {
|
|
100
|
-
auth: {
|
|
101
|
-
verify(credential?: StatelyCredential | string): Promise<VerifyApiKeyResponse>;
|
|
102
|
-
};
|
|
103
|
-
projects: {
|
|
104
|
-
list(): Promise<ProjectData[]>;
|
|
105
|
-
create(input: CreateProjectInput): Promise<ProjectData>;
|
|
106
|
-
ensure(input: EnsureProjectInput): Promise<ProjectData>;
|
|
107
|
-
get(projectId: string): Promise<ProjectData>;
|
|
108
|
-
};
|
|
109
|
-
machines: {
|
|
110
|
-
create<TMachine = Record<string, unknown>>(input: CreateMachineInput<TMachine>): Promise<StudioMachineRecord<TMachine>>;
|
|
111
|
-
createMany<TMachine = Record<string, unknown>>(input: CreateMachineInput<TMachine>): Promise<Array<StudioMachineRecord<TMachine>>>;
|
|
112
|
-
update<TMachine = Record<string, unknown>>(input: UpdateMachineInput<TMachine>): Promise<StudioMachineRecord<TMachine>>;
|
|
113
|
-
get<TMachine = Record<string, unknown>>(machineId: string, options?: GetMachineOptions): Promise<TMachine>;
|
|
114
|
-
};
|
|
115
|
-
code: {
|
|
116
|
-
extractMachines(code: string, options?: {
|
|
117
|
-
credential?: StatelyCredential | null; /** @deprecated Use credential. */
|
|
118
|
-
apiKey?: string | null;
|
|
119
|
-
authMode?: StatelyAuthMode;
|
|
120
|
-
}): Promise<ExtractMachinesResponse>;
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
declare function createStatelyClient(options?: StudioClientOptions): StudioClient;
|
|
124
|
-
//#endregion
|
|
125
|
-
export { ConnectedRepo, CreateMachineFromDefinitionInput, CreateMachineFromTemplateInput, CreateMachineInput, CreateMachineTemplate, CreateProjectInput, EnsureProjectInput, ExtractMachinesResponse, ExtractedMachine, GetMachineOptions, ProjectData, ProjectMachine, ProjectVisibility, RepoType, StudioApiError, StudioClient, StudioClientOptions, StudioMachineRecord, UpdateMachineInput, VerifyApiKeyResponse, XStateVersion, createStatelyClient };
|
|
1
|
+
import { A as Machine, C as StudioMachineRecord, D as VerifyApiKeyResponse, E as UpdateProjectInput, F as ProjectVisibility, I as VerifyResult, L as XStateVersion, M as Project, N as ProjectMachineSummary, O as createStatelyClient, P as ProjectSummary, R as ResourceErrorCode, S as StudioClientOptions, T as UpdateMachineInput, _ as ProjectMachine, a as CreateMachineTemplate, b as StudioApiErrorOptions, c as EnsureProjectInput, d as ExtractedMachine, f as GetMachineOptions, g as ProjectData, h as LegacyUpdateMachineInput, i as CreateMachineInput, j as MachineVersion, k as ExtractedMachines, l as ExtractMachinesInput, m as LegacyProjectVisibility, n as CreateMachineFromDefinitionInput, o as CreateProjectInput, p as LegacyExtractMachinesOptions, r as CreateMachineFromTemplateInput, s as DEFAULT_STATELY_BASE_URL, t as ConnectedRepo, u as ExtractMachinesResponse, v as RepoType, w as StudioRequestOptions, x as StudioClient, y as StudioApiError } from "./studio-Da5pyxv6.mjs";
|
|
2
|
+
export { ConnectedRepo, CreateMachineFromDefinitionInput, CreateMachineFromTemplateInput, CreateMachineInput, CreateMachineTemplate, CreateProjectInput, DEFAULT_STATELY_BASE_URL, EnsureProjectInput, ExtractMachinesInput, ExtractMachinesResponse, ExtractedMachine, ExtractedMachines, GetMachineOptions, LegacyExtractMachinesOptions, LegacyProjectVisibility, LegacyUpdateMachineInput, Machine, MachineVersion, Project, ProjectData, ProjectMachine, ProjectMachineSummary, ProjectSummary, ProjectVisibility, RepoType, ResourceErrorCode, StudioApiError, StudioApiErrorOptions, StudioClient, StudioClientOptions, StudioMachineRecord, StudioRequestOptions, UpdateMachineInput, UpdateProjectInput, VerifyApiKeyResponse, VerifyResult, XStateVersion, createStatelyClient };
|
package/dist/studio.mjs
CHANGED
|
@@ -1,172 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as StudioApiError, r as createStatelyClient, t as DEFAULT_STATELY_BASE_URL } from "./studio-txdyJHD7.mjs";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
var StudioApiError = class extends Error {
|
|
5
|
-
status;
|
|
6
|
-
constructor(message, status) {
|
|
7
|
-
super(message);
|
|
8
|
-
this.name = "StudioApiError";
|
|
9
|
-
this.status = status;
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
function getFetch(fetchImpl) {
|
|
13
|
-
const resolvedFetch = fetchImpl ?? globalThis.fetch;
|
|
14
|
-
if (!resolvedFetch) throw new Error("No fetch implementation available. Pass one via createStatelyClient({ fetch }).");
|
|
15
|
-
return resolvedFetch;
|
|
16
|
-
}
|
|
17
|
-
function joinApiUrl(baseUrl, path) {
|
|
18
|
-
return `${baseUrl.replace(/\/+$/, "")}/registry/api/v1${path}`;
|
|
19
|
-
}
|
|
20
|
-
async function parseJson(response) {
|
|
21
|
-
if (!response.headers.get("content-type")?.includes("application/json")) return null;
|
|
22
|
-
return response.json().catch(() => null);
|
|
23
|
-
}
|
|
24
|
-
function getErrorMessage(data, status) {
|
|
25
|
-
if (typeof data === "object" && data !== null) {
|
|
26
|
-
if ("error" in data && typeof data.error === "string") return data.error;
|
|
27
|
-
if ("error" in data) {
|
|
28
|
-
const error = data.error;
|
|
29
|
-
if (typeof error === "object" && error !== null && "json" in error) {
|
|
30
|
-
const errorJson = error.json;
|
|
31
|
-
if (typeof errorJson === "object" && errorJson !== null && "message" in errorJson && typeof errorJson.message === "string") return errorJson.message;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
if (Array.isArray(data)) for (const item of data) {
|
|
36
|
-
const message = getErrorMessage(item, status);
|
|
37
|
-
if (message !== `HTTP ${status}`) return message;
|
|
38
|
-
}
|
|
39
|
-
return `HTTP ${status}`;
|
|
40
|
-
}
|
|
41
|
-
function unwrapResponseData(data) {
|
|
42
|
-
if (typeof data === "object" && data !== null && "data" in data) return data.data;
|
|
43
|
-
return data;
|
|
44
|
-
}
|
|
45
|
-
function normalizeProjectMachine(machine) {
|
|
46
|
-
if (typeof machine !== "object" || machine === null) return null;
|
|
47
|
-
const candidate = machine;
|
|
48
|
-
const machineId = typeof candidate.machineId === "string" ? candidate.machineId : typeof candidate.id === "string" ? candidate.id : void 0;
|
|
49
|
-
if (!machineId) return null;
|
|
50
|
-
return {
|
|
51
|
-
machineId,
|
|
52
|
-
name: typeof candidate.name === "string" && candidate.name.trim().length > 0 ? candidate.name : typeof candidate.key === "string" && candidate.key.trim().length > 0 ? candidate.key : machineId
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
function normalizeProjectData(project) {
|
|
56
|
-
const machines = Array.isArray(project.machines) ? project.machines.map((machine) => normalizeProjectMachine(machine)).filter((machine) => machine != null) : [];
|
|
57
|
-
if (project.projectVersionId) return {
|
|
58
|
-
...project,
|
|
59
|
-
machines
|
|
60
|
-
};
|
|
61
|
-
if (project.projectId && project.id) return {
|
|
62
|
-
...project,
|
|
63
|
-
machines,
|
|
64
|
-
projectVersionId: project.id
|
|
65
|
-
};
|
|
66
|
-
return {
|
|
67
|
-
...project,
|
|
68
|
-
machines
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
function normalizeRepoUrl(url) {
|
|
72
|
-
if (!url) return;
|
|
73
|
-
return url.replace(/\.git$/i, "").replace(/\/+$/, "");
|
|
74
|
-
}
|
|
75
|
-
function connectedReposMatch(left, right) {
|
|
76
|
-
if (!left || !right) return false;
|
|
77
|
-
const normalizedLeft = normalizeRepoUrl(left.url);
|
|
78
|
-
const normalizedRight = normalizeRepoUrl(right.url);
|
|
79
|
-
return normalizedLeft != null && normalizedRight != null && normalizedLeft === normalizedRight && left.branch === right.branch || left.owner === right.owner && left.repo === right.repo && left.branch === right.branch;
|
|
80
|
-
}
|
|
81
|
-
function createStatelyClient(options = {}) {
|
|
82
|
-
const baseUrl = options.baseUrl ?? "https://stately.ai";
|
|
83
|
-
const fetchImpl = getFetch(options.fetch);
|
|
84
|
-
const defaultCredential = options.credential ?? (options.apiKey ? {
|
|
85
|
-
type: "api_key",
|
|
86
|
-
token: options.apiKey
|
|
87
|
-
} : void 0);
|
|
88
|
-
const defaultAuthMode = options.authMode ?? "auto";
|
|
89
|
-
async function request(path, init = {}, credentialOverride, authModeOverride) {
|
|
90
|
-
const headers = new Headers(init.headers);
|
|
91
|
-
const authMode = authModeOverride ?? defaultAuthMode;
|
|
92
|
-
const credential = credentialOverride ?? defaultCredential;
|
|
93
|
-
if (authMode !== "none") {
|
|
94
|
-
const token = getCredentialToken(credential);
|
|
95
|
-
if (authMode === "bearer" && (!token || !credential)) throw new StudioApiError("No Stately credential configured. Pass createStatelyClient({ credential }) or use authMode: \"auto\" to let the server decide whether authentication is required.", 401);
|
|
96
|
-
if (token && credential) headers.set("Authorization", createAuthorizationHeader(credential));
|
|
97
|
-
}
|
|
98
|
-
const response = await fetchImpl(joinApiUrl(baseUrl, path), {
|
|
99
|
-
...init,
|
|
100
|
-
headers
|
|
101
|
-
});
|
|
102
|
-
const data = await parseJson(response);
|
|
103
|
-
if (!response.ok) throw new StudioApiError(getErrorMessage(data, response.status), response.status);
|
|
104
|
-
return unwrapResponseData(data);
|
|
105
|
-
}
|
|
106
|
-
return {
|
|
107
|
-
auth: { verify(credential) {
|
|
108
|
-
return request("/verify", { method: "GET" }, credential);
|
|
109
|
-
} },
|
|
110
|
-
projects: {
|
|
111
|
-
list() {
|
|
112
|
-
return request("/projects", { method: "GET" }).then((projects) => projects.map(normalizeProjectData));
|
|
113
|
-
},
|
|
114
|
-
create(input) {
|
|
115
|
-
return request("/projects/create", {
|
|
116
|
-
method: "POST",
|
|
117
|
-
headers: { "Content-Type": "application/json" },
|
|
118
|
-
body: JSON.stringify(input)
|
|
119
|
-
}).then(normalizeProjectData);
|
|
120
|
-
},
|
|
121
|
-
async ensure(input) {
|
|
122
|
-
if (input.repo && input.matchConnectedRepo !== false) {
|
|
123
|
-
const existingProject = (await this.list()).find((project) => connectedReposMatch(project.connectedRepo, input.repo));
|
|
124
|
-
if (existingProject) return existingProject;
|
|
125
|
-
}
|
|
126
|
-
return this.create(input);
|
|
127
|
-
},
|
|
128
|
-
get(projectId) {
|
|
129
|
-
return request(`/projects/${encodeURIComponent(projectId)}`, { method: "GET" }).then(normalizeProjectData);
|
|
130
|
-
}
|
|
131
|
-
},
|
|
132
|
-
machines: {
|
|
133
|
-
async create(input) {
|
|
134
|
-
return request("/machines/create", {
|
|
135
|
-
method: "POST",
|
|
136
|
-
headers: { "Content-Type": "application/json" },
|
|
137
|
-
body: JSON.stringify(input)
|
|
138
|
-
});
|
|
139
|
-
},
|
|
140
|
-
async createMany(input) {
|
|
141
|
-
return [await this.create(input)];
|
|
142
|
-
},
|
|
143
|
-
update(input) {
|
|
144
|
-
return request(`/machines/${encodeURIComponent(input.id)}`, {
|
|
145
|
-
method: "PATCH",
|
|
146
|
-
headers: { "Content-Type": "application/json" },
|
|
147
|
-
body: JSON.stringify(input)
|
|
148
|
-
});
|
|
149
|
-
},
|
|
150
|
-
get(machineId, getOptions = {}) {
|
|
151
|
-
const search = new URLSearchParams();
|
|
152
|
-
if (getOptions.version) search.set("version", getOptions.version);
|
|
153
|
-
const suffix = search.size > 0 ? `?${search.toString()}` : "";
|
|
154
|
-
return request(`/machines/${encodeURIComponent(machineId)}${suffix}`, { method: "GET" });
|
|
155
|
-
}
|
|
156
|
-
},
|
|
157
|
-
code: { extractMachines(code, extractOptions = {}) {
|
|
158
|
-
const credential = extractOptions.credential ?? (extractOptions.apiKey ? {
|
|
159
|
-
type: "api_key",
|
|
160
|
-
token: extractOptions.apiKey
|
|
161
|
-
} : void 0);
|
|
162
|
-
return request("/code", {
|
|
163
|
-
method: "POST",
|
|
164
|
-
headers: { "Content-Type": "application/json" },
|
|
165
|
-
body: JSON.stringify({ code })
|
|
166
|
-
}, credential, extractOptions.authMode);
|
|
167
|
-
} }
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
//#endregion
|
|
172
|
-
export { StudioApiError, createStatelyClient };
|
|
3
|
+
export { DEFAULT_STATELY_BASE_URL, StudioApiError, createStatelyClient };
|
package/dist/sync.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as DigraphConfig, i as StatelyGraph } from "./graph-
|
|
2
|
-
import {
|
|
1
|
+
import { b as DigraphConfig, i as StatelyGraph } from "./graph-DuOeLGvh.mjs";
|
|
2
|
+
import { C as StudioMachineRecord, L as XStateVersion, g as ProjectData, o as CreateProjectInput, x as StudioClient } from "./studio-Da5pyxv6.mjs";
|
|
3
3
|
import { GraphDiff } from "@statelyai/graph";
|
|
4
4
|
|
|
5
5
|
//#region src/sync.d.ts
|
package/dist/sync.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createStatelyClient } from "./studio.mjs";
|
|
2
|
-
import {
|
|
1
|
+
import { r as createStatelyClient } from "./studio-txdyJHD7.mjs";
|
|
2
|
+
import { i as INLINE_EXPRESSION_DIRECTIVE_FIELDS, m as xstateSourceToConfig, n as getStatelyPragma, p as serializeJS, r as upsertStatelyPragma, s as detectXStateSourceProfile, t as findStatelyPragmaAttachments, u as graphToXStateTS } from "./statelyPragma-Bm9O4XV6.mjs";
|
|
3
3
|
import { fromStudioMachine, toStudioMachine } from "./graph.mjs";
|
|
4
4
|
import * as ts$1 from "typescript";
|
|
5
5
|
import ts from "typescript";
|
|
@@ -1456,16 +1456,16 @@ function inferXStateTargetLanguage(targetPath) {
|
|
|
1456
1456
|
return /\.(?:c|m)?jsx?$/i.test(targetPath) ? "javascript" : "typescript";
|
|
1457
1457
|
}
|
|
1458
1458
|
async function resolveRemoteMachine(machineId, baseUrl, kind, locator, options) {
|
|
1459
|
-
const
|
|
1459
|
+
const digraph = (await (options.client ?? createStatelyClient({
|
|
1460
1460
|
apiKey: options.apiKey,
|
|
1461
1461
|
baseUrl,
|
|
1462
1462
|
fetch: options.fetch
|
|
1463
|
-
})).machines.get(machineId);
|
|
1463
|
+
})).machines.get(machineId)).definition;
|
|
1464
1464
|
return {
|
|
1465
1465
|
kind,
|
|
1466
1466
|
locator,
|
|
1467
1467
|
format: "digraph",
|
|
1468
|
-
graph: fromStudioMachine(
|
|
1468
|
+
graph: fromStudioMachine(digraph),
|
|
1469
1469
|
remoteMachineId: machineId
|
|
1470
1470
|
};
|
|
1471
1471
|
}
|
|
@@ -1534,33 +1534,22 @@ function inferDefaultProjectName(sourcePath, repo) {
|
|
|
1534
1534
|
return path.basename(sourcePath, path.extname(sourcePath));
|
|
1535
1535
|
}
|
|
1536
1536
|
async function resolvePushProject(client, sourcePath, options) {
|
|
1537
|
-
async function withResolvedProjectVersionId(project, explicitProjectVersionId) {
|
|
1538
|
-
if (project.projectVersionId) return project;
|
|
1539
|
-
if (explicitProjectVersionId) return {
|
|
1540
|
-
...project,
|
|
1541
|
-
projectVersionId: explicitProjectVersionId
|
|
1542
|
-
};
|
|
1543
|
-
const matchedProject = (await client.projects.list()).find((candidate) => {
|
|
1544
|
-
return candidate.projectId === project.projectId || candidate.id != null && project.id != null && candidate.id === project.id;
|
|
1545
|
-
});
|
|
1546
|
-
if (matchedProject?.projectVersionId) return {
|
|
1547
|
-
...project,
|
|
1548
|
-
projectVersionId: matchedProject.projectVersionId
|
|
1549
|
-
};
|
|
1550
|
-
return project;
|
|
1551
|
-
}
|
|
1552
1537
|
const explicitProject = options.project;
|
|
1553
|
-
if (explicitProject?.
|
|
1554
|
-
if (explicitProject?.
|
|
1538
|
+
if (explicitProject?.projectId) return client.projects.get(explicitProject.projectId);
|
|
1539
|
+
if (explicitProject?.projectVersionId) {
|
|
1540
|
+
const matchedProject = (await client.projects.list()).find((candidate) => candidate.projectVersionId === explicitProject.projectVersionId);
|
|
1541
|
+
if (!matchedProject) throw new Error(`No project found for projectVersionId "${explicitProject.projectVersionId}".`);
|
|
1542
|
+
return client.projects.get(matchedProject.projectId);
|
|
1543
|
+
}
|
|
1555
1544
|
const inferredRepo = explicitProject?.repo ?? await inferConnectedRepo(sourcePath, options.cwd);
|
|
1556
1545
|
const projectInput = {
|
|
1557
1546
|
name: explicitProject?.name ?? inferDefaultProjectName(sourcePath, inferredRepo),
|
|
1558
|
-
visibility: explicitProject?.visibility ?? "
|
|
1547
|
+
visibility: explicitProject?.visibility ?? "private",
|
|
1559
1548
|
...explicitProject?.description ? { description: explicitProject.description } : {},
|
|
1560
1549
|
...explicitProject?.keywords ? { keywords: explicitProject.keywords } : {},
|
|
1561
1550
|
...inferredRepo ? { repo: inferredRepo } : {}
|
|
1562
1551
|
};
|
|
1563
|
-
return
|
|
1552
|
+
return client.projects.ensure(projectInput);
|
|
1564
1553
|
}
|
|
1565
1554
|
async function pushSync(options) {
|
|
1566
1555
|
const client = options.client ?? createStatelyClient({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@statelyai/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -81,12 +81,13 @@
|
|
|
81
81
|
"tsdown": "0.21.0-beta.2",
|
|
82
82
|
"vitest": "^3.2.4",
|
|
83
83
|
"ws": "^8.19.0",
|
|
84
|
-
"@statelyai/graph-tools": "0.0.7"
|
|
84
|
+
"@statelyai/graph-tools": "0.0.7",
|
|
85
|
+
"@statelyai/api-contract": "0.0.1"
|
|
85
86
|
},
|
|
86
87
|
"scripts": {
|
|
87
88
|
"build": "tsdown",
|
|
88
89
|
"test": "vitest run",
|
|
89
|
-
"test:live": "vitest run
|
|
90
|
+
"test:live": "vitest run --config vitest.live.config.ts",
|
|
90
91
|
"test:watch": "vitest"
|
|
91
92
|
}
|
|
92
93
|
}
|