@powerhousedao/service-offering 1.0.0-dev.10 → 1.0.0-dev.11

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.
@@ -1 +1 @@
1
- {"version":3,"file":"resolvers.d.ts","sourceRoot":"","sources":["../../../subgraphs/resources-services/resolvers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAyD/D,eAAO,MAAM,YAAY,GACvB,UAAU,YAAY,KACrB,MAAM,CAAC,MAAM,EAAE,OAAO,CAsfxB,CAAC"}
1
+ {"version":3,"file":"resolvers.d.ts","sourceRoot":"","sources":["../../../subgraphs/resources-services/resolvers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAyD/D,eAAO,MAAM,YAAY,GACvB,UAAU,YAAY,KACrB,MAAM,CAAC,MAAM,EAAE,OAAO,CAqgBxB,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { getUserSelectionPriceBreakdown, } from "../../document-models/service-offering/v1/src/utils.js";
2
- import { createAction } from "document-model/core";
3
- import { addFile, driveCreateDocument } from "document-drive";
2
+ import { createAction, generateId } from "document-model/core";
3
+ import { addFile, addFolder, driveCreateDocument } from "document-drive";
4
4
  import { ResourceInstance } from "../../document-models/resource-instance/v1/module.js";
5
5
  import { SubscriptionInstance } from "../../document-models/subscription-instance/v1/module.js";
6
6
  import { mapOfferingToSubscription } from "../../editors/subscription-instance-editor/components/mapOfferingToSubscription.js";
@@ -269,26 +269,29 @@ export const getResolvers = (subgraph) => {
269
269
  const builderProfileDoc = await reactorClient.createEmpty("powerhouse/builder-profile", { parentIdentifier: driveId });
270
270
  const resourceInstanceDoc = await reactorClient.createEmpty("powerhouse/resource-instance", { parentIdentifier: driveId });
271
271
  const subscriptionInstanceDoc = await reactorClient.createEmpty("powerhouse/subscription-instance", { parentIdentifier: driveId });
272
- // add file references to the team drive
273
- const teamRootFolder = teamBuilderAdminDrive.state.global.nodes.find((node) => node.kind === "folder")?.parentFolder;
272
+ // create "Service Subscriptions" folder and organize files in team drive
273
+ const teamServiceSubsFolderId = generateId();
274
274
  await reactorClient.execute(driveId, "main", [
275
+ addFolder({
276
+ id: teamServiceSubsFolderId,
277
+ name: "Service Subscriptions",
278
+ }),
275
279
  addFile({
276
280
  documentType: "powerhouse/builder-profile",
277
281
  id: builderProfileDoc.header.id,
278
282
  name: `${parsedTeamName} Builder Profile`,
279
- parentFolder: teamRootFolder,
280
283
  }),
281
284
  addFile({
282
285
  documentType: "powerhouse/resource-instance",
283
286
  id: resourceInstanceDoc.header.id,
284
287
  name: `${parsedTeamName} Resource Instance`,
285
- parentFolder: teamRootFolder,
288
+ parentFolder: teamServiceSubsFolderId,
286
289
  }),
287
290
  addFile({
288
291
  documentType: "powerhouse/subscription-instance",
289
292
  id: subscriptionInstanceDoc.header.id,
290
293
  name: `${parsedTeamName} Subscription Instance`,
291
- parentFolder: teamRootFolder,
294
+ parentFolder: teamServiceSubsFolderId,
292
295
  }),
293
296
  ]);
294
297
  // update builder profile
@@ -307,26 +310,37 @@ export const getResolvers = (subgraph) => {
307
310
  if (!operatorProfileId) {
308
311
  throw new Error(`Operator profile not found for drive ${operatorDrive.header.id}`);
309
312
  }
310
- const operatorParentFolder = operatorDrive.state.global.nodes.find((node) => node.kind === "folder")?.parentFolder;
313
+ // find or create "Service Subscriptions" folder in the operator drive
314
+ let serviceSubscriptionsFolderId = operatorDrive.state.global.nodes.find((node) => node.kind === "folder" &&
315
+ node.name === "Service Subscriptions")?.id;
316
+ if (!serviceSubscriptionsFolderId) {
317
+ serviceSubscriptionsFolderId = generateId();
318
+ await reactorClient.execute(operatorDrive.header.id, "main", [
319
+ addFolder({
320
+ id: serviceSubscriptionsFolderId,
321
+ name: "Service Subscriptions",
322
+ }),
323
+ ]);
324
+ }
311
325
  // add reactor-level relationships so Connect syncs the child documents
312
326
  // (createEmpty guarantees CREATE_DOCUMENT is persisted before this runs)
313
327
  await reactorClient.addChildren(operatorDrive.header.id, [
314
328
  resourceInstanceDoc.header.id,
315
329
  subscriptionInstanceDoc.header.id,
316
330
  ]);
317
- // add file references to operator drive
331
+ // add file references to operator drive under "Service Subscriptions"
318
332
  await reactorClient.execute(operatorDrive.header.id, "main", [
319
333
  addFile({
320
334
  documentType: "powerhouse/resource-instance",
321
335
  id: resourceInstanceDoc.header.id,
322
336
  name: `${parsedTeamName} Resource Instance`,
323
- parentFolder: operatorParentFolder,
337
+ parentFolder: serviceSubscriptionsFolderId,
324
338
  }),
325
339
  addFile({
326
340
  documentType: "powerhouse/subscription-instance",
327
341
  id: subscriptionInstanceDoc.header.id,
328
342
  name: `${parsedTeamName} Subscription Instance`,
329
- parentFolder: operatorParentFolder,
343
+ parentFolder: serviceSubscriptionsFolderId,
330
344
  }),
331
345
  ]);
332
346
  // populate documents after all files are added to both drives
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.10",
4
+ "version": "1.0.0-dev.11",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": {
7
7
  "type": "git",