Skip to content

Commit 9ef9f43

Browse files
committed
fix(api): move subjects back to OpenMeter
Signed-off-by: Mark Sagi-Kazar <[email protected]>
1 parent fbba1c9 commit 9ef9f43

File tree

4 files changed

+64
-60
lines changed

4 files changed

+64
-60
lines changed

api/spec/src/cloud/subjects.tsp

+3-53
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ interface Subjects {
1616
*/
1717
@get
1818
@operationId("listSubjects")
19-
list(): Subject[] | OpenMeter.CommonErrors;
19+
list(): OpenMeter.Subject[] | OpenMeter.CommonErrors;
2020

2121
/**
2222
* Get subject by ID or key.
2323
*/
2424
@get
2525
@operationId("getSubject")
26-
get(@path subjectIdOrKey: string): Subject | OpenMeter.NotFoundError | OpenMeter.CommonErrors;
26+
get(@path subjectIdOrKey: string): OpenMeter.Subject | OpenMeter.NotFoundError | OpenMeter.CommonErrors;
2727

2828
/**
2929
* Upserts a subject. Creates or updates subject.
@@ -33,7 +33,7 @@ interface Subjects {
3333
*/
3434
@post
3535
@operationId("upsertSubject")
36-
upsert(@body subject: Subject[]): Subject[] | OpenMeter.CommonErrors;
36+
upsert(@body subject: OpenMeter.Subject[]): OpenMeter.Subject[] | OpenMeter.CommonErrors;
3737

3838
/**
3939
* Delete subject by ID or key.
@@ -42,53 +42,3 @@ interface Subjects {
4242
@operationId("deleteSubject")
4343
delete(@path subjectIdOrKey: string): void | OpenMeter.CommonErrors;
4444
}
45-
46-
/**
47-
* A subject is a unique identifier for a user or entity.
48-
*/
49-
@friendlyName("Subject")
50-
@example(#{
51-
id: "01G65Z755AFWAKHE12NY0CQ9FH",
52-
key: "customer-id",
53-
displayName: "Customer Name",
54-
metadata: #{ hubspotId: "123456" },
55-
currentPeriodStart: DateTime.fromISO("2023-01-01T00:00:00Z"),
56-
currentPeriodEnd: DateTime.fromISO("2023-02-01T00:00:00Z"),
57-
stripeCustomerId: "cus_JMOlctsKV8",
58-
})
59-
model Subject {
60-
// Validator doesn't obey required for readOnly properties
61-
// See: https://github.com/stoplightio/spectral/issues/1274
62-
63-
/**
64-
* A unique identifier for the subject.
65-
*/
66-
@visibility("read")
67-
@example("01G65Z755AFWAKHE12NY0CQ9FH")
68-
id: ULID;
69-
70-
/**
71-
* A unique, human-readable identifier for the subject.
72-
* Must consist only alphanumeric and underscore characters.
73-
*/
74-
@example("customer-id")
75-
key: Key;
76-
77-
/**
78-
* A human-readable display name for the subject.
79-
*/
80-
@example("Customer Name")
81-
displayName?: string;
82-
83-
@example(#{ hubspotId: "123456" })
84-
metadata?: Record<string>;
85-
86-
@example(DateTime.fromISO("2023-01-01T00:00:00Z"))
87-
currentPeriodStart?: DateTime;
88-
89-
@example(DateTime.fromISO("2023-02-01T00:00:00Z"))
90-
currentPeriodEnd?: DateTime;
91-
92-
@example("cus_JMOlctsKV8")
93-
stripeCustomerId?: string;
94-
}

api/spec/src/main.tsp

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import "./customer.tsp";
1313
import "./events.tsp";
1414
import "./meters.tsp";
1515
import "./portal.tsp";
16+
import "./subjects.tsp";
1617
import "./debug.tsp";
1718
import "./notification";
1819
import "./entitlements";

api/spec/src/notification/event.tsp

+1-7
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ model EventBalanceThresholdPayloadData {
108108

109109
@visibility("read")
110110
@summary("Subject")
111-
subject: Subject;
111+
subject: OpenMeter.Subject;
112112

113113
@visibility("read")
114114
@summary("Entitlement Value")
@@ -119,12 +119,6 @@ model EventBalanceThresholdPayloadData {
119119
threshold: RuleBalanceThresholdValue;
120120
}
121121

122-
/**
123-
* FIXME: move subject api to OpenMeter so Subject model is avaiable here.
124-
*/
125-
@friendlyName("DummySubject")
126-
model Subject {}
127-
128122
/**
129123
* Type of the notification event.
130124
*/

api/spec/src/subjects.tsp

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import "@typespec/http";
2+
import "@typespec/rest";
3+
import "@typespec/openapi3";
4+
5+
using TypeSpec.Http;
6+
using TypeSpec.Rest;
7+
using TypeSpec.OpenAPI;
8+
9+
namespace OpenMeter;
10+
11+
/**
12+
* A subject is a unique identifier for a user or entity.
13+
*/
14+
@friendlyName("Subject")
15+
@example(#{
16+
id: "01G65Z755AFWAKHE12NY0CQ9FH",
17+
key: "customer-id",
18+
displayName: "Customer Name",
19+
metadata: #{ hubspotId: "123456" },
20+
currentPeriodStart: DateTime.fromISO("2023-01-01T00:00:00Z"),
21+
currentPeriodEnd: DateTime.fromISO("2023-02-01T00:00:00Z"),
22+
stripeCustomerId: "cus_JMOlctsKV8",
23+
})
24+
model Subject {
25+
// Validator doesn't obey required for readOnly properties
26+
// See: https://github.com/stoplightio/spectral/issues/1274
27+
28+
/**
29+
* A unique identifier for the subject.
30+
*/
31+
@visibility("read")
32+
@example("01G65Z755AFWAKHE12NY0CQ9FH")
33+
id: ULID;
34+
35+
/**
36+
* A unique, human-readable identifier for the subject.
37+
* Must consist only alphanumeric and underscore characters.
38+
*/
39+
@example("customer-id")
40+
key: Key;
41+
42+
/**
43+
* A human-readable display name for the subject.
44+
*/
45+
@example("Customer Name")
46+
displayName?: string;
47+
48+
@example(#{ hubspotId: "123456" })
49+
metadata?: Record<string>;
50+
51+
@example(DateTime.fromISO("2023-01-01T00:00:00Z"))
52+
currentPeriodStart?: DateTime;
53+
54+
@example(DateTime.fromISO("2023-02-01T00:00:00Z"))
55+
currentPeriodEnd?: DateTime;
56+
57+
@example("cus_JMOlctsKV8")
58+
stripeCustomerId?: string;
59+
}

0 commit comments

Comments
 (0)