@timeback/core 0.2.1 → 0.2.2-beta.20260320221119

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.
@@ -1,246 +0,0 @@
1
- /**
2
- * Timeback Core Types
3
- *
4
- * Configuration types for the unified Timeback client,
5
- * plus re-exports of entity types from all services.
6
- *
7
- * @example
8
- * ```typescript
9
- * import type { User, School, Organization } from '@timeback/core/types'
10
- * ```
11
- */
12
- import type { TimebackProvider } from '@timeback/internal-client-infra';
13
- import type { PLATFORMS } from '@timeback/internal-constants';
14
- export * as OneRoster from '@timeback/oneroster/types';
15
- export * as Caliper from '@timeback/caliper/types';
16
- export * as Webhooks from '@timeback/webhooks/types';
17
- export * as Edubridge from '@timeback/edubridge/types';
18
- export * as Qti from '@timeback/qti/types';
19
- export * as PowerPath from '@timeback/powerpath/types';
20
- /**
21
- * Supported Timeback platform implementations.
22
- * Derived from PLATFORMS constant in {@link @timeback/internal-constants.PLATFORMS}.
23
- */
24
- export type Platform = (typeof PLATFORMS)[number];
25
- /**
26
- * Timeback deployment environment.
27
- */
28
- export type Environment = 'staging' | 'production';
29
- /**
30
- * Resolved service URLs for environment mode.
31
- * @internal
32
- */
33
- export interface EnvServiceUrls {
34
- oneroster: string;
35
- caliper: string;
36
- webhooks: string;
37
- edubridge: string;
38
- qti: string;
39
- powerpath?: string;
40
- authUrl: string;
41
- }
42
- /**
43
- * OAuth2 client credentials for environment mode.
44
- * Token URL is derived from the environment.
45
- */
46
- export interface EnvAuthCredentials {
47
- clientId: string;
48
- clientSecret: string;
49
- }
50
- /**
51
- * OAuth2 client credentials with explicit token URL.
52
- * Required when using baseUrl or services mode.
53
- */
54
- export interface ExplicitAuthCredentials {
55
- clientId: string;
56
- clientSecret: string;
57
- authUrl: string;
58
- }
59
- /**
60
- * Service endpoint configuration.
61
- * Can be a simple URL string or an object with baseUrl and optional authUrl override.
62
- */
63
- export type ServiceEndpoint = string | {
64
- baseUrl: string;
65
- authUrl?: string;
66
- };
67
- /**
68
- * Explicit URLs for each service.
69
- * All fields optional — only configure services you need.
70
- */
71
- export interface ServiceUrls {
72
- /** OneRoster API endpoint */
73
- oneroster?: ServiceEndpoint;
74
- /** Caliper API endpoint */
75
- caliper?: ServiceEndpoint;
76
- /** Webhooks API endpoint */
77
- webhooks?: ServiceEndpoint;
78
- /** Edubridge API endpoint */
79
- edubridge?: ServiceEndpoint;
80
- /** QTI API endpoint */
81
- qti?: ServiceEndpoint;
82
- /** PowerPath API endpoint */
83
- powerpath?: ServiceEndpoint;
84
- }
85
- /**
86
- * Environment mode: URLs derived from platform and environment.
87
- *
88
- * @example
89
- * ```typescript
90
- * // BeyondAI platform (default)
91
- * const client = new TimebackClient({
92
- * env: 'staging',
93
- * auth: { clientId: '...', clientSecret: '...' },
94
- * })
95
- *
96
- * // LearnWith.AI platform
97
- * const client = new TimebackClient({
98
- * platform: 'LEARNWITH_AI',
99
- * env: 'production',
100
- * auth: { clientId: '...', clientSecret: '...' },
101
- * })
102
- * ```
103
- */
104
- export interface EnvConfig {
105
- platform?: Platform;
106
- env: Environment;
107
- auth?: Partial<EnvAuthCredentials>;
108
- timeout?: number;
109
- }
110
- /**
111
- * Base URL mode: Single base URL, service paths derived automatically.
112
- *
113
- * @example
114
- * ```typescript
115
- * const client = new TimebackClient({
116
- * baseUrl: 'https://timeback.myschool.edu',
117
- * auth: {
118
- * clientId: '...',
119
- * clientSecret: '...',
120
- * authUrl: 'https://timeback.myschool.edu/oauth/token',
121
- * },
122
- * })
123
- * ```
124
- */
125
- export interface BaseUrlConfig {
126
- baseUrl: string;
127
- auth: ExplicitAuthCredentials;
128
- timeout?: number;
129
- }
130
- /**
131
- * Explicit services mode: Full control over each service URL.
132
- *
133
- * @example
134
- * ```typescript
135
- * const client = new TimebackClient({
136
- * services: {
137
- * oneroster: 'https://roster.example.com/v1p2',
138
- * caliper: 'https://analytics.example.com/caliper',
139
- * edubridge: 'https://api.example.com/edubridge',
140
- * qti: 'https://qti.example.com/api',
141
- * },
142
- * auth: {
143
- * clientId: '...',
144
- * clientSecret: '...',
145
- * authUrl: 'https://auth.example.com/oauth/token',
146
- * },
147
- * })
148
- * ```
149
- */
150
- export interface ServicesConfig {
151
- services: ServiceUrls;
152
- auth: ExplicitAuthCredentials;
153
- timeout?: number;
154
- }
155
- /**
156
- * Provider mode: use a pre-built TimebackProvider.
157
- *
158
- * @example
159
- * ```typescript
160
- * import { TimebackProvider } from '@timeback/internal-client-infra'
161
- *
162
- * const provider = new TimebackProvider({
163
- * platform: 'BEYOND_AI',
164
- * env: 'staging',
165
- * auth: { clientId: '...', clientSecret: '...' },
166
- * })
167
- *
168
- * const client = new TimebackClient({ provider })
169
- * ```
170
- */
171
- export interface ProviderConfig {
172
- provider: TimebackProvider;
173
- }
174
- /**
175
- * Configuration for the unified Timeback client.
176
- *
177
- * Supports four modes:
178
- * - **Provider**: `{ provider: TimebackProvider }` — pre-built provider
179
- * - **Environment**: `{ env: 'staging' | 'production', auth: {...} }`
180
- * - **Base URL**: `{ baseUrl: '...', auth: {..., authUrl: '...' } }`
181
- * - **Explicit services**: `{ services: {...}, auth: {..., authUrl: '...' } }`
182
- */
183
- export type TimebackClientConfig = ProviderConfig | EnvConfig | BaseUrlConfig | ServicesConfig;
184
- /**
185
- * Result of a broadcast operation for a single client.
186
- * Similar to PromiseSettledResult but with simpler `ok` boolean.
187
- */
188
- export type BroadcastResult<T> = {
189
- ok: true;
190
- value: T;
191
- } | {
192
- ok: false;
193
- error: Error;
194
- };
195
- /**
196
- * Convenience methods available on broadcast results.
197
- *
198
- * @typeParam T - The value type returned by successful operations
199
- * @typeParam TNames - Union of client names (for typed tuples)
200
- */
201
- export interface BroadcastResultMethods<T, TNames extends string = string> {
202
- /** Get all successful results as [name, value] tuples */
203
- readonly succeeded: Array<[TNames, T]>;
204
- /** Get all failed results as [name, error] tuples */
205
- readonly failed: Array<[TNames, Error]>;
206
- /** True if all operations succeeded */
207
- readonly allSucceeded: boolean;
208
- /** True if any operation failed */
209
- readonly anyFailed: boolean;
210
- /** Get all successful values (throws if any failed) */
211
- values(): T[];
212
- }
213
- /**
214
- * Broadcast results with both direct property access and convenience methods.
215
- *
216
- * Access results directly by name or use helper methods:
217
- *
218
- * @typeParam T - The value type returned by successful operations
219
- * @typeParam TNames - Union of client names (enables autocomplete)
220
- *
221
- * @example
222
- * ```typescript
223
- * const results = await manager.broadcast(c => c.oneroster.users.create(user))
224
- *
225
- * // Direct access (like a plain object):
226
- * results.alpha.ok
227
- * results['beta'].error
228
- *
229
- * // Convenience methods:
230
- * if (results.allSucceeded) {
231
- * console.log('All platforms synced!')
232
- * }
233
- *
234
- * results.succeeded.forEach(([name, user]) => {
235
- * console.log(`Created on ${name}:`, user.id)
236
- * })
237
- *
238
- * results.failed.forEach(([name, error]) => {
239
- * console.error(`Failed on ${name}:`, error.message)
240
- * })
241
- * ```
242
- */
243
- export type BroadcastResults<T, TNames extends string = string> = {
244
- [K in TNames]: BroadcastResult<T>;
245
- } & BroadcastResultMethods<T, TNames>;
246
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAA;AACvE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AAM7D,OAAO,KAAK,SAAS,MAAM,2BAA2B,CAAA;AACtD,OAAO,KAAK,OAAO,MAAM,yBAAyB,CAAA;AAClD,OAAO,KAAK,QAAQ,MAAM,0BAA0B,CAAA;AACpD,OAAO,KAAK,SAAS,MAAM,2BAA2B,CAAA;AACtD,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAA;AAC1C,OAAO,KAAK,SAAS,MAAM,2BAA2B,CAAA;AAMtD;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,SAAS,CAAC,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AAC,EAAE,CAAA;CACb;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,EAAE,MAAM,SAAS,MAAM,GAAG,MAAM,IAAI;KAChE,CAAC,IAAI,MAAM,GAAG,eAAe,CAAC,CAAC,CAAC;CACjC,GAAG,sBAAsB,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,eAAe,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AAE9D,YAAY,EACX,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,cAAc,GACd,MAAM,qBAAqB,CAAA"}