@common-grants/core 0.1.0-alpha.10 → 0.1.0-alpha.12
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 -4
- package/lib/core/fields/index.tsp +3 -0
- package/lib/core/filters/base.tsp +1 -0
- package/lib/core/filters/index.tsp +3 -0
- package/lib/core/pagination.tsp +2 -1
- package/lib/core/responses/index.tsp +3 -0
- package/lib/core/routes/opportunities.tsp +3 -3
- package/lib/core/sorting.tsp +3 -2
- package/lib/core/types.tsp +3 -0
- 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
|
@@ -5,15 +5,26 @@ import "@typespec/openapi";
|
|
|
5
5
|
|
|
6
6
|
using TypeSpec.Http;
|
|
7
7
|
using TypeSpec.OpenAPI;
|
|
8
|
-
|
|
9
8
|
/** The base OpenAPI specification for a CommonGrants API
|
|
10
9
|
*
|
|
11
10
|
* In order for an API to be "compliant" with the CommonGrants protocol,
|
|
12
11
|
* it must implement all of the routes with the "required" tag in this specification.
|
|
13
12
|
*/
|
|
14
|
-
@service({
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
@service(#{ title: "CommonGrants Base API" })
|
|
14
|
+
@tagMetadata(
|
|
15
|
+
"Opportunities",
|
|
16
|
+
#{ description: "Endpoints related to funding opportunities" }
|
|
17
|
+
)
|
|
18
|
+
@tagMetadata(
|
|
19
|
+
"required",
|
|
20
|
+
#{
|
|
21
|
+
description: "Endpoints that MUST be implemented by all CommonGrants APIs",
|
|
22
|
+
}
|
|
23
|
+
)
|
|
24
|
+
@tagMetadata(
|
|
25
|
+
"optional",
|
|
26
|
+
#{ description: "Endpoints that MAY be implemented by CommonGrants APIs" }
|
|
27
|
+
)
|
|
17
28
|
namespace CommonGrants.API;
|
|
18
29
|
|
|
19
30
|
@tag("Opportunities")
|
|
@@ -3,6 +3,8 @@ import "./metadata.tsp";
|
|
|
3
3
|
import "./money.tsp";
|
|
4
4
|
import "./event.tsp";
|
|
5
5
|
|
|
6
|
+
using TypeSpec.JsonSchema;
|
|
7
|
+
|
|
6
8
|
/** A standard set of fields, e.g. `money` that can be reused across models
|
|
7
9
|
*
|
|
8
10
|
* @example How to use the `Fields` namespace
|
|
@@ -17,4 +19,5 @@ import "./event.tsp";
|
|
|
17
19
|
* }
|
|
18
20
|
* ```
|
|
19
21
|
*/
|
|
22
|
+
@jsonSchema
|
|
20
23
|
namespace CommonGrants.Fields;
|
|
@@ -4,6 +4,8 @@ import "./numeric.tsp";
|
|
|
4
4
|
import "./money.tsp";
|
|
5
5
|
import "./string.tsp";
|
|
6
6
|
|
|
7
|
+
using TypeSpec.JsonSchema;
|
|
8
|
+
|
|
7
9
|
/** A standard set of filters, e.g. `StringArrayFilter`, that can be reused across models
|
|
8
10
|
*
|
|
9
11
|
* @example How to use the `Filters` namespace
|
|
@@ -34,4 +36,5 @@ import "./string.tsp";
|
|
|
34
36
|
* }
|
|
35
37
|
* ```
|
|
36
38
|
*/
|
|
39
|
+
@jsonSchema
|
|
37
40
|
namespace CommonGrants.Filters;
|
package/lib/core/pagination.tsp
CHANGED
|
@@ -3,6 +3,8 @@ import "@typespec/http";
|
|
|
3
3
|
import "./error.tsp";
|
|
4
4
|
import "./success.tsp";
|
|
5
5
|
|
|
6
|
+
using TypeSpec.JsonSchema;
|
|
7
|
+
|
|
6
8
|
/** A standardized set of response schemas for CommonGrants API routes
|
|
7
9
|
*
|
|
8
10
|
* @example How to use the `Responses` namespace
|
|
@@ -21,4 +23,5 @@ import "./success.tsp";
|
|
|
21
23
|
* }
|
|
22
24
|
* ```
|
|
23
25
|
*/
|
|
26
|
+
@jsonSchema
|
|
24
27
|
namespace CommonGrants.Responses;
|
|
@@ -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
|
|
@@ -94,5 +94,5 @@ interface Opportunities {
|
|
|
94
94
|
|
|
95
95
|
/** Pagination instructions for the results */
|
|
96
96
|
pagination?: Pagination.PaginatedBodyParams,
|
|
97
|
-
): Responses.Filtered<T, Models.OppFilters
|
|
97
|
+
): Responses.Filtered<T, Models.OppFilters>;
|
|
98
98
|
}
|
package/lib/core/sorting.tsp
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "@typespec/http";
|
|
2
2
|
|
|
3
3
|
using TypeSpec.Http;
|
|
4
|
-
|
|
4
|
+
using TypeSpec.JsonSchema;
|
|
5
5
|
/** Models for sorting
|
|
6
6
|
*
|
|
7
7
|
* @example How to use the `Sorting` namespace
|
|
@@ -15,6 +15,7 @@ using TypeSpec.Http;
|
|
|
15
15
|
* op list(sorting: Sorting.SortQueryParams): Responses.Sorted<MyModel>;
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
|
+
@jsonSchema
|
|
18
19
|
namespace CommonGrants.Sorting;
|
|
19
20
|
|
|
20
21
|
enum SortOrder {
|
|
@@ -27,7 +28,7 @@ model SortQueryParams {
|
|
|
27
28
|
/** The field to sort by */
|
|
28
29
|
@query
|
|
29
30
|
@example("lastModifiedAt")
|
|
30
|
-
sortBy:
|
|
31
|
+
sortBy: unknown;
|
|
31
32
|
|
|
32
33
|
/** Implementation-defined sort key */
|
|
33
34
|
@query
|
package/lib/core/types.tsp
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
using TypeSpec.JsonSchema;
|
|
2
|
+
|
|
1
3
|
/** A collection of base data types used throughout the CommonGrants API
|
|
2
4
|
*
|
|
3
5
|
* @example How to use the `Types` namespace
|
|
@@ -16,6 +18,7 @@
|
|
|
16
18
|
* }
|
|
17
19
|
* ```
|
|
18
20
|
*/
|
|
21
|
+
@jsonSchema
|
|
19
22
|
namespace CommonGrants.Types;
|
|
20
23
|
|
|
21
24
|
/** A time on a clock, without a timezone, in ISO 8601 format HH:mm:ss */
|
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.12",
|
|
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",
|