@powerhousedao/vetra-builder-package 0.0.19 → 0.0.21

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.
Files changed (61) hide show
  1. package/dist/document-models/builder-team/gen/document-model.js +40 -18
  2. package/dist/document-models/builder-team/gen/packages/actions.d.ts +6 -2
  3. package/dist/document-models/builder-team/gen/packages/creators.d.ts +3 -2
  4. package/dist/document-models/builder-team/gen/packages/creators.js +1 -0
  5. package/dist/document-models/builder-team/gen/packages/object.d.ts +2 -1
  6. package/dist/document-models/builder-team/gen/packages/object.js +4 -1
  7. package/dist/document-models/builder-team/gen/packages/operations.d.ts +2 -1
  8. package/dist/document-models/builder-team/gen/reducer.js +8 -0
  9. package/dist/document-models/builder-team/gen/schema/types.d.ts +9 -14
  10. package/dist/document-models/builder-team/gen/schema/zod.d.ts +3 -1
  11. package/dist/document-models/builder-team/gen/schema/zod.js +13 -0
  12. package/dist/document-models/builder-team/gen/spaces/actions.d.ts +6 -2
  13. package/dist/document-models/builder-team/gen/spaces/creators.d.ts +3 -2
  14. package/dist/document-models/builder-team/gen/spaces/creators.js +1 -0
  15. package/dist/document-models/builder-team/gen/spaces/object.d.ts +2 -1
  16. package/dist/document-models/builder-team/gen/spaces/object.js +4 -1
  17. package/dist/document-models/builder-team/gen/spaces/operations.d.ts +2 -1
  18. package/dist/document-models/builder-team/index.d.ts +2 -0
  19. package/dist/document-models/builder-team/src/reducers/packages.js +21 -0
  20. package/dist/document-models/builder-team/src/reducers/spaces.js +16 -0
  21. package/dist/editors/builder-team-editor/components/Header.js +2 -2
  22. package/dist/editors/builder-team-editor/components/MembersSection.d.ts +1 -6
  23. package/dist/editors/builder-team-editor/components/MembersSection.js +39 -111
  24. package/dist/editors/builder-team-editor/components/PackageForm.js +7 -75
  25. package/dist/editors/builder-team-editor/components/PackageItem.js +28 -85
  26. package/dist/editors/builder-team-editor/components/PackagesTable.d.ts +9 -0
  27. package/dist/editors/builder-team-editor/components/PackagesTable.js +80 -0
  28. package/dist/editors/builder-team-editor/components/ProfileSection.js +2 -2
  29. package/dist/editors/builder-team-editor/components/QuickStats.js +2 -1
  30. package/dist/editors/builder-team-editor/components/SpaceForm.js +1 -1
  31. package/dist/editors/builder-team-editor/components/SpaceItem.d.ts +2 -1
  32. package/dist/editors/builder-team-editor/components/SpaceItem.js +5 -4
  33. package/dist/editors/builder-team-editor/components/SpacesSection.d.ts +3 -1
  34. package/dist/editors/builder-team-editor/components/SpacesSection.js +19 -3
  35. package/dist/editors/builder-team-editor/components/SpacesTable.d.ts +11 -0
  36. package/dist/editors/builder-team-editor/components/SpacesTable.js +71 -0
  37. package/dist/editors/builder-team-editor/config.d.ts +1 -0
  38. package/dist/editors/builder-team-editor/config.js +22 -5
  39. package/dist/editors/builder-team-editor/editor.js +7 -1
  40. package/dist/editors/builder-team-editor/hooks/usePackageHandlers.js +0 -1
  41. package/dist/editors/builder-team-editor/services/renown-api.d.ts +21 -0
  42. package/dist/editors/builder-team-editor/services/renown-api.js +63 -0
  43. package/dist/editors/builder-team-editor/services/vetra-api.d.ts +31 -0
  44. package/dist/editors/builder-team-editor/services/vetra-api.js +70 -0
  45. package/dist/editors/builder-team-editor/types/index.d.ts +33 -0
  46. package/dist/editors/builder-team-editor/types/index.js +1 -0
  47. package/dist/editors/builder-team-editor/utils/format.d.ts +7 -0
  48. package/dist/editors/builder-team-editor/utils/format.js +13 -0
  49. package/dist/editors/builder-team-editor/utils/graphql.d.ts +7 -0
  50. package/dist/editors/builder-team-editor/utils/graphql.js +55 -0
  51. package/dist/powerhouse.manifest.json +3 -3
  52. package/dist/processors/vetra-builder-relational-db-processor/builder-team-handlers.d.ts +2 -0
  53. package/dist/processors/vetra-builder-relational-db-processor/builder-team-handlers.js +65 -40
  54. package/dist/processors/vetra-builder-relational-db-processor/factory.js +0 -1
  55. package/dist/processors/vetra-builder-relational-db-processor/index.js +0 -1
  56. package/dist/style.css +302 -28
  57. package/dist/subgraphs/builder-team/resolvers.js +48 -4
  58. package/dist/subgraphs/builder-team/schema.js +21 -14
  59. package/dist/subgraphs/vetra-builders/resolvers.js +34 -11
  60. package/dist/subgraphs/vetra-builders/schema.js +2 -14
  61. package/package.json +1 -1
