@campfire-interactive/volume-intelligence-client 0.1.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.
- package/dist/client.d.ts +18 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +25 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +16 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +38 -0
- package/dist/errors.js.map +1 -0
- package/dist/http.d.ts +21 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +83 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/mock.d.ts +16 -0
- package/dist/mock.d.ts.map +1 -0
- package/dist/mock.js +73 -0
- package/dist/mock.js.map +1 -0
- package/dist/programs.d.ts +18 -0
- package/dist/programs.d.ts.map +1 -0
- package/dist/programs.js +44 -0
- package/dist/programs.js.map +1 -0
- package/dist/types.d.ts +69 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +29 -0
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ProgramsResource } from './programs';
|
|
2
|
+
import type { VolumeIntelligenceClientConfig } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Client for Volume Intelligence — the platform's canonical volume data plane
|
|
5
|
+
* (2026-06-11 data-plane ADR). Consumers (OMSF first; cashflow/capex later)
|
|
6
|
+
* read volume through this rather than keeping their own copies.
|
|
7
|
+
*
|
|
8
|
+
* const vi = new VolumeIntelligenceClient({
|
|
9
|
+
* baseUrl: process.env.FORECAST_BASE_URL!,
|
|
10
|
+
* getToken: () => getSystemTokenForTenant(tenantId, 'forecast'),
|
|
11
|
+
* });
|
|
12
|
+
* const programs = await vi.programs.listActive({ minForwardAnnual: 1000 });
|
|
13
|
+
*/
|
|
14
|
+
export declare class VolumeIntelligenceClient {
|
|
15
|
+
readonly programs: ProgramsResource;
|
|
16
|
+
constructor(config: VolumeIntelligenceClientConfig);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,SAAS,CAAC;AAE9D;;;;;;;;;;GAUG;AACH,qBAAa,wBAAwB;IACnC,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;gBAExB,MAAM,EAAE,8BAA8B;CAInD"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VolumeIntelligenceClient = void 0;
|
|
4
|
+
const http_1 = require("./http");
|
|
5
|
+
const programs_1 = require("./programs");
|
|
6
|
+
/**
|
|
7
|
+
* Client for Volume Intelligence — the platform's canonical volume data plane
|
|
8
|
+
* (2026-06-11 data-plane ADR). Consumers (OMSF first; cashflow/capex later)
|
|
9
|
+
* read volume through this rather than keeping their own copies.
|
|
10
|
+
*
|
|
11
|
+
* const vi = new VolumeIntelligenceClient({
|
|
12
|
+
* baseUrl: process.env.FORECAST_BASE_URL!,
|
|
13
|
+
* getToken: () => getSystemTokenForTenant(tenantId, 'forecast'),
|
|
14
|
+
* });
|
|
15
|
+
* const programs = await vi.programs.listActive({ minForwardAnnual: 1000 });
|
|
16
|
+
*/
|
|
17
|
+
class VolumeIntelligenceClient {
|
|
18
|
+
programs;
|
|
19
|
+
constructor(config) {
|
|
20
|
+
const http = new http_1.HttpTransport(config);
|
|
21
|
+
this.programs = new programs_1.ProgramsResource(http);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.VolumeIntelligenceClient = VolumeIntelligenceClient;
|
|
25
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAAA,iCAAuC;AACvC,yCAA8C;AAG9C;;;;;;;;;;GAUG;AACH,MAAa,wBAAwB;IAC1B,QAAQ,CAAmB;IAEpC,YAAY,MAAsC;QAChD,MAAM,IAAI,GAAG,IAAI,oBAAa,CAAC,MAAM,CAAC,CAAC;QACvC,IAAI,CAAC,QAAQ,GAAG,IAAI,2BAAgB,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;CACF;AAPD,4DAOC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare class VolumeIntelligenceError extends Error {
|
|
2
|
+
readonly statusCode: number;
|
|
3
|
+
readonly code: string;
|
|
4
|
+
readonly requestId: string | undefined;
|
|
5
|
+
constructor(message: string, statusCode: number, code: string, requestId?: string);
|
|
6
|
+
}
|
|
7
|
+
export declare class NotFoundError extends VolumeIntelligenceError {
|
|
8
|
+
constructor(message?: string, requestId?: string);
|
|
9
|
+
}
|
|
10
|
+
export declare class UnauthorizedError extends VolumeIntelligenceError {
|
|
11
|
+
constructor(message?: string, requestId?: string);
|
|
12
|
+
}
|
|
13
|
+
export declare class ForbiddenError extends VolumeIntelligenceError {
|
|
14
|
+
constructor(message?: string, requestId?: string);
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAIA,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;gBAE3B,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;CAOlF;AAED,qBAAa,aAAc,SAAQ,uBAAuB;gBAC5C,OAAO,SAAuB,EAAE,SAAS,CAAC,EAAE,MAAM;CAG/D;AAED,qBAAa,iBAAkB,SAAQ,uBAAuB;gBAChD,OAAO,SAAiB,EAAE,SAAS,CAAC,EAAE,MAAM;CAGzD;AAED,qBAAa,cAAe,SAAQ,uBAAuB;gBAC7C,OAAO,SAAc,EAAE,SAAS,CAAC,EAAE,MAAM;CAGtD"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// =============================================================================
|
|
3
|
+
// Client-side error hierarchy — mirrors the backend's AppError shape.
|
|
4
|
+
// =============================================================================
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ForbiddenError = exports.UnauthorizedError = exports.NotFoundError = exports.VolumeIntelligenceError = void 0;
|
|
7
|
+
class VolumeIntelligenceError extends Error {
|
|
8
|
+
statusCode;
|
|
9
|
+
code;
|
|
10
|
+
requestId;
|
|
11
|
+
constructor(message, statusCode, code, requestId) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.name = this.constructor.name;
|
|
14
|
+
this.statusCode = statusCode;
|
|
15
|
+
this.code = code;
|
|
16
|
+
this.requestId = requestId;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.VolumeIntelligenceError = VolumeIntelligenceError;
|
|
20
|
+
class NotFoundError extends VolumeIntelligenceError {
|
|
21
|
+
constructor(message = 'Resource not found', requestId) {
|
|
22
|
+
super(message, 404, 'NOT_FOUND', requestId);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.NotFoundError = NotFoundError;
|
|
26
|
+
class UnauthorizedError extends VolumeIntelligenceError {
|
|
27
|
+
constructor(message = 'Unauthorized', requestId) {
|
|
28
|
+
super(message, 401, 'UNAUTHORIZED', requestId);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.UnauthorizedError = UnauthorizedError;
|
|
32
|
+
class ForbiddenError extends VolumeIntelligenceError {
|
|
33
|
+
constructor(message = 'Forbidden', requestId) {
|
|
34
|
+
super(message, 403, 'FORBIDDEN', requestId);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.ForbiddenError = ForbiddenError;
|
|
38
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,sEAAsE;AACtE,gFAAgF;;;AAEhF,MAAa,uBAAwB,SAAQ,KAAK;IACvC,UAAU,CAAS;IACnB,IAAI,CAAS;IACb,SAAS,CAAqB;IAEvC,YAAY,OAAe,EAAE,UAAkB,EAAE,IAAY,EAAE,SAAkB;QAC/E,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAClC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CACF;AAZD,0DAYC;AAED,MAAa,aAAc,SAAQ,uBAAuB;IACxD,YAAY,OAAO,GAAG,oBAAoB,EAAE,SAAkB;QAC5D,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;IAC9C,CAAC;CACF;AAJD,sCAIC;AAED,MAAa,iBAAkB,SAAQ,uBAAuB;IAC5D,YAAY,OAAO,GAAG,cAAc,EAAE,SAAkB;QACtD,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;IACjD,CAAC;CACF;AAJD,8CAIC;AAED,MAAa,cAAe,SAAQ,uBAAuB;IACzD,YAAY,OAAO,GAAG,WAAW,EAAE,SAAkB;QACnD,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;IAC9C,CAAC;CACF;AAJD,wCAIC"}
|
package/dist/http.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { VolumeIntelligenceClientConfig } from './types';
|
|
2
|
+
interface HttpRequestOptions {
|
|
3
|
+
method: 'GET' | 'POST';
|
|
4
|
+
path: string;
|
|
5
|
+
body?: unknown;
|
|
6
|
+
query?: Record<string, string | undefined>;
|
|
7
|
+
}
|
|
8
|
+
/** Auth-aware fetch transport. Mirrors master-data-client / cfi-ai-hub-client:
|
|
9
|
+
* `{ baseUrl, getToken, timeout }`, bearer-token injection, timeout via
|
|
10
|
+
* AbortController, and status→error mapping. Read-focused for v0.1. */
|
|
11
|
+
export declare class HttpTransport {
|
|
12
|
+
private readonly baseUrl;
|
|
13
|
+
private readonly getToken;
|
|
14
|
+
private readonly timeout;
|
|
15
|
+
constructor(config: VolumeIntelligenceClientConfig);
|
|
16
|
+
request<T>(options: HttpRequestOptions): Promise<T>;
|
|
17
|
+
private buildUrl;
|
|
18
|
+
private throwForStatus;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,SAAS,CAAC;AAK9D,UAAU,kBAAkB;IAC1B,MAAM,EAAE,KAAK,GAAG,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;CAC5C;AAED;;wEAEwE;AACxE,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAiC;IAC1D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAErB,MAAM,EAAE,8BAA8B;IAM5C,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC;IA2CzD,OAAO,CAAC,QAAQ;IAUhB,OAAO,CAAC,cAAc;CAuBvB"}
|
package/dist/http.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpTransport = void 0;
|
|
4
|
+
const errors_1 = require("./errors");
|
|
5
|
+
const DEFAULT_TIMEOUT = 30_000;
|
|
6
|
+
/** Auth-aware fetch transport. Mirrors master-data-client / cfi-ai-hub-client:
|
|
7
|
+
* `{ baseUrl, getToken, timeout }`, bearer-token injection, timeout via
|
|
8
|
+
* AbortController, and status→error mapping. Read-focused for v0.1. */
|
|
9
|
+
class HttpTransport {
|
|
10
|
+
baseUrl;
|
|
11
|
+
getToken;
|
|
12
|
+
timeout;
|
|
13
|
+
constructor(config) {
|
|
14
|
+
this.baseUrl = config.baseUrl.replace(/\/+$/, '');
|
|
15
|
+
this.getToken = config.getToken;
|
|
16
|
+
this.timeout = config.timeout ?? DEFAULT_TIMEOUT;
|
|
17
|
+
}
|
|
18
|
+
async request(options) {
|
|
19
|
+
const { method, path, body, query } = options;
|
|
20
|
+
const url = this.buildUrl(path, query);
|
|
21
|
+
const token = await this.getToken();
|
|
22
|
+
const headers = {
|
|
23
|
+
'Content-Type': 'application/json',
|
|
24
|
+
Authorization: `Bearer ${token}`,
|
|
25
|
+
};
|
|
26
|
+
const controller = new AbortController();
|
|
27
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
28
|
+
let response;
|
|
29
|
+
try {
|
|
30
|
+
response = await fetch(url, {
|
|
31
|
+
method,
|
|
32
|
+
headers,
|
|
33
|
+
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
34
|
+
signal: controller.signal,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
if (error.name === 'AbortError') {
|
|
39
|
+
throw new errors_1.VolumeIntelligenceError('Request timed out', 0, 'TIMEOUT');
|
|
40
|
+
}
|
|
41
|
+
throw new errors_1.VolumeIntelligenceError(`Network error: ${error.message}`, 0, 'NETWORK_ERROR');
|
|
42
|
+
}
|
|
43
|
+
finally {
|
|
44
|
+
clearTimeout(timeoutId);
|
|
45
|
+
}
|
|
46
|
+
if (response.status === 204) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
const responseBody = await response.json().catch(() => undefined);
|
|
50
|
+
if (!response.ok) {
|
|
51
|
+
this.throwForStatus(response.status, responseBody);
|
|
52
|
+
}
|
|
53
|
+
return responseBody;
|
|
54
|
+
}
|
|
55
|
+
buildUrl(path, query) {
|
|
56
|
+
const url = new URL(`${this.baseUrl}${path}`);
|
|
57
|
+
if (query) {
|
|
58
|
+
for (const [key, value] of Object.entries(query)) {
|
|
59
|
+
if (value !== undefined)
|
|
60
|
+
url.searchParams.set(key, value);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return url.toString();
|
|
64
|
+
}
|
|
65
|
+
throwForStatus(status, body) {
|
|
66
|
+
const errorBody = body;
|
|
67
|
+
const rawError = errorBody?.error;
|
|
68
|
+
const message = typeof rawError === 'string' ? rawError : rawError?.message || `Request failed with status ${status}`;
|
|
69
|
+
const requestId = errorBody?.meta?.requestId;
|
|
70
|
+
switch (status) {
|
|
71
|
+
case 404:
|
|
72
|
+
throw new errors_1.NotFoundError(message, requestId);
|
|
73
|
+
case 401:
|
|
74
|
+
throw new errors_1.UnauthorizedError(message, requestId);
|
|
75
|
+
case 403:
|
|
76
|
+
throw new errors_1.ForbiddenError(message, requestId);
|
|
77
|
+
default:
|
|
78
|
+
throw new errors_1.VolumeIntelligenceError(message, status, typeof rawError === 'object' ? rawError?.code || 'UNKNOWN_ERROR' : 'UNKNOWN_ERROR', requestId);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.HttpTransport = HttpTransport;
|
|
83
|
+
//# sourceMappingURL=http.js.map
|
package/dist/http.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":";;;AACA,qCAAqG;AAErG,MAAM,eAAe,GAAG,MAAM,CAAC;AAS/B;;wEAEwE;AACxE,MAAa,aAAa;IACP,OAAO,CAAS;IAChB,QAAQ,CAAiC;IACzC,OAAO,CAAS;IAEjC,YAAY,MAAsC;QAChD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAClD,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;QAChC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,eAAe,CAAC;IACnD,CAAC;IAED,KAAK,CAAC,OAAO,CAAI,OAA2B;QAC1C,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;QAC9C,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACvC,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;QAEpC,MAAM,OAAO,GAA2B;YACtC,cAAc,EAAE,kBAAkB;YAClC,aAAa,EAAE,UAAU,KAAK,EAAE;SACjC,CAAC;QAEF,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;QACzC,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,U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eIntelligenceClient } from './mock';
|
|
3
|
+
export { ProgramsResource } from './programs';
|
|
4
|
+
export { VolumeIntelligenceError, NotFoundError, UnauthorizedError, ForbiddenError, } from './errors';
|
|
5
|
+
export type { VolumeIntelligenceClientConfig, ProgramView, ProgramWithVolumes, MonthlyVolume, ListActiveProgramsOptions, ListProgramsForMatchingOptions, ProgramListResponse, } from './types';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,4BAA4B,EAAE,MAAM,QAAQ,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EACL,uBAAuB,EACvB,aAAa,EACb,iBAAiB,EACjB,cAAc,GACf,MAAM,UAAU,CAAC;AAClB,YAAY,EACV,8BAA8B,EAC9B,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,yBAAyB,EACzB,8BAA8B,EAC9B,mBAAmB,GACpB,MAAM,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ForbiddenError = exports.UnauthorizedError = exports.NotFoundError = exports.VolumeIntelligenceError = exports.ProgramsResource = exports.MockVolumeIntelligenceClient = exports.VolumeIntelligenceClient = void 0;
|
|
4
|
+
var client_1 = require("./client");
|
|
5
|
+
Object.defineProperty(exports, "VolumeIntelligenceClient", { enumerable: true, get: function () { return client_1.VolumeIntelligenceClient; } });
|
|
6
|
+
var mock_1 = require("./mock");
|
|
7
|
+
Object.defineProperty(exports, "MockVolumeIntelligenceClient", { enumerable: true, get: function () { return mock_1.MockVolumeIntelligenceClient; } });
|
|
8
|
+
var programs_1 = require("./programs");
|
|
9
|
+
Object.defineProperty(exports, "ProgramsResource", { enumerable: true, get: function () { return programs_1.ProgramsResource; } });
|
|
10
|
+
var errors_1 = require("./errors");
|
|
11
|
+
Object.defineProperty(exports, "VolumeIntelligenceError", { enumerable: true, get: function () { return errors_1.VolumeIntelligenceError; } });
|
|
12
|
+
Object.defineProperty(exports, "NotFoundError", { enumerable: true, get: function () { return errors_1.NotFoundError; } });
|
|
13
|
+
Object.defineProperty(exports, "UnauthorizedError", { enumerable: true, get: function () { return errors_1.UnauthorizedError; } });
|
|
14
|
+
Object.defineProperty(exports, "ForbiddenError", { enumerable: true, get: function () { return errors_1.ForbiddenError; } });
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAAoD;AAA3C,kHAAA,wBAAwB,OAAA;AACjC,+BAAsD;AAA7C,oHAAA,4BAA4B,OAAA;AACrC,uCAA8C;AAArC,4GAAA,gBAAgB,OAAA;AACzB,mCAKkB;AAJhB,iHAAA,uBAAuB,OAAA;AACvB,uGAAA,aAAa,OAAA;AACb,2GAAA,iBAAiB,OAAA;AACjB,wGAAA,cAAc,OAAA"}
|
package/dist/mock.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ProgramView, ProgramWithVolumes, ListActiveProgramsOptions, ListProgramsForMatchingOptions } from './types';
|
|
2
|
+
declare class MockProgramsResource {
|
|
3
|
+
private programs;
|
|
4
|
+
constructor(programs: ProgramWithVolumes[]);
|
|
5
|
+
seed(programs: ProgramWithVolumes[]): void;
|
|
6
|
+
getAll(): ProgramWithVolumes[];
|
|
7
|
+
listActive(options?: ListActiveProgramsOptions): Promise<ProgramView[]>;
|
|
8
|
+
listForMatching(options?: ListProgramsForMatchingOptions): Promise<ProgramWithVolumes[]>;
|
|
9
|
+
}
|
|
10
|
+
export declare class MockVolumeIntelligenceClient {
|
|
11
|
+
readonly programs: MockProgramsResource;
|
|
12
|
+
constructor(seed?: ProgramWithVolumes[]);
|
|
13
|
+
reset(): void;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=mock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../src/mock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,kBAAkB,EAElB,yBAAyB,EACzB,8BAA8B,EAC/B,MAAM,SAAS,CAAC;AA+BjB,cAAM,oBAAoB;IACZ,OAAO,CAAC,QAAQ;gBAAR,QAAQ,EAAE,kBAAkB,EAAE;IAElD,IAAI,CAAC,QAAQ,EAAE,kBAAkB,EAAE,GAAG,IAAI;IAI1C,MAAM,IAAI,kBAAkB,EAAE;IAIxB,UAAU,CAAC,OAAO,CAAC,EAAE,yBAAyB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAWvE,eAAe,CAAC,OAAO,CAAC,EAAE,8BAA8B,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC;CAS/F;AAED,qBAAa,4BAA4B;IACvC,QAAQ,CAAC,QAAQ,EAAE,oBAAoB,CAAC;gBAE5B,IAAI,CAAC,EAAE,kBAAkB,EAAE;IAIvC,KAAK,IAAI,IAAI;CAGd"}
|
package/dist/mock.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MockVolumeIntelligenceClient = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* In-memory mock for consumer unit tests (mirrors MockMasterDataClient /
|
|
6
|
+
* MockPriceIndexClient). Seed it with `ProgramWithVolumes` fixtures; the
|
|
7
|
+
* `ProgramView` projection (active filter + forward-annual) is derived the same
|
|
8
|
+
* way the real backend derives it.
|
|
9
|
+
*/
|
|
10
|
+
function thisMonth() {
|
|
11
|
+
const now = new Date();
|
|
12
|
+
return { year: now.getFullYear(), month: now.getMonth() + 1 };
|
|
13
|
+
}
|
|
14
|
+
function forwardAnnual(volumes) {
|
|
15
|
+
const start = thisMonth();
|
|
16
|
+
const startYM = start.year * 12 + (start.month - 1);
|
|
17
|
+
const endYM = startYM + 12;
|
|
18
|
+
return volumes
|
|
19
|
+
.filter((v) => {
|
|
20
|
+
const ym = v.year * 12 + (v.month - 1);
|
|
21
|
+
return ym >= startYM && ym < endYM;
|
|
22
|
+
})
|
|
23
|
+
.reduce((s, v) => s + v.volume, 0);
|
|
24
|
+
}
|
|
25
|
+
function isActive(eop) {
|
|
26
|
+
if (!eop)
|
|
27
|
+
return true;
|
|
28
|
+
return eop >= new Date().toISOString().slice(0, 10);
|
|
29
|
+
}
|
|
30
|
+
class MockProgramsResource {
|
|
31
|
+
programs;
|
|
32
|
+
constructor(programs) {
|
|
33
|
+
this.programs = programs;
|
|
34
|
+
}
|
|
35
|
+
seed(programs) {
|
|
36
|
+
this.programs = programs;
|
|
37
|
+
}
|
|
38
|
+
getAll() {
|
|
39
|
+
return this.programs;
|
|
40
|
+
}
|
|
41
|
+
async listActive(options) {
|
|
42
|
+
const min = options?.minForwardAnnual ?? 0;
|
|
43
|
+
return this.programs
|
|
44
|
+
.filter((p) => isActive(p.eop))
|
|
45
|
+
.map((p) => {
|
|
46
|
+
const { monthlyVolumes, ...rest } = p;
|
|
47
|
+
return { ...rest, forwardAnnualVolume: forwardAnnual(monthlyVolumes) };
|
|
48
|
+
})
|
|
49
|
+
.filter((p) => p.forwardAnnualVolume >= min);
|
|
50
|
+
}
|
|
51
|
+
async listForMatching(options) {
|
|
52
|
+
const nameplate = options?.nameplate?.toLowerCase();
|
|
53
|
+
const oem = options?.oem?.toLowerCase();
|
|
54
|
+
return this.programs.filter((p) => {
|
|
55
|
+
if (nameplate && !p.nameplate.toLowerCase().includes(nameplate))
|
|
56
|
+
return false;
|
|
57
|
+
if (oem && !p.oem.toLowerCase().includes(oem) && !p.manufacturerGroup.toLowerCase().includes(oem))
|
|
58
|
+
return false;
|
|
59
|
+
return true;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
class MockVolumeIntelligenceClient {
|
|
64
|
+
programs;
|
|
65
|
+
constructor(seed) {
|
|
66
|
+
this.programs = new MockProgramsResource(seed ?? []);
|
|
67
|
+
}
|
|
68
|
+
reset() {
|
|
69
|
+
this.programs.seed([]);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.MockVolumeIntelligenceClient = MockVolumeIntelligenceClient;
|
|
73
|
+
//# sourceMappingURL=mock.js.map
|
package/dist/mock.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock.js","sourceRoot":"","sources":["../src/mock.ts"],"names":[],"mappings":";;;AAQA;;;;;GAKG;AAEH,SAAS,SAAS;IAChB,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IACvB,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC;AAChE,CAAC;AAED,SAAS,aAAa,CAAC,OAAwB;IAC7C,MAAM,KAAK,GAAG,SAAS,EAAE,CAAC;IAC1B,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;IACpD,MAAM,KAAK,GAAG,OAAO,GAAG,EAAE,CAAC;IAC3B,OAAO,OAAO;SACX,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE;QACZ,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QACvC,OAAO,EAAE,IAAI,OAAO,IAAI,EAAE,GAAG,KAAK,CAAC;IACrC,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,CAAC,EAA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CAAC;QACxC,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE;YAChC,IAAI,SAAS,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC;gBAAE,OAAO,KAAK,CAAC;YAC9E,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,iBAAiB,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC;gBAAE,OAAO,KAAK,CAAC;YAChH,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED,MAAa,4BAA4B;IAC9B,QAAQ,CAAuB;IAExC,YAAY,IAA2B;QACrC,IAAI,CAAC,QAAQ,GAAG,IAAI,oBAAoB,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;IACvD,CAAC;IAED,KAAK;QACH,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACzB,CAAC;CACF;AAVD,oEAUC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { HttpTransport } from './http';
|
|
2
|
+
import type { ProgramView, ProgramWithVolumes, ListActiveProgramsOptions, ListProgramsForMatchingOptions } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Program reads. The projection turns VI's internal weekly/criteria model into
|
|
5
|
+
* the program-shaped, monthly view consumers expect (see the backend
|
|
6
|
+
* programViewService). Tenant scope comes from the caller's token.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ProgramsResource {
|
|
9
|
+
private readonly http;
|
|
10
|
+
constructor(http: HttpTransport);
|
|
11
|
+
/** Active programs (EOP null or future) with their 12-month forward-annual
|
|
12
|
+
* volume. Bulk read for OMSF's unengaged-opportunity sync. */
|
|
13
|
+
listActive(options?: ListActiveProgramsOptions): Promise<ProgramView[]>;
|
|
14
|
+
/** Candidate programs + monthly curves for consumer-side matching (e.g.
|
|
15
|
+
* OMSF's per-quote forecast). `nameplate`/`oem` coarse-filter the payload. */
|
|
16
|
+
listForMatching(options?: ListProgramsForMatchingOptions): Promise<ProgramWithVolumes[]>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=programs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"programs.d.ts","sourceRoot":"","sources":["../src/programs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EACV,WAAW,EACX,kBAAkB,EAClB,yBAAyB,EACzB,8BAA8B,EAE/B,MAAM,SAAS,CAAC;AAEjB;;;;GAIG;AACH,qBAAa,gBAAgB;IACf,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,aAAa;IAEhD;mEAC+D;IACzD,UAAU,CAAC,OAAO,CAAC,EAAE,yBAAyB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAa7E;mFAC+E;IACzE,eAAe,CAAC,OAAO,CAAC,EAAE,8BAA8B,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC;CAY/F"}
|
package/dist/programs.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProgramsResource = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Program reads. The projection turns VI's internal weekly/criteria model into
|
|
6
|
+
* the program-shaped, monthly view consumers expect (see the backend
|
|
7
|
+
* programViewService). Tenant scope comes from the caller's token.
|
|
8
|
+
*/
|
|
9
|
+
class ProgramsResource {
|
|
10
|
+
http;
|
|
11
|
+
constructor(http) {
|
|
12
|
+
this.http = http;
|
|
13
|
+
}
|
|
14
|
+
/** Active programs (EOP null or future) with their 12-month forward-annual
|
|
15
|
+
* volume. Bulk read for OMSF's unengaged-opportunity sync. */
|
|
16
|
+
async listActive(options) {
|
|
17
|
+
const query = { activeOnly: 'true' };
|
|
18
|
+
if (options?.minForwardAnnual !== undefined) {
|
|
19
|
+
query.minForwardAnnual = String(options.minForwardAnnual);
|
|
20
|
+
}
|
|
21
|
+
const res = await this.http.request({
|
|
22
|
+
method: 'GET',
|
|
23
|
+
path: '/v1/programs',
|
|
24
|
+
query,
|
|
25
|
+
});
|
|
26
|
+
return res.items;
|
|
27
|
+
}
|
|
28
|
+
/** Candidate programs + monthly curves for consumer-side matching (e.g.
|
|
29
|
+
* OMSF's per-quote forecast). `nameplate`/`oem` coarse-filter the payload. */
|
|
30
|
+
async listForMatching(options) {
|
|
31
|
+
const query = {
|
|
32
|
+
nameplate: options?.nameplate,
|
|
33
|
+
oem: options?.oem,
|
|
34
|
+
};
|
|
35
|
+
const res = await this.http.request({
|
|
36
|
+
method: 'GET',
|
|
37
|
+
path: '/v1/programs/candidates',
|
|
38
|
+
query,
|
|
39
|
+
});
|
|
40
|
+
return res.items;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.ProgramsResource = ProgramsResource;
|
|
44
|
+
//# sourceMappingURL=programs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"programs.js","sourceRoot":"","sources":["../src/programs.ts"],"names":[],"mappings":";;;AASA;;;;GAIG;AACH,MAAa,gBAAgB;IACE;IAA7B,YAA6B,IAAmB;QAAnB,SAAI,GAAJ,IAAI,CAAe;IAAG,CAAC;IAEpD;mEAC+D;IAC/D,KAAK,CAAC,UAAU,CAAC,OAAmC;QAClD,MAAM,KAAK,GAAuC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC;QACzE,IAAI,OAAO,EAAE,gBAAgB,KAAK,SAAS,EAAE,CAAC;YAC5C,KAAK,CAAC,gBAAgB,GAAG,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;QAC5D,CAAC;QACD,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAmC;YACpE,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,cAAc;YACpB,KAAK;SACN,CAAC,CAAC;QACH,OAAO,GAAG,CAAC,KAAK,CAAC;IACnB,CAAC;IAED;mFAC+E;IAC/E,KAAK,CAAC,eAAe,CAAC,OAAwC;QAC5D,MAAM,KAAK,GAAuC;YAChD,SAAS,EAAE,OAAO,EAAE,SAAS;YAC7B,GAAG,EAAE,OAAO,EAAE,GAAG;SAClB,CAAC;QACF,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAA0C;YAC3E,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,yBAAyB;YAC/B,KAAK;SACN,CAAC,CAAC;QACH,OAAO,GAAG,CAAC,KAAK,CAAC;IACnB,CAAC;CACF;AAhCD,4CAgCC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export interface VolumeIntelligenceClientConfig {
|
|
2
|
+
/** Full base URL of the Volume Intelligence (forecast) API, e.g.
|
|
3
|
+
* `https://api.forecast.campfiresuite.com`. */
|
|
4
|
+
baseUrl: string;
|
|
5
|
+
/** Async or sync provider returning a platform-identity JWT. Backends pass a
|
|
6
|
+
* system token minted for the tenant (audience `forecast`); browsers pass a
|
|
7
|
+
* BrowserAuth token. */
|
|
8
|
+
getToken: () => string | Promise<string>;
|
|
9
|
+
/** Request timeout in milliseconds. Defaults to 30_000. */
|
|
10
|
+
timeout?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface MonthlyVolume {
|
|
13
|
+
year: number;
|
|
14
|
+
month: number;
|
|
15
|
+
volume: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A production program projected for bulk consumers (OMSF's unengaged-opp
|
|
19
|
+
* sync). `programKey` is a stable identifier — consumers may key derived
|
|
20
|
+
* records (e.g. opportunity numbers) off it, so it is stable across reads.
|
|
21
|
+
* `forwardAnnualVolume` is the sum of the next 12 months of the adjusted
|
|
22
|
+
* (campfire + analyst-edited) curve.
|
|
23
|
+
*/
|
|
24
|
+
export interface ProgramView {
|
|
25
|
+
programKey: string;
|
|
26
|
+
oem: string;
|
|
27
|
+
manufacturerGroup: string;
|
|
28
|
+
programName: string;
|
|
29
|
+
nameplate: string;
|
|
30
|
+
plant: string;
|
|
31
|
+
city: string;
|
|
32
|
+
region: string;
|
|
33
|
+
sop: string | null;
|
|
34
|
+
eop: string | null;
|
|
35
|
+
forwardAnnualVolume: number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A program plus its full monthly volume curve. Consumers that run their own
|
|
39
|
+
* matching (e.g. OMSF's per-quote forecast) read these candidates and score
|
|
40
|
+
* them client-side.
|
|
41
|
+
*/
|
|
42
|
+
export interface ProgramWithVolumes {
|
|
43
|
+
programKey: string;
|
|
44
|
+
oem: string;
|
|
45
|
+
manufacturerGroup: string;
|
|
46
|
+
programName: string;
|
|
47
|
+
nameplate: string;
|
|
48
|
+
plant: string;
|
|
49
|
+
city: string;
|
|
50
|
+
region: string;
|
|
51
|
+
sop: string | null;
|
|
52
|
+
eop: string | null;
|
|
53
|
+
monthlyVolumes: MonthlyVolume[];
|
|
54
|
+
}
|
|
55
|
+
export interface ListActiveProgramsOptions {
|
|
56
|
+
/** Only return programs whose 12-month forward volume is at least this. */
|
|
57
|
+
minForwardAnnual?: number;
|
|
58
|
+
}
|
|
59
|
+
export interface ListProgramsForMatchingOptions {
|
|
60
|
+
/** Coarse server-side pre-filters to bound payload. Consumers still apply
|
|
61
|
+
* their own match logic over the returned candidates. */
|
|
62
|
+
nameplate?: string;
|
|
63
|
+
oem?: string;
|
|
64
|
+
}
|
|
65
|
+
/** List envelope returned by the program reads. */
|
|
66
|
+
export interface ProgramListResponse<T> {
|
|
67
|
+
items: T[];
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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;IAC3E,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,8BAA8B;IAC7C;8DAC0D;IAC1D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,mDAAmD;AACnD,MAAM,WAAW,mBAAmB,CAAC,CAAC;IACpC,KAAK,EAAE,CAAC,EAAE,CAAC;CACZ"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@campfire-interactive/volume-intelligence-client",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "TypeScript client for Volume Intelligence (the platform's volume data plane)",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"clean": "rm -rf dist"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/Campfire-Interactive/packages.git"
|
|
17
|
+
},
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"registry": "https://registry.npmjs.org",
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/node": "^25.5.0",
|
|
24
|
+
"typescript": "^5.3.3"
|
|
25
|
+
},
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=18.0.0"
|
|
28
|
+
}
|
|
29
|
+
}
|