@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,153 +1,91 @@
|
|
|
1
|
-
|
|
1
|
+
// @bun
|
|
2
|
+
// src/billing/billing.event.ts
|
|
2
3
|
import { ScalarTypeEnum, defineSchemaModel } from "@contractspec/lib.schema";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
quantity: {
|
|
21
|
-
type: ScalarTypeEnum.Int_unsecure(),
|
|
22
|
-
isOptional: false
|
|
23
|
-
},
|
|
24
|
-
billingPeriod: {
|
|
25
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
26
|
-
isOptional: false
|
|
27
|
-
},
|
|
28
|
-
recordedAt: {
|
|
29
|
-
type: ScalarTypeEnum.DateTime(),
|
|
30
|
-
isOptional: false
|
|
31
|
-
}
|
|
32
|
-
}
|
|
4
|
+
import { defineEvent } from "@contractspec/lib.contracts";
|
|
5
|
+
var UsageRecordedPayload = defineSchemaModel({
|
|
6
|
+
name: "UsageRecordedPayload",
|
|
7
|
+
description: "Payload when feature usage is recorded",
|
|
8
|
+
fields: {
|
|
9
|
+
organizationId: {
|
|
10
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
11
|
+
isOptional: false
|
|
12
|
+
},
|
|
13
|
+
feature: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
14
|
+
quantity: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
15
|
+
billingPeriod: {
|
|
16
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
17
|
+
isOptional: false
|
|
18
|
+
},
|
|
19
|
+
recordedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
20
|
+
}
|
|
33
21
|
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
isOptional: false
|
|
48
|
-
},
|
|
49
|
-
limit: {
|
|
50
|
-
type: ScalarTypeEnum.Int_unsecure(),
|
|
51
|
-
isOptional: false
|
|
52
|
-
},
|
|
53
|
-
currentUsage: {
|
|
54
|
-
type: ScalarTypeEnum.Int_unsecure(),
|
|
55
|
-
isOptional: false
|
|
56
|
-
},
|
|
57
|
-
reachedAt: {
|
|
58
|
-
type: ScalarTypeEnum.DateTime(),
|
|
59
|
-
isOptional: false
|
|
60
|
-
}
|
|
61
|
-
}
|
|
22
|
+
var UsageLimitReachedPayload = defineSchemaModel({
|
|
23
|
+
name: "UsageLimitReachedPayload",
|
|
24
|
+
description: "Payload when usage limit is reached",
|
|
25
|
+
fields: {
|
|
26
|
+
organizationId: {
|
|
27
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
28
|
+
isOptional: false
|
|
29
|
+
},
|
|
30
|
+
feature: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
31
|
+
limit: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
32
|
+
currentUsage: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
|
|
33
|
+
reachedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
34
|
+
}
|
|
62
35
|
});
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
isOptional: false
|
|
81
|
-
},
|
|
82
|
-
previousStatus: {
|
|
83
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
84
|
-
isOptional: true
|
|
85
|
-
},
|
|
86
|
-
newStatus: {
|
|
87
|
-
type: ScalarTypeEnum.String_unsecure(),
|
|
88
|
-
isOptional: false
|
|
89
|
-
},
|
|
90
|
-
changedAt: {
|
|
91
|
-
type: ScalarTypeEnum.DateTime(),
|
|
92
|
-
isOptional: false
|
|
93
|
-
}
|
|
94
|
-
}
|
|
36
|
+
var SubscriptionChangedPayload = defineSchemaModel({
|
|
37
|
+
name: "SubscriptionChangedPayload",
|
|
38
|
+
description: "Payload when subscription status changes",
|
|
39
|
+
fields: {
|
|
40
|
+
organizationId: {
|
|
41
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
42
|
+
isOptional: false
|
|
43
|
+
},
|
|
44
|
+
previousPlan: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
|
|
45
|
+
newPlan: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
46
|
+
previousStatus: {
|
|
47
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
48
|
+
isOptional: true
|
|
49
|
+
},
|
|
50
|
+
newStatus: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
51
|
+
changedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
|
|
52
|
+
}
|
|
95
53
|
});
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
tags: [
|
|
107
|
-
"billing",
|
|
108
|
-
"usage",
|
|
109
|
-
"recorded"
|
|
110
|
-
]
|
|
111
|
-
},
|
|
112
|
-
payload: UsageRecordedPayload
|
|
54
|
+
var UsageRecordedEvent = defineEvent({
|
|
55
|
+
meta: {
|
|
56
|
+
key: "billing.usage.recorded",
|
|
57
|
+
version: "1.0.0",
|
|
58
|
+
description: "Feature usage has been recorded.",
|
|
59
|
+
stability: "stable",
|
|
60
|
+
owners: ["@saas-team"],
|
|
61
|
+
tags: ["billing", "usage", "recorded"]
|
|
62
|
+
},
|
|
63
|
+
payload: UsageRecordedPayload
|
|
113
64
|
});
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
tags: [
|
|
125
|
-
"billing",
|
|
126
|
-
"limit",
|
|
127
|
-
"reached"
|
|
128
|
-
]
|
|
129
|
-
},
|
|
130
|
-
payload: UsageLimitReachedPayload
|
|
65
|
+
var UsageLimitReachedEvent = defineEvent({
|
|
66
|
+
meta: {
|
|
67
|
+
key: "billing.limit.reached",
|
|
68
|
+
version: "1.0.0",
|
|
69
|
+
description: "Usage limit has been reached for a feature.",
|
|
70
|
+
stability: "stable",
|
|
71
|
+
owners: ["@saas-team"],
|
|
72
|
+
tags: ["billing", "limit", "reached"]
|
|
73
|
+
},
|
|
74
|
+
payload: UsageLimitReachedPayload
|
|
131
75
|
});
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
tags: [
|
|
143
|
-
"billing",
|
|
144
|
-
"subscription",
|
|
145
|
-
"changed"
|
|
146
|
-
]
|
|
147
|
-
},
|
|
148
|
-
payload: SubscriptionChangedPayload
|
|
76
|
+
var SubscriptionChangedEvent = defineEvent({
|
|
77
|
+
meta: {
|
|
78
|
+
key: "billing.subscription.changed",
|
|
79
|
+
version: "1.0.0",
|
|
80
|
+
description: "Subscription status has changed.",
|
|
81
|
+
stability: "stable",
|
|
82
|
+
owners: ["@saas-team"],
|
|
83
|
+
tags: ["billing", "subscription", "changed"]
|
|
84
|
+
},
|
|
85
|
+
payload: SubscriptionChangedPayload
|
|
149
86
|
});
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
87
|
+
export {
|
|
88
|
+
UsageRecordedEvent,
|
|
89
|
+
UsageLimitReachedEvent,
|
|
90
|
+
SubscriptionChangedEvent
|
|
91
|
+
};
|
|
@@ -1,82 +1,79 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
1
|
+
export interface Subscription {
|
|
2
|
+
id: string;
|
|
3
|
+
organizationId: string;
|
|
4
|
+
planId: string;
|
|
5
|
+
planName: string;
|
|
6
|
+
status: 'ACTIVE' | 'TRIALING' | 'PAST_DUE' | 'CANCELED' | 'UNPAID';
|
|
7
|
+
currentPeriodStart: Date;
|
|
8
|
+
currentPeriodEnd: Date;
|
|
9
|
+
limits: {
|
|
10
|
+
projects: number;
|
|
11
|
+
users: number;
|
|
12
|
+
storage: number;
|
|
13
|
+
apiCalls: number;
|
|
14
|
+
};
|
|
15
|
+
usage: {
|
|
16
|
+
projects: number;
|
|
17
|
+
users: number;
|
|
18
|
+
storage: number;
|
|
19
|
+
apiCalls: number;
|
|
20
|
+
};
|
|
22
21
|
}
|
|
23
|
-
interface UsageSummary {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
22
|
+
export interface UsageSummary {
|
|
23
|
+
organizationId: string;
|
|
24
|
+
period: string;
|
|
25
|
+
apiCalls: {
|
|
26
|
+
total: number;
|
|
27
|
+
limit: number;
|
|
28
|
+
percentUsed: number;
|
|
29
|
+
};
|
|
30
|
+
storage: {
|
|
31
|
+
totalGb: number;
|
|
32
|
+
limitGb: number;
|
|
33
|
+
percentUsed: number;
|
|
34
|
+
};
|
|
35
|
+
activeProjects: number;
|
|
36
|
+
activeUsers: number;
|
|
37
|
+
breakdown: {
|
|
38
|
+
date: string;
|
|
39
|
+
apiCalls: number;
|
|
40
|
+
storageGb: number;
|
|
41
|
+
}[];
|
|
43
42
|
}
|
|
44
|
-
interface RecordUsageInput {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
export interface RecordUsageInput {
|
|
44
|
+
metric: string;
|
|
45
|
+
quantity: number;
|
|
46
|
+
timestamp?: Date;
|
|
47
|
+
metadata?: Record<string, unknown>;
|
|
49
48
|
}
|
|
50
|
-
interface CheckFeatureAccessInput {
|
|
51
|
-
|
|
49
|
+
export interface CheckFeatureAccessInput {
|
|
50
|
+
feature: string;
|
|
52
51
|
}
|
|
53
|
-
interface CheckFeatureAccessOutput {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
export interface CheckFeatureAccessOutput {
|
|
53
|
+
allowed: boolean;
|
|
54
|
+
reason?: 'PLAN_LIMIT' | 'FEATURE_NOT_INCLUDED' | 'QUOTA_EXCEEDED' | 'SUBSCRIPTION_INACTIVE';
|
|
55
|
+
currentUsage?: number;
|
|
56
|
+
limit?: number;
|
|
58
57
|
}
|
|
59
58
|
/**
|
|
60
59
|
* Mock handler for GetSubscriptionContract.
|
|
61
60
|
*/
|
|
62
|
-
declare function mockGetSubscriptionHandler(): Promise<Subscription>;
|
|
61
|
+
export declare function mockGetSubscriptionHandler(): Promise<Subscription>;
|
|
63
62
|
/**
|
|
64
63
|
* Mock handler for GetUsageSummaryContract.
|
|
65
64
|
*/
|
|
66
|
-
declare function mockGetUsageSummaryHandler(input: {
|
|
67
|
-
|
|
65
|
+
export declare function mockGetUsageSummaryHandler(input: {
|
|
66
|
+
period?: string;
|
|
68
67
|
}): Promise<UsageSummary>;
|
|
69
68
|
/**
|
|
70
69
|
* Mock handler for RecordUsageContract.
|
|
71
70
|
*/
|
|
72
|
-
declare function mockRecordUsageHandler(input: RecordUsageInput): Promise<{
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
export declare function mockRecordUsageHandler(input: RecordUsageInput): Promise<{
|
|
72
|
+
recorded: boolean;
|
|
73
|
+
newTotal: number;
|
|
75
74
|
}>;
|
|
76
75
|
/**
|
|
77
76
|
* Mock handler for CheckFeatureAccessContract.
|
|
78
77
|
*/
|
|
79
|
-
declare function mockCheckFeatureAccessHandler(input: CheckFeatureAccessInput): Promise<CheckFeatureAccessOutput>;
|
|
80
|
-
//#endregion
|
|
81
|
-
export { CheckFeatureAccessInput, CheckFeatureAccessOutput, RecordUsageInput, Subscription, UsageSummary, mockCheckFeatureAccessHandler, mockGetSubscriptionHandler, mockGetUsageSummaryHandler, mockRecordUsageHandler };
|
|
78
|
+
export declare function mockCheckFeatureAccessHandler(input: CheckFeatureAccessInput): Promise<CheckFeatureAccessOutput>;
|
|
82
79
|
//# sourceMappingURL=billing.handler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"billing.handler.d.ts","
|
|
1
|
+
{"version":3,"file":"billing.handler.d.ts","sourceRoot":"","sources":["../../src/billing/billing.handler.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,QAAQ,GAAG,UAAU,GAAG,UAAU,GAAG,UAAU,GAAG,QAAQ,CAAC;IACnE,kBAAkB,EAAE,IAAI,CAAC;IACzB,gBAAgB,EAAE,IAAI,CAAC;IACvB,MAAM,EAAE;QACN,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,KAAK,EAAE;QACL,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED,MAAM,WAAW,YAAY;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE;QACR,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,OAAO,EAAE;QACP,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE;QACT,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;KACnB,EAAE,CAAC;CACL;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EACH,YAAY,GACZ,sBAAsB,GACtB,gBAAgB,GAChB,uBAAuB,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,wBAAsB,0BAA0B,IAAI,OAAO,CAAC,YAAY,CAAC,CAExE;AAED;;GAEG;AACH,wBAAsB,0BAA0B,CAAC,KAAK,EAAE;IACtD,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC,YAAY,CAAC,CAKxB;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAC1C,KAAK,EAAE,gBAAgB,GACtB,OAAO,CAAC;IAAE,QAAQ,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAQlD;AAED;;GAEG;AACH,wBAAsB,6BAA6B,CACjD,KAAK,EAAE,uBAAuB,GAC7B,OAAO,CAAC,wBAAwB,CAAC,CAyBnC"}
|
|
@@ -1,58 +1,149 @@
|
|
|
1
|
-
|
|
1
|
+
// @bun
|
|
2
|
+
// src/shared/mock-data.ts
|
|
3
|
+
var MOCK_PROJECTS = [
|
|
4
|
+
{
|
|
5
|
+
id: "proj-1",
|
|
6
|
+
name: "Marketing Website",
|
|
7
|
+
description: "Main company website redesign project",
|
|
8
|
+
slug: "marketing-website",
|
|
9
|
+
organizationId: "demo-org",
|
|
10
|
+
createdBy: "user-1",
|
|
11
|
+
status: "ACTIVE",
|
|
12
|
+
isPublic: false,
|
|
13
|
+
tags: ["marketing", "website", "redesign"],
|
|
14
|
+
createdAt: new Date("2024-01-15T10:00:00Z"),
|
|
15
|
+
updatedAt: new Date("2024-03-20T14:30:00Z")
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
id: "proj-2",
|
|
19
|
+
name: "Mobile App v2",
|
|
20
|
+
description: "Next generation mobile application",
|
|
21
|
+
slug: "mobile-app-v2",
|
|
22
|
+
organizationId: "demo-org",
|
|
23
|
+
createdBy: "user-2",
|
|
24
|
+
status: "ACTIVE",
|
|
25
|
+
isPublic: false,
|
|
26
|
+
tags: ["mobile", "app", "v2"],
|
|
27
|
+
createdAt: new Date("2024-02-01T09:00:00Z"),
|
|
28
|
+
updatedAt: new Date("2024-04-05T11:15:00Z")
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: "proj-3",
|
|
32
|
+
name: "API Integration",
|
|
33
|
+
description: "Third-party API integration project",
|
|
34
|
+
slug: "api-integration",
|
|
35
|
+
organizationId: "demo-org",
|
|
36
|
+
createdBy: "user-1",
|
|
37
|
+
status: "DRAFT",
|
|
38
|
+
isPublic: false,
|
|
39
|
+
tags: ["api", "integration"],
|
|
40
|
+
createdAt: new Date("2024-03-10T08:00:00Z"),
|
|
41
|
+
updatedAt: new Date("2024-03-10T08:00:00Z")
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
id: "proj-4",
|
|
45
|
+
name: "Analytics Dashboard",
|
|
46
|
+
description: "Internal analytics and reporting dashboard",
|
|
47
|
+
slug: "analytics-dashboard",
|
|
48
|
+
organizationId: "demo-org",
|
|
49
|
+
createdBy: "user-3",
|
|
50
|
+
status: "ARCHIVED",
|
|
51
|
+
isPublic: true,
|
|
52
|
+
tags: ["analytics", "dashboard", "reporting"],
|
|
53
|
+
createdAt: new Date("2023-10-01T12:00:00Z"),
|
|
54
|
+
updatedAt: new Date("2024-02-28T16:45:00Z")
|
|
55
|
+
}
|
|
56
|
+
];
|
|
57
|
+
var MOCK_SUBSCRIPTION = {
|
|
58
|
+
id: "sub-1",
|
|
59
|
+
organizationId: "demo-org",
|
|
60
|
+
planId: "pro",
|
|
61
|
+
planName: "Professional",
|
|
62
|
+
status: "ACTIVE",
|
|
63
|
+
currentPeriodStart: new Date("2024-04-01T00:00:00Z"),
|
|
64
|
+
currentPeriodEnd: new Date("2024-05-01T00:00:00Z"),
|
|
65
|
+
limits: {
|
|
66
|
+
projects: 25,
|
|
67
|
+
users: 10,
|
|
68
|
+
storage: 50,
|
|
69
|
+
apiCalls: 1e5
|
|
70
|
+
},
|
|
71
|
+
usage: {
|
|
72
|
+
projects: 4,
|
|
73
|
+
users: 5,
|
|
74
|
+
storage: 12.5,
|
|
75
|
+
apiCalls: 45230
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
var MOCK_USAGE_SUMMARY = {
|
|
79
|
+
organizationId: "demo-org",
|
|
80
|
+
period: "current_month",
|
|
81
|
+
apiCalls: {
|
|
82
|
+
total: 45230,
|
|
83
|
+
limit: 1e5,
|
|
84
|
+
percentUsed: 45.23
|
|
85
|
+
},
|
|
86
|
+
storage: {
|
|
87
|
+
totalGb: 12.5,
|
|
88
|
+
limitGb: 50,
|
|
89
|
+
percentUsed: 25
|
|
90
|
+
},
|
|
91
|
+
activeProjects: 4,
|
|
92
|
+
activeUsers: 5,
|
|
93
|
+
breakdown: [
|
|
94
|
+
{ date: "2024-04-01", apiCalls: 3200, storageGb: 12.1 },
|
|
95
|
+
{ date: "2024-04-02", apiCalls: 2800, storageGb: 12.2 },
|
|
96
|
+
{ date: "2024-04-03", apiCalls: 4100, storageGb: 12.3 },
|
|
97
|
+
{ date: "2024-04-04", apiCalls: 3600, storageGb: 12.4 },
|
|
98
|
+
{ date: "2024-04-05", apiCalls: 3800, storageGb: 12.5 }
|
|
99
|
+
]
|
|
100
|
+
};
|
|
2
101
|
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Mock handlers for Billing contracts.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Mock handler for GetSubscriptionContract.
|
|
9
|
-
*/
|
|
102
|
+
// src/billing/billing.handler.ts
|
|
10
103
|
async function mockGetSubscriptionHandler() {
|
|
11
|
-
|
|
104
|
+
return MOCK_SUBSCRIPTION;
|
|
12
105
|
}
|
|
13
|
-
/**
|
|
14
|
-
* Mock handler for GetUsageSummaryContract.
|
|
15
|
-
*/
|
|
16
106
|
async function mockGetUsageSummaryHandler(input) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
107
|
+
return {
|
|
108
|
+
...MOCK_USAGE_SUMMARY,
|
|
109
|
+
period: input.period ?? "current_month"
|
|
110
|
+
};
|
|
21
111
|
}
|
|
22
|
-
/**
|
|
23
|
-
* Mock handler for RecordUsageContract.
|
|
24
|
-
*/
|
|
25
112
|
async function mockRecordUsageHandler(input) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
113
|
+
const currentUsage = MOCK_USAGE_SUMMARY.apiCalls.total;
|
|
114
|
+
const newTotal = currentUsage + input.quantity;
|
|
115
|
+
return {
|
|
116
|
+
recorded: true,
|
|
117
|
+
newTotal
|
|
118
|
+
};
|
|
30
119
|
}
|
|
31
|
-
/**
|
|
32
|
-
* Mock handler for CheckFeatureAccessContract.
|
|
33
|
-
*/
|
|
34
120
|
async function mockCheckFeatureAccessHandler(input) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
121
|
+
const { feature } = input;
|
|
122
|
+
const featureMap = {
|
|
123
|
+
custom_domains: {
|
|
124
|
+
allowed: true
|
|
125
|
+
},
|
|
126
|
+
api_access: {
|
|
127
|
+
allowed: true,
|
|
128
|
+
currentUsage: MOCK_USAGE_SUMMARY.apiCalls.total,
|
|
129
|
+
limit: MOCK_USAGE_SUMMARY.apiCalls.limit
|
|
130
|
+
},
|
|
131
|
+
advanced_analytics: {
|
|
132
|
+
allowed: false,
|
|
133
|
+
reason: "FEATURE_NOT_INCLUDED"
|
|
134
|
+
},
|
|
135
|
+
unlimited_projects: {
|
|
136
|
+
allowed: false,
|
|
137
|
+
reason: "PLAN_LIMIT",
|
|
138
|
+
currentUsage: MOCK_SUBSCRIPTION.usage.projects,
|
|
139
|
+
limit: MOCK_SUBSCRIPTION.limits.projects
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
return featureMap[feature] ?? { allowed: true };
|
|
54
143
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
144
|
+
export {
|
|
145
|
+
mockRecordUsageHandler,
|
|
146
|
+
mockGetUsageSummaryHandler,
|
|
147
|
+
mockGetSubscriptionHandler,
|
|
148
|
+
mockCheckFeatureAccessHandler
|
|
149
|
+
};
|