@@ -41,9 +41,9 @@ export class BuilderTeamHandlers {
41
41
  case "UPDATE_SPACE_INFO":
42
42
  await this.handleUpdateSpaceInfo(documentId, action, state);
43
43
  break;
44
- // case "REORDER_SPACES":
45
- // await this.handleReorderSpaces(documentId, action, state);
46
- // break;
44
+ case "REORDER_SPACES":
45
+ await this.handleReorderSpaces(documentId, action, state);
46
+ break;
47
47
  // Packages operations
48
48
  case "ADD_PACKAGE":
49
49
  await this.handleAddPackage(documentId, action, state);
@@ -54,6 +54,9 @@ export class BuilderTeamHandlers {
54
54
  case "UPDATE_PACKAGE_INFO":
55
55
  await this.handleUpdatePackageInfo(documentId, action, state);
56
56
  break;
57
+ case "REORDER_PACKAGES":
58
+ await this.handleReorderPackages(documentId, action, state);
59
+ break;
57
60
  }
58
61
  }
59
62
  // Profile operations
@@ -119,6 +122,9 @@ export class BuilderTeamHandlers {
119
122
  // Spaces operations
120
123
  async handleAddSpace(documentId, action, state) {
121
124
  await this.dbHelpers.ensureBuilderAccountExistsAndIsNotdeleted(documentId);
125
+ // Find the space in state to get its sortOrder
126
+ const space = state.spaces.find(s => s.id === action.input.id);
127
+ const sortOrder = space?.sortOrder ?? 0;
122
128
  await this.db
123
129
  .insertInto("builder_team_spaces")
124
130
  .values({
@@ -126,7 +132,7 @@ export class BuilderTeamHandlers {
126
132
  builder_team_id: documentId,
127
133
  title: "",
128
134
  description: "",
129
- sort_order: 0,
135
+ sort_order: sortOrder,
130
136
  created_at: new Date(),
131
137
  updated_at: new Date(),
132
138
  })
@@ -154,22 +160,25 @@ export class BuilderTeamHandlers {
154
160
  await this.dbHelpers.updateBuilderSpace(action.input.id, documentId, updates);
155
161
  }
156
162
  }
157
- // private async handleReorderSpaces(
158
- // documentId: string,
159
- // action: ReorderSpacesAction,
160
- // state: BuilderAccountState
161
- // ): Promise<void> {
162
- // const { ids, insertAfter } = action.input;
163
- // for (let i = 0; i < ids.length; i++) {
164
- // const spaceId = ids[i];
165
- // const sortOrder = insertAfter !== null ? Number(insertAfter) + i + 1 : i;
166
- // await this.dbHelpers.updateBuilderSpace(spaceId, documentId, {
167
- // sort_order: sortOrder,
168
- // });
169
- // }
170
- // }
163
+ async handleReorderSpaces(documentId, action, state) {
164
+ // Update sortOrder for all spaces based on the state
165
+ for (const space of state.spaces) {
166
+ await this.dbHelpers.updateBuilderSpace(space.id, documentId, {
167
+ sort_order: space.sortOrder,
168
+ });
169
+ }
170
+ }
171
171
  // Packages operations
172
172
  async handleAddPackage(documentId, action, state) {
173
+ // Find the package in state to get its sortOrder
174
+ let sortOrder = 0;
175
+ for (const space of state.spaces) {
176
+ const pkg = space.packages.find(p => p.id === action.input.id);
177
+ if (pkg) {
178
+ sortOrder = pkg.sortOrder ?? 0;
179
+ break;
180
+ }
181
+ }
173
182
  await this.db
174
183
  .insertInto("builder_team_packages")
175
184
  .values({
@@ -184,7 +193,7 @@ export class BuilderTeamHandlers {
184
193
  npm_url: "",
185
194
  vetra_drive_url: "",
186
195
  drive_id: "",
187
- sort_order: 0,
196
+ sort_order: sortOrder,
188
197
  created_at: new Date(),
189
198
  updated_at: new Date(),
190
199
  })
@@ -207,6 +216,15 @@ export class BuilderTeamHandlers {
207
216
  }
208
217
  async handleUpdatePackageInfo(documentId, action, state) {
209
218
  const updates = {};
219
+ // Find the package in the state to get additional information
220
+ let packageFromState = null;
221
+ for (const space of state.spaces) {
222
+ const pkg = space.packages.find(p => p.id === action.input.id);
223
+ if (pkg) {
224
+ packageFromState = pkg;
225
+ break;
226
+ }
227
+ }
210
228
  // Map input fields to database columns, only include provided fields
211
229
  if (action.input.title !== undefined) {
212
230
  updates.title = action.input.title;
@@ -226,32 +244,39 @@ export class BuilderTeamHandlers {
226
244
  if (action.input.spaceId !== undefined) {
227
245
  updates.space_id = action.input.spaceId;
228
246
  }
229
- // Note: phid is not stored in the packages table, and id is the WHERE condition
247
+ // If we found the package in state and phid is available, store it
248
+ if (packageFromState?.phid) {
249
+ updates.drive_id = packageFromState.phid;
250
+ }
251
+ else if (action.input.phid) {
252
+ updates.drive_id = action.input.phid;
253
+ }
254
+ // Always update the updated_at timestamp
255
+ updates.updated_at = new Date();
230
256
  // Only update if there are actual changes
231
257
  if (Object.keys(updates).length > 0) {
232
258
  await this.dbHelpers.updateBuilderPackage(action.input.id, updates);
233
259
  }
234
260
  }
235
- // private async handleReorderPackages(
236
- // documentId: string,
237
- // action: ReorderPackagesAction,
238
- // state: BuilderAccountState
239
- // ): Promise<void> {
240
- // const { ids, insertAfter, spaceId } = action.input;
241
- // for (let i = 0; i < ids.length; i++) {
242
- // const packageId = ids[i];
243
- // const sortOrder = insertAfter !== null ? Number(insertAfter) + i + 1 : i;
244
- // await this.db
245
- // .updateTable("builder_packages")
246
- // .set({
247
- // sort_order: sortOrder,
248
- // updated_at: new Date(),
249
- // })
250
- // .where("id", "=", packageId)
251
- // .where("space_id", "=", spaceId)
252
- // .execute();
253
- // }
254
- // }
261
+ async handleReorderPackages(documentId, action, state) {
262
+ const { spaceId } = action.input;
263
+ // Find the space in state
264
+ const space = state.spaces.find(s => s.id === spaceId);
265
+ if (!space)
266
+ return;
267
+ // Update sortOrder for all packages in the space based on the state
268
+ for (const pkg of space.packages) {
269
+ await this.db
270
+ .updateTable("builder_team_packages")
271
+ .set({
272
+ sort_order: pkg.sortOrder,
273
+ updated_at: new Date(),
274
+ })
275
+ .where("id", "=", pkg.id)
276
+ .where("space_id", "=", spaceId)
277
+ .execute();
278
+ }
279
+ }
255
280
  async handleDeletePackage(documentId, action, state) {
256
281
  await this.db
257
282
  .deleteFrom("builder_team_packages")
@@ -13,7 +13,6 @@ export const vetraBuilderTeamRelationalDbProcessorFactory = (module) => async (d
13
13
  };
14
14
  // Create the processor
15
15
  const processor = new VetraBuilderRelationalDbProcessor(namespace, filter, store);
16
- console.log("vetraBuilderRelationalDbProcessorFactory", processor);
17
16
  return [
18
17
  {
19
18
  processor,
@@ -22,7 +22,6 @@ export class VetraBuilderRelationalDbProcessor extends RelationalDbProcessor {
22
22
  if (strand.operations.length === 0) {
23
23
  continue;
24
24
  }
25
- console.log("onStrands", strand);
26
25
  for (const operation of strand.operations) {
27
26
  if (strand.documentType.includes("powerhouse/document-drive")) {
28
27
  await this.handleDocumentDriveOperation(strand.documentId, strand.driveId, operation.action, operation.state);