@powerhousedao/service-offering 0.0.4 → 0.0.6
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/document-models/document-models.d.ts.map +1 -1
- package/dist/document-models/document-models.js +0 -2
- package/dist/document-models/index.d.ts +0 -1
- package/dist/document-models/index.d.ts.map +1 -1
- package/dist/document-models/index.js +0 -1
- package/dist/document-models/subscription-instance/gen/schema/zod.d.ts +1 -1
- package/dist/subgraphs/resources-services/resolvers.d.ts.map +1 -1
- package/dist/subgraphs/resources-services/resolvers.js +52 -41
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document-models.d.ts","sourceRoot":"","sources":["../../document-models/document-models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"document-models.d.ts","sourceRoot":"","sources":["../../document-models/document-models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAO1D,eAAO,MAAM,cAAc,EAAE,mBAAmB,CAAC,GAAG,CAAC,EAMpD,CAAC"}
|
|
@@ -2,13 +2,11 @@ import { Facet } from "./facet/module.js";
|
|
|
2
2
|
import { ResourceInstance } from "./resource-instance/module.js";
|
|
3
3
|
import { ResourceTemplate } from "./resource-template/module.js";
|
|
4
4
|
import { ServiceOffering } from "./service-offering/module.js";
|
|
5
|
-
import { ServiceSubscription } from "./service-subscription/module.js";
|
|
6
5
|
import { SubscriptionInstance } from "./subscription-instance/module.js";
|
|
7
6
|
export const documentModels = [
|
|
8
7
|
Facet,
|
|
9
8
|
ResourceInstance,
|
|
10
9
|
ResourceTemplate,
|
|
11
10
|
ServiceOffering,
|
|
12
|
-
ServiceSubscription,
|
|
13
11
|
SubscriptionInstance,
|
|
14
12
|
];
|
|
@@ -2,6 +2,5 @@ export { Facet } from "./facet/module.js";
|
|
|
2
2
|
export { ResourceInstance } from "./resource-instance/module.js";
|
|
3
3
|
export { ResourceTemplate } from "./resource-template/module.js";
|
|
4
4
|
export { ServiceOffering } from "./service-offering/module.js";
|
|
5
|
-
export { ServiceSubscription } from "./service-subscription/module.js";
|
|
6
5
|
export { SubscriptionInstance } from "./subscription-instance/module.js";
|
|
7
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../document-models/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../document-models/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC"}
|
|
@@ -2,5 +2,4 @@ export { Facet } from "./facet/module.js";
|
|
|
2
2
|
export { ResourceInstance } from "./resource-instance/module.js";
|
|
3
3
|
export { ResourceTemplate } from "./resource-template/module.js";
|
|
4
4
|
export { ServiceOffering } from "./service-offering/module.js";
|
|
5
|
-
export { ServiceSubscription } from "./service-subscription/module.js";
|
|
6
5
|
export { SubscriptionInstance } from "./subscription-instance/module.js";
|
|
@@ -41,10 +41,10 @@ export declare const ResetPeriodSchema: z.ZodEnum<{
|
|
|
41
41
|
}>;
|
|
42
42
|
export declare const SubscriptionStatusSchema: z.ZodEnum<{
|
|
43
43
|
ACTIVE: "ACTIVE";
|
|
44
|
-
PENDING: "PENDING";
|
|
45
44
|
CANCELLED: "CANCELLED";
|
|
46
45
|
EXPIRING: "EXPIRING";
|
|
47
46
|
PAUSED: "PAUSED";
|
|
47
|
+
PENDING: "PENDING";
|
|
48
48
|
}>;
|
|
49
49
|
export declare const TierPricingModeSchema: z.ZodEnum<{
|
|
50
50
|
CALCULATED: "CALCULATED";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolvers.d.ts","sourceRoot":"","sources":["../../../subgraphs/resources-services/resolvers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"resolvers.d.ts","sourceRoot":"","sources":["../../../subgraphs/resources-services/resolvers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAsC5D,eAAO,MAAM,YAAY,GAAI,UAAU,SAAS,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAuZxE,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {} from "@powerhousedao/reactor-api";
|
|
2
2
|
import { createAction } from "document-model/core";
|
|
3
3
|
import { addFile } from "document-drive";
|
|
4
|
-
import { ResourceInstance,
|
|
4
|
+
import { ResourceInstance, SubscriptionInstance, } from "@powerhousedao/service-offering/document-models";
|
|
5
|
+
import { mapOfferingToSubscription } from "../../editors/subscription-instance-editor/components/mapOfferingToSubscription.js";
|
|
5
6
|
export const getResolvers = (subgraph) => {
|
|
6
7
|
const reactor = subgraph.reactor;
|
|
7
8
|
return {
|
|
@@ -219,52 +220,62 @@ export const getResolvers = (subgraph) => {
|
|
|
219
220
|
parentFolder: teamBuilderAdminDrive.state.global.nodes?.find((node) => node.kind === "folder")?.parentFolder,
|
|
220
221
|
}));
|
|
221
222
|
await reactor.addAction(builderProfileDoc.header.id, createAction("UPDATE_PROFILE", { name }, undefined, undefined, "global"));
|
|
222
|
-
// create resource-instance
|
|
223
|
+
// create resource-instance and subscription-instance docs
|
|
223
224
|
const resourceInstanceDoc = await reactor.addDocument("powerhouse/resource-instance");
|
|
224
|
-
await reactor.
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
name: `${parsedName} Resource Instance`,
|
|
228
|
-
parentFolder: teamBuilderAdminDrive.state.global.nodes?.find((node) => node.kind === "folder")?.parentFolder,
|
|
229
|
-
}));
|
|
230
|
-
await populateResourceInstance(reactor, resourceInstanceDoc.header.id, resourceTemplateId, builderProfileDoc.header.id, name);
|
|
231
|
-
// create service-subscription doc inside the team-builder-admin drive
|
|
232
|
-
const subscriptionDoc = await reactor.addDocument("powerhouse/service-subscription");
|
|
233
|
-
await reactor.addAction(teamBuilderAdminDrive.header.id, addFile({
|
|
234
|
-
documentType: "powerhouse/service-subscription",
|
|
235
|
-
id: subscriptionDoc.header.id,
|
|
236
|
-
name: `${parsedName} Service Subscription`,
|
|
237
|
-
parentFolder: teamBuilderAdminDrive.state.global.nodes?.find((node) => node.kind === "folder")?.parentFolder,
|
|
238
|
-
}));
|
|
239
|
-
const now = new Date().toISOString();
|
|
240
|
-
await reactor.addAction(subscriptionDoc.header.id, ServiceSubscription.actions.initializeSubscription({
|
|
241
|
-
id: subscriptionDoc.header.id,
|
|
242
|
-
customerId: builderProfileDoc.header.id,
|
|
243
|
-
customerName: name,
|
|
244
|
-
serviceOfferingId,
|
|
245
|
-
serviceOfferingTitle: serviceOfferingState.title,
|
|
246
|
-
resourceTemplateId,
|
|
247
|
-
selectedTierId: finalConfiguration.selectedTierId,
|
|
248
|
-
createdAt: now,
|
|
249
|
-
lastModified: now,
|
|
250
|
-
}));
|
|
251
|
-
// add resource-instance and subscription to operator's drive
|
|
225
|
+
const subscriptionInstanceDoc = await reactor.addDocument("powerhouse/subscription-instance");
|
|
226
|
+
// resolve parent folders for both drives
|
|
227
|
+
const teamParentFolder = teamBuilderAdminDrive.state.global.nodes?.find((node) => node.kind === "folder")?.parentFolder;
|
|
252
228
|
const operatorDrive = await getOperatorDrive(reactor, resourceTemplateId);
|
|
253
229
|
if (!operatorDrive) {
|
|
254
230
|
throw new Error(`Operator drive not found for resource template ${resourceTemplateId}`);
|
|
255
231
|
}
|
|
256
232
|
const operatorParentFolder = operatorDrive.state.global.nodes?.find((node) => node.kind === "folder")?.parentFolder;
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
233
|
+
// batch add resource-instance and subscription-instance to team-builder-admin drive
|
|
234
|
+
await reactor.addActions(teamBuilderAdminDrive.header.id, [
|
|
235
|
+
addFile({
|
|
236
|
+
documentType: "powerhouse/resource-instance",
|
|
237
|
+
id: resourceInstanceDoc.header.id,
|
|
238
|
+
name: `${parsedName} Resource Instance`,
|
|
239
|
+
parentFolder: teamParentFolder,
|
|
240
|
+
}),
|
|
241
|
+
addFile({
|
|
242
|
+
documentType: "powerhouse/subscription-instance",
|
|
243
|
+
id: subscriptionInstanceDoc.header.id,
|
|
244
|
+
name: `${parsedName} Subscription Instance`,
|
|
245
|
+
parentFolder: teamParentFolder,
|
|
246
|
+
}),
|
|
247
|
+
]);
|
|
248
|
+
// batch add resource-instance and subscription-instance to operator drive
|
|
249
|
+
await reactor.addActions(operatorDrive.header.id, [
|
|
250
|
+
addFile({
|
|
251
|
+
documentType: "powerhouse/resource-instance",
|
|
252
|
+
id: resourceInstanceDoc.header.id,
|
|
253
|
+
name: `${parsedName} Resource Instance`,
|
|
254
|
+
parentFolder: operatorParentFolder,
|
|
255
|
+
}),
|
|
256
|
+
addFile({
|
|
257
|
+
documentType: "powerhouse/subscription-instance",
|
|
258
|
+
id: subscriptionInstanceDoc.header.id,
|
|
259
|
+
name: `${parsedName} Subscription Instance`,
|
|
260
|
+
parentFolder: operatorParentFolder,
|
|
261
|
+
}),
|
|
262
|
+
]);
|
|
263
|
+
// populate documents after all files are added to both drives
|
|
264
|
+
await populateResourceInstance(reactor, resourceInstanceDoc.header.id, resourceTemplateId, builderProfileDoc.header.id, name);
|
|
265
|
+
const now = new Date().toISOString();
|
|
266
|
+
const subscriptionInput = mapOfferingToSubscription({
|
|
267
|
+
offering: serviceOfferingState,
|
|
268
|
+
tierId: finalConfiguration.selectedTierId,
|
|
269
|
+
selectedBillingCycle: finalConfiguration.selectedBillingCycle,
|
|
270
|
+
customerId: builderProfileDoc.header.id,
|
|
271
|
+
customerName: name,
|
|
272
|
+
createdAt: now,
|
|
273
|
+
});
|
|
274
|
+
await reactor.addAction(subscriptionInstanceDoc.header.id, SubscriptionInstance.actions.initializeSubscription({
|
|
275
|
+
...subscriptionInput,
|
|
276
|
+
resourceId: resourceInstanceDoc.header.id,
|
|
277
|
+
resourceLabel: name,
|
|
278
|
+
resourceThumbnailUrl: serviceOfferingState.thumbnailUrl,
|
|
268
279
|
}));
|
|
269
280
|
return {
|
|
270
281
|
success: true,
|