@groton/veracross-api 0.0.3 → 0.0.4
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/CHANGELOG.md +2 -0
- package/package.json +2 -1
- package/spec/Authorization-API.yaml +0 -732
- package/spec/Data-API.yaml +0 -73643
- package/spec/Files-API.yaml +0 -1041
- package/templates/client.handlebars +0 -25
- package/templates/create.handlebars +0 -23
- package/templates/delete.handlebars +0 -20
- package/templates/get.handlebars +0 -24
- package/templates/index.handlebars +0 -2
- package/templates/list.handlebars +0 -50
- package/templates/post.handlebars +0 -31
- package/templates/read.handlebars +0 -24
- package/templates/update.handlebars +0 -22
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Client, ClientConfiguration } from '#Client.js';
|
|
2
|
-
import type { paths } from '#spec/{{spec}}';
|
|
3
|
-
|
|
4
|
-
let _client: Client<paths> | undefined = undefined;
|
|
5
|
-
|
|
6
|
-
export function register(config: ClientConfiguration) {
|
|
7
|
-
_client = new Client<paths>({
|
|
8
|
-
...config,
|
|
9
|
-
baseUrl: '{{url}}'
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function client() {
|
|
14
|
-
if (!_client) {
|
|
15
|
-
throw new Error('Client not initialied');
|
|
16
|
-
}
|
|
17
|
-
return _client.client();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function defaults() {
|
|
21
|
-
if (!_client) {
|
|
22
|
-
throw new Error('Client not initialized');
|
|
23
|
-
}
|
|
24
|
-
return _client.defaults();
|
|
25
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { operations } from '#spec/{{spec}}';
|
|
2
|
-
import { client } from '#{{api}}/client.js';
|
|
3
|
-
import { EndpointOptions } from '#types/EndpointOptions.js';
|
|
4
|
-
|
|
5
|
-
{{#if scope}}
|
|
6
|
-
export const CREATE_SCOPE = '{{scope}}';
|
|
7
|
-
{{/if}}
|
|
8
|
-
|
|
9
|
-
/** {{operation.summary}} */
|
|
10
|
-
export async function create({ {{#if params.path.length}}{{#each params.path}}
|
|
11
|
-
{{this}},{{/each}}{{/if}}
|
|
12
|
-
data,
|
|
13
|
-
...rest
|
|
14
|
-
}: EndpointOptions<operations, '{{operation.operationId}}'>): Promise<number|undefined> {
|
|
15
|
-
const { data: {data: { id } = {}} = {}, error } = await client().POST('{{endpoint}}', {
|
|
16
|
-
params: { {{#if params.path.length}}path: { {{#each params.path}}{{this}}, {{/each}} }, {{/if}}...rest },
|
|
17
|
-
body: { data }
|
|
18
|
-
});
|
|
19
|
-
if (error) {
|
|
20
|
-
throw new Error('Error creating {{typeName}}', { cause: error });
|
|
21
|
-
}
|
|
22
|
-
return id;
|
|
23
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { operations } from '#spec/{{spec}}';
|
|
2
|
-
import { client } from '#{{api}}/client.js';
|
|
3
|
-
import { EndpointOptions } from '#types/EndpointOptions.js';
|
|
4
|
-
|
|
5
|
-
{{#if scope}}
|
|
6
|
-
export const DELETE_SCOPE = '{{scope}}';
|
|
7
|
-
{{/if}}
|
|
8
|
-
|
|
9
|
-
/** {{operation.summary}} */
|
|
10
|
-
export async function delete_({ {{#if params.path.length}}{{#each params.path}}
|
|
11
|
-
{{this}}, {{/each}}{{/if}}
|
|
12
|
-
...rest
|
|
13
|
-
}: EndpointOptions<operations, '{{operation.operationId}}'>): Promise<void> {
|
|
14
|
-
const { error } = await client().DELETE('{{endpoint}}', {
|
|
15
|
-
params: { {{#if params.path.length}}path: { {{#each params.path}}{{this}}, {{/each}} }, {{/if}}...rest }
|
|
16
|
-
});
|
|
17
|
-
if (error) {
|
|
18
|
-
throw new Error('Error deleting {{typeName}}', { cause: error });
|
|
19
|
-
}
|
|
20
|
-
}
|
package/templates/get.handlebars
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { operations } from '#spec/{{spec}}';
|
|
2
|
-
import { client } from '#{{api}}/client.js';
|
|
3
|
-
import { EndpointOptions } from '#types/EndpointOptions.js';
|
|
4
|
-
import { ResponseBody } from '#types/ResponseBody.js'
|
|
5
|
-
|
|
6
|
-
{{#if scope}}
|
|
7
|
-
export const GET_SCOPE = '{{scope}}';
|
|
8
|
-
{{/if}}
|
|
9
|
-
|
|
10
|
-
export type {{typeName}} = ResponseBody<operations, '{{operation.operationId}}'>;
|
|
11
|
-
|
|
12
|
-
/** {{operation.summary}} */
|
|
13
|
-
export async function get({ {{#if params.path.length}}{{#each params.path}}
|
|
14
|
-
{{this}}, {{/each}}{{/if}}
|
|
15
|
-
...rest
|
|
16
|
-
}: EndpointOptions<operations, '{{operation.operationId}}', 'GET'>): Promise<{{typeName}}|undefined> {
|
|
17
|
-
const {data,error} = await client().GET('{{endpoint}}', {
|
|
18
|
-
params: { {{#if params.path.length}}path: { {{#each params.path}}{{this}}, {{/each}} }, {{/if}}...rest }
|
|
19
|
-
});
|
|
20
|
-
if (error) {
|
|
21
|
-
throw new Error('Error retrieving {{typeName}}', { cause: error });
|
|
22
|
-
}
|
|
23
|
-
return data;
|
|
24
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { operations } from '#spec/{{spec}}';
|
|
2
|
-
import { client, defaults } from '#{{api}}/client.js';
|
|
3
|
-
import { EndpointOptions } from '#types/EndpointOptions.js';
|
|
4
|
-
import { ResponseData } from '#types/ResponseBody.js';
|
|
5
|
-
|
|
6
|
-
{{#if scope}}
|
|
7
|
-
export const LIST_SCOPE = '{{scope}}';
|
|
8
|
-
{{/if}}
|
|
9
|
-
|
|
10
|
-
export type {{typeName}}Collection = ResponseData<operations, '{{operation.operationId}}'>;
|
|
11
|
-
|
|
12
|
-
/** {{operation.summary}} */
|
|
13
|
-
export async function list({ {{#if params.path.length}}{{#each params.path}}
|
|
14
|
-
{{this}}, {{/each}}{{/if}}
|
|
15
|
-
header,
|
|
16
|
-
...rest
|
|
17
|
-
}: EndpointOptions<operations, '{{operation.operationId}}'>): Promise<{{typeName}}Collection> {
|
|
18
|
-
const collection: {{typeName}}Collection = [];
|
|
19
|
-
let page = !!header && header['X-Page-Number'] ?
|
|
20
|
-
header['X-Page-Number'] :
|
|
21
|
-
1;
|
|
22
|
-
const page_size = !!header && header['X-Page-Size'] ?
|
|
23
|
-
header['X-Page-Size'] :
|
|
24
|
-
defaults().DEFAULT_PAGE_SIZE;
|
|
25
|
-
let done: boolean;
|
|
26
|
-
do {
|
|
27
|
-
const {data,error} = await client().GET('{{endpoint}}', {
|
|
28
|
-
params: {
|
|
29
|
-
{{#if params.path.length}}path : { {{#each params.path}}{{this}}, {{/each}} },
|
|
30
|
-
{{/if}}
|
|
31
|
-
header: {
|
|
32
|
-
...header,
|
|
33
|
-
'X-Page-Number': page,
|
|
34
|
-
'X-Page-Size': page_size
|
|
35
|
-
},
|
|
36
|
-
...rest
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
if (error) {
|
|
40
|
-
throw new Error(
|
|
41
|
-
`Error list of {{typeName}} at page ${page}`,
|
|
42
|
-
{ cause: error }
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
collection.push(...data.data);
|
|
46
|
-
page++;
|
|
47
|
-
done = data.data.length < page_size;
|
|
48
|
-
} while (!done);
|
|
49
|
-
return collection;
|
|
50
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { operations } from '#spec/{{spec}}';
|
|
2
|
-
import { client } from '#{{api}}/client.js';
|
|
3
|
-
import { EndpointOptions } from '#types/EndpointOptions.js';
|
|
4
|
-
import { ResponseBody } from '#types/ResponseBody.js';
|
|
5
|
-
|
|
6
|
-
{{#if scope}}
|
|
7
|
-
export const POST_SCOPE = '{{scope}}';
|
|
8
|
-
{{/if}}
|
|
9
|
-
|
|
10
|
-
/** {{operation.summary}} */
|
|
11
|
-
export async function post({ {{#if params.path.length}}{{#each params.path}}
|
|
12
|
-
{{this}},{{/each}}{{/if}}
|
|
13
|
-
body,
|
|
14
|
-
...params
|
|
15
|
-
}: EndpointOptions<operations, '{{operation.operationId}}'>): Promise<ResponseBody<operations, '{{operation.operationId}}'>|undefined> {
|
|
16
|
-
const { header, ...rest} = params;
|
|
17
|
-
const { data, error } = await client().POST('{{endpoint}}', {
|
|
18
|
-
params: {
|
|
19
|
-
{{#if params.path.length}}path: { {{#each params.path}}{{this}}, {{/each}} },
|
|
20
|
-
{{/if}}header: {
|
|
21
|
-
...header{{#if form}},
|
|
22
|
-
'Content-Type': 'application/x-www-form-urlencoded'{{/if}}
|
|
23
|
-
},
|
|
24
|
-
...rest },
|
|
25
|
-
body
|
|
26
|
-
});
|
|
27
|
-
if (error) {
|
|
28
|
-
throw new Error('Error creating {{typeName}}', { cause: error });
|
|
29
|
-
}
|
|
30
|
-
return data;
|
|
31
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { operations } from '#spec/{{spec}}';
|
|
2
|
-
import { client } from '#{{api}}/client.js';
|
|
3
|
-
import { EndpointOptions } from '#types/EndpointOptions.js';
|
|
4
|
-
import { ResponseData } from '#types/ResponseBody.js'
|
|
5
|
-
|
|
6
|
-
{{#if scope}}
|
|
7
|
-
export const READ_SCOPE = '{{scope}}';
|
|
8
|
-
{{/if}}
|
|
9
|
-
|
|
10
|
-
export type {{typeName}} = ResponseData<operations, '{{operation.operationId}}'>;
|
|
11
|
-
|
|
12
|
-
/** {{operation.summary}} */
|
|
13
|
-
export async function read({ {{#if params.path.length}}{{#each params.path}}
|
|
14
|
-
{{this}}, {{/each}}{{/if}}
|
|
15
|
-
...rest
|
|
16
|
-
}: EndpointOptions<operations, '{{operation.operationId}}'>): Promise<{{typeName}}> {
|
|
17
|
-
const {data,error} = await client().GET('{{endpoint}}', {
|
|
18
|
-
params: { {{#if params.path.length}}path: { {{#each params.path}}{{this}}, {{/each}} }, {{/if}}...rest }
|
|
19
|
-
});
|
|
20
|
-
if (error) {
|
|
21
|
-
throw new Error('Error retrieving {{typeName}}', { cause: error });
|
|
22
|
-
}
|
|
23
|
-
return data.data;
|
|
24
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { operations } from '#spec/{{spec}}';
|
|
2
|
-
import { client } from '#{{api}}/client.js';
|
|
3
|
-
import { EndpointOptions } from '#types/EndpointOptions.js';
|
|
4
|
-
|
|
5
|
-
{{#if scope}}
|
|
6
|
-
export const UPDATE_SCOPE = '{{scope}}';
|
|
7
|
-
{{/if}}
|
|
8
|
-
|
|
9
|
-
/** {{operation.summary}} */
|
|
10
|
-
export async function update({ {{#if params.path.length}}{{#each params.path}}
|
|
11
|
-
{{this}}, {{/each}}{{/if}}
|
|
12
|
-
data,
|
|
13
|
-
...rest
|
|
14
|
-
}: EndpointOptions<operations, '{{operation.operationId}}'>): Promise<void> {
|
|
15
|
-
const { error } = await client().PATCH('{{endpoint}}', {
|
|
16
|
-
params: { {{#if params.path.length}}path: { {{#each params.path}}{{this}}, {{/each}} }, {{/if}}...rest },
|
|
17
|
-
body: { data }
|
|
18
|
-
});
|
|
19
|
-
if (error) {
|
|
20
|
-
throw new Error('Error updating {{typeName}}', { cause: error });
|
|
21
|
-
}
|
|
22
|
-
}
|