Skip to content

Commit f65e81d

Browse files
authored
feat(api): tax codes v3 spec (#3882)
1 parent 5cb17d1 commit f65e81d

11 files changed

Lines changed: 1149 additions & 526 deletions

File tree

api/spec/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
}
2626
},
2727
"devDependencies": {
28-
"@redocly/cli": "2.14.5",
28+
"@redocly/cli": "2.19.1",
2929
"@types/node": "24.10.1",
3030
"@typespec/compiler": "1.6.0",
3131
"@typespec/http": "1.6.0",
@@ -35,7 +35,7 @@
3535
"@typespec/prettier-plugin-typespec": "1.6.0",
3636
"@typespec/rest": "0.76.0",
3737
"@typespec/versioning": "0.76.0",
38-
"prettier": "3.8.0",
38+
"prettier": "3.8.1",
3939
"yaml": "2.8.2"
4040
},
4141
"private": true,
@@ -53,7 +53,9 @@
5353
"@typespec/http-client-python": "patches/@typespec__http-client-python.patch"
5454
},
5555
"overrides": {
56-
"tar@<=7.5.2": ">=7.5.3"
56+
"minimatch@<10.2.1": ">=10.2.1",
57+
"tar@<7.5.8": ">=7.5.8",
58+
"ajv@>=7.0.0-alpha.0 <8.18.0": ">=8.18.0"
5759
}
5860
}
5961
}

api/spec/pnpm-lock.yaml

Lines changed: 168 additions & 268 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/spec/src/v3/konnect.tsp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import "./entitlements/index.tsp";
1010
import "./subscriptions/index.tsp";
1111
import "./apps/index.tsp";
1212
import "./billing/index.tsp";
13+
import "./tax/index.tsp";
1314

1415
using TypeSpec.Http;
1516
using TypeSpec.OpenAPI;
@@ -43,6 +44,7 @@ using TypeSpec.OpenAPI;
4344
)
4445
@tagMetadata(Shared.AppsTag, #{ description: Shared.AppsDescription })
4546
@tagMetadata(Shared.BillingTag, #{ description: Shared.BillingDescription })
47+
@tagMetadata(Shared.TaxTag, #{ description: Shared.TaxDescription })
4648
@useAuth(systemAccountAccessToken | personalAccessToken | konnectAccessToken)
4749
namespace MeteringAndBilling;
4850

@@ -81,6 +83,10 @@ interface AppsEndpoints extends Apps.AppsOperations {}
8183
@tag(Shared.BillingTag)
8284
interface BillingProfilesEndpoints extends Billing.BillingProfilesOperations {}
8385

86+
@route("/openmeter/tax-codes")
87+
@tag(Shared.TaxTag)
88+
interface TaxCodesEndpoints extends Tax.TaxCodesOperations {}
89+
8490
/**
8591
* The system account access token is meant for automations and integrations that are not directly associated with a human identity.
8692
*/

api/spec/src/v3/openmeter.tsp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ using TypeSpec.OpenAPI;
4040
)
4141
@tagMetadata(Shared.AppsTag, #{ description: Shared.AppsDescription })
4242
@tagMetadata(Shared.BillingTag, #{ description: Shared.BillingDescription })
43+
@tagMetadata(Shared.TaxTag, #{ description: Shared.TaxDescription })
4344
namespace OpenMeter;
4445

4546
@route("/openmeter/events")
@@ -76,3 +77,7 @@ interface AppsEndpoints extends Apps.AppsOperations {}
7677
@route("/openmeter/profiles")
7778
@tag(Shared.BillingTag)
7879
interface BillingProfilesEndpoints extends Billing.BillingProfilesOperations {}
80+
81+
@route("/openmeter/tax-codes")
82+
@tag(Shared.TaxTag)
83+
interface TaxCodesEndpoints extends Tax.TaxCodesOperations {}

api/spec/src/v3/shared/consts.tsp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ const AppsDescription = "Apps enable you to extend and customize billing and usa
2323
const BillingTag = "OpenMeter Billing";
2424
const BillingDescription = "Billing manages the billing profiles, and invoices for customers.";
2525

26+
const TaxTag = "OpenMeter Tax";
27+
const TaxDescription = "Tax codes are used to calculate taxes for customers.";
28+
2629
const UnstableExtension = "x-unstable";
2730
const InternalExtension = "x-internal";
2831
const PrivateExtension = "x-private";

api/spec/src/v3/tax/codes.tsp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import "../shared/resource.tsp";
2+
import "../shared/index.tsp";
3+
import "../apps/app.tsp";
4+
5+
namespace Tax;
6+
7+
/**
8+
* Mapping of app types to tax codes.
9+
*/
10+
@friendlyName("BillingTaxCodeAppMapping")
11+
model TaxCodeAppMapping {
12+
/**
13+
* The app type that the tax code is associated with.
14+
*/
15+
@summary("App type")
16+
app_type: Apps.AppType;
17+
18+
/**
19+
* Tax code.
20+
*/
21+
@summary("Tax code")
22+
tax_code: string;
23+
}
24+
25+
/**
26+
* Tax codes by provider.
27+
*/
28+
@friendlyName("BillingTaxCode")
29+
model TaxCode {
30+
...Shared.ResourceWithKey;
31+
32+
/**
33+
* Mapping of app types to tax codes.
34+
*/
35+
@visibility(Lifecycle.Read, Lifecycle.Update, Lifecycle.Create)
36+
@summary("App type to tax code mappings")
37+
app_mappings: TaxCodeAppMapping[];
38+
}

api/spec/src/v3/tax/index.tsp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import "./codes.tsp";
2+
import "./operations.tsp";

api/spec/src/v3/tax/operations.tsp

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import "@typespec/http";
2+
import "@typespec/rest";
3+
import "@typespec/openapi";
4+
import "@typespec/openapi3";
5+
import "../common/error.tsp";
6+
import "../common/pagination.tsp";
7+
import "../common/parameters.tsp";
8+
import "../shared/index.tsp";
9+
import "./codes.tsp";
10+
11+
using TypeSpec.Http;
12+
using TypeSpec.OpenAPI;
13+
14+
namespace Tax;
15+
16+
interface TaxCodesOperations {
17+
@post
18+
@operationId("create-tax-code")
19+
@summary("Create tax code")
20+
@extension(Shared.PrivateExtension, true)
21+
@extension(Shared.UnstableExtension, true)
22+
create(
23+
@body
24+
tax_code: Shared.CreateRequest<TaxCode>,
25+
): Shared.CreateResponse<TaxCode> | Common.ErrorResponses;
26+
27+
@get
28+
@operationId("get-tax-code")
29+
@summary("Get tax code")
30+
@extension(Shared.PrivateExtension, true)
31+
@extension(Shared.UnstableExtension, true)
32+
get(
33+
@path taxCodeId: Shared.ULID,
34+
): Shared.GetResponse<TaxCode> | Common.NotFound | Common.ErrorResponses;
35+
36+
@get
37+
@operationId("list-tax-codes")
38+
@summary("List tax codes")
39+
@extension(Shared.PrivateExtension, true)
40+
@extension(Shared.UnstableExtension, true)
41+
list(
42+
...Common.PagePaginationQuery,
43+
): Shared.PagePaginatedResponse<TaxCode> | Common.ErrorResponses;
44+
45+
@put
46+
@operationId("upsert-tax-code")
47+
@summary("Upsert tax code")
48+
@extension(Shared.PrivateExtension, true)
49+
@extension(Shared.UnstableExtension, true)
50+
upsert(
51+
@path taxCodeId: Shared.ULID,
52+
53+
@body
54+
tax_code: Shared.UpsertRequest<TaxCode>,
55+
):
56+
| Shared.UpsertResponse<TaxCode>
57+
| Common.Gone
58+
| Common.NotFound
59+
| Common.ErrorResponses;
60+
61+
@delete
62+
@operationId("delete-tax-code")
63+
@summary("Delete tax code")
64+
@extension(Shared.PrivateExtension, true)
65+
@extension(Shared.UnstableExtension, true)
66+
delete(
67+
@path taxCodeId: Shared.ULID,
68+
): Shared.DeleteResponse | Common.NotFound | Common.ErrorResponses;
69+
}

0 commit comments

Comments
 (0)