@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.
Files changed (284) hide show
  1. package/.turbo/turbo-build.log +160 -188
  2. package/.turbo/turbo-prebuild.log +1 -0
  3. package/CHANGELOG.md +45 -0
  4. package/dist/billing/billing.entity.d.ts +40 -45
  5. package/dist/billing/billing.entity.d.ts.map +1 -1
  6. package/dist/billing/billing.entity.js +110 -118
  7. package/dist/billing/billing.enum.d.ts +2 -8
  8. package/dist/billing/billing.enum.d.ts.map +1 -1
  9. package/dist/billing/billing.enum.js +17 -24
  10. package/dist/billing/billing.event.d.ts +67 -73
  11. package/dist/billing/billing.event.d.ts.map +1 -1
  12. package/dist/billing/billing.event.js +84 -146
  13. package/dist/billing/billing.handler.d.ts +59 -62
  14. package/dist/billing/billing.handler.d.ts.map +1 -1
  15. package/dist/billing/billing.handler.js +140 -49
  16. package/dist/billing/billing.operations.d.ts +138 -144
  17. package/dist/billing/billing.operations.d.ts.map +1 -1
  18. package/dist/billing/billing.operations.js +273 -175
  19. package/dist/billing/billing.presentation.d.ts +2 -7
  20. package/dist/billing/billing.presentation.d.ts.map +1 -1
  21. package/dist/billing/billing.presentation.js +51 -57
  22. package/dist/billing/billing.schema.d.ts +159 -164
  23. package/dist/billing/billing.schema.d.ts.map +1 -1
  24. package/dist/billing/billing.schema.js +112 -204
  25. package/dist/billing/index.d.ts +11 -8
  26. package/dist/billing/index.d.ts.map +1 -0
  27. package/dist/billing/index.js +689 -9
  28. package/dist/browser/billing/billing.entity.js +113 -0
  29. package/dist/browser/billing/billing.enum.js +19 -0
  30. package/dist/browser/billing/billing.event.js +90 -0
  31. package/dist/browser/billing/billing.handler.js +148 -0
  32. package/dist/browser/billing/billing.operations.js +278 -0
  33. package/dist/browser/billing/billing.presentation.js +52 -0
  34. package/dist/browser/billing/billing.schema.js +121 -0
  35. package/dist/browser/billing/index.js +688 -0
  36. package/dist/browser/dashboard/dashboard.presentation.js +52 -0
  37. package/dist/browser/dashboard/index.js +52 -0
  38. package/dist/browser/docs/index.js +93 -0
  39. package/dist/browser/docs/saas-boilerplate.docblock.js +93 -0
  40. package/dist/browser/example.js +39 -0
  41. package/dist/browser/handlers/index.js +358 -0
  42. package/dist/browser/handlers/saas.handlers.js +134 -0
  43. package/dist/browser/index.js +3340 -0
  44. package/dist/browser/presentations/index.js +290 -0
  45. package/dist/browser/project/index.js +790 -0
  46. package/dist/browser/project/project.entity.js +77 -0
  47. package/dist/browser/project/project.enum.js +18 -0
  48. package/dist/browser/project/project.event.js +103 -0
  49. package/dist/browser/project/project.handler.js +178 -0
  50. package/dist/browser/project/project.operations.js +372 -0
  51. package/dist/browser/project/project.presentation.js +177 -0
  52. package/dist/browser/project/project.schema.js +134 -0
  53. package/dist/browser/saas-boilerplate.feature.js +88 -0
  54. package/dist/browser/seeders/index.js +20 -0
  55. package/dist/browser/settings/index.js +75 -0
  56. package/dist/browser/settings/settings.entity.js +74 -0
  57. package/dist/browser/settings/settings.enum.js +11 -0
  58. package/dist/browser/shared/mock-data.js +104 -0
  59. package/dist/browser/shared/overlay-types.js +0 -0
  60. package/dist/browser/tests/operations.test-spec.js +112 -0
  61. package/dist/browser/ui/SaasDashboard.js +988 -0
  62. package/dist/browser/ui/SaasProjectList.js +162 -0
  63. package/dist/browser/ui/SaasSettingsPanel.js +145 -0
  64. package/dist/browser/ui/hooks/index.js +159 -0
  65. package/dist/browser/ui/hooks/useProjectList.js +66 -0
  66. package/dist/browser/ui/hooks/useProjectMutations.js +91 -0
  67. package/dist/browser/ui/index.js +1808 -0
  68. package/dist/browser/ui/modals/CreateProjectModal.js +153 -0
  69. package/dist/browser/ui/modals/ProjectActionsModal.js +335 -0
  70. package/dist/browser/ui/modals/index.js +487 -0
  71. package/dist/browser/ui/overlays/demo-overlays.js +61 -0
  72. package/dist/browser/ui/overlays/index.js +61 -0
  73. package/dist/browser/ui/renderers/index.js +675 -0
  74. package/dist/browser/ui/renderers/project-list.markdown.js +499 -0
  75. package/dist/browser/ui/renderers/project-list.renderer.js +177 -0
  76. package/dist/dashboard/dashboard.presentation.d.ts +2 -7
  77. package/dist/dashboard/dashboard.presentation.d.ts.map +1 -1
  78. package/dist/dashboard/dashboard.presentation.js +51 -53
  79. package/dist/dashboard/index.d.ts +5 -2
  80. package/dist/dashboard/index.d.ts.map +1 -0
  81. package/dist/dashboard/index.js +53 -3
  82. package/dist/docs/index.d.ts +2 -1
  83. package/dist/docs/index.d.ts.map +1 -0
  84. package/dist/docs/index.js +94 -1
  85. package/dist/docs/saas-boilerplate.docblock.d.ts +2 -1
  86. package/dist/docs/saas-boilerplate.docblock.d.ts.map +1 -0
  87. package/dist/docs/saas-boilerplate.docblock.js +45 -51
  88. package/dist/example.d.ts +2 -6
  89. package/dist/example.d.ts.map +1 -1
  90. package/dist/example.js +37 -50
  91. package/dist/handlers/index.d.ts +7 -4
  92. package/dist/handlers/index.d.ts.map +1 -0
  93. package/dist/handlers/index.js +358 -4
  94. package/dist/handlers/saas.handlers.d.ts +60 -60
  95. package/dist/handlers/saas.handlers.d.ts.map +1 -1
  96. package/dist/handlers/saas.handlers.js +127 -140
  97. package/dist/index.d.ts +15 -45
  98. package/dist/index.d.ts.map +1 -1
  99. package/dist/index.js +3335 -75
  100. package/dist/node/billing/billing.entity.js +113 -0
  101. package/dist/node/billing/billing.enum.js +19 -0
  102. package/dist/node/billing/billing.event.js +90 -0
  103. package/dist/node/billing/billing.handler.js +148 -0
  104. package/dist/node/billing/billing.operations.js +278 -0
  105. package/dist/node/billing/billing.presentation.js +52 -0
  106. package/dist/node/billing/billing.schema.js +121 -0
  107. package/dist/node/billing/index.js +688 -0
  108. package/dist/node/dashboard/dashboard.presentation.js +52 -0
  109. package/dist/node/dashboard/index.js +52 -0
  110. package/dist/node/docs/index.js +93 -0
  111. package/dist/node/docs/saas-boilerplate.docblock.js +93 -0
  112. package/dist/node/example.js +39 -0
  113. package/dist/node/handlers/index.js +358 -0
  114. package/dist/node/handlers/saas.handlers.js +134 -0
  115. package/dist/node/index.js +3340 -0
  116. package/dist/node/presentations/index.js +290 -0
  117. package/dist/node/project/index.js +790 -0
  118. package/dist/node/project/project.entity.js +77 -0
  119. package/dist/node/project/project.enum.js +18 -0
  120. package/dist/node/project/project.event.js +103 -0
  121. package/dist/node/project/project.handler.js +178 -0
  122. package/dist/node/project/project.operations.js +372 -0
  123. package/dist/node/project/project.presentation.js +177 -0
  124. package/dist/node/project/project.schema.js +134 -0
  125. package/dist/node/saas-boilerplate.feature.js +88 -0
  126. package/dist/node/seeders/index.js +20 -0
  127. package/dist/node/settings/index.js +75 -0
  128. package/dist/node/settings/settings.entity.js +74 -0
  129. package/dist/node/settings/settings.enum.js +11 -0
  130. package/dist/node/shared/mock-data.js +104 -0
  131. package/dist/node/shared/overlay-types.js +0 -0
  132. package/dist/node/tests/operations.test-spec.js +112 -0
  133. package/dist/node/ui/SaasDashboard.js +988 -0
  134. package/dist/node/ui/SaasProjectList.js +162 -0
  135. package/dist/node/ui/SaasSettingsPanel.js +145 -0
  136. package/dist/node/ui/hooks/index.js +159 -0
  137. package/dist/node/ui/hooks/useProjectList.js +66 -0
  138. package/dist/node/ui/hooks/useProjectMutations.js +91 -0
  139. package/dist/node/ui/index.js +1808 -0
  140. package/dist/node/ui/modals/CreateProjectModal.js +153 -0
  141. package/dist/node/ui/modals/ProjectActionsModal.js +335 -0
  142. package/dist/node/ui/modals/index.js +487 -0
  143. package/dist/node/ui/overlays/demo-overlays.js +61 -0
  144. package/dist/node/ui/overlays/index.js +61 -0
  145. package/dist/node/ui/renderers/index.js +675 -0
  146. package/dist/node/ui/renderers/project-list.markdown.js +499 -0
  147. package/dist/node/ui/renderers/project-list.renderer.js +177 -0
  148. package/dist/presentations/index.d.ts +13 -15
  149. package/dist/presentations/index.d.ts.map +1 -1
  150. package/dist/presentations/index.js +289 -15
  151. package/dist/project/index.d.ts +11 -8
  152. package/dist/project/index.d.ts.map +1 -0
  153. package/dist/project/index.js +791 -9
  154. package/dist/project/project.entity.d.ts +23 -28
  155. package/dist/project/project.entity.d.ts.map +1 -1
  156. package/dist/project/project.entity.js +75 -82
  157. package/dist/project/project.enum.d.ts +2 -8
  158. package/dist/project/project.enum.d.ts.map +1 -1
  159. package/dist/project/project.enum.js +16 -23
  160. package/dist/project/project.event.d.ts +69 -75
  161. package/dist/project/project.event.d.ts.map +1 -1
  162. package/dist/project/project.event.js +95 -156
  163. package/dist/project/project.handler.d.ts +44 -47
  164. package/dist/project/project.handler.d.ts.map +1 -1
  165. package/dist/project/project.handler.js +168 -71
  166. package/dist/project/project.operations.d.ts +341 -347
  167. package/dist/project/project.operations.d.ts.map +1 -1
  168. package/dist/project/project.operations.js +366 -253
  169. package/dist/project/project.presentation.d.ts +2 -7
  170. package/dist/project/project.presentation.d.ts.map +1 -1
  171. package/dist/project/project.presentation.js +174 -61
  172. package/dist/project/project.schema.d.ts +191 -196
  173. package/dist/project/project.schema.d.ts.map +1 -1
  174. package/dist/project/project.schema.js +125 -205
  175. package/dist/saas-boilerplate.feature.d.ts +1 -7
  176. package/dist/saas-boilerplate.feature.d.ts.map +1 -1
  177. package/dist/saas-boilerplate.feature.js +87 -206
  178. package/dist/seeders/index.d.ts +4 -8
  179. package/dist/seeders/index.d.ts.map +1 -1
  180. package/dist/seeders/index.js +18 -16
  181. package/dist/settings/index.d.ts +6 -3
  182. package/dist/settings/index.d.ts.map +1 -0
  183. package/dist/settings/index.js +75 -3
  184. package/dist/settings/settings.entity.d.ts +23 -28
  185. package/dist/settings/settings.entity.d.ts.map +1 -1
  186. package/dist/settings/settings.entity.js +72 -75
  187. package/dist/settings/settings.enum.d.ts +1 -6
  188. package/dist/settings/settings.enum.d.ts.map +1 -1
  189. package/dist/settings/settings.enum.js +10 -19
  190. package/dist/shared/mock-data.d.ts +74 -77
  191. package/dist/shared/mock-data.d.ts.map +1 -1
  192. package/dist/shared/mock-data.js +102 -135
  193. package/dist/shared/overlay-types.d.ts +25 -28
  194. package/dist/shared/overlay-types.d.ts.map +1 -1
  195. package/dist/shared/overlay-types.js +1 -0
  196. package/dist/tests/operations.test-spec.d.ts +4 -9
  197. package/dist/tests/operations.test-spec.d.ts.map +1 -1
  198. package/dist/tests/operations.test-spec.js +108 -118
  199. package/dist/ui/SaasDashboard.d.ts +1 -6
  200. package/dist/ui/SaasDashboard.d.ts.map +1 -1
  201. package/dist/ui/SaasDashboard.js +977 -286
  202. package/dist/ui/SaasProjectList.d.ts +4 -11
  203. package/dist/ui/SaasProjectList.d.ts.map +1 -1
  204. package/dist/ui/SaasProjectList.js +159 -72
  205. package/dist/ui/SaasSettingsPanel.d.ts +1 -6
  206. package/dist/ui/SaasSettingsPanel.d.ts.map +1 -1
  207. package/dist/ui/SaasSettingsPanel.js +142 -134
  208. package/dist/ui/hooks/index.d.ts +3 -3
  209. package/dist/ui/hooks/index.d.ts.map +1 -0
  210. package/dist/ui/hooks/index.js +158 -4
  211. package/dist/ui/hooks/useProjectList.d.ts +26 -30
  212. package/dist/ui/hooks/useProjectList.d.ts.map +1 -1
  213. package/dist/ui/hooks/useProjectList.js +63 -71
  214. package/dist/ui/hooks/useProjectMutations.d.ts +20 -24
  215. package/dist/ui/hooks/useProjectMutations.d.ts.map +1 -1
  216. package/dist/ui/hooks/useProjectMutations.js +88 -142
  217. package/dist/ui/index.d.ts +8 -14
  218. package/dist/ui/index.d.ts.map +1 -0
  219. package/dist/ui/index.js +1809 -15
  220. package/dist/ui/modals/CreateProjectModal.d.ts +10 -19
  221. package/dist/ui/modals/CreateProjectModal.d.ts.map +1 -1
  222. package/dist/ui/modals/CreateProjectModal.js +150 -135
  223. package/dist/ui/modals/ProjectActionsModal.d.ts +20 -33
  224. package/dist/ui/modals/ProjectActionsModal.d.ts.map +1 -1
  225. package/dist/ui/modals/ProjectActionsModal.js +333 -289
  226. package/dist/ui/modals/index.d.ts +3 -3
  227. package/dist/ui/modals/index.d.ts.map +1 -0
  228. package/dist/ui/modals/index.js +487 -3
  229. package/dist/ui/overlays/demo-overlays.d.ts +10 -9
  230. package/dist/ui/overlays/demo-overlays.d.ts.map +1 -1
  231. package/dist/ui/overlays/demo-overlays.js +60 -68
  232. package/dist/ui/overlays/index.d.ts +2 -2
  233. package/dist/ui/overlays/index.d.ts.map +1 -0
  234. package/dist/ui/overlays/index.js +62 -3
  235. package/dist/ui/renderers/index.d.ts +3 -3
  236. package/dist/ui/renderers/index.d.ts.map +1 -0
  237. package/dist/ui/renderers/index.js +675 -3
  238. package/dist/ui/renderers/project-list.markdown.d.ts +15 -15
  239. package/dist/ui/renderers/project-list.markdown.d.ts.map +1 -1
  240. package/dist/ui/renderers/project-list.markdown.js +496 -144
  241. package/dist/ui/renderers/project-list.renderer.d.ts +6 -8
  242. package/dist/ui/renderers/project-list.renderer.d.ts.map +1 -1
  243. package/dist/ui/renderers/project-list.renderer.js +176 -15
  244. package/package.json +509 -99
  245. package/src/ui/renderers/project-list.markdown.ts +1 -1
  246. package/tsdown.config.js +1 -2
  247. package/.turbo/turbo-build$colon$bundle.log +0 -188
  248. package/dist/billing/billing.entity.js.map +0 -1
  249. package/dist/billing/billing.enum.js.map +0 -1
  250. package/dist/billing/billing.event.js.map +0 -1
  251. package/dist/billing/billing.handler.js.map +0 -1
  252. package/dist/billing/billing.operations.js.map +0 -1
  253. package/dist/billing/billing.presentation.js.map +0 -1
  254. package/dist/billing/billing.schema.js.map +0 -1
  255. package/dist/dashboard/dashboard.presentation.js.map +0 -1
  256. package/dist/docs/saas-boilerplate.docblock.js.map +0 -1
  257. package/dist/example.js.map +0 -1
  258. package/dist/handlers/saas.handlers.js.map +0 -1
  259. package/dist/index.js.map +0 -1
  260. package/dist/presentations/index.js.map +0 -1
  261. package/dist/project/project.entity.js.map +0 -1
  262. package/dist/project/project.enum.js.map +0 -1
  263. package/dist/project/project.event.js.map +0 -1
  264. package/dist/project/project.handler.js.map +0 -1
  265. package/dist/project/project.operations.js.map +0 -1
  266. package/dist/project/project.presentation.js.map +0 -1
  267. package/dist/project/project.schema.js.map +0 -1
  268. package/dist/saas-boilerplate.feature.js.map +0 -1
  269. package/dist/seeders/index.js.map +0 -1
  270. package/dist/settings/settings.entity.js.map +0 -1
  271. package/dist/settings/settings.enum.js.map +0 -1
  272. package/dist/shared/mock-data.js.map +0 -1
  273. package/dist/tests/operations.test-spec.js.map +0 -1
  274. package/dist/ui/SaasDashboard.js.map +0 -1
  275. package/dist/ui/SaasProjectList.js.map +0 -1
  276. package/dist/ui/SaasSettingsPanel.js.map +0 -1
  277. package/dist/ui/hooks/useProjectList.js.map +0 -1
  278. package/dist/ui/hooks/useProjectMutations.js.map +0 -1
  279. package/dist/ui/modals/CreateProjectModal.js.map +0 -1
  280. package/dist/ui/modals/ProjectActionsModal.js.map +0 -1
  281. package/dist/ui/overlays/demo-overlays.js.map +0 -1
  282. package/dist/ui/renderers/project-list.markdown.js.map +0 -1
  283. package/dist/ui/renderers/project-list.renderer.js.map +0 -1
  284. package/tsconfig.tsbuildinfo +0 -1
@@ -1,181 +1,279 @@
1
- import { CheckFeatureAccessInputModel, CheckFeatureAccessOutputModel, GetUsageSummaryInputModel, GetUsageSummaryOutputModel, RecordUsageInputModel, RecordUsageOutputModel, SubscriptionModel, UsageRecordedPayloadModel } from "./billing.schema.js";
2
- import { defineCommand, defineQuery } from "@contractspec/lib.contracts";
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
- //#region src/billing/billing.operations.ts
5
- const OWNERS = ["@example.saas-boilerplate"];
6
- /**
7
- * Get subscription status.
8
- */
9
- const GetSubscriptionContract = defineQuery({
10
- meta: {
11
- key: "saas.billing.subscription.get",
12
- version: "1.0.0",
13
- stability: "stable",
14
- owners: [...OWNERS],
15
- tags: [
16
- "saas",
17
- "billing",
18
- "subscription"
19
- ],
20
- description: "Get organization subscription status.",
21
- goal: "Show current plan and billing status.",
22
- context: "Billing page, plan upgrade prompts."
23
- },
24
- io: {
25
- input: null,
26
- output: SubscriptionModel
27
- },
28
- policy: { auth: "user" },
29
- acceptance: {
30
- scenarios: [{
31
- key: "get-subscription-happy-path",
32
- given: ["Organization has active subscription"],
33
- when: ["User requests subscription status"],
34
- then: ["Subscription details are returned"]
35
- }],
36
- examples: [{
37
- key: "get-basic",
38
- input: null,
39
- output: {
40
- plan: "pro",
41
- status: "active",
42
- currentPeriodEnd: "2025-02-01T00:00:00Z"
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
- * Record feature usage.
49
- */
50
- const RecordUsageContract = defineCommand({
51
- meta: {
52
- key: "saas.billing.usage.record",
53
- version: "1.0.0",
54
- stability: "stable",
55
- owners: [...OWNERS],
56
- tags: [
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
- * Get usage summary.
99
- */
100
- const GetUsageSummaryContract = defineQuery({
101
- meta: {
102
- key: "saas.billing.usage.summary",
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
- * Check feature access.
140
- */
141
- const CheckFeatureAccessContract = defineQuery({
142
- meta: {
143
- key: "saas.billing.feature.check",
144
- version: "1.0.0",
145
- stability: "stable",
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
- //#endregion
180
- export { CheckFeatureAccessContract, GetSubscriptionContract, GetUsageSummaryContract, RecordUsageContract };
181
- //# sourceMappingURL=billing.operations.js.map
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: _contractspec_lib_contracts8.PresentationSpec;
4
+ export declare const SubscriptionPresentation: import("@contractspec/lib.contracts").PresentationSpec;
8
5
  /**
9
6
  * Presentation for usage dashboard.
10
7
  */
11
- declare const UsageDashboardPresentation: _contractspec_lib_contracts8.PresentationSpec;
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","names":[],"sources":["../../src/billing/billing.presentation.ts"],"sourcesContent":[],"mappings":";;;;;;AAKa,cAAA,wBAuBX,EAAA,4BAAA,CAvBmC,gBAuBnC;AAKF;;;cAAa,4BAsBX,4BAAA,CAtBqC"}
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
- import { StabilityEnum, definePresentation } from "@contractspec/lib.contracts";
2
-
3
- //#region src/billing/billing.presentation.ts
4
- /**
5
- * Presentation for subscription overview.
6
- */
7
- const SubscriptionPresentation = definePresentation({
8
- meta: {
9
- key: "saas.billing.subscription",
10
- version: "1.0.0",
11
- title: "Subscription Status",
12
- description: "Subscription status with plan info, limits, and current usage",
13
- domain: "saas-boilerplate",
14
- owners: ["@saas-team"],
15
- tags: ["billing", "subscription"],
16
- stability: StabilityEnum.Beta,
17
- goal: "View subscription plan and status",
18
- context: "Billing section"
19
- },
20
- source: {
21
- type: "component",
22
- framework: "react",
23
- componentKey: "SubscriptionView"
24
- },
25
- targets: ["react", "markdown"],
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
- * Presentation for usage dashboard.
30
- */
31
- const UsageDashboardPresentation = definePresentation({
32
- meta: {
33
- key: "saas.billing.usage",
34
- version: "1.0.0",
35
- title: "Usage Dashboard",
36
- description: "Usage metrics and breakdown by resource type",
37
- domain: "saas-boilerplate",
38
- owners: ["@saas-team"],
39
- tags: [
40
- "billing",
41
- "usage",
42
- "metrics"
43
- ],
44
- stability: StabilityEnum.Beta,
45
- goal: "Monitor feature usage and limits",
46
- context: "Billing section"
47
- },
48
- source: {
49
- type: "component",
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
- //#endregion
58
- export { SubscriptionPresentation, UsageDashboardPresentation };
59
- //# sourceMappingURL=billing.presentation.js.map
50
+ export {
51
+ UsageDashboardPresentation,
52
+ SubscriptionPresentation
53
+ };