@oauth2-cli/sky-api 0.2.1 → 0.3.0

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.
Files changed (84) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/Client.d.ts +15 -0
  3. package/dist/Client.js +56 -0
  4. package/dist/Credentials.d.ts +4 -0
  5. package/dist/Paginated.d.ts +12 -0
  6. package/dist/Paginated.js +37 -0
  7. package/dist/SkyAPI.d.ts +2 -0
  8. package/dist/SkyAPI.js +2 -0
  9. package/dist/buildQuery.d.ts +1 -0
  10. package/dist/buildQuery.js +7 -0
  11. package/dist/index.d.ts +1 -14
  12. package/dist/index.js +4 -37
  13. package/dist/school/index.d.ts +1 -0
  14. package/dist/school/index.js +1 -0
  15. package/dist/school/v1/academics/index.d.ts +1 -0
  16. package/dist/school/v1/academics/index.js +1 -0
  17. package/dist/school/v1/academics/sections/assignments/Assignment.d.ts +21 -0
  18. package/dist/school/v1/academics/sections/assignments/Assignment.js +1 -0
  19. package/dist/school/v1/academics/sections/assignments/AssignmentCollection.d.ts +7 -0
  20. package/dist/school/v1/academics/sections/assignments/AssignmentCollection.js +1 -0
  21. package/dist/school/v1/academics/sections/assignments/IdDescriptorField.d.ts +4 -0
  22. package/dist/school/v1/academics/sections/assignments/IdDescriptorField.js +1 -0
  23. package/dist/school/v1/academics/sections/assignments/assignmentsBySection.d.ts +11 -0
  24. package/dist/school/v1/academics/sections/assignments/assignmentsBySection.js +6 -0
  25. package/dist/school/v1/academics/sections/assignments/index.d.ts +4 -0
  26. package/dist/school/v1/academics/sections/assignments/index.js +4 -0
  27. package/dist/school/v1/academics/sections/index.d.ts +1 -0
  28. package/dist/school/v1/academics/sections/index.js +1 -0
  29. package/dist/school/v1/contentmanagement/BaseRole.d.ts +4 -0
  30. package/dist/school/v1/contentmanagement/BaseRole.js +1 -0
  31. package/dist/school/v1/contentmanagement/CategoryRequest.d.ts +4 -0
  32. package/dist/school/v1/contentmanagement/CategoryRequest.js +1 -0
  33. package/dist/school/v1/contentmanagement/ContentCategory.d.ts +9 -0
  34. package/dist/school/v1/contentmanagement/ContentCategory.js +1 -0
  35. package/dist/school/v1/contentmanagement/ContentManagementRequest.d.ts +8 -0
  36. package/dist/school/v1/contentmanagement/ContentManagementRequest.js +1 -0
  37. package/dist/school/v1/contentmanagement/RoleModel.d.ts +6 -0
  38. package/dist/school/v1/contentmanagement/RoleModel.js +1 -0
  39. package/dist/school/v1/contentmanagement/announcements/ContentAnnouncement.d.ts +14 -0
  40. package/dist/school/v1/contentmanagement/announcements/ContentAnnouncement.js +1 -0
  41. package/dist/school/v1/contentmanagement/announcements/ContentAnnouncementCategory.d.ts +11 -0
  42. package/dist/school/v1/contentmanagement/announcements/ContentAnnouncementCategory.js +1 -0
  43. package/dist/school/v1/contentmanagement/announcements/ContentAnnouncementCategoryCollection.d.ts +7 -0
  44. package/dist/school/v1/contentmanagement/announcements/ContentAnnouncementCategoryCollection.js +1 -0
  45. package/dist/school/v1/contentmanagement/announcements/index.d.ts +9 -0
  46. package/dist/school/v1/contentmanagement/announcements/index.js +11 -0
  47. package/dist/school/v1/contentmanagement/index.d.ts +8 -0
  48. package/dist/school/v1/contentmanagement/index.js +8 -0
  49. package/dist/school/v1/contentmanagement/news/NewsCategory.d.ts +19 -0
  50. package/dist/school/v1/contentmanagement/news/NewsCategory.js +1 -0
  51. package/dist/school/v1/contentmanagement/news/NewsCategoryCollection.d.ts +7 -0
  52. package/dist/school/v1/contentmanagement/news/NewsCategoryCollection.js +1 -0
  53. package/dist/school/v1/contentmanagement/news/NewsItem.d.ts +20 -0
  54. package/dist/school/v1/contentmanagement/news/NewsItem.js +1 -0
  55. package/dist/school/v1/contentmanagement/news/index.d.ts +9 -0
  56. package/dist/school/v1/contentmanagement/news/index.js +11 -0
  57. package/dist/school/v1/contentmanagement/photoalbums/ImageDimension.d.ts +5 -0
  58. package/dist/school/v1/contentmanagement/photoalbums/ImageDimension.js +1 -0
  59. package/dist/school/v1/contentmanagement/photoalbums/ImageSettings.d.ts +10 -0
  60. package/dist/school/v1/contentmanagement/photoalbums/ImageSettings.js +1 -0
  61. package/dist/school/v1/contentmanagement/photoalbums/MediaItem.d.ts +12 -0
  62. package/dist/school/v1/contentmanagement/photoalbums/MediaItem.js +1 -0
  63. package/dist/school/v1/contentmanagement/photoalbums/MediaItemCollection.d.ts +7 -0
  64. package/dist/school/v1/contentmanagement/photoalbums/MediaItemCollection.js +1 -0
  65. package/dist/school/v1/contentmanagement/photoalbums/PhotoAlbum.d.ts +11 -0
  66. package/dist/school/v1/contentmanagement/photoalbums/PhotoAlbum.js +1 -0
  67. package/dist/school/v1/contentmanagement/photoalbums/PhotoCategory.d.ts +10 -0
  68. package/dist/school/v1/contentmanagement/photoalbums/PhotoCategory.js +1 -0
  69. package/dist/school/v1/contentmanagement/photoalbums/PhotoCategoryCollection.d.ts +6 -0
  70. package/dist/school/v1/contentmanagement/photoalbums/PhotoCategoryCollection.js +1 -0
  71. package/dist/school/v1/contentmanagement/photoalbums/index.d.ts +15 -0
  72. package/dist/school/v1/contentmanagement/photoalbums/index.js +18 -0
  73. package/dist/school/v1/index.d.ts +2 -0
  74. package/dist/school/v1/index.js +2 -0
  75. package/package.json +18 -10
  76. package/.versionrc.json +0 -5
  77. package/dist/School/Assignment.d.ts +0 -23
  78. package/dist/School/index.d.ts +0 -1
  79. package/dist/School/index.js +0 -1
  80. package/src/School/Assignment.ts +0 -25
  81. package/src/School/index.ts +0 -1
  82. package/src/index.ts +0 -52
  83. package/tsconfig.json +0 -8
  84. /package/dist/{School/Assignment.js → Credentials.js} +0 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,38 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
4
4
 
5
+ ## [0.3.0](https://github.com/groton-school/myschoolapp-reporting/compare/oauth2-cli/sky-api/0.2.2...oauth2-cli/sky-api/0.3.0) (2025-12-24)
6
+
7
+
8
+ ### ⚠ BREAKING CHANGES
9
+
10
+ * rewritten as cleaner extension of @oauth2-cli/qui-cli-plugin
11
+ * re-type section assignments to map more clearly to API documentation
12
+ * rename school API to match Blackbaud documentation
13
+
14
+ ### Features
15
+
16
+ * allow typing fetch response ([e93a758](https://github.com/groton-school/myschoolapp-reporting/commit/e93a7583ca781410ca88f0856ddbdd86ba5a95c5))
17
+ * async iterate across paginated responses ([9d0cbfb](https://github.com/groton-school/myschoolapp-reporting/commit/9d0cbfb5e0c72229e44315ede6a0ff4e4d7cecd8))
18
+ * content management announcements ([fc724d1](https://github.com/groton-school/myschoolapp-reporting/commit/fc724d1440de4e04b63a8d5b492bec8af28b8e56))
19
+ * content management news ([3bc3cd0](https://github.com/groton-school/myschoolapp-reporting/commit/3bc3cd0042f3d20b8779b0ba8bcece482dffd0f0))
20
+ * contentmenagement.photoalbums.categories and contentmanagement.photoalbums.list types ([881851f](https://github.com/groton-school/myschoolapp-reporting/commit/881851fcef2b801b622301621789b942b1d39c01))
21
+ * expose endpoints as async methods ([b4d40a2](https://github.com/groton-school/myschoolapp-reporting/commit/b4d40a2ffb561c763a8e3b6ee73af85f73560107))
22
+ * re-type section assignments to map more clearly to API documentation ([36c8ca9](https://github.com/groton-school/myschoolapp-reporting/commit/36c8ca94e2beb4a3cef95cce42f6a501d134d491))
23
+ * rewritten as cleaner extension of @oauth2-cli/qui-cli-plugin ([e623f8a](https://github.com/groton-school/myschoolapp-reporting/commit/e623f8a5b3a08a28a832002176e76d2a4e6d1823))
24
+
25
+
26
+ ### Bug Fixes
27
+
28
+ * rename school API to match Blackbaud documentation ([ba25292](https://github.com/groton-school/myschoolapp-reporting/commit/ba25292e37ec66d1b53b5ca6af6ce88af6e6aea6))
29
+
30
+ ## [0.2.2](https://github.com/battis/oauth2-cli/compare/sky-api/0.2.1...sky-api/0.2.2) (2025-09-11)
31
+
32
+
33
+ ### Bug Fixes
34
+
35
+ * update dependencies to address transient openid-client config error ([f0ca9a8](https://github.com/battis/oauth2-cli/commit/f0ca9a8d2bb4551b80a49e48aa43df5ba66a5a9b))
36
+
5
37
  ## [0.2.1](https://github.com/battis/oauth2-cli/compare/sky-api/0.2.0...sky-api/0.2.1) (2025-03-15)
6
38
 
7
39
 
@@ -0,0 +1,15 @@
1
+ import { OAuth2 } from '@oauth2-cli/qui-cli-plugin';
2
+ import * as Plugin from '@qui-cli/plugin';
3
+ export type Configuration = Plugin.Configuration & {
4
+ subscription_key?: string;
5
+ subscriptionKeyEnvVar: string;
6
+ };
7
+ export declare const name = "@oauth2-cli/sky-api";
8
+ export declare function configure(proposal?: Partial<Configuration>): void;
9
+ export declare function options(): Plugin.Options;
10
+ export declare function init({ values }: Plugin.ExpectedArguments<typeof options>): Promise<void>;
11
+ export declare const getToken: typeof OAuth2.getToken;
12
+ export declare const request: typeof OAuth2.request;
13
+ export declare const requestJSON: typeof OAuth2.requestJSON;
14
+ /** @deprecated Use {@link requestJSON} */
15
+ export declare const fetch: typeof OAuth2.request;
package/dist/Client.js ADDED
@@ -0,0 +1,56 @@
1
+ import { OAuth2 } from '@oauth2-cli/qui-cli-plugin';
2
+ import { Colors } from '@qui-cli/colors';
3
+ import { Env } from '@qui-cli/env-1password';
4
+ OAuth2.configure({
5
+ authorization_endpoint: 'https://app.blackbaud.com/oauth/authorize',
6
+ token_endpoint: 'https://oauth2.sky.blackbaud.com/token',
7
+ env: {
8
+ client_id: 'SKY_CLIENT_ID',
9
+ client_secret: 'SKY_CLIENT_SECRET',
10
+ redirect_uri: 'SKY_REDIRECT_URI',
11
+ token_path: 'SKY_TOKEN_PATH',
12
+ access_token: 'SKY_ACCESS_TOKEN'
13
+ },
14
+ man: { heading: 'Sky API options' },
15
+ suppress: {
16
+ authorizationEndpoint: true,
17
+ tokenEndpoint: true,
18
+ tokenPath: true
19
+ }
20
+ });
21
+ export const name = '@oauth2-cli/sky-api';
22
+ const config = {
23
+ subscriptionKeyEnvVar: 'SKY_SUBSCRIPTION_KEY'
24
+ };
25
+ export function configure(proposal = {}) {
26
+ for (const key in proposal) {
27
+ if (proposal[key] !== undefined) {
28
+ config[key] = proposal[key];
29
+ }
30
+ }
31
+ }
32
+ export function options() {
33
+ return {
34
+ opt: {
35
+ subscriptionKey: {
36
+ description: `Blackbaud subscription access key; will use environment variable ${Colors.varName(config.subscriptionKeyEnvVar)} if present`,
37
+ secret: true,
38
+ default: config.subscription_key
39
+ }
40
+ }
41
+ };
42
+ }
43
+ export async function init({ values }) {
44
+ const { subscriptionKey: subscription_key = await Env.get({
45
+ key: config.subscriptionKeyEnvVar
46
+ }) } = values;
47
+ configure({ subscription_key, ...values });
48
+ OAuth2.configure({
49
+ headers: { 'Bb-Api-Subscription-Key': config.subscription_key }
50
+ });
51
+ }
52
+ export const getToken = OAuth2.getToken;
53
+ export const request = OAuth2.request;
54
+ export const requestJSON = OAuth2.requestJSON;
55
+ /** @deprecated Use {@link requestJSON} */
56
+ export const fetch = OAuth2.request;
@@ -0,0 +1,4 @@
1
+ import * as OAuth2 from 'oauth2-cli';
2
+ export type Credentials = Omit<OAuth2.Credentials, 'authorization_endpoint' | 'token_endpoint'> & {
3
+ subscription_key: string;
4
+ };
@@ -0,0 +1,12 @@
1
+ import { URLString } from '@battis/descriptive-types';
2
+ type Data<T> = {
3
+ count?: number;
4
+ next_link?: URLString;
5
+ value?: T[];
6
+ };
7
+ export declare class Paginated<T> implements AsyncIterable<T> {
8
+ private data;
9
+ constructor(data: Data<T>);
10
+ [Symbol.asyncIterator](): AsyncIterator<T>;
11
+ }
12
+ export {};
@@ -0,0 +1,37 @@
1
+ import * as Client from './Client.js';
2
+ export class Paginated {
3
+ data;
4
+ constructor(data) {
5
+ this.data = data;
6
+ }
7
+ [Symbol.asyncIterator]() {
8
+ let index = 0;
9
+ let data = this.data;
10
+ return {
11
+ next: async () => {
12
+ if (index === data.value?.length && data.next_link) {
13
+ data = await Client.requestJSON(data.next_link);
14
+ index = 0;
15
+ }
16
+ if (data.value && index < data.value.length) {
17
+ const value = data.value[index];
18
+ index++;
19
+ return {
20
+ value,
21
+ done: false
22
+ };
23
+ }
24
+ else {
25
+ return {
26
+ value: undefined,
27
+ done: true
28
+ };
29
+ }
30
+ },
31
+ return: async () => ({
32
+ value: undefined,
33
+ done: true
34
+ })
35
+ };
36
+ }
37
+ }
@@ -0,0 +1,2 @@
1
+ export * from './Client.js';
2
+ export * as school from './school/index.js';
package/dist/SkyAPI.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from './Client.js';
2
+ export * as school from './school/index.js';
@@ -0,0 +1 @@
1
+ export declare function buildQuery(params: Record<string, unknown>): string;
@@ -0,0 +1,7 @@
1
+ export function buildQuery(params) {
2
+ const search = new URLSearchParams();
3
+ for (const key in params) {
4
+ search.append(key, `${params[key]}`);
5
+ }
6
+ return search.toString();
7
+ }
package/dist/index.d.ts CHANGED
@@ -1,14 +1 @@
1
- import { RequestInfo, RequestInit } from 'node-fetch';
2
- import * as OAuth2 from 'oauth2-cli';
3
- export * as School from './School/index.js';
4
- export type Credentials = Omit<OAuth2.Credentials, 'authorization_endpoint' | 'token_endpoint'> & {
5
- subscription_key: string;
6
- };
7
- export declare class SkyAPI {
8
- private client;
9
- private token?;
10
- private subscription_key;
11
- constructor({ subscription_key, ...credentials }: Credentials);
12
- getToken(): Promise<OAuth2.Token | undefined>;
13
- fetch(endpoint: URL | RequestInfo, init?: RequestInit): Promise<unknown>;
14
- }
1
+ export * as SkyAPI from './SkyAPI.js';
package/dist/index.js CHANGED
@@ -1,37 +1,4 @@
1
- // TODO replace node-fetch dependency with native fetch when bumping to node@>=21
2
- import nodeFetch from 'node-fetch';
3
- import * as OAuth2 from 'oauth2-cli';
4
- export * as School from './School/index.js';
5
- const SUBSCRIPTION_HEADER = 'Bb-Api-Subscription-Key';
6
- export class SkyAPI {
7
- client;
8
- token;
9
- subscription_key;
10
- constructor({ subscription_key, ...credentials }) {
11
- this.subscription_key = subscription_key;
12
- this.client = new OAuth2.Client({
13
- ...credentials,
14
- authorization_endpoint: 'https://app.blackbaud.com/oauth/authorize',
15
- token_endpoint: 'https://oauth2.sky.blackbaud.com/token',
16
- headers: { [SUBSCRIPTION_HEADER]: this.subscription_key }
17
- });
18
- }
19
- async getToken() {
20
- this.token = await this.client.getToken();
21
- return this.token;
22
- }
23
- async fetch(endpoint, init) {
24
- await this.getToken();
25
- if (!this.token) {
26
- throw new Error('No access token');
27
- }
28
- return await (await nodeFetch(new URL(endpoint, 'https://api.sky.blackbaud.com'), {
29
- ...init,
30
- headers: {
31
- ...init?.headers,
32
- Authorization: `Bearer ${this.token.access_token}`,
33
- [SUBSCRIPTION_HEADER]: this.subscription_key
34
- }
35
- })).json();
36
- }
37
- }
1
+ import { register } from '@qui-cli/plugin';
2
+ import * as Client from './Client.js';
3
+ export * as SkyAPI from './SkyAPI.js';
4
+ await register(Client);
@@ -0,0 +1 @@
1
+ export * as v1 from './v1/index.js';
@@ -0,0 +1 @@
1
+ export * as v1 from './v1/index.js';
@@ -0,0 +1 @@
1
+ export * as sections from './sections/index.js';
@@ -0,0 +1 @@
1
+ export * as sections from './sections/index.js';
@@ -0,0 +1,21 @@
1
+ import { DateTimeString } from '@battis/descriptive-types';
2
+ import { IdDescriptorField } from './IdDescriptorField.js';
3
+ export type Assignment = {
4
+ id?: number;
5
+ date?: DateTimeString<'ISO'>;
6
+ description?: string;
7
+ discussion?: boolean;
8
+ due_date?: DateTimeString<'ISO'>;
9
+ enrolled?: number;
10
+ graded_count?: number;
11
+ index_id?: number;
12
+ major?: boolean;
13
+ name?: string;
14
+ publish_on_assigned?: boolean;
15
+ published?: boolean;
16
+ rank?: number;
17
+ status?: 0 | 1 | 2 | -1;
18
+ type?: string;
19
+ type_id?: number;
20
+ rubric: IdDescriptorField;
21
+ };
@@ -0,0 +1,7 @@
1
+ import { URLString } from '@battis/descriptive-types';
2
+ import { Assignment } from './Assignment.js';
3
+ export type AssignmentCollection = {
4
+ count?: number;
5
+ next_link?: URLString;
6
+ value: Assignment[];
7
+ };
@@ -0,0 +1,4 @@
1
+ export type IdDescriptorField = {
2
+ id?: number;
3
+ description?: string;
4
+ };
@@ -0,0 +1,11 @@
1
+ import { Paginated } from '../../../../../Paginated.js';
2
+ import { Assignment } from './Assignment.js';
3
+ type Options = {
4
+ types?: string;
5
+ status?: '0' | '1' | '2' | '-1';
6
+ persona_id?: 2 | 3;
7
+ filter?: 'expired' | 'future' | 'all';
8
+ search?: string;
9
+ };
10
+ export declare function assignmentsBySection(section_id: number, params?: Options): Promise<Paginated<Assignment>>;
11
+ export {};
@@ -0,0 +1,6 @@
1
+ import { buildQuery } from '../../../../../buildQuery.js';
2
+ import * as SkyAPI from '../../../../../Client.js';
3
+ import { Paginated } from '../../../../../Paginated.js';
4
+ export async function assignmentsBySection(section_id, params = {}) {
5
+ return new Paginated(await SkyAPI.requestJSON(`https://api.sky.blackbaud.com/school/v1/academics/sections/${section_id}/assignments?${buildQuery(params)}`));
6
+ }
@@ -0,0 +1,4 @@
1
+ export * from './Assignment.js';
2
+ export * from './AssignmentCollection.js';
3
+ export * from './IdDescriptorField.js';
4
+ export * from './assignmentsBySection.js';
@@ -0,0 +1,4 @@
1
+ export * from './Assignment.js';
2
+ export * from './AssignmentCollection.js';
3
+ export * from './IdDescriptorField.js';
4
+ export * from './assignmentsBySection.js';
@@ -0,0 +1 @@
1
+ export * as assignments from './assignments/index.js';
@@ -0,0 +1 @@
1
+ export * as assignments from './assignments/index.js';
@@ -0,0 +1,4 @@
1
+ export type BaseRole = {
2
+ id?: number;
3
+ name?: string;
4
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export type CategoryRequest = {
2
+ id?: number;
3
+ type?: 'Page content' | 'Class' | 'Activity' | 'Advisory' | 'Team' | 'Dorm' | 'Community';
4
+ };
@@ -0,0 +1,9 @@
1
+ import { DateTimeString } from '@battis/descriptive-types';
2
+ export type ContentCategory = {
3
+ id?: number;
4
+ name?: string;
5
+ type?: string;
6
+ primary?: boolean;
7
+ publish_date?: DateTimeString;
8
+ expire_date?: DateTimeString;
9
+ };
@@ -0,0 +1,8 @@
1
+ import { DateTimeString } from '@battis/descriptive-types';
2
+ import { CategoryRequest } from './CategoryRequest.js';
3
+ export type ContentManagementRequest = {
4
+ categories: CategoryRequest[];
5
+ as_of_date?: DateTimeString<'ISO'>;
6
+ last_modified?: DateTimeString<'ISO'>;
7
+ show_secured?: boolean;
8
+ };
@@ -0,0 +1,6 @@
1
+ import { BaseRole } from './BaseRole.js';
2
+ export type RoleModel = {
3
+ id?: number;
4
+ name?: string;
5
+ base_role?: BaseRole;
6
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ import { DateTimeString } from '@battis/descriptive-types';
2
+ import { ContentCategory } from '../ContentCategory.js';
3
+ export type ContentAnnouncement = {
4
+ id?: number;
5
+ headline?: string;
6
+ author?: string;
7
+ description?: string;
8
+ send_notification?: boolean;
9
+ created_date?: DateTimeString;
10
+ modified_date?: DateTimeString;
11
+ created_by?: number;
12
+ modified_by?: number;
13
+ categories?: ContentCategory[];
14
+ };
@@ -0,0 +1,11 @@
1
+ import { URLString } from '@battis/descriptive-types';
2
+ import { RoleModel } from '../RoleModel.js';
3
+ export type ContentAnnouncementCategory = {
4
+ category_id?: number;
5
+ category_name?: string;
6
+ allow_user_management?: boolean;
7
+ rss_enabled?: boolean;
8
+ rss_feed?: URLString;
9
+ is_public?: boolean;
10
+ access_roles?: RoleModel;
11
+ };
@@ -0,0 +1,7 @@
1
+ import { URLString } from '@battis/descriptive-types';
2
+ import { ContentAnnouncementCategory } from './ContentAnnouncementCategory.js';
3
+ export type ContentAnnouncementCategoryCollection = {
4
+ count?: number;
5
+ next_link?: URLString;
6
+ value?: ContentAnnouncementCategory[];
7
+ };
@@ -0,0 +1,9 @@
1
+ import { Paginated } from '../../../../Paginated.js';
2
+ import { ContentManagementRequest } from '../ContentManagementRequest.js';
3
+ import { ContentAnnouncement } from './ContentAnnouncement.js';
4
+ import { ContentAnnouncementCategory } from './ContentAnnouncementCategory.js';
5
+ export * from './ContentAnnouncement.js';
6
+ export * from './ContentAnnouncementCategory.js';
7
+ export * from './ContentAnnouncementCategoryCollection.js';
8
+ export declare function categories(): Promise<Paginated<ContentAnnouncementCategory>>;
9
+ export declare function list(request: ContentManagementRequest): Promise<ContentAnnouncement[]>;
@@ -0,0 +1,11 @@
1
+ import * as SkyAPI from '../../../../Client.js';
2
+ import { Paginated } from '../../../../Paginated.js';
3
+ export * from './ContentAnnouncement.js';
4
+ export * from './ContentAnnouncementCategory.js';
5
+ export * from './ContentAnnouncementCategoryCollection.js';
6
+ export async function categories() {
7
+ return new Paginated(await SkyAPI.requestJSON('https://api.sky.blackbaud.com/school/v1/contentmanagement/announcements/categories'));
8
+ }
9
+ export async function list(request) {
10
+ return SkyAPI.requestJSON('https://api.sky.blackbaud.com/school/v1/contentmanagement/announcements/list', 'POST', JSON.stringify(request));
11
+ }
@@ -0,0 +1,8 @@
1
+ export * as announcements from './announcements/index.js';
2
+ export * from './BaseRole.js';
3
+ export * from './CategoryRequest.js';
4
+ export * from './ContentCategory.js';
5
+ export * from './ContentManagementRequest.js';
6
+ export * as news from './news/index.js';
7
+ export * as photoalbums from './photoalbums/index.js';
8
+ export * from './RoleModel.js';
@@ -0,0 +1,8 @@
1
+ export * as announcements from './announcements/index.js';
2
+ export * from './BaseRole.js';
3
+ export * from './CategoryRequest.js';
4
+ export * from './ContentCategory.js';
5
+ export * from './ContentManagementRequest.js';
6
+ export * as news from './news/index.js';
7
+ export * as photoalbums from './photoalbums/index.js';
8
+ export * from './RoleModel.js';
@@ -0,0 +1,19 @@
1
+ import { URLString } from '@battis/descriptive-types';
2
+ import { RoleModel } from '../RoleModel.js';
3
+ import { ImageSettings } from '../photoalbums/ImageSettings.js';
4
+ export type NewsCategory = {
5
+ category_id?: number;
6
+ category_name?: string;
7
+ allow_user_management?: boolean;
8
+ show_brief_description?: boolean;
9
+ show_long_description?: boolean;
10
+ association_id?: number;
11
+ association_name?: string;
12
+ rss_ind?: boolean;
13
+ allow_coments?: string;
14
+ comment_approval?: string;
15
+ rss_feed?: URLString;
16
+ is_public?: boolean;
17
+ access_roles?: RoleModel[];
18
+ image_settings?: ImageSettings;
19
+ };
@@ -0,0 +1,7 @@
1
+ import { URLString } from '@battis/descriptive-types';
2
+ import { NewsCategory } from './NewsCategory.js';
3
+ export type NewsCategoryCollection = {
4
+ count?: number;
5
+ next_link?: URLString;
6
+ value?: NewsCategory[];
7
+ };
@@ -0,0 +1,20 @@
1
+ import { DateTimeString } from '@battis/descriptive-types';
2
+ import { ContentCategory } from '../ContentCategory.js';
3
+ import { MediaItem } from '../photoalbums/MediaItem.js';
4
+ export type NewsItem = {
5
+ id?: number;
6
+ headline?: string;
7
+ author?: string;
8
+ short_description?: string;
9
+ long_description?: string;
10
+ featured?: boolean;
11
+ media_item?: MediaItem[];
12
+ categories?: ContentCategory[];
13
+ send_notification?: boolean;
14
+ show_brief_description?: boolean;
15
+ show_long_description?: boolean;
16
+ created_by?: number;
17
+ created_date?: DateTimeString;
18
+ modified_by?: number;
19
+ modified_date?: DateTimeString;
20
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ import { Paginated } from '../../../../Paginated.js';
2
+ import { ContentManagementRequest } from '../ContentManagementRequest.js';
3
+ import { NewsCategory } from './NewsCategory.js';
4
+ import { NewsItem } from './NewsItem.js';
5
+ export * from './NewsCategory.js';
6
+ export * from './NewsCategoryCollection.js';
7
+ export * from './NewsItem.js';
8
+ export declare function categories(): Promise<Paginated<NewsCategory>>;
9
+ export declare function list(request: ContentManagementRequest): Promise<NewsItem[]>;
@@ -0,0 +1,11 @@
1
+ import * as SkyAPI from '../../../../Client.js';
2
+ import { Paginated } from '../../../../Paginated.js';
3
+ export * from './NewsCategory.js';
4
+ export * from './NewsCategoryCollection.js';
5
+ export * from './NewsItem.js';
6
+ export async function categories() {
7
+ return new Paginated(await SkyAPI.requestJSON('https://api.sky.blackbaud.com/school/v1/contentmanagement/news/categories'));
8
+ }
9
+ export async function list(request) {
10
+ return await SkyAPI.requestJSON('https://api.sky.blackbaud.com/school/v1/contentmanagement/news/list', 'POST', JSON.stringify(request));
11
+ }
@@ -0,0 +1,5 @@
1
+ export type ImageDimension = {
2
+ include?: boolean;
3
+ max_width?: number;
4
+ max_height?: number;
5
+ };
@@ -0,0 +1,10 @@
1
+ import { ImageDimension } from './ImageDimension.js';
2
+ export type ImageSettings = {
3
+ max_allowed?: number;
4
+ allow_title?: boolean;
5
+ allow_captions?: boolean;
6
+ allow_descriptions?: boolean;
7
+ standard?: ImageDimension;
8
+ zoom?: ImageDimension;
9
+ thumbnail?: ImageDimension;
10
+ };
@@ -0,0 +1,12 @@
1
+ import { URLString } from '@battis/descriptive-types';
2
+ export type MediaItem = {
3
+ id?: number;
4
+ type?: string;
5
+ title?: string;
6
+ caption?: string;
7
+ tags?: string;
8
+ description?: string;
9
+ is_cover?: boolean;
10
+ url?: URLString;
11
+ thumbnail_url?: URLString;
12
+ };
@@ -0,0 +1,7 @@
1
+ import { URLString } from '@battis/descriptive-types';
2
+ import { MediaItem } from './MediaItem.js';
3
+ export type MediaItemCollection = {
4
+ count?: number;
5
+ next_link?: URLString;
6
+ value?: MediaItem[];
7
+ };
@@ -0,0 +1,11 @@
1
+ import { URLString } from '@battis/descriptive-types';
2
+ import { ContentCategory } from '../ContentCategory.js';
3
+ export type PhotoAlbum = {
4
+ id?: number;
5
+ title?: string;
6
+ description?: string;
7
+ allow_downloads?: boolean;
8
+ featured?: boolean;
9
+ categories?: ContentCategory[];
10
+ url?: URLString;
11
+ };
@@ -0,0 +1,10 @@
1
+ import { RoleModel } from '../RoleModel.js';
2
+ import { ImageSettings } from './ImageSettings.js';
3
+ export type PhotoCategory = {
4
+ id?: number;
5
+ description?: string;
6
+ include_description_for_photos?: boolean;
7
+ is_public?: boolean;
8
+ access_roles?: RoleModel[];
9
+ image_settings?: ImageSettings;
10
+ };
@@ -0,0 +1,6 @@
1
+ import { PhotoCategory } from './PhotoCategory.js';
2
+ export type PhotoCategoryCollection = {
3
+ count?: number;
4
+ next_link?: string;
5
+ value: PhotoCategory[];
6
+ };
@@ -0,0 +1,15 @@
1
+ import { Paginated } from '../../../../Paginated.js';
2
+ import { ContentManagementRequest } from '../ContentManagementRequest.js';
3
+ import { MediaItem } from './MediaItem.js';
4
+ import { PhotoAlbum } from './PhotoAlbum.js';
5
+ import { PhotoCategory } from './PhotoCategory.js';
6
+ export * from './ImageDimension.js';
7
+ export * from './ImageSettings.js';
8
+ export * from './MediaItem.js';
9
+ export * from './MediaItemCollection.js';
10
+ export * from './PhotoAlbum.js';
11
+ export * from './PhotoCategory.js';
12
+ export * from './PhotoCategoryCollection.js';
13
+ export declare function categories(): Promise<Paginated<PhotoCategory>>;
14
+ export declare function list(request: ContentManagementRequest): Promise<PhotoAlbum[]>;
15
+ export declare function photosById(album_id: number): Promise<Paginated<MediaItem>>;
@@ -0,0 +1,18 @@
1
+ import * as SkyAPI from '../../../../Client.js';
2
+ import { Paginated } from '../../../../Paginated.js';
3
+ export * from './ImageDimension.js';
4
+ export * from './ImageSettings.js';
5
+ export * from './MediaItem.js';
6
+ export * from './MediaItemCollection.js';
7
+ export * from './PhotoAlbum.js';
8
+ export * from './PhotoCategory.js';
9
+ export * from './PhotoCategoryCollection.js';
10
+ export async function categories() {
11
+ return new Paginated(await SkyAPI.requestJSON('https://api.sky.blackbaud.com/school/v1/contentmanagement/photoalbums/categories'));
12
+ }
13
+ export async function list(request) {
14
+ return await SkyAPI.requestJSON('https://api.sky.blackbaud.com/school/v1/contentmanagement/photoalbums/list', 'POST', JSON.stringify(request));
15
+ }
16
+ export async function photosById(album_id) {
17
+ return new Paginated(await SkyAPI.requestJSON(`https://api.sky.blackbaud.com/school/v1/contentmanagement/photoalbums/${album_id}`));
18
+ }
@@ -0,0 +1,2 @@
1
+ export * as academics from './academics/index.js';
2
+ export * as contentmanagement from './contentmanagement/index.js';
@@ -0,0 +1,2 @@
1
+ export * as academics from './academics/index.js';
2
+ export * as contentmanagement from './contentmanagement/index.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oauth2-cli/sky-api",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "keywords": [
5
5
  "blackbaud",
6
6
  "sky",
@@ -8,30 +8,38 @@
8
8
  "oauth",
9
9
  "cli"
10
10
  ],
11
- "homepage": "https://github.com/battis/oauth2-cli/tree/main/packages/sky-api#readme",
11
+ "homepage": "https://github.com/groton-school/myschoolapp-reporting/tree/main/packages/oauth2-cli/sky-api#readme",
12
12
  "repository": {
13
13
  "type": "git",
14
- "url": "git+https://github.com/battis/oauth2-cli.git",
15
- "directory": "packages/sky-api"
14
+ "url": "https://github.com/groton-school/myschoolapp-reporting.git",
15
+ "directory": "packages/oauth2-cli/sky-api"
16
16
  },
17
17
  "author": {
18
18
  "name": "Seth Battis",
19
- "url": "https://github.com/battis"
19
+ "email": "sbattis@groton.org"
20
20
  },
21
21
  "type": "module",
22
22
  "main": "./dist/index.js",
23
23
  "types": "./dist/index.d.ts",
24
24
  "dependencies": {
25
25
  "node-fetch": "^3.3.2",
26
- "oauth2-cli": "0.2.0"
26
+ "oauth2-cli": "^0.2.3"
27
27
  },
28
28
  "devDependencies": {
29
- "@battis/descriptive-types": "^0.1.0",
30
- "@tsconfig/node20": "^20.1.4",
31
- "commit-and-tag-version": "^12.5.0",
29
+ "@battis/descriptive-types": "^0.2.6",
30
+ "@oauth2-cli/qui-cli-plugin": "^0.3.0",
31
+ "@qui-cli/colors": "^3.1.1",
32
+ "@qui-cli/env-1password": "^1.2.2",
33
+ "@qui-cli/plugin": "^4.0.0",
34
+ "@tsconfig/node20": "^20.1.8",
35
+ "commit-and-tag-version": "^12.6.1",
32
36
  "del-cli": "^6.0.0",
33
37
  "npm-run-all": "^4.1.5",
34
- "typescript": "^5.8.2"
38
+ "typescript": "^5.9.3"
39
+ },
40
+ "peerDependencies": {
41
+ "@oauth2-cli/qui-cli-plugin": "0.x",
42
+ "@qui-cli/plugin": "4.x"
35
43
  },
36
44
  "scripts": {
37
45
  "clean": "del ./dist",
package/.versionrc.json DELETED
@@ -1,5 +0,0 @@
1
- {
2
- "path": ".",
3
- "tag-prefix": "sky-api/",
4
- "releaseCommitMessageFormat": "chore(sky-api): @oauth2-cli/sky-api@{{currentTag}}"
5
- }
@@ -1,23 +0,0 @@
1
- import { DateTimeString } from '@battis/descriptive-types';
2
- export type Assignment = {
3
- id: number;
4
- date: DateTimeString;
5
- description: string;
6
- discussion: false;
7
- due_date: DateTimeString;
8
- enrolled: number;
9
- graded_count: number;
10
- index_id: number;
11
- major: boolean;
12
- name: string;
13
- publish_on_assigned: boolean;
14
- published: boolean;
15
- rank: number;
16
- status: number;
17
- type: string;
18
- type_id: number;
19
- };
20
- export type AssignmentList = {
21
- count: number;
22
- value: Assignment[];
23
- };
@@ -1 +0,0 @@
1
- export * from './Assignment.js';
@@ -1 +0,0 @@
1
- export * from './Assignment.js';
@@ -1,25 +0,0 @@
1
- import { DateTimeString } from '@battis/descriptive-types';
2
-
3
- export type Assignment = {
4
- id: number;
5
- date: DateTimeString;
6
- description: string;
7
- discussion: false;
8
- due_date: DateTimeString;
9
- enrolled: number;
10
- graded_count: number;
11
- index_id: number;
12
- major: boolean;
13
- name: string;
14
- publish_on_assigned: boolean;
15
- published: boolean;
16
- rank: number;
17
- status: number;
18
- type: string;
19
- type_id: number;
20
- };
21
-
22
- export type AssignmentList = {
23
- count: number;
24
- value: Assignment[];
25
- };
@@ -1 +0,0 @@
1
- export * from './Assignment.js';
package/src/index.ts DELETED
@@ -1,52 +0,0 @@
1
- // TODO replace node-fetch dependency with native fetch when bumping to node@>=21
2
- import nodeFetch, { RequestInfo, RequestInit } from 'node-fetch';
3
- import * as OAuth2 from 'oauth2-cli';
4
-
5
- export * as School from './School/index.js';
6
-
7
- export type Credentials = Omit<
8
- OAuth2.Credentials,
9
- 'authorization_endpoint' | 'token_endpoint'
10
- > & {
11
- subscription_key: string;
12
- };
13
-
14
- const SUBSCRIPTION_HEADER = 'Bb-Api-Subscription-Key';
15
-
16
- export class SkyAPI {
17
- private client: OAuth2.Client;
18
- private token?: OAuth2.Token;
19
- private subscription_key: string;
20
-
21
- public constructor({ subscription_key, ...credentials }: Credentials) {
22
- this.subscription_key = subscription_key;
23
- this.client = new OAuth2.Client({
24
- ...credentials,
25
- authorization_endpoint: 'https://app.blackbaud.com/oauth/authorize',
26
- token_endpoint: 'https://oauth2.sky.blackbaud.com/token',
27
- headers: { [SUBSCRIPTION_HEADER]: this.subscription_key }
28
- });
29
- }
30
-
31
- public async getToken() {
32
- this.token = await this.client.getToken();
33
- return this.token;
34
- }
35
-
36
- public async fetch(endpoint: URL | RequestInfo, init?: RequestInit) {
37
- await this.getToken();
38
- if (!this.token) {
39
- throw new Error('No access token');
40
- }
41
- return await (
42
- await nodeFetch(new URL(endpoint, 'https://api.sky.blackbaud.com'), {
43
- ...init,
44
- headers: {
45
- ...init?.headers,
46
- Authorization: `Bearer ${this.token.access_token}`,
47
- [SUBSCRIPTION_HEADER]: this.subscription_key
48
- }
49
- })
50
- ).json();
51
- }
52
- }
package/tsconfig.json DELETED
@@ -1,8 +0,0 @@
1
- {
2
- "extends": "@tsconfig/node20/tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "./dist",
5
- "declaration": true
6
- },
7
- "include": ["./src"]
8
- }
File without changes