@contractspec/example.saas-boilerplate 1.56.1 → 1.58.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/.turbo/turbo-build.log +160 -188
- package/.turbo/turbo-prebuild.log +1 -0
- package/CHANGELOG.md +45 -0
- package/dist/billing/billing.entity.d.ts +40 -45
- package/dist/billing/billing.entity.d.ts.map +1 -1
- package/dist/billing/billing.entity.js +110 -118
- package/dist/billing/billing.enum.d.ts +2 -8
- package/dist/billing/billing.enum.d.ts.map +1 -1
- package/dist/billing/billing.enum.js +17 -24
- package/dist/billing/billing.event.d.ts +67 -73
- package/dist/billing/billing.event.d.ts.map +1 -1
- package/dist/billing/billing.event.js +84 -146
- package/dist/billing/billing.handler.d.ts +59 -62
- package/dist/billing/billing.handler.d.ts.map +1 -1
- package/dist/billing/billing.handler.js +140 -49
- package/dist/billing/billing.operations.d.ts +138 -144
- package/dist/billing/billing.operations.d.ts.map +1 -1
- package/dist/billing/billing.operations.js +273 -175
- package/dist/billing/billing.presentation.d.ts +2 -7
- package/dist/billing/billing.presentation.d.ts.map +1 -1
- package/dist/billing/billing.presentation.js +51 -57
- package/dist/billing/billing.schema.d.ts +159 -164
- package/dist/billing/billing.schema.d.ts.map +1 -1
- package/dist/billing/billing.schema.js +112 -204
- package/dist/billing/index.d.ts +11 -8
- package/dist/billing/index.d.ts.map +1 -0
- package/dist/billing/index.js +689 -9
- package/dist/browser/billing/billing.entity.js +113 -0
- package/dist/browser/billing/billing.enum.js +19 -0
- package/dist/browser/billing/billing.event.js +90 -0
- package/dist/browser/billing/billing.handler.js +148 -0
- package/dist/browser/billing/billing.operations.js +278 -0
- package/dist/browser/billing/billing.presentation.js +52 -0
- package/dist/browser/billing/billing.schema.js +121 -0
- package/dist/browser/billing/index.js +688 -0
- package/dist/browser/dashboard/dashboard.presentation.js +52 -0
- package/dist/browser/dashboard/index.js +52 -0
- package/dist/browser/docs/index.js +93 -0
- package/dist/browser/docs/saas-boilerplate.docblock.js +93 -0
- package/dist/browser/example.js +39 -0
- package/dist/browser/handlers/index.js +358 -0
- package/dist/browser/handlers/saas.handlers.js +134 -0
- package/dist/browser/index.js +3340 -0
- package/dist/browser/presentations/index.js +290 -0
- package/dist/browser/project/index.js +790 -0
- package/dist/browser/project/project.entity.js +77 -0
- package/dist/browser/project/project.enum.js +18 -0
- package/dist/browser/project/project.event.js +103 -0
- package/dist/browser/project/project.handler.js +178 -0
- package/dist/browser/project/project.operations.js +372 -0
- package/dist/browser/project/project.presentation.js +177 -0
- package/dist/browser/project/project.schema.js +134 -0
- package/dist/browser/saas-boilerplate.feature.js +88 -0
- package/dist/browser/seeders/index.js +20 -0
- package/dist/browser/settings/index.js +75 -0
- package/dist/browser/settings/settings.entity.js +74 -0
- package/dist/browser/settings/settings.enum.js +11 -0
- package/dist/browser/shared/mock-data.js +104 -0
- package/dist/browser/shared/overlay-types.js +0 -0
- package/dist/browser/tests/operations.test-spec.js +112 -0
- package/dist/browser/ui/SaasDashboard.js +988 -0
- package/dist/browser/ui/SaasProjectList.js +162 -0
- package/dist/browser/ui/SaasSettingsPanel.js +145 -0
- package/dist/browser/ui/hooks/index.js +159 -0
- package/dist/browser/ui/hooks/useProjectList.js +66 -0
- package/dist/browser/ui/hooks/useProjectMutations.js +91 -0
- package/dist/browser/ui/index.js +1808 -0
- package/dist/browser/ui/modals/CreateProjectModal.js +153 -0
- package/dist/browser/ui/modals/ProjectActionsModal.js +335 -0
- package/dist/browser/ui/modals/index.js +487 -0
- package/dist/browser/ui/overlays/demo-overlays.js +61 -0
- package/dist/browser/ui/overlays/index.js +61 -0
- package/dist/browser/ui/renderers/index.js +675 -0
- package/dist/browser/ui/renderers/project-list.markdown.js +499 -0
- package/dist/browser/ui/renderers/project-list.renderer.js +177 -0
- package/dist/dashboard/dashboard.presentation.d.ts +2 -7
- package/dist/dashboard/dashboard.presentation.d.ts.map +1 -1
- package/dist/dashboard/dashboard.presentation.js +51 -53
- package/dist/dashboard/index.d.ts +5 -2
- package/dist/dashboard/index.d.ts.map +1 -0
- package/dist/dashboard/index.js +53 -3
- package/dist/docs/index.d.ts +2 -1
- package/dist/docs/index.d.ts.map +1 -0
- package/dist/docs/index.js +94 -1
- package/dist/docs/saas-boilerplate.docblock.d.ts +2 -1
- package/dist/docs/saas-boilerplate.docblock.d.ts.map +1 -0
- package/dist/docs/saas-boilerplate.docblock.js +45 -51
- package/dist/example.d.ts +2 -6
- package/dist/example.d.ts.map +1 -1
- package/dist/example.js +37 -50
- package/dist/handlers/index.d.ts +7 -4
- package/dist/handlers/index.d.ts.map +1 -0
- package/dist/handlers/index.js +358 -4
- package/dist/handlers/saas.handlers.d.ts +60 -60
- package/dist/handlers/saas.handlers.d.ts.map +1 -1
- package/dist/handlers/saas.handlers.js +127 -140
- package/dist/index.d.ts +15 -45
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3335 -75
- package/dist/node/billing/billing.entity.js +113 -0
- package/dist/node/billing/billing.enum.js +19 -0
- package/dist/node/billing/billing.event.js +90 -0
- package/dist/node/billing/billing.handler.js +148 -0
- package/dist/node/billing/billing.operations.js +278 -0
- package/dist/node/billing/billing.presentation.js +52 -0
- package/dist/node/billing/billing.schema.js +121 -0
- package/dist/node/billing/index.js +688 -0
- package/dist/node/dashboard/dashboard.presentation.js +52 -0
- package/dist/node/dashboard/index.js +52 -0
- package/dist/node/docs/index.js +93 -0
- package/dist/node/docs/saas-boilerplate.docblock.js +93 -0
- package/dist/node/example.js +39 -0
- package/dist/node/handlers/index.js +358 -0
- package/dist/node/handlers/saas.handlers.js +134 -0
- package/dist/node/index.js +3340 -0
- package/dist/node/presentations/index.js +290 -0
- package/dist/node/project/index.js +790 -0
- package/dist/node/project/project.entity.js +77 -0
- package/dist/node/project/project.enum.js +18 -0
- package/dist/node/project/project.event.js +103 -0
- package/dist/node/project/project.handler.js +178 -0
- package/dist/node/project/project.operations.js +372 -0
- package/dist/node/project/project.presentation.js +177 -0
- package/dist/node/project/project.schema.js +134 -0
- package/dist/node/saas-boilerplate.feature.js +88 -0
- package/dist/node/seeders/index.js +20 -0
- package/dist/node/settings/index.js +75 -0
- package/dist/node/settings/settings.entity.js +74 -0
- package/dist/node/settings/settings.enum.js +11 -0
- package/dist/node/shared/mock-data.js +104 -0
- package/dist/node/shared/overlay-types.js +0 -0
- package/dist/node/tests/operations.test-spec.js +112 -0
- package/dist/node/ui/SaasDashboard.js +988 -0
- package/dist/node/ui/SaasProjectList.js +162 -0
- package/dist/node/ui/SaasSettingsPanel.js +145 -0
- package/dist/node/ui/hooks/index.js +159 -0
- package/dist/node/ui/hooks/useProjectList.js +66 -0
- package/dist/node/ui/hooks/useProjectMutations.js +91 -0
- package/dist/node/ui/index.js +1808 -0
- package/dist/node/ui/modals/CreateProjectModal.js +153 -0
- package/dist/node/ui/modals/ProjectActionsModal.js +335 -0
- package/dist/node/ui/modals/index.js +487 -0
- package/dist/node/ui/overlays/demo-overlays.js +61 -0
- package/dist/node/ui/overlays/index.js +61 -0
- package/dist/node/ui/renderers/index.js +675 -0
- package/dist/node/ui/renderers/project-list.markdown.js +499 -0
- package/dist/node/ui/renderers/project-list.renderer.js +177 -0
- package/dist/presentations/index.d.ts +13 -15
- package/dist/presentations/index.d.ts.map +1 -1
- package/dist/presentations/index.js +289 -15
- package/dist/project/index.d.ts +11 -8
- package/dist/project/index.d.ts.map +1 -0
- package/dist/project/index.js +791 -9
- package/dist/project/project.entity.d.ts +23 -28
- package/dist/project/project.entity.d.ts.map +1 -1
- package/dist/project/project.entity.js +75 -82
- package/dist/project/project.enum.d.ts +2 -8
- package/dist/project/project.enum.d.ts.map +1 -1
- package/dist/project/project.enum.js +16 -23
- package/dist/project/project.event.d.ts +69 -75
- package/dist/project/project.event.d.ts.map +1 -1
- package/dist/project/project.event.js +95 -156
- package/dist/project/project.handler.d.ts +44 -47
- package/dist/project/project.handler.d.ts.map +1 -1
- package/dist/project/project.handler.js +168 -71
- package/dist/project/project.operations.d.ts +341 -347
- package/dist/project/project.operations.d.ts.map +1 -1
- package/dist/project/project.operations.js +366 -253
- package/dist/project/project.presentation.d.ts +2 -7
- package/dist/project/project.presentation.d.ts.map +1 -1
- package/dist/project/project.presentation.js +174 -61
- package/dist/project/project.schema.d.ts +191 -196
- package/dist/project/project.schema.d.ts.map +1 -1
- package/dist/project/project.schema.js +125 -205
- package/dist/saas-boilerplate.feature.d.ts +1 -7
- package/dist/saas-boilerplate.feature.d.ts.map +1 -1
- package/dist/saas-boilerplate.feature.js +87 -206
- package/dist/seeders/index.d.ts +4 -8
- package/dist/seeders/index.d.ts.map +1 -1
- package/dist/seeders/index.js +18 -16
- package/dist/settings/index.d.ts +6 -3
- package/dist/settings/index.d.ts.map +1 -0
- package/dist/settings/index.js +75 -3
- package/dist/settings/settings.entity.d.ts +23 -28
- package/dist/settings/settings.entity.d.ts.map +1 -1
- package/dist/settings/settings.entity.js +72 -75
- package/dist/settings/settings.enum.d.ts +1 -6
- package/dist/settings/settings.enum.d.ts.map +1 -1
- package/dist/settings/settings.enum.js +10 -19
- package/dist/shared/mock-data.d.ts +74 -77
- package/dist/shared/mock-data.d.ts.map +1 -1
- package/dist/shared/mock-data.js +102 -135
- package/dist/shared/overlay-types.d.ts +25 -28
- package/dist/shared/overlay-types.d.ts.map +1 -1
- package/dist/shared/overlay-types.js +1 -0
- package/dist/tests/operations.test-spec.d.ts +4 -9
- package/dist/tests/operations.test-spec.d.ts.map +1 -1
- package/dist/tests/operations.test-spec.js +108 -118
- package/dist/ui/SaasDashboard.d.ts +1 -6
- package/dist/ui/SaasDashboard.d.ts.map +1 -1
- package/dist/ui/SaasDashboard.js +977 -286
- package/dist/ui/SaasProjectList.d.ts +4 -11
- package/dist/ui/SaasProjectList.d.ts.map +1 -1
- package/dist/ui/SaasProjectList.js +159 -72
- package/dist/ui/SaasSettingsPanel.d.ts +1 -6
- package/dist/ui/SaasSettingsPanel.d.ts.map +1 -1
- package/dist/ui/SaasSettingsPanel.js +142 -134
- package/dist/ui/hooks/index.d.ts +3 -3
- package/dist/ui/hooks/index.d.ts.map +1 -0
- package/dist/ui/hooks/index.js +158 -4
- package/dist/ui/hooks/useProjectList.d.ts +26 -30
- package/dist/ui/hooks/useProjectList.d.ts.map +1 -1
- package/dist/ui/hooks/useProjectList.js +63 -71
- package/dist/ui/hooks/useProjectMutations.d.ts +20 -24
- package/dist/ui/hooks/useProjectMutations.d.ts.map +1 -1
- package/dist/ui/hooks/useProjectMutations.js +88 -142
- package/dist/ui/index.d.ts +8 -14
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +1809 -15
- package/dist/ui/modals/CreateProjectModal.d.ts +10 -19
- package/dist/ui/modals/CreateProjectModal.d.ts.map +1 -1
- package/dist/ui/modals/CreateProjectModal.js +150 -135
- package/dist/ui/modals/ProjectActionsModal.d.ts +20 -33
- package/dist/ui/modals/ProjectActionsModal.d.ts.map +1 -1
- package/dist/ui/modals/ProjectActionsModal.js +333 -289
- package/dist/ui/modals/index.d.ts +3 -3
- package/dist/ui/modals/index.d.ts.map +1 -0
- package/dist/ui/modals/index.js +487 -3
- package/dist/ui/overlays/demo-overlays.d.ts +10 -9
- package/dist/ui/overlays/demo-overlays.d.ts.map +1 -1
- package/dist/ui/overlays/demo-overlays.js +60 -68
- package/dist/ui/overlays/index.d.ts +2 -2
- package/dist/ui/overlays/index.d.ts.map +1 -0
- package/dist/ui/overlays/index.js +62 -3
- package/dist/ui/renderers/index.d.ts +3 -3
- package/dist/ui/renderers/index.d.ts.map +1 -0
- package/dist/ui/renderers/index.js +675 -3
- package/dist/ui/renderers/project-list.markdown.d.ts +15 -15
- package/dist/ui/renderers/project-list.markdown.d.ts.map +1 -1
- package/dist/ui/renderers/project-list.markdown.js +496 -144
- package/dist/ui/renderers/project-list.renderer.d.ts +6 -8
- package/dist/ui/renderers/project-list.renderer.d.ts.map +1 -1
- package/dist/ui/renderers/project-list.renderer.js +176 -15
- package/package.json +509 -99
- package/src/ui/renderers/project-list.markdown.ts +1 -1
- package/tsdown.config.js +1 -2
- package/.turbo/turbo-build$colon$bundle.log +0 -188
- package/dist/billing/billing.entity.js.map +0 -1
- package/dist/billing/billing.enum.js.map +0 -1
- package/dist/billing/billing.event.js.map +0 -1
- package/dist/billing/billing.handler.js.map +0 -1
- package/dist/billing/billing.operations.js.map +0 -1
- package/dist/billing/billing.presentation.js.map +0 -1
- package/dist/billing/billing.schema.js.map +0 -1
- package/dist/dashboard/dashboard.presentation.js.map +0 -1
- package/dist/docs/saas-boilerplate.docblock.js.map +0 -1
- package/dist/example.js.map +0 -1
- package/dist/handlers/saas.handlers.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/presentations/index.js.map +0 -1
- package/dist/project/project.entity.js.map +0 -1
- package/dist/project/project.enum.js.map +0 -1
- package/dist/project/project.event.js.map +0 -1
- package/dist/project/project.handler.js.map +0 -1
- package/dist/project/project.operations.js.map +0 -1
- package/dist/project/project.presentation.js.map +0 -1
- package/dist/project/project.schema.js.map +0 -1
- package/dist/saas-boilerplate.feature.js.map +0 -1
- package/dist/seeders/index.js.map +0 -1
- package/dist/settings/settings.entity.js.map +0 -1
- package/dist/settings/settings.enum.js.map +0 -1
- package/dist/shared/mock-data.js.map +0 -1
- package/dist/tests/operations.test-spec.js.map +0 -1
- package/dist/ui/SaasDashboard.js.map +0 -1
- package/dist/ui/SaasProjectList.js.map +0 -1
- package/dist/ui/SaasSettingsPanel.js.map +0 -1
- package/dist/ui/hooks/useProjectList.js.map +0 -1
- package/dist/ui/hooks/useProjectMutations.js.map +0 -1
- package/dist/ui/modals/CreateProjectModal.js.map +0 -1
- package/dist/ui/modals/ProjectActionsModal.js.map +0 -1
- package/dist/ui/overlays/demo-overlays.js.map +0 -1
- package/dist/ui/renderers/project-list.markdown.js.map +0 -1
- package/dist/ui/renderers/project-list.renderer.js.map +0 -1
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -1,181 +1,279 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// @bun
|
|
2
|
+
// src/billing/billing.enum.ts
|
|
3
|
+
import { defineEnum } from "@contractspec/lib.schema";
|
|
4
|
+
var SubscriptionStatusSchemaEnum = defineEnum("SubscriptionStatus", [
|
|
5
|
+
"TRIALING",
|
|
6
|
+
"ACTIVE",
|
|
7
|
+
"PAST_DUE",
|
|
8
|
+
"CANCELED",
|
|
9
|
+
"PAUSED"
|
|
10
|
+
]);
|
|
11
|
+
var FeatureAccessReasonEnum = defineEnum("FeatureAccessReason", [
|
|
12
|
+
"included",
|
|
13
|
+
"limit_available",
|
|
14
|
+
"limit_reached",
|
|
15
|
+
"not_in_plan"
|
|
16
|
+
]);
|
|
3
17
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
18
|
+
// src/billing/billing.schema.ts
|
|
19
|
+
import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
|
|
20
|
+
var SubscriptionModel = defineSchemaModel({
|
|
21
|
+
name: "Subscription",
|
|
22
|
+
description: "Organization subscription details",
|
|
23
|
+
fields: {
|
|
24
|
+
id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
25
|
+
organizationId: {
|
|
26
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
27
|
+
isOptional: false
|
|
28
|
+
},
|
|
29
|
+
planId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
30
|
+
planName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
31
|
+
status: { type: SubscriptionStatusSchemaEnum, isOptional: false },
|
|
32
|
+
currentPeriodStart: { type: ScalarTypeEnum.DateTime(), isOptional: false },
|
|
33
|
+
currentPeriodEnd: { type: ScalarTypeEnum.DateTime(), isOptional: false },
|
|
34
|
+
trialEndsAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
|
|
35
|
+
cancelAtPeriodEnd: { type: ScalarTypeEnum.Boolean(), isOptional: false }
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
var UsageSummaryModel = defineSchemaModel({
|
|
39
|
+
name: "UsageSummary",
|
|
40
|
+
description: "Usage summary for a feature",
|
|
41
|
+
fields: {
|
|
42
|
+
feature: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
43
|
+
used: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
44
|
+
limit: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
|
|
45
|
+
unit: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
46
|
+
percentage: { type: ScalarTypeEnum.Float_unsecure(), isOptional: true }
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
var RecordUsageInputModel = defineSchemaModel({
|
|
50
|
+
name: "RecordUsageInput",
|
|
51
|
+
description: "Input for recording feature usage",
|
|
52
|
+
fields: {
|
|
53
|
+
feature: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
54
|
+
quantity: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
55
|
+
sourceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
56
|
+
sourceType: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
57
|
+
metadata: { type: ScalarTypeEnum.JSONObject(), isOptional: true }
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
var RecordUsageOutputModel = defineSchemaModel({
|
|
61
|
+
name: "RecordUsageOutput",
|
|
62
|
+
description: "Output for recording feature usage",
|
|
63
|
+
fields: {
|
|
64
|
+
recorded: { type: ScalarTypeEnum.Boolean(), isOptional: false },
|
|
65
|
+
currentUsage: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
66
|
+
limit: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
|
|
67
|
+
limitReached: { type: ScalarTypeEnum.Boolean(), isOptional: false }
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
var UsageRecordedPayloadModel = defineSchemaModel({
|
|
71
|
+
name: "UsageRecordedPayload",
|
|
72
|
+
description: "Payload for usage.recorded event",
|
|
73
|
+
fields: {
|
|
74
|
+
feature: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
75
|
+
quantity: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false }
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
var GetUsageSummaryInputModel = defineSchemaModel({
|
|
79
|
+
name: "GetUsageSummaryInput",
|
|
80
|
+
description: "Input for getting usage summary",
|
|
81
|
+
fields: {
|
|
82
|
+
billingPeriod: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
|
|
83
|
+
}
|
|
46
84
|
});
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
"saas",
|
|
58
|
-
"billing",
|
|
59
|
-
"usage"
|
|
60
|
-
],
|
|
61
|
-
description: "Record usage of a metered feature.",
|
|
62
|
-
goal: "Track feature usage for billing.",
|
|
63
|
-
context: "Called by services when metered features are used."
|
|
64
|
-
},
|
|
65
|
-
io: {
|
|
66
|
-
input: RecordUsageInputModel,
|
|
67
|
-
output: RecordUsageOutputModel
|
|
68
|
-
},
|
|
69
|
-
policy: { auth: "user" },
|
|
70
|
-
sideEffects: { emits: [{
|
|
71
|
-
key: "billing.usage.recorded",
|
|
72
|
-
version: "1.0.0",
|
|
73
|
-
when: "Usage is recorded",
|
|
74
|
-
payload: UsageRecordedPayloadModel
|
|
75
|
-
}] },
|
|
76
|
-
acceptance: {
|
|
77
|
-
scenarios: [{
|
|
78
|
-
key: "record-usage-happy-path",
|
|
79
|
-
given: ["Organization exists"],
|
|
80
|
-
when: ["System records feature usage"],
|
|
81
|
-
then: ["Usage is recorded"]
|
|
82
|
-
}],
|
|
83
|
-
examples: [{
|
|
84
|
-
key: "record-api-call",
|
|
85
|
-
input: {
|
|
86
|
-
feature: "api_calls",
|
|
87
|
-
quantity: 1,
|
|
88
|
-
idempotencyKey: "abc-123"
|
|
89
|
-
},
|
|
90
|
-
output: {
|
|
91
|
-
recorded: true,
|
|
92
|
-
currentUsage: 100
|
|
93
|
-
}
|
|
94
|
-
}]
|
|
95
|
-
}
|
|
85
|
+
var GetUsageSummaryOutputModel = defineSchemaModel({
|
|
86
|
+
name: "GetUsageSummaryOutput",
|
|
87
|
+
description: "Output for usage summary",
|
|
88
|
+
fields: {
|
|
89
|
+
billingPeriod: {
|
|
90
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
91
|
+
isOptional: false
|
|
92
|
+
},
|
|
93
|
+
usage: { type: UsageSummaryModel, isArray: true, isOptional: false }
|
|
94
|
+
}
|
|
96
95
|
});
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
version: "1.0.0",
|
|
104
|
-
stability: "stable",
|
|
105
|
-
owners: [...OWNERS],
|
|
106
|
-
tags: [
|
|
107
|
-
"saas",
|
|
108
|
-
"billing",
|
|
109
|
-
"usage"
|
|
110
|
-
],
|
|
111
|
-
description: "Get usage summary for the current billing period.",
|
|
112
|
-
goal: "Show usage vs limits.",
|
|
113
|
-
context: "Billing page, usage dashboards."
|
|
114
|
-
},
|
|
115
|
-
io: {
|
|
116
|
-
input: GetUsageSummaryInputModel,
|
|
117
|
-
output: GetUsageSummaryOutputModel
|
|
118
|
-
},
|
|
119
|
-
policy: { auth: "user" },
|
|
120
|
-
acceptance: {
|
|
121
|
-
scenarios: [{
|
|
122
|
-
key: "get-usage-happy-path",
|
|
123
|
-
given: ["Organization has usage history"],
|
|
124
|
-
when: ["User requests usage summary"],
|
|
125
|
-
then: ["Usage metrics are returned"]
|
|
126
|
-
}],
|
|
127
|
-
examples: [{
|
|
128
|
-
key: "get-current-usage",
|
|
129
|
-
input: { period: "current" },
|
|
130
|
-
output: { features: [{
|
|
131
|
-
name: "api_calls",
|
|
132
|
-
used: 100,
|
|
133
|
-
limit: 1e3
|
|
134
|
-
}] }
|
|
135
|
-
}]
|
|
136
|
-
}
|
|
96
|
+
var CheckFeatureAccessInputModel = defineSchemaModel({
|
|
97
|
+
name: "CheckFeatureAccessInput",
|
|
98
|
+
description: "Input for checking feature access",
|
|
99
|
+
fields: {
|
|
100
|
+
feature: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }
|
|
101
|
+
}
|
|
137
102
|
});
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
owners: [...OWNERS],
|
|
147
|
-
tags: [
|
|
148
|
-
"saas",
|
|
149
|
-
"billing",
|
|
150
|
-
"feature"
|
|
151
|
-
],
|
|
152
|
-
description: "Check if organization has access to a feature.",
|
|
153
|
-
goal: "Gate features based on plan/usage.",
|
|
154
|
-
context: "Feature access checks, upgrade prompts."
|
|
155
|
-
},
|
|
156
|
-
io: {
|
|
157
|
-
input: CheckFeatureAccessInputModel,
|
|
158
|
-
output: CheckFeatureAccessOutputModel
|
|
159
|
-
},
|
|
160
|
-
policy: { auth: "user" },
|
|
161
|
-
acceptance: {
|
|
162
|
-
scenarios: [{
|
|
163
|
-
key: "check-access-granted",
|
|
164
|
-
given: ["Organization is on Pro plan"],
|
|
165
|
-
when: ["User checks access to Pro feature"],
|
|
166
|
-
then: ["Access is granted"]
|
|
167
|
-
}],
|
|
168
|
-
examples: [{
|
|
169
|
-
key: "check-advanced-reports",
|
|
170
|
-
input: { feature: "advanced_reports" },
|
|
171
|
-
output: {
|
|
172
|
-
hasAccess: true,
|
|
173
|
-
reason: "Included in Pro plan"
|
|
174
|
-
}
|
|
175
|
-
}]
|
|
176
|
-
}
|
|
103
|
+
var CheckFeatureAccessOutputModel = defineSchemaModel({
|
|
104
|
+
name: "CheckFeatureAccessOutput",
|
|
105
|
+
description: "Output for feature access check",
|
|
106
|
+
fields: {
|
|
107
|
+
hasAccess: { type: ScalarTypeEnum.Boolean(), isOptional: false },
|
|
108
|
+
reason: { type: FeatureAccessReasonEnum, isOptional: true },
|
|
109
|
+
upgradeUrl: { type: ScalarTypeEnum.URL(), isOptional: true }
|
|
110
|
+
}
|
|
177
111
|
});
|
|
178
112
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
113
|
+
// src/billing/billing.operations.ts
|
|
114
|
+
import { defineCommand, defineQuery } from "@contractspec/lib.contracts";
|
|
115
|
+
var OWNERS = ["@example.saas-boilerplate"];
|
|
116
|
+
var GetSubscriptionContract = defineQuery({
|
|
117
|
+
meta: {
|
|
118
|
+
key: "saas.billing.subscription.get",
|
|
119
|
+
version: "1.0.0",
|
|
120
|
+
stability: "stable",
|
|
121
|
+
owners: [...OWNERS],
|
|
122
|
+
tags: ["saas", "billing", "subscription"],
|
|
123
|
+
description: "Get organization subscription status.",
|
|
124
|
+
goal: "Show current plan and billing status.",
|
|
125
|
+
context: "Billing page, plan upgrade prompts."
|
|
126
|
+
},
|
|
127
|
+
io: {
|
|
128
|
+
input: null,
|
|
129
|
+
output: SubscriptionModel
|
|
130
|
+
},
|
|
131
|
+
policy: {
|
|
132
|
+
auth: "user"
|
|
133
|
+
},
|
|
134
|
+
acceptance: {
|
|
135
|
+
scenarios: [
|
|
136
|
+
{
|
|
137
|
+
key: "get-subscription-happy-path",
|
|
138
|
+
given: ["Organization has active subscription"],
|
|
139
|
+
when: ["User requests subscription status"],
|
|
140
|
+
then: ["Subscription details are returned"]
|
|
141
|
+
}
|
|
142
|
+
],
|
|
143
|
+
examples: [
|
|
144
|
+
{
|
|
145
|
+
key: "get-basic",
|
|
146
|
+
input: null,
|
|
147
|
+
output: {
|
|
148
|
+
plan: "pro",
|
|
149
|
+
status: "active",
|
|
150
|
+
currentPeriodEnd: "2025-02-01T00:00:00Z"
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
]
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
var RecordUsageContract = defineCommand({
|
|
157
|
+
meta: {
|
|
158
|
+
key: "saas.billing.usage.record",
|
|
159
|
+
version: "1.0.0",
|
|
160
|
+
stability: "stable",
|
|
161
|
+
owners: [...OWNERS],
|
|
162
|
+
tags: ["saas", "billing", "usage"],
|
|
163
|
+
description: "Record usage of a metered feature.",
|
|
164
|
+
goal: "Track feature usage for billing.",
|
|
165
|
+
context: "Called by services when metered features are used."
|
|
166
|
+
},
|
|
167
|
+
io: {
|
|
168
|
+
input: RecordUsageInputModel,
|
|
169
|
+
output: RecordUsageOutputModel
|
|
170
|
+
},
|
|
171
|
+
policy: {
|
|
172
|
+
auth: "user"
|
|
173
|
+
},
|
|
174
|
+
sideEffects: {
|
|
175
|
+
emits: [
|
|
176
|
+
{
|
|
177
|
+
key: "billing.usage.recorded",
|
|
178
|
+
version: "1.0.0",
|
|
179
|
+
when: "Usage is recorded",
|
|
180
|
+
payload: UsageRecordedPayloadModel
|
|
181
|
+
}
|
|
182
|
+
]
|
|
183
|
+
},
|
|
184
|
+
acceptance: {
|
|
185
|
+
scenarios: [
|
|
186
|
+
{
|
|
187
|
+
key: "record-usage-happy-path",
|
|
188
|
+
given: ["Organization exists"],
|
|
189
|
+
when: ["System records feature usage"],
|
|
190
|
+
then: ["Usage is recorded"]
|
|
191
|
+
}
|
|
192
|
+
],
|
|
193
|
+
examples: [
|
|
194
|
+
{
|
|
195
|
+
key: "record-api-call",
|
|
196
|
+
input: { feature: "api_calls", quantity: 1, idempotencyKey: "abc-123" },
|
|
197
|
+
output: { recorded: true, currentUsage: 100 }
|
|
198
|
+
}
|
|
199
|
+
]
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
var GetUsageSummaryContract = defineQuery({
|
|
203
|
+
meta: {
|
|
204
|
+
key: "saas.billing.usage.summary",
|
|
205
|
+
version: "1.0.0",
|
|
206
|
+
stability: "stable",
|
|
207
|
+
owners: [...OWNERS],
|
|
208
|
+
tags: ["saas", "billing", "usage"],
|
|
209
|
+
description: "Get usage summary for the current billing period.",
|
|
210
|
+
goal: "Show usage vs limits.",
|
|
211
|
+
context: "Billing page, usage dashboards."
|
|
212
|
+
},
|
|
213
|
+
io: {
|
|
214
|
+
input: GetUsageSummaryInputModel,
|
|
215
|
+
output: GetUsageSummaryOutputModel
|
|
216
|
+
},
|
|
217
|
+
policy: {
|
|
218
|
+
auth: "user"
|
|
219
|
+
},
|
|
220
|
+
acceptance: {
|
|
221
|
+
scenarios: [
|
|
222
|
+
{
|
|
223
|
+
key: "get-usage-happy-path",
|
|
224
|
+
given: ["Organization has usage history"],
|
|
225
|
+
when: ["User requests usage summary"],
|
|
226
|
+
then: ["Usage metrics are returned"]
|
|
227
|
+
}
|
|
228
|
+
],
|
|
229
|
+
examples: [
|
|
230
|
+
{
|
|
231
|
+
key: "get-current-usage",
|
|
232
|
+
input: { period: "current" },
|
|
233
|
+
output: { features: [{ name: "api_calls", used: 100, limit: 1000 }] }
|
|
234
|
+
}
|
|
235
|
+
]
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
var CheckFeatureAccessContract = defineQuery({
|
|
239
|
+
meta: {
|
|
240
|
+
key: "saas.billing.feature.check",
|
|
241
|
+
version: "1.0.0",
|
|
242
|
+
stability: "stable",
|
|
243
|
+
owners: [...OWNERS],
|
|
244
|
+
tags: ["saas", "billing", "feature"],
|
|
245
|
+
description: "Check if organization has access to a feature.",
|
|
246
|
+
goal: "Gate features based on plan/usage.",
|
|
247
|
+
context: "Feature access checks, upgrade prompts."
|
|
248
|
+
},
|
|
249
|
+
io: {
|
|
250
|
+
input: CheckFeatureAccessInputModel,
|
|
251
|
+
output: CheckFeatureAccessOutputModel
|
|
252
|
+
},
|
|
253
|
+
policy: {
|
|
254
|
+
auth: "user"
|
|
255
|
+
},
|
|
256
|
+
acceptance: {
|
|
257
|
+
scenarios: [
|
|
258
|
+
{
|
|
259
|
+
key: "check-access-granted",
|
|
260
|
+
given: ["Organization is on Pro plan"],
|
|
261
|
+
when: ["User checks access to Pro feature"],
|
|
262
|
+
then: ["Access is granted"]
|
|
263
|
+
}
|
|
264
|
+
],
|
|
265
|
+
examples: [
|
|
266
|
+
{
|
|
267
|
+
key: "check-advanced-reports",
|
|
268
|
+
input: { feature: "advanced_reports" },
|
|
269
|
+
output: { hasAccess: true, reason: "Included in Pro plan" }
|
|
270
|
+
}
|
|
271
|
+
]
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
export {
|
|
275
|
+
RecordUsageContract,
|
|
276
|
+
GetUsageSummaryContract,
|
|
277
|
+
GetSubscriptionContract,
|
|
278
|
+
CheckFeatureAccessContract
|
|
279
|
+
};
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import * as _contractspec_lib_contracts8 from "@contractspec/lib.contracts";
|
|
2
|
-
|
|
3
|
-
//#region src/billing/billing.presentation.d.ts
|
|
4
1
|
/**
|
|
5
2
|
* Presentation for subscription overview.
|
|
6
3
|
*/
|
|
7
|
-
declare const SubscriptionPresentation:
|
|
4
|
+
export declare const SubscriptionPresentation: import("@contractspec/lib.contracts").PresentationSpec;
|
|
8
5
|
/**
|
|
9
6
|
* Presentation for usage dashboard.
|
|
10
7
|
*/
|
|
11
|
-
declare const UsageDashboardPresentation:
|
|
12
|
-
//#endregion
|
|
13
|
-
export { SubscriptionPresentation, UsageDashboardPresentation };
|
|
8
|
+
export declare const UsageDashboardPresentation: import("@contractspec/lib.contracts").PresentationSpec;
|
|
14
9
|
//# sourceMappingURL=billing.presentation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"billing.presentation.d.ts","
|
|
1
|
+
{"version":3,"file":"billing.presentation.d.ts","sourceRoot":"","sources":["../../src/billing/billing.presentation.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,wBAAwB,wDAuBnC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,0BAA0B,wDAsBrC,CAAC"}
|
|
@@ -1,59 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
policy: { flags: ["saas.billing.enabled"] }
|
|
1
|
+
// @bun
|
|
2
|
+
// src/billing/billing.presentation.ts
|
|
3
|
+
import { definePresentation, StabilityEnum } from "@contractspec/lib.contracts";
|
|
4
|
+
var SubscriptionPresentation = definePresentation({
|
|
5
|
+
meta: {
|
|
6
|
+
key: "saas.billing.subscription",
|
|
7
|
+
version: "1.0.0",
|
|
8
|
+
title: "Subscription Status",
|
|
9
|
+
description: "Subscription status with plan info, limits, and current usage",
|
|
10
|
+
domain: "saas-boilerplate",
|
|
11
|
+
owners: ["@saas-team"],
|
|
12
|
+
tags: ["billing", "subscription"],
|
|
13
|
+
stability: StabilityEnum.Beta,
|
|
14
|
+
goal: "View subscription plan and status",
|
|
15
|
+
context: "Billing section"
|
|
16
|
+
},
|
|
17
|
+
source: {
|
|
18
|
+
type: "component",
|
|
19
|
+
framework: "react",
|
|
20
|
+
componentKey: "SubscriptionView"
|
|
21
|
+
},
|
|
22
|
+
targets: ["react", "markdown"],
|
|
23
|
+
policy: {
|
|
24
|
+
flags: ["saas.billing.enabled"]
|
|
25
|
+
}
|
|
27
26
|
});
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
framework: "react",
|
|
51
|
-
componentKey: "UsageDashboardView"
|
|
52
|
-
},
|
|
53
|
-
targets: ["react", "markdown"],
|
|
54
|
-
policy: { flags: ["saas.billing.enabled"] }
|
|
27
|
+
var UsageDashboardPresentation = definePresentation({
|
|
28
|
+
meta: {
|
|
29
|
+
key: "saas.billing.usage",
|
|
30
|
+
version: "1.0.0",
|
|
31
|
+
title: "Usage Dashboard",
|
|
32
|
+
description: "Usage metrics and breakdown by resource type",
|
|
33
|
+
domain: "saas-boilerplate",
|
|
34
|
+
owners: ["@saas-team"],
|
|
35
|
+
tags: ["billing", "usage", "metrics"],
|
|
36
|
+
stability: StabilityEnum.Beta,
|
|
37
|
+
goal: "Monitor feature usage and limits",
|
|
38
|
+
context: "Billing section"
|
|
39
|
+
},
|
|
40
|
+
source: {
|
|
41
|
+
type: "component",
|
|
42
|
+
framework: "react",
|
|
43
|
+
componentKey: "UsageDashboardView"
|
|
44
|
+
},
|
|
45
|
+
targets: ["react", "markdown"],
|
|
46
|
+
policy: {
|
|
47
|
+
flags: ["saas.billing.enabled"]
|
|
48
|
+
}
|
|
55
49
|
});
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
50
|
+
export {
|
|
51
|
+
UsageDashboardPresentation,
|
|
52
|
+
SubscriptionPresentation
|
|
53
|
+
};
|