@openframe-org/criteria-set-protocol 1.0.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.
@@ -0,0 +1,3 @@
1
+ export * from './services';
2
+ export * from './types';
3
+ export * as v1 from './v1';
package/dist/index.js ADDED
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
+ };
21
+ var __importStar = (this && this.__importStar) || function (mod) {
22
+ if (mod && mod.__esModule) return mod;
23
+ var result = {};
24
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
+ __setModuleDefault(result, mod);
26
+ return result;
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.v1 = void 0;
30
+ __exportStar(require("./services"), exports);
31
+ __exportStar(require("./types"), exports);
32
+ exports.v1 = __importStar(require("./v1"));
@@ -0,0 +1,5 @@
1
+ import { ProtocolVersionServiceMap } from '../types';
2
+ export interface IVersionedService {
3
+ version: string;
4
+ supportsProtocol: <ProtocolVersion extends number>(protocolVersion: ProtocolVersion) => this is ProtocolVersionServiceMap<ProtocolVersion>;
5
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export * from './i-versioned.service';
2
+ export * from './versions.service';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./i-versioned.service"), exports);
18
+ __exportStar(require("./versions.service"), exports);
@@ -0,0 +1,10 @@
1
+ import { IVersionedService } from './i-versioned.service';
2
+ import { ProtocolVersionServiceMap } from '../types';
3
+ export declare class VersionsService {
4
+ protected versions: IVersionedService[];
5
+ constructor(versions: IVersionedService[]);
6
+ getAll(): IVersionedService[];
7
+ getServiceVersions<ProtocolVersion extends number, ProtocolImplementingService = ProtocolVersionServiceMap<ProtocolVersion>>(protocolVersion: ProtocolVersion): ProtocolImplementingService[];
8
+ get(version: string): IVersionedService | undefined;
9
+ getLatestVersion(): IVersionedService;
10
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VersionsService = void 0;
4
+ class VersionsService {
5
+ constructor(versions) {
6
+ this.versions = versions;
7
+ }
8
+ getAll() {
9
+ return this.versions;
10
+ }
11
+ getServiceVersions(protocolVersion) {
12
+ return this.versions.filter((service) => service.supportsProtocol(protocolVersion));
13
+ }
14
+ get(version) {
15
+ return this.versions.find((service) => service.version === version);
16
+ }
17
+ getLatestVersion() {
18
+ return this.versions[this.versions.length - 1];
19
+ }
20
+ }
21
+ exports.VersionsService = VersionsService;
@@ -0,0 +1,2 @@
1
+ import { IProtocolV1Service } from './v1/services/i-protocol-v1.service';
2
+ export type ProtocolVersionServiceMap<Version extends number> = Version extends 1 ? IProtocolV1Service : unknown;
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ export * from './schemas';
2
+ export * from './services';
3
+ export * from './types';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./schemas"), exports);
18
+ __exportStar(require("./services"), exports);
19
+ __exportStar(require("./types"), exports);
@@ -0,0 +1,10 @@
1
+ import * as yup from 'yup';
2
+ export declare const criteriaSetIdParamSchema: yup.ObjectSchema<{
3
+ params: {
4
+ criteriaSetId: string;
5
+ };
6
+ }, yup.AnyObject, {
7
+ params: {
8
+ criteriaSetId: undefined;
9
+ };
10
+ }, "">;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.criteriaSetIdParamSchema = void 0;
27
+ const yup = __importStar(require("yup"));
28
+ exports.criteriaSetIdParamSchema = yup.object({
29
+ params: yup.object({
30
+ criteriaSetId: yup.string()
31
+ .matches(/^[a-zA-Z0-9.-_]+$/, 'Criteria set ID must contain only full stops, alphanumeric characters, dashes and underscores')
32
+ .required()
33
+ })
34
+ });
@@ -0,0 +1,12 @@
1
+ import * as yup from 'yup';
2
+ export declare const downloadMatrixBodySchema: yup.ObjectSchema<{
3
+ body: {
4
+ values: {};
5
+ parameters: {};
6
+ };
7
+ }, yup.AnyObject, {
8
+ body: {
9
+ parameters: {};
10
+ values: {};
11
+ };
12
+ }, "">;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.downloadMatrixBodySchema = void 0;
27
+ const yup = __importStar(require("yup"));
28
+ exports.downloadMatrixBodySchema = yup.object({
29
+ body: yup.object({
30
+ parameters: yup.object().required(),
31
+ values: yup.object()
32
+ })
33
+ });
@@ -0,0 +1,3 @@
1
+ export * from './criteria-set-id-param-schema';
2
+ export * from './download-matrix-body-schema';
3
+ export * from './version-param-schema';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./criteria-set-id-param-schema"), exports);
18
+ __exportStar(require("./download-matrix-body-schema"), exports);
19
+ __exportStar(require("./version-param-schema"), exports);
@@ -0,0 +1,10 @@
1
+ import * as yup from 'yup';
2
+ export declare const versionParamSchema: yup.ObjectSchema<{
3
+ params: {
4
+ version: string;
5
+ };
6
+ }, yup.AnyObject, {
7
+ params: {
8
+ version: undefined;
9
+ };
10
+ }, "">;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.versionParamSchema = void 0;
27
+ const yup = __importStar(require("yup"));
28
+ exports.versionParamSchema = yup.object({
29
+ params: yup.object({
30
+ version: yup.string()
31
+ .matches(/^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$/, 'Service version must be a SemVer-formatted string which includes exclusively a major, minor and patch version')
32
+ .required()
33
+ })
34
+ });
@@ -0,0 +1,9 @@
1
+ import { CriteriaTree, Metadata, StreamMatrixResponse, TaskItemValueMap } from '../types';
2
+ export interface IProtocolV1Service {
3
+ version: string;
4
+ getCriteriaTree(criteriaSetId: string, rawParameters: Record<string, unknown>): Promise<CriteriaTree>;
5
+ validateParameters<RequestParameters>(criteriaSetId: string, parameters: RequestParameters): void;
6
+ streamMatrix(criteriaSetId: string, rawParameters: Record<string, unknown>, values: TaskItemValueMap): Promise<StreamMatrixResponse>;
7
+ getMatrixMetadataList(): Metadata[];
8
+ getParametersJsonSchema(criteriaSetId: string): Record<string, unknown>;
9
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export * from './i-protocol-v1.service';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./i-protocol-v1.service"), exports);
@@ -0,0 +1,64 @@
1
+ export type Metadata = {
2
+ id: string;
3
+ version: string;
4
+ date: Date;
5
+ name: string;
6
+ description: string;
7
+ documentation?: string;
8
+ };
9
+ export type CriteriaTree = Criterion[];
10
+ export type Criterion = {
11
+ quality: string;
12
+ title: string;
13
+ label?: string;
14
+ tags?: string[];
15
+ items: (Task | TaskGroup)[];
16
+ documentation?: Record<string, string[]>;
17
+ };
18
+ export type TaskGroup = {
19
+ title: string;
20
+ label?: string;
21
+ tags?: string[];
22
+ items: (Task | TaskGroup)[];
23
+ documentation?: Record<string, string[]>;
24
+ };
25
+ export type Task = {
26
+ title: string;
27
+ label?: string;
28
+ tags?: string[];
29
+ items: TaskItem[];
30
+ documentation?: Record<string, string[]>;
31
+ };
32
+ export type TaskItem = {
33
+ id: string;
34
+ text?: string;
35
+ description?: string;
36
+ label?: string;
37
+ tags?: string[];
38
+ definition: SelectSingleType | SelectMultipleType | NumberType | BooleanType;
39
+ documentation?: Record<string, string[]>;
40
+ };
41
+ export type SelectSingleType = {
42
+ type: 'select-single';
43
+ options: PointOption[];
44
+ };
45
+ export type SelectMultipleType = {
46
+ type: 'select-multiple';
47
+ options: PointOption[];
48
+ };
49
+ export type NumberType = {
50
+ type: 'number';
51
+ minimum?: number;
52
+ maximum?: number;
53
+ step?: number;
54
+ };
55
+ export type BooleanType = {
56
+ type: 'boolean';
57
+ };
58
+ export type PointOption = {
59
+ id?: string;
60
+ label: string;
61
+ value: number;
62
+ annotation?: string;
63
+ };
64
+ export type TaskItemValue = string | number | boolean | null | Array<string | number | boolean | null>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,21 @@
1
+ /// <reference types="node" />
2
+ import { Stream } from 'stream';
3
+ import { Metadata, TaskItemValue } from './criteria';
4
+ export type MetadataSchema<Parameters extends ParameterCombination = ParameterCombination> = {
5
+ protocol: 1;
6
+ metadata: Metadata;
7
+ parameters: Parameters;
8
+ };
9
+ export type StringParam<ParamName extends string> = Record<ParamName, string>;
10
+ export type TaskItemValueMap = Record<string, TaskItemValue>;
11
+ export type StreamCriteriaSetMatrixBody = {
12
+ parameters: ParameterCombination;
13
+ values?: TaskItemValueMap;
14
+ };
15
+ export type StreamMatrixResponse = {
16
+ filename: string;
17
+ contentType: string;
18
+ stream: Stream;
19
+ };
20
+ export type CriteriaSetsAndVersionsMap = Record<string, Metadata[]>;
21
+ export type ParameterCombination = Record<string, any>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export * from './express';
2
+ export * from './criteria';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./express"), exports);
18
+ __exportStar(require("./criteria"), exports);
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@openframe-org/criteria-set-protocol",
3
+ "version": "1.0.0",
4
+ "description": "A protocol and tools for defining and working with criteria sets",
5
+ "private": false,
6
+ "author": "Andrés Angulo <aa@openframe.org>",
7
+ "license": "MIT",
8
+ "main": "dist/index.js",
9
+ "types": "dist/index.d.ts",
10
+ "scripts": {
11
+ "prepublishOnly": "tsc"
12
+ },
13
+ "files": [
14
+ "dist/**/*"
15
+ ],
16
+ "dependencies": {
17
+ "yup": "^1.2.0"
18
+ },
19
+ "devDependencies": {
20
+ "@types/node": "^20.6.3",
21
+ "typescript": "^5.2.2"
22
+ },
23
+ "publishConfig": {
24
+ "access": "public",
25
+ "registry": "https://registry.npmjs.org/"
26
+ }
27
+ }