@powerhousedao/service-offering 1.0.0-dev.18 → 1.0.0-dev.20
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/dist/editors/resource-instance-editor/utils/graphql-client.d.ts +3 -38
- package/dist/editors/resource-instance-editor/utils/graphql-client.d.ts.map +1 -1
- package/dist/editors/resource-instance-editor/utils/graphql-client.js +3 -187
- package/dist/editors/service-offering-editor/utils/graphql-client.d.ts +3 -78
- package/dist/editors/service-offering-editor/utils/graphql-client.d.ts.map +1 -1
- package/dist/editors/service-offering-editor/utils/graphql-client.js +3 -264
- package/dist/editors/utils/graphql-client.d.ts +83 -0
- package/dist/editors/utils/graphql-client.d.ts.map +1 -0
- package/dist/editors/utils/graphql-client.js +197 -0
- package/dist/style.css +1 -1
- package/package.json +19 -31
|
@@ -1,41 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Re-exports from the shared GraphQL client.
|
|
3
|
+
* @deprecated Import directly from "../../utils/graphql-client.js" instead.
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
6
|
-
id: string;
|
|
7
|
-
state: {
|
|
8
|
-
name: string | null;
|
|
9
|
-
slug: string | null;
|
|
10
|
-
icon: string | null;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Fetches all available remote drives
|
|
15
|
-
*/
|
|
16
|
-
export declare function fetchRemoteDrives(): Promise<string[]>;
|
|
17
|
-
/**
|
|
18
|
-
* Fetches drive ID by slug
|
|
19
|
-
*/
|
|
20
|
-
export declare function fetchDriveIdBySlug(slug: string): Promise<string | null>;
|
|
21
|
-
/**
|
|
22
|
-
* Fetches all builder profiles from a specific drive
|
|
23
|
-
*/
|
|
24
|
-
export declare function fetchBuilderProfilesFromDrive(driveId: string, options?: {
|
|
25
|
-
silent?: boolean;
|
|
26
|
-
}): Promise<RemoteBuilderProfile[]>;
|
|
27
|
-
/**
|
|
28
|
-
* Fetches a single builder profile by document ID
|
|
29
|
-
*/
|
|
30
|
-
export declare function fetchBuilderProfileById(docId: string, driveId?: string): Promise<RemoteBuilderProfile | null>;
|
|
31
|
-
/**
|
|
32
|
-
* Fetches all builder profiles from all available remote drives.
|
|
33
|
-
* This aggregates profiles from multiple drives into a single list.
|
|
34
|
-
*/
|
|
35
|
-
export declare function fetchAllRemoteBuilderProfiles(): Promise<RemoteBuilderProfile[]>;
|
|
36
|
-
/**
|
|
37
|
-
* Fetches multiple builder profiles by their IDs.
|
|
38
|
-
* Tries to find them across all available remote drives.
|
|
39
|
-
*/
|
|
40
|
-
export declare function fetchRemoteBuilderProfilesByIds(phids: string[]): Promise<Map<string, RemoteBuilderProfile>>;
|
|
5
|
+
export { fetchAllRemoteBuilderProfiles, fetchBuilderProfileById, fetchRemoteBuilderProfilesByIds, type RemoteBuilderProfile, } from "../../utils/graphql-client.js";
|
|
41
6
|
//# sourceMappingURL=graphql-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql-client.d.ts","sourceRoot":"","sources":["../../../../editors/resource-instance-editor/utils/graphql-client.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"graphql-client.d.ts","sourceRoot":"","sources":["../../../../editors/resource-instance-editor/utils/graphql-client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,6BAA6B,EAC7B,uBAAuB,EACvB,+BAA+B,EAC/B,KAAK,oBAAoB,GAC1B,MAAM,+BAA+B,CAAC"}
|
|
@@ -1,189 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Re-exports from the shared GraphQL client.
|
|
3
|
+
* @deprecated Import directly from "../../utils/graphql-client.js" instead.
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
if (typeof window === "undefined") {
|
|
7
|
-
return "http://localhost:4001/graphql";
|
|
8
|
-
}
|
|
9
|
-
const baseURI = window.document.baseURI;
|
|
10
|
-
if (baseURI.includes("localhost")) {
|
|
11
|
-
return "http://localhost:4001/graphql";
|
|
12
|
-
}
|
|
13
|
-
// Determine the appropriate Switchboard URL based on environment
|
|
14
|
-
if (baseURI.includes("-dev.")) {
|
|
15
|
-
return "https://switchboard-dev.powerhouse.xyz/graphql";
|
|
16
|
-
}
|
|
17
|
-
if (baseURI.includes("-staging.")) {
|
|
18
|
-
return "https://switchboard-staging.powerhouse.xyz/graphql";
|
|
19
|
-
}
|
|
20
|
-
// Production environment
|
|
21
|
-
return "https://switchboard.powerhouse.xyz/graphql";
|
|
22
|
-
}
|
|
23
|
-
async function graphqlRequest(query, variables, options) {
|
|
24
|
-
try {
|
|
25
|
-
const response = await fetch(getGraphQLUrl(), {
|
|
26
|
-
method: "POST",
|
|
27
|
-
headers: {
|
|
28
|
-
"Content-Type": "application/json",
|
|
29
|
-
},
|
|
30
|
-
body: JSON.stringify({ query, variables }),
|
|
31
|
-
});
|
|
32
|
-
if (!response.ok) {
|
|
33
|
-
if (!options?.silent) {
|
|
34
|
-
console.warn("[graphql-client] Request failed:", response.status, response.statusText);
|
|
35
|
-
}
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
const result = (await response.json());
|
|
39
|
-
// Return data even if there are errors - partial data might still be useful
|
|
40
|
-
// Only treat as full failure if there's no data at all
|
|
41
|
-
if (result.errors?.length && !result.data) {
|
|
42
|
-
if (!options?.silent) {
|
|
43
|
-
console.warn("[graphql-client] GraphQL errors:", result.errors);
|
|
44
|
-
}
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
return result.data ?? null;
|
|
48
|
-
}
|
|
49
|
-
catch (error) {
|
|
50
|
-
// Silently fail - this is a fallback mechanism
|
|
51
|
-
if (!options?.silent) {
|
|
52
|
-
console.warn("[graphql-client] Request error:", error);
|
|
53
|
-
}
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
// Query to get all available drives
|
|
58
|
-
const GET_DRIVES_QUERY = `
|
|
59
|
-
query GetDrives {
|
|
60
|
-
drives
|
|
61
|
-
}
|
|
62
|
-
`;
|
|
63
|
-
// Query to get drive ID by slug
|
|
64
|
-
const GET_DRIVE_ID_BY_SLUG_QUERY = `
|
|
65
|
-
query GetDriveIdBySlug($slug: String!) {
|
|
66
|
-
driveIdBySlug(slug: $slug)
|
|
67
|
-
}
|
|
68
|
-
`;
|
|
69
|
-
// Query to get builder profile documents from a drive
|
|
70
|
-
const GET_BUILDER_PROFILES_QUERY = `
|
|
71
|
-
query GetBuilderProfiles($driveId: String!) {
|
|
72
|
-
BuilderProfile {
|
|
73
|
-
getDocuments(driveId: $driveId) {
|
|
74
|
-
id
|
|
75
|
-
state {
|
|
76
|
-
name
|
|
77
|
-
slug
|
|
78
|
-
icon
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
`;
|
|
84
|
-
// Query to get a single builder profile by ID
|
|
85
|
-
const GET_BUILDER_PROFILE_QUERY = `
|
|
86
|
-
query GetBuilderProfile($docId: PHID!, $driveId: PHID) {
|
|
87
|
-
BuilderProfile {
|
|
88
|
-
getDocument(docId: $docId, driveId: $driveId) {
|
|
89
|
-
id
|
|
90
|
-
state {
|
|
91
|
-
name
|
|
92
|
-
slug
|
|
93
|
-
icon
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
`;
|
|
99
|
-
/**
|
|
100
|
-
* Fetches all available remote drives
|
|
101
|
-
*/
|
|
102
|
-
export async function fetchRemoteDrives() {
|
|
103
|
-
const data = await graphqlRequest(GET_DRIVES_QUERY);
|
|
104
|
-
return data?.drives ?? [];
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Fetches drive ID by slug
|
|
108
|
-
*/
|
|
109
|
-
export async function fetchDriveIdBySlug(slug) {
|
|
110
|
-
const data = await graphqlRequest(GET_DRIVE_ID_BY_SLUG_QUERY, { slug });
|
|
111
|
-
return data?.driveIdBySlug ?? null;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Fetches all builder profiles from a specific drive
|
|
115
|
-
*/
|
|
116
|
-
export async function fetchBuilderProfilesFromDrive(driveId, options) {
|
|
117
|
-
const data = await graphqlRequest(GET_BUILDER_PROFILES_QUERY, { driveId }, options);
|
|
118
|
-
return data?.BuilderProfile?.getDocuments ?? [];
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Fetches a single builder profile by document ID
|
|
122
|
-
*/
|
|
123
|
-
export async function fetchBuilderProfileById(docId, driveId) {
|
|
124
|
-
const data = await graphqlRequest(GET_BUILDER_PROFILE_QUERY, { docId, driveId });
|
|
125
|
-
return data?.BuilderProfile?.getDocument ?? null;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Fetches all builder profiles from all available remote drives.
|
|
129
|
-
* This aggregates profiles from multiple drives into a single list.
|
|
130
|
-
*/
|
|
131
|
-
export async function fetchAllRemoteBuilderProfiles() {
|
|
132
|
-
try {
|
|
133
|
-
const drives = await fetchRemoteDrives();
|
|
134
|
-
if (!drives.length) {
|
|
135
|
-
return [];
|
|
136
|
-
}
|
|
137
|
-
// Fetch profiles from all drives in parallel (silent to avoid console spam)
|
|
138
|
-
const profilePromises = drives.map((driveSlug) => fetchBuilderProfilesFromDrive(driveSlug, { silent: true }).catch(() => []));
|
|
139
|
-
const profileArrays = await Promise.all(profilePromises);
|
|
140
|
-
// Flatten and dedupe by ID
|
|
141
|
-
const profileMap = new Map();
|
|
142
|
-
for (const profiles of profileArrays) {
|
|
143
|
-
for (const profile of profiles) {
|
|
144
|
-
if (!profileMap.has(profile.id)) {
|
|
145
|
-
profileMap.set(profile.id, profile);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
return Array.from(profileMap.values());
|
|
150
|
-
}
|
|
151
|
-
catch {
|
|
152
|
-
return [];
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Fetches multiple builder profiles by their IDs.
|
|
157
|
-
* Tries to find them across all available remote drives.
|
|
158
|
-
*/
|
|
159
|
-
export async function fetchRemoteBuilderProfilesByIds(phids) {
|
|
160
|
-
if (!phids.length) {
|
|
161
|
-
return new Map();
|
|
162
|
-
}
|
|
163
|
-
try {
|
|
164
|
-
// First, get all profiles from all drives
|
|
165
|
-
const allProfiles = await fetchAllRemoteBuilderProfiles();
|
|
166
|
-
// Filter to only the ones we need
|
|
167
|
-
const result = new Map();
|
|
168
|
-
for (const profile of allProfiles) {
|
|
169
|
-
if (phids.includes(profile.id)) {
|
|
170
|
-
result.set(profile.id, profile);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
// For any missing profiles, try direct fetch
|
|
174
|
-
const missingPhids = phids.filter((phid) => !result.has(phid));
|
|
175
|
-
if (missingPhids.length > 0) {
|
|
176
|
-
const directFetches = missingPhids.map(async (phid) => {
|
|
177
|
-
const profile = await fetchBuilderProfileById(phid);
|
|
178
|
-
if (profile) {
|
|
179
|
-
result.set(phid, profile);
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
await Promise.all(directFetches);
|
|
183
|
-
}
|
|
184
|
-
return result;
|
|
185
|
-
}
|
|
186
|
-
catch {
|
|
187
|
-
return new Map();
|
|
188
|
-
}
|
|
189
|
-
}
|
|
5
|
+
export { fetchAllRemoteBuilderProfiles, fetchBuilderProfileById, fetchRemoteBuilderProfilesByIds, } from "../../utils/graphql-client.js";
|
|
@@ -1,81 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Re-exports from the shared GraphQL client.
|
|
3
|
+
* @deprecated Import directly from "../../utils/graphql-client.js" instead.
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
6
|
-
id: string;
|
|
7
|
-
state: {
|
|
8
|
-
name: string | null;
|
|
9
|
-
slug: string | null;
|
|
10
|
-
icon: string | null;
|
|
11
|
-
description: string | null;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Fetches a single builder profile by document ID
|
|
16
|
-
*/
|
|
17
|
-
export declare function fetchBuilderProfileById(docId: string): Promise<RemoteBuilderProfile | null>;
|
|
18
|
-
/**
|
|
19
|
-
* Fetches all builder profiles using BuilderProfile_findDocuments.
|
|
20
|
-
*/
|
|
21
|
-
export declare function fetchAllRemoteBuilderProfiles(): Promise<RemoteBuilderProfile[]>;
|
|
22
|
-
/**
|
|
23
|
-
* Fetches multiple builder profiles by their IDs.
|
|
24
|
-
*/
|
|
25
|
-
export declare function fetchRemoteBuilderProfilesByIds(phids: string[]): Promise<Map<string, RemoteBuilderProfile>>;
|
|
26
|
-
export interface SetOpHubMemberInput {
|
|
27
|
-
name: string | null;
|
|
28
|
-
phid: string | null;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Sets the operational hub member on a builder profile document.
|
|
32
|
-
*
|
|
33
|
-
* @param docId - The builder profile document ID (PHID)
|
|
34
|
-
* @param input - The operational hub member data (name and phid of the op hub)
|
|
35
|
-
* @returns true if successful, false otherwise
|
|
36
|
-
*/
|
|
37
|
-
export declare function setOpHubMemberOnBuilderProfile(docId: string, input: SetOpHubMemberInput): Promise<boolean>;
|
|
38
|
-
interface RemoteResourceTemplateService {
|
|
39
|
-
id: string;
|
|
40
|
-
title: string;
|
|
41
|
-
isSetupFormation: boolean;
|
|
42
|
-
description: string | null;
|
|
43
|
-
displayOrder: number | null;
|
|
44
|
-
optionGroupId: string | null;
|
|
45
|
-
}
|
|
46
|
-
export interface RemoteResourceTemplate {
|
|
47
|
-
id: string;
|
|
48
|
-
name: string | null;
|
|
49
|
-
operatorName?: string | null;
|
|
50
|
-
state: {
|
|
51
|
-
id: string | null;
|
|
52
|
-
operatorId: string | null;
|
|
53
|
-
title: string | null;
|
|
54
|
-
summary: string | null;
|
|
55
|
-
description: string | null;
|
|
56
|
-
thumbnailUrl: string | null;
|
|
57
|
-
infoLink: string | null;
|
|
58
|
-
status: string | null;
|
|
59
|
-
lastModified: string | null;
|
|
60
|
-
targetAudiences: Array<{
|
|
61
|
-
id: string;
|
|
62
|
-
label: string;
|
|
63
|
-
color: string | null;
|
|
64
|
-
}>;
|
|
65
|
-
setupServices: string[];
|
|
66
|
-
recurringServices: string[];
|
|
67
|
-
facetTargets: Array<{
|
|
68
|
-
id: string;
|
|
69
|
-
categoryKey: string;
|
|
70
|
-
categoryLabel: string;
|
|
71
|
-
selectedOptions: string[];
|
|
72
|
-
}>;
|
|
73
|
-
services: RemoteResourceTemplateService[];
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Fetches all resource template documents from the remote Switchboard.
|
|
78
|
-
*/
|
|
79
|
-
export declare function fetchAllRemoteResourceTemplates(): Promise<RemoteResourceTemplate[]>;
|
|
80
|
-
export {};
|
|
5
|
+
export { fetchAllRemoteBuilderProfiles, fetchBuilderProfileById, fetchRemoteBuilderProfilesByIds, setOpHubMemberOnBuilderProfile, fetchAllRemoteResourceTemplates, type RemoteBuilderProfile, type RemoteResourceTemplate, type SetOpHubMemberInput, } from "../../utils/graphql-client.js";
|
|
81
6
|
//# sourceMappingURL=graphql-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql-client.d.ts","sourceRoot":"","sources":["../../../../editors/service-offering-editor/utils/graphql-client.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"graphql-client.d.ts","sourceRoot":"","sources":["../../../../editors/service-offering-editor/utils/graphql-client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,6BAA6B,EAC7B,uBAAuB,EACvB,+BAA+B,EAC/B,8BAA8B,EAC9B,+BAA+B,EAC/B,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,GACzB,MAAM,+BAA+B,CAAC"}
|
|
@@ -1,266 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Re-exports from the shared GraphQL client.
|
|
3
|
+
* @deprecated Import directly from "../../utils/graphql-client.js" instead.
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
if (typeof window === "undefined") {
|
|
7
|
-
return "http://localhost:4001/graphql";
|
|
8
|
-
}
|
|
9
|
-
const baseURI = window.document.baseURI;
|
|
10
|
-
if (baseURI.includes("localhost")) {
|
|
11
|
-
return "http://localhost:4001/graphql";
|
|
12
|
-
}
|
|
13
|
-
// Determine the appropriate Switchboard URL based on environment
|
|
14
|
-
if (baseURI.includes("-dev.")) {
|
|
15
|
-
return "https://switchboard-dev.powerhouse.xyz/graphql";
|
|
16
|
-
}
|
|
17
|
-
if (baseURI.includes("-staging.")) {
|
|
18
|
-
return "https://switchboard-staging.powerhouse.xyz/graphql";
|
|
19
|
-
}
|
|
20
|
-
// Production environment
|
|
21
|
-
return "https://switchboard.powerhouse.xyz/graphql";
|
|
22
|
-
}
|
|
23
|
-
async function graphqlRequest(query, variables, options) {
|
|
24
|
-
try {
|
|
25
|
-
const response = await fetch(getGraphQLUrl(), {
|
|
26
|
-
method: "POST",
|
|
27
|
-
headers: {
|
|
28
|
-
"Content-Type": "application/json",
|
|
29
|
-
},
|
|
30
|
-
body: JSON.stringify({ query, variables }),
|
|
31
|
-
});
|
|
32
|
-
if (!response.ok) {
|
|
33
|
-
if (!options?.silent) {
|
|
34
|
-
console.warn("[graphql-client] Request failed:", response.status, response.statusText);
|
|
35
|
-
}
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
const result = (await response.json());
|
|
39
|
-
// Return data even if there are errors - partial data might still be useful
|
|
40
|
-
// Only treat as full failure if there's no data at all
|
|
41
|
-
if (result.errors?.length && !result.data) {
|
|
42
|
-
if (!options?.silent) {
|
|
43
|
-
console.warn("[graphql-client] GraphQL errors:", result.errors);
|
|
44
|
-
}
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
return result.data ?? null;
|
|
48
|
-
}
|
|
49
|
-
catch (error) {
|
|
50
|
-
// Silently fail - this is a fallback mechanism
|
|
51
|
-
if (!options?.silent) {
|
|
52
|
-
console.warn("[graphql-client] Request error:", error);
|
|
53
|
-
}
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
// Query to find all builder profile documents
|
|
58
|
-
const FIND_BUILDER_PROFILES_QUERY = `
|
|
59
|
-
query FindBuilderProfiles {
|
|
60
|
-
BuilderProfile_findDocuments(search: {}) {
|
|
61
|
-
items {
|
|
62
|
-
id
|
|
63
|
-
name
|
|
64
|
-
state {
|
|
65
|
-
global {
|
|
66
|
-
id
|
|
67
|
-
name
|
|
68
|
-
slug
|
|
69
|
-
icon
|
|
70
|
-
description
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
totalCount
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
`;
|
|
78
|
-
// Query to get a single builder profile by identifier
|
|
79
|
-
const GET_BUILDER_PROFILE_QUERY = `
|
|
80
|
-
query GetBuilderProfile($identifier: String!) {
|
|
81
|
-
BuilderProfile_document(identifier: $identifier) {
|
|
82
|
-
document {
|
|
83
|
-
id
|
|
84
|
-
name
|
|
85
|
-
state {
|
|
86
|
-
global {
|
|
87
|
-
id
|
|
88
|
-
name
|
|
89
|
-
slug
|
|
90
|
-
icon
|
|
91
|
-
description
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
`;
|
|
98
|
-
function toRemoteProfile(item) {
|
|
99
|
-
return {
|
|
100
|
-
id: item.id,
|
|
101
|
-
state: {
|
|
102
|
-
name: item.state.global.name,
|
|
103
|
-
slug: item.state.global.slug,
|
|
104
|
-
icon: item.state.global.icon,
|
|
105
|
-
description: item.state.global.description,
|
|
106
|
-
},
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Fetches a single builder profile by document ID
|
|
111
|
-
*/
|
|
112
|
-
export async function fetchBuilderProfileById(docId) {
|
|
113
|
-
const data = await graphqlRequest(GET_BUILDER_PROFILE_QUERY, { identifier: docId });
|
|
114
|
-
const item = data?.BuilderProfile_document?.document;
|
|
115
|
-
return item ? toRemoteProfile(item) : null;
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Fetches all builder profiles using BuilderProfile_findDocuments.
|
|
119
|
-
*/
|
|
120
|
-
export async function fetchAllRemoteBuilderProfiles() {
|
|
121
|
-
try {
|
|
122
|
-
const data = await graphqlRequest(FIND_BUILDER_PROFILES_QUERY);
|
|
123
|
-
const items = data?.BuilderProfile_findDocuments?.items ?? [];
|
|
124
|
-
return items.map(toRemoteProfile);
|
|
125
|
-
}
|
|
126
|
-
catch {
|
|
127
|
-
return [];
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Fetches multiple builder profiles by their IDs.
|
|
132
|
-
*/
|
|
133
|
-
export async function fetchRemoteBuilderProfilesByIds(phids) {
|
|
134
|
-
if (!phids.length) {
|
|
135
|
-
return new Map();
|
|
136
|
-
}
|
|
137
|
-
try {
|
|
138
|
-
const allProfiles = await fetchAllRemoteBuilderProfiles();
|
|
139
|
-
const result = new Map();
|
|
140
|
-
for (const profile of allProfiles) {
|
|
141
|
-
if (phids.includes(profile.id)) {
|
|
142
|
-
result.set(profile.id, profile);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
// For any missing profiles, try direct fetch
|
|
146
|
-
const missingPhids = phids.filter((phid) => !result.has(phid));
|
|
147
|
-
if (missingPhids.length > 0) {
|
|
148
|
-
const directFetches = missingPhids.map(async (phid) => {
|
|
149
|
-
const profile = await fetchBuilderProfileById(phid);
|
|
150
|
-
if (profile) {
|
|
151
|
-
result.set(phid, profile);
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
await Promise.all(directFetches);
|
|
155
|
-
}
|
|
156
|
-
return result;
|
|
157
|
-
}
|
|
158
|
-
catch {
|
|
159
|
-
return new Map();
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
// Mutation to set operational hub member on a builder profile
|
|
163
|
-
const SET_OP_HUB_MEMBER_MUTATION = `
|
|
164
|
-
mutation BuilderProfile_setOpHubMember($docId: PHID!, $input: BuilderProfile_SetOpHubMemberInput!) {
|
|
165
|
-
BuilderProfile_setOpHubMember(docId: $docId, input: $input)
|
|
166
|
-
}
|
|
167
|
-
`;
|
|
168
|
-
/**
|
|
169
|
-
* Sets the operational hub member on a builder profile document.
|
|
170
|
-
*
|
|
171
|
-
* @param docId - The builder profile document ID (PHID)
|
|
172
|
-
* @param input - The operational hub member data (name and phid of the op hub)
|
|
173
|
-
* @returns true if successful, false otherwise
|
|
174
|
-
*/
|
|
175
|
-
export async function setOpHubMemberOnBuilderProfile(docId, input) {
|
|
176
|
-
try {
|
|
177
|
-
const data = await graphqlRequest(SET_OP_HUB_MEMBER_MUTATION, { docId, input });
|
|
178
|
-
return data?.BuilderProfile_setOpHubMember ?? false;
|
|
179
|
-
}
|
|
180
|
-
catch (error) {
|
|
181
|
-
console.warn("[graphql-client] Failed to set op hub member:", error);
|
|
182
|
-
return false;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
// ── Resource Template queries ──
|
|
186
|
-
const FIND_RESOURCE_TEMPLATES_QUERY = `
|
|
187
|
-
query FindResourceTemplates {
|
|
188
|
-
ResourceTemplate_findDocuments(search: {}) {
|
|
189
|
-
items {
|
|
190
|
-
id
|
|
191
|
-
name
|
|
192
|
-
state {
|
|
193
|
-
global {
|
|
194
|
-
id
|
|
195
|
-
operatorId
|
|
196
|
-
title
|
|
197
|
-
summary
|
|
198
|
-
description
|
|
199
|
-
thumbnailUrl
|
|
200
|
-
infoLink
|
|
201
|
-
status
|
|
202
|
-
lastModified
|
|
203
|
-
targetAudiences {
|
|
204
|
-
id
|
|
205
|
-
label
|
|
206
|
-
color
|
|
207
|
-
}
|
|
208
|
-
setupServices
|
|
209
|
-
recurringServices
|
|
210
|
-
facetTargets {
|
|
211
|
-
id
|
|
212
|
-
categoryKey
|
|
213
|
-
categoryLabel
|
|
214
|
-
selectedOptions
|
|
215
|
-
}
|
|
216
|
-
services {
|
|
217
|
-
id
|
|
218
|
-
title
|
|
219
|
-
isSetupFormation
|
|
220
|
-
description
|
|
221
|
-
displayOrder
|
|
222
|
-
optionGroupId
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
totalCount
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
`;
|
|
231
|
-
function toRemoteResourceTemplate(item) {
|
|
232
|
-
const g = item.state.global;
|
|
233
|
-
return {
|
|
234
|
-
id: item.id,
|
|
235
|
-
name: item.name,
|
|
236
|
-
state: {
|
|
237
|
-
id: g.id,
|
|
238
|
-
operatorId: g.operatorId,
|
|
239
|
-
title: g.title,
|
|
240
|
-
summary: g.summary,
|
|
241
|
-
description: g.description,
|
|
242
|
-
thumbnailUrl: g.thumbnailUrl,
|
|
243
|
-
infoLink: g.infoLink,
|
|
244
|
-
status: g.status,
|
|
245
|
-
lastModified: g.lastModified,
|
|
246
|
-
targetAudiences: g.targetAudiences ?? [],
|
|
247
|
-
setupServices: g.setupServices ?? [],
|
|
248
|
-
recurringServices: g.recurringServices ?? [],
|
|
249
|
-
facetTargets: g.facetTargets ?? [],
|
|
250
|
-
services: g.services ?? [],
|
|
251
|
-
},
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* Fetches all resource template documents from the remote Switchboard.
|
|
256
|
-
*/
|
|
257
|
-
export async function fetchAllRemoteResourceTemplates() {
|
|
258
|
-
try {
|
|
259
|
-
const data = await graphqlRequest(FIND_RESOURCE_TEMPLATES_QUERY, undefined, { silent: true });
|
|
260
|
-
const items = data?.ResourceTemplate_findDocuments?.items ?? [];
|
|
261
|
-
return items.map(toRemoteResourceTemplate);
|
|
262
|
-
}
|
|
263
|
-
catch {
|
|
264
|
-
return [];
|
|
265
|
-
}
|
|
266
|
-
}
|
|
5
|
+
export { fetchAllRemoteBuilderProfiles, fetchBuilderProfileById, fetchRemoteBuilderProfilesByIds, setOpHubMemberOnBuilderProfile, fetchAllRemoteResourceTemplates, } from "../../utils/graphql-client.js";
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared GraphQL client for fetching data from the Reactor API.
|
|
3
|
+
* All editors should import from this module instead of maintaining their own copies.
|
|
4
|
+
*/
|
|
5
|
+
export declare function graphqlRequest<T>(query: string, variables?: Record<string, unknown>, options?: {
|
|
6
|
+
silent?: boolean;
|
|
7
|
+
}): Promise<T | null>;
|
|
8
|
+
export interface FindDocumentsItem {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
state: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
export declare function getGlobalState(state: Record<string, unknown>): Record<string, unknown>;
|
|
14
|
+
export declare function findDocuments(type: string, options?: {
|
|
15
|
+
silent?: boolean;
|
|
16
|
+
}): Promise<FindDocumentsItem[]>;
|
|
17
|
+
export declare function getDocument(identifier: string): Promise<FindDocumentsItem | null>;
|
|
18
|
+
export declare function mutateDocument(documentIdentifier: string, actions: Array<{
|
|
19
|
+
type: string;
|
|
20
|
+
input: unknown;
|
|
21
|
+
scope: string;
|
|
22
|
+
}>): Promise<{
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
} | null>;
|
|
26
|
+
export interface RemoteBuilderProfile {
|
|
27
|
+
id: string;
|
|
28
|
+
state: {
|
|
29
|
+
name: string | null;
|
|
30
|
+
slug: string | null;
|
|
31
|
+
icon: string | null;
|
|
32
|
+
description?: string | null;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export declare function fetchBuilderProfileById(docId: string): Promise<RemoteBuilderProfile | null>;
|
|
36
|
+
export declare function fetchAllRemoteBuilderProfiles(): Promise<RemoteBuilderProfile[]>;
|
|
37
|
+
export declare function fetchRemoteBuilderProfilesByIds(phids: string[]): Promise<Map<string, RemoteBuilderProfile>>;
|
|
38
|
+
interface RemoteResourceTemplateService {
|
|
39
|
+
id: string;
|
|
40
|
+
title: string;
|
|
41
|
+
isSetupFormation: boolean;
|
|
42
|
+
description: string | null;
|
|
43
|
+
displayOrder: number | null;
|
|
44
|
+
optionGroupId: string | null;
|
|
45
|
+
}
|
|
46
|
+
export interface RemoteResourceTemplate {
|
|
47
|
+
id: string;
|
|
48
|
+
name: string | null;
|
|
49
|
+
operatorName?: string | null;
|
|
50
|
+
state: {
|
|
51
|
+
id: string | null;
|
|
52
|
+
operatorId: string | null;
|
|
53
|
+
title: string | null;
|
|
54
|
+
summary: string | null;
|
|
55
|
+
description: string | null;
|
|
56
|
+
thumbnailUrl: string | null;
|
|
57
|
+
infoLink: string | null;
|
|
58
|
+
status: string | null;
|
|
59
|
+
lastModified: string | null;
|
|
60
|
+
targetAudiences: Array<{
|
|
61
|
+
id: string;
|
|
62
|
+
label: string;
|
|
63
|
+
color: string | null;
|
|
64
|
+
}>;
|
|
65
|
+
setupServices: string[];
|
|
66
|
+
recurringServices: string[];
|
|
67
|
+
facetTargets: Array<{
|
|
68
|
+
id: string;
|
|
69
|
+
categoryKey: string;
|
|
70
|
+
categoryLabel: string;
|
|
71
|
+
selectedOptions: string[];
|
|
72
|
+
}>;
|
|
73
|
+
services: RemoteResourceTemplateService[];
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
export declare function fetchAllRemoteResourceTemplates(): Promise<RemoteResourceTemplate[]>;
|
|
77
|
+
export interface SetOpHubMemberInput {
|
|
78
|
+
name: string | null;
|
|
79
|
+
phid: string | null;
|
|
80
|
+
}
|
|
81
|
+
export declare function setOpHubMemberOnBuilderProfile(docId: string, input: SetOpHubMemberInput): Promise<boolean>;
|
|
82
|
+
export {};
|
|
83
|
+
//# sourceMappingURL=graphql-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql-client.d.ts","sourceRoot":"","sources":["../../../editors/utils/graphql-client.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared GraphQL client for fetching data from the Reactor API.
|
|
3
|
+
* All editors should import from this module instead of maintaining their own copies.
|
|
4
|
+
*/
|
|
5
|
+
// ── URL resolution ──
|
|
6
|
+
function getGraphQLUrl() {
|
|
7
|
+
if (typeof window === "undefined") {
|
|
8
|
+
return "http://localhost:4001/graphql";
|
|
9
|
+
}
|
|
10
|
+
const baseURI = window.document.baseURI;
|
|
11
|
+
if (baseURI.includes("localhost")) {
|
|
12
|
+
return "http://localhost:4001/graphql";
|
|
13
|
+
}
|
|
14
|
+
if (baseURI.includes("-dev.")) {
|
|
15
|
+
return "https://switchboard-dev.powerhouse.xyz/graphql";
|
|
16
|
+
}
|
|
17
|
+
if (baseURI.includes("-staging.")) {
|
|
18
|
+
return "https://switchboard-staging.powerhouse.xyz/graphql";
|
|
19
|
+
}
|
|
20
|
+
return "https://switchboard.powerhouse.xyz/graphql";
|
|
21
|
+
}
|
|
22
|
+
export async function graphqlRequest(query, variables, options) {
|
|
23
|
+
try {
|
|
24
|
+
const response = await fetch(getGraphQLUrl(), {
|
|
25
|
+
method: "POST",
|
|
26
|
+
headers: { "Content-Type": "application/json" },
|
|
27
|
+
body: JSON.stringify({ query, variables }),
|
|
28
|
+
});
|
|
29
|
+
if (!response.ok) {
|
|
30
|
+
if (!options?.silent) {
|
|
31
|
+
console.warn("[graphql-client] Request failed:", response.status, response.statusText);
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
const result = (await response.json());
|
|
36
|
+
if (result.errors?.length && !result.data) {
|
|
37
|
+
if (!options?.silent) {
|
|
38
|
+
console.warn("[graphql-client] GraphQL errors:", result.errors);
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
return result.data ?? null;
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
if (!options?.silent) {
|
|
46
|
+
console.warn("[graphql-client] Request error:", error);
|
|
47
|
+
}
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// ── Helpers ──
|
|
52
|
+
export function getGlobalState(state) {
|
|
53
|
+
if (state && typeof state === "object" && "global" in state) {
|
|
54
|
+
return state.global;
|
|
55
|
+
}
|
|
56
|
+
return state;
|
|
57
|
+
}
|
|
58
|
+
// ── Generic queries ──
|
|
59
|
+
const FIND_DOCUMENTS_QUERY = `
|
|
60
|
+
query FindDocuments($type: String!) {
|
|
61
|
+
findDocuments(search: { type: $type }) {
|
|
62
|
+
items { id name state }
|
|
63
|
+
totalCount
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
`;
|
|
67
|
+
const GET_DOCUMENT_QUERY = `
|
|
68
|
+
query GetDocument($identifier: String!) {
|
|
69
|
+
document(identifier: $identifier) {
|
|
70
|
+
document { id name state }
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
`;
|
|
74
|
+
const MUTATE_DOCUMENT_MUTATION = `
|
|
75
|
+
mutation MutateDocument($documentIdentifier: String!, $actions: [JSONObject!]!) {
|
|
76
|
+
mutateDocument(documentIdentifier: $documentIdentifier, actions: $actions) {
|
|
77
|
+
id
|
|
78
|
+
name
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
`;
|
|
82
|
+
export async function findDocuments(type, options) {
|
|
83
|
+
const data = await graphqlRequest(FIND_DOCUMENTS_QUERY, { type }, options);
|
|
84
|
+
return data?.findDocuments?.items ?? [];
|
|
85
|
+
}
|
|
86
|
+
export async function getDocument(identifier) {
|
|
87
|
+
const data = await graphqlRequest(GET_DOCUMENT_QUERY, { identifier });
|
|
88
|
+
return data?.document?.document ?? null;
|
|
89
|
+
}
|
|
90
|
+
export async function mutateDocument(documentIdentifier, actions) {
|
|
91
|
+
const data = await graphqlRequest(MUTATE_DOCUMENT_MUTATION, { documentIdentifier, actions });
|
|
92
|
+
return data?.mutateDocument ?? null;
|
|
93
|
+
}
|
|
94
|
+
function toRemoteProfile(item, includeDescription = false) {
|
|
95
|
+
const global = getGlobalState(item.state);
|
|
96
|
+
const profile = {
|
|
97
|
+
id: item.id,
|
|
98
|
+
state: {
|
|
99
|
+
name: global.name ?? null,
|
|
100
|
+
slug: global.slug ?? null,
|
|
101
|
+
icon: global.icon ?? null,
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
if (includeDescription) {
|
|
105
|
+
profile.state.description = global.description ?? null;
|
|
106
|
+
}
|
|
107
|
+
return profile;
|
|
108
|
+
}
|
|
109
|
+
export async function fetchBuilderProfileById(docId) {
|
|
110
|
+
const item = await getDocument(docId);
|
|
111
|
+
return item ? toRemoteProfile(item, true) : null;
|
|
112
|
+
}
|
|
113
|
+
export async function fetchAllRemoteBuilderProfiles() {
|
|
114
|
+
try {
|
|
115
|
+
const items = await findDocuments("powerhouse/builder-profile");
|
|
116
|
+
return items.map((item) => toRemoteProfile(item, true));
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
return [];
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
export async function fetchRemoteBuilderProfilesByIds(phids) {
|
|
123
|
+
if (!phids.length) {
|
|
124
|
+
return new Map();
|
|
125
|
+
}
|
|
126
|
+
try {
|
|
127
|
+
const allProfiles = await fetchAllRemoteBuilderProfiles();
|
|
128
|
+
const result = new Map();
|
|
129
|
+
for (const profile of allProfiles) {
|
|
130
|
+
if (phids.includes(profile.id)) {
|
|
131
|
+
result.set(profile.id, profile);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const missingPhids = phids.filter((phid) => !result.has(phid));
|
|
135
|
+
if (missingPhids.length > 0) {
|
|
136
|
+
const directFetches = missingPhids.map(async (phid) => {
|
|
137
|
+
const profile = await fetchBuilderProfileById(phid);
|
|
138
|
+
if (profile) {
|
|
139
|
+
result.set(phid, profile);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
await Promise.all(directFetches);
|
|
143
|
+
}
|
|
144
|
+
return result;
|
|
145
|
+
}
|
|
146
|
+
catch {
|
|
147
|
+
return new Map();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
function toRemoteResourceTemplate(item) {
|
|
151
|
+
const g = getGlobalState(item.state);
|
|
152
|
+
return {
|
|
153
|
+
id: item.id,
|
|
154
|
+
name: item.name,
|
|
155
|
+
state: {
|
|
156
|
+
id: g.id ?? null,
|
|
157
|
+
operatorId: g.operatorId ?? null,
|
|
158
|
+
title: g.title ?? null,
|
|
159
|
+
summary: g.summary ?? null,
|
|
160
|
+
description: g.description ?? null,
|
|
161
|
+
thumbnailUrl: g.thumbnailUrl ?? null,
|
|
162
|
+
infoLink: g.infoLink ?? null,
|
|
163
|
+
status: g.status ?? null,
|
|
164
|
+
lastModified: g.lastModified ?? null,
|
|
165
|
+
targetAudiences: g.targetAudiences ??
|
|
166
|
+
[],
|
|
167
|
+
setupServices: g.setupServices ?? [],
|
|
168
|
+
recurringServices: g.recurringServices ?? [],
|
|
169
|
+
facetTargets: g.facetTargets ??
|
|
170
|
+
[],
|
|
171
|
+
services: g.services ?? [],
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
export async function fetchAllRemoteResourceTemplates() {
|
|
176
|
+
try {
|
|
177
|
+
const items = await findDocuments("powerhouse/resource-template", {
|
|
178
|
+
silent: true,
|
|
179
|
+
});
|
|
180
|
+
return items.map(toRemoteResourceTemplate);
|
|
181
|
+
}
|
|
182
|
+
catch {
|
|
183
|
+
return [];
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
export async function setOpHubMemberOnBuilderProfile(docId, input) {
|
|
187
|
+
try {
|
|
188
|
+
const result = await mutateDocument(docId, [
|
|
189
|
+
{ type: "SET_OP_HUB_MEMBER", input, scope: "global" },
|
|
190
|
+
]);
|
|
191
|
+
return result !== null;
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
console.warn("[graphql-client] Failed to set op hub member:", error);
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
}
|
package/dist/style.css
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerhousedao/service-offering",
|
|
3
3
|
"description": "service offering document models",
|
|
4
|
-
"version": "1.0.0-dev.
|
|
4
|
+
"version": "1.0.0-dev.20",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"./style.css": "./dist/style.css"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
|
58
|
-
"build": "
|
|
59
|
-
"copy-
|
|
58
|
+
"build": "bun run tsc && bun run tailwind && bun run copy-assets",
|
|
59
|
+
"copy-assets": "mkdir -p dist/editors/service-offering-editor && cp editors/service-offering-editor/editor.css dist/editors/service-offering-editor/editor.css",
|
|
60
60
|
"test": "vitest run",
|
|
61
61
|
"test:watch": "vitest",
|
|
62
62
|
"lint": "eslint --config eslint.config.js --cache --cache-strategy content",
|
|
@@ -76,59 +76,47 @@
|
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
78
|
"@electric-sql/pglite": "0.3.15",
|
|
79
|
-
"@powerhousedao/builder-tools": "6.0.0-
|
|
80
|
-
"@powerhousedao/common": "6.0.0-
|
|
81
|
-
"@powerhousedao/design-system": "6.0.0-
|
|
79
|
+
"@powerhousedao/builder-tools": "6.0.0-dev.104",
|
|
80
|
+
"@powerhousedao/common": "6.0.0-dev.104",
|
|
81
|
+
"@powerhousedao/design-system": "6.0.0-dev.104",
|
|
82
82
|
"@powerhousedao/document-engineering": "1.40.1",
|
|
83
|
-
"@powerhousedao/vetra": "6.0.0-
|
|
84
|
-
"@tailwindcss/vite": "^4.2.1",
|
|
83
|
+
"@powerhousedao/vetra": "6.0.0-dev.104",
|
|
85
84
|
"@uiw/react-md-editor": "^4.0.11",
|
|
86
|
-
"
|
|
87
|
-
"document-model": "6.0.0-staging.0",
|
|
85
|
+
"document-model": "6.0.0-dev.104",
|
|
88
86
|
"graphql": "16.12.0",
|
|
89
87
|
"graphql-tag": "^2.12.6",
|
|
90
88
|
"lucide-react": "^0.577.0",
|
|
91
89
|
"rehype-slug": "^6.0.0",
|
|
92
|
-
"vite-plugin-html": "^3.2.2",
|
|
93
|
-
"vite-plugin-svgr": "^4.5.0",
|
|
94
90
|
"zod": "^4.3.5"
|
|
95
91
|
},
|
|
96
92
|
"devDependencies": {
|
|
97
93
|
"@eslint/js": "^9.38.0",
|
|
98
|
-
"@openfeature/web-sdk": "^1.7.3",
|
|
99
|
-
"@powerhousedao/analytics-engine-core": "6.0.0-staging.0",
|
|
100
|
-
"@powerhousedao/config": "6.0.0-staging.0",
|
|
101
|
-
"@powerhousedao/connect": "6.0.0-staging.0",
|
|
102
|
-
"@powerhousedao/ph-cli": "6.0.0-staging.0",
|
|
103
|
-
"@powerhousedao/reactor-api": "6.0.0-staging.0",
|
|
104
|
-
"@powerhousedao/reactor-browser": "6.0.0-staging.0",
|
|
105
|
-
"@powerhousedao/reactor-local": "6.0.0-staging.0",
|
|
106
|
-
"@powerhousedao/switchboard": "6.0.0-staging.0",
|
|
107
94
|
"@semantic-release/changelog": "^6.0.3",
|
|
108
95
|
"@semantic-release/git": "^10.0.1",
|
|
109
|
-
"@
|
|
96
|
+
"@powerhousedao/analytics-engine-core": "6.0.0-dev.104",
|
|
97
|
+
"@powerhousedao/config": "6.0.0-dev.104",
|
|
98
|
+
"@powerhousedao/connect": "6.0.0-dev.104",
|
|
99
|
+
"@powerhousedao/ph-cli": "6.0.0-dev.104",
|
|
100
|
+
"@powerhousedao/reactor-api": "6.0.0-dev.104",
|
|
101
|
+
"@powerhousedao/reactor-browser": "6.0.0-dev.104",
|
|
102
|
+
"@powerhousedao/reactor-local": "6.0.0-dev.104",
|
|
103
|
+
"@powerhousedao/switchboard": "6.0.0-dev.104",
|
|
110
104
|
"@tailwindcss/cli": "^4.1.4",
|
|
111
105
|
"@testing-library/react": "^16.3.0",
|
|
112
106
|
"@types/node": "^24.9.2",
|
|
113
107
|
"@types/react": "^19.2.3",
|
|
114
108
|
"@vitejs/plugin-react": "^5.1.0",
|
|
115
|
-
"document-drive": "6.0.0-
|
|
109
|
+
"document-drive": "6.0.0-dev.104",
|
|
116
110
|
"eslint": "^9.38.0",
|
|
117
111
|
"eslint-config-prettier": "^10.1.8",
|
|
118
112
|
"eslint-plugin-prettier": "^5.5.4",
|
|
119
113
|
"eslint-plugin-react": "^7.37.5",
|
|
120
114
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
121
115
|
"globals": "^16.4.0",
|
|
122
|
-
"i18next": "^25.5.2",
|
|
123
116
|
"package-manager-detector": "^0.2.8",
|
|
124
117
|
"pm2": "^5.4.3",
|
|
125
|
-
"react": "^19.2.
|
|
118
|
+
"react": "^19.2.3",
|
|
126
119
|
"react-dom": "^19.2.3",
|
|
127
|
-
"react-error-boundary": "^6.0.0",
|
|
128
|
-
"react-hotkeys-hook": "^5.1.0",
|
|
129
|
-
"react-i18next": "^16.0.0",
|
|
130
|
-
"react-router-dom": "^7.9.3",
|
|
131
|
-
"semantic-release": "^25.0.3",
|
|
132
120
|
"tailwindcss": "^4.1.16",
|
|
133
121
|
"typescript": "^5.9.3",
|
|
134
122
|
"typescript-eslint": "^8.46.2",
|
|
@@ -137,7 +125,7 @@
|
|
|
137
125
|
"vitest": "^3.0.9"
|
|
138
126
|
},
|
|
139
127
|
"overrides": {
|
|
140
|
-
"graphql": "
|
|
128
|
+
"graphql": "$graphql"
|
|
141
129
|
},
|
|
142
130
|
"peerDependencies": {
|
|
143
131
|
"react": ">=19.0.0",
|