@common-grants/core 0.1.0-alpha.11 → 0.1.0-alpha.13
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/README.md +1 -3
- package/lib/api.tsp +15 -3
- package/lib/core/pagination.tsp +1 -1
- package/lib/core/responses/success.tsp +8 -3
- package/lib/core/routes/opportunities.tsp +7 -3
- package/lib/core/sorting.tsp +8 -5
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -101,9 +101,7 @@ import "./routes.tsp"; // Import the routes from above
|
|
|
101
101
|
using TypeSpec.Http;
|
|
102
102
|
|
|
103
103
|
/** Description of your API goes here */
|
|
104
|
-
@service({
|
|
105
|
-
title: "Custom API",
|
|
106
|
-
})
|
|
104
|
+
@service(#{ title: "Custom API" })
|
|
107
105
|
namespace CustomAPI;
|
|
108
106
|
```
|
|
109
107
|
|
package/lib/api.tsp
CHANGED
|
@@ -11,9 +11,21 @@ using TypeSpec.OpenAPI;
|
|
|
11
11
|
* In order for an API to be "compliant" with the CommonGrants protocol,
|
|
12
12
|
* it must implement all of the routes with the "required" tag in this specification.
|
|
13
13
|
*/
|
|
14
|
-
@service({
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
@service(#{ title: "CommonGrants Base API" })
|
|
15
|
+
@tagMetadata(
|
|
16
|
+
"optional",
|
|
17
|
+
#{ description: "Endpoints that MAY be implemented by CommonGrants APIs" }
|
|
18
|
+
)
|
|
19
|
+
@tagMetadata(
|
|
20
|
+
"required",
|
|
21
|
+
#{
|
|
22
|
+
description: "Endpoints that MUST be implemented by all CommonGrants APIs",
|
|
23
|
+
}
|
|
24
|
+
)
|
|
25
|
+
@tagMetadata(
|
|
26
|
+
"Opportunities",
|
|
27
|
+
#{ description: "Endpoints related to funding opportunities" }
|
|
28
|
+
)
|
|
17
29
|
namespace CommonGrants.API;
|
|
18
30
|
|
|
19
31
|
@tag("Opportunities")
|
package/lib/core/pagination.tsp
CHANGED
|
@@ -75,7 +75,7 @@ model Paginated<T> extends Success {
|
|
|
75
75
|
items: T[];
|
|
76
76
|
|
|
77
77
|
/** Details about the paginated results */
|
|
78
|
-
paginationInfo: Pagination.
|
|
78
|
+
paginationInfo: Pagination.PaginatedResultsInfo;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
// ############################################################################
|
|
@@ -103,7 +103,7 @@ model Sorted<T> {
|
|
|
103
103
|
...Paginated<T>;
|
|
104
104
|
|
|
105
105
|
/** The sort order of the items */
|
|
106
|
-
sortInfo: Sorting.
|
|
106
|
+
sortInfo: Sorting.SortedResultsInfo;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
// ############################################################################
|
|
@@ -137,5 +137,10 @@ model Filtered<ItemsT, FilterT> extends Success {
|
|
|
137
137
|
...Sorted<ItemsT>;
|
|
138
138
|
|
|
139
139
|
/** The filters applied to the response items */
|
|
140
|
-
filterInfo:
|
|
140
|
+
filterInfo: {
|
|
141
|
+
filters: FilterT;
|
|
142
|
+
|
|
143
|
+
/** Non-fatal errors that occurred during filtering */
|
|
144
|
+
errors?: string[];
|
|
145
|
+
};
|
|
141
146
|
}
|
|
@@ -49,7 +49,7 @@ interface Opportunities {
|
|
|
49
49
|
@list
|
|
50
50
|
list<T extends Models.OpportunityBase = Models.OpportunityBase>(
|
|
51
51
|
...Pagination.PaginatedQueryParams,
|
|
52
|
-
): Responses.Paginated<T
|
|
52
|
+
): Responses.Paginated<T>;
|
|
53
53
|
|
|
54
54
|
// ##############################
|
|
55
55
|
// View an opportunity
|
|
@@ -66,7 +66,7 @@ interface Opportunities {
|
|
|
66
66
|
read<T extends Models.OpportunityBase = Models.OpportunityBase>(
|
|
67
67
|
/** The ID of the opportunity to view */
|
|
68
68
|
@path id: Types.uuid,
|
|
69
|
-
): Responses.Ok<T> | Responses.NotFound
|
|
69
|
+
): Responses.Ok<T> | Responses.NotFound;
|
|
70
70
|
|
|
71
71
|
// ###############################
|
|
72
72
|
// Search opportunities
|
|
@@ -82,6 +82,10 @@ interface Opportunities {
|
|
|
82
82
|
@post
|
|
83
83
|
@route("/search")
|
|
84
84
|
search<T extends Models.OpportunityBase = Models.OpportunityBase>(
|
|
85
|
+
/** Opportunity search query */
|
|
86
|
+
@example("Pre-school education")
|
|
87
|
+
search?: string,
|
|
88
|
+
|
|
85
89
|
/** Filters to apply to the opportunity search
|
|
86
90
|
*
|
|
87
91
|
* Multiple filter conditions will be combined with AND logic, so that
|
|
@@ -94,5 +98,5 @@ interface Opportunities {
|
|
|
94
98
|
|
|
95
99
|
/** Pagination instructions for the results */
|
|
96
100
|
pagination?: Pagination.PaginatedBodyParams,
|
|
97
|
-
): Responses.Filtered<T, Models.OppFilters
|
|
101
|
+
): Responses.Filtered<T, Models.OppFilters>;
|
|
98
102
|
}
|
package/lib/core/sorting.tsp
CHANGED
|
@@ -57,16 +57,19 @@ model SortBodyParams {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
/** Information about the sort order of the items returned */
|
|
60
|
-
model
|
|
61
|
-
/** The field
|
|
60
|
+
model SortedResultsInfo {
|
|
61
|
+
/** The field results are sorted by, or "custom" if an implementation-defined sort key is used */
|
|
62
62
|
@example("lastModifiedAt")
|
|
63
63
|
sortBy: string;
|
|
64
64
|
|
|
65
|
-
/** Implementation-defined sort key */
|
|
65
|
+
/** Implementation-defined sort key used to sort the results, if applicable */
|
|
66
66
|
@example("customField")
|
|
67
67
|
customSortBy?: string;
|
|
68
68
|
|
|
69
|
-
/** The order
|
|
69
|
+
/** The order in which the results are sorted, e.g. ascending or descending */
|
|
70
70
|
@example(SortOrder.asc)
|
|
71
|
-
sortOrder
|
|
71
|
+
sortOrder: SortOrder;
|
|
72
|
+
|
|
73
|
+
/** Non-fatal errors that occurred during sorting */
|
|
74
|
+
errors?: string[];
|
|
72
75
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@common-grants/core",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.13",
|
|
4
4
|
"description": "TypeSpec library for defining grant opportunity data models and APIs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -55,11 +55,11 @@
|
|
|
55
55
|
"author": "CommonGrants",
|
|
56
56
|
"license": "CC0-1.0",
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"@typespec/compiler": "^0.
|
|
59
|
-
"@typespec/http": "^0.
|
|
60
|
-
"@typespec/json-schema": "^0.
|
|
61
|
-
"@typespec/openapi3": "^0.
|
|
62
|
-
"@typespec/rest": "^0.
|
|
58
|
+
"@typespec/compiler": "^0.66.0",
|
|
59
|
+
"@typespec/http": "^0.66.0",
|
|
60
|
+
"@typespec/json-schema": "^0.66.0",
|
|
61
|
+
"@typespec/openapi3": "^0.66.0",
|
|
62
|
+
"@typespec/rest": "^0.66.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@types/node": "^20.10.6",
|