New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@opencrvs/toolkit

Package Overview
Dependencies
Maintainers
4
Versions
860
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opencrvs/toolkit - npm Package Compare versions

Comparing version

to
0.0.22-scopes

dist/commons/api/router.d.ts

2

dist/api/index.d.ts
import { CreateTRPCClient } from '@trpc/client';
import { AppRouter } from './router';
import { AppRouter } from '../commons/api/router';
/**

@@ -4,0 +4,0 @@ * Creates a tRPC client with the specified base URL and authorization token.

@@ -1,2 +0,2 @@

import { ClauseInput, ClauseOutput } from '@opencrvs/commons/events';
import { ClauseInput, ClauseOutput } from '../commons/events';
export declare function and(clauses: ClauseInput[]): ClauseOutput;

@@ -3,0 +3,0 @@ export declare function or(clauses: ClauseInput[]): ClauseOutput;

@@ -16,3 +16,3 @@ "use strict";

exports.field = field;
const events_1 = require("@opencrvs/commons/events");
const events_1 = require("../commons/events");
function and(clauses) {

@@ -19,0 +19,0 @@ return {

@@ -1,3 +0,3 @@

import { JSONSchema } from '@opencrvs/commons/conditionals';
import { ActionDocument } from '@opencrvs/commons/events';
import { JSONSchema } from '../commons/conditionals';
import { ActionDocument } from '../commons/events';
export * as deduplication from './deduplication';

@@ -58,34 +58,124 @@ export declare function defineConditional(conditional: JSONSchema): JSONSchema;

};
export type FieldAPI = {
inArray: (values: string[]) => FieldAPI;
isBeforeNow: () => FieldAPI;
isEqualTo: (value: string) => FieldAPI;
isUndefined: () => FieldAPI;
not: {
inArray: (values: string[]) => FieldAPI;
equalTo: (value: string) => FieldAPI;
export declare function field(fieldId: string): {
isBeforeNow: () => {
type: string;
properties: {
$form: {
type: string;
properties: {
[x: string]: {
type: string;
format: string;
formatMaximum: {
$data: string;
};
};
};
required: string[];
};
$now: {
type: string;
format: string;
};
};
required: string[];
};
/**
* joins multiple conditions with OR instead of AND.
* @example field('fieldId').or((field) => field.isUndefined().not.inArray(['value1', 'value2'])).apply()
*/
or: (callback: (field: FieldAPI) => FieldAPI) => FieldAPI;
/**
* @private
* @returns array of conditions. Used internally by methods that consolidate multiple conditions into one.
*/
_apply: () => JSONSchema[];
/**
* @public
* @returns single object for consolidated conditions
*/
apply: () => JSONSchema;
isEqualTo: (value: string) => {
type: string;
properties: {
$form: {
type: string;
properties: {
[x: string]: {
const: string;
};
};
required: string[];
};
};
required: string[];
};
isInArray: (values: string[]) => {
type: string;
properties: {
$form: {
type: string;
properties: {
[x: string]: {
enum: string[];
};
};
required: string[];
};
};
required: string[];
};
isNotInArray: (values: string[]) => {
type: string;
properties: {
$form: {
type: string;
properties: {
[x: string]: {
not: {
enum: string[];
};
};
};
required: string[];
};
};
required: string[];
};
isUndefinedOrInArray: (values: string[]) => {
type: string;
properties: {
$form: {
type: string;
anyOf: ({
required: string[];
properties: {
[x: string]: {
enum: string[];
};
};
not?: undefined;
} | {
not: {
required: string[];
};
required?: undefined;
properties?: undefined;
})[];
};
};
required: string[];
};
isUndefinedOrNotInArray: (values: string[]) => {
type: string;
properties: {
$form: {
type: string;
anyOf: ({
required: string[];
properties: {
[x: string]: {
not: {
enum: string[];
};
};
};
not?: undefined;
} | {
not: {
required: string[];
};
required?: undefined;
properties?: undefined;
})[];
};
};
required: string[];
};
};
/**
* Generate conditional rules for a field.
* @param fieldId - The field ID conditions are being applied to
*
* @returns @see FieldAPI
*/
export declare function field(fieldId: string): FieldAPI;
//# sourceMappingURL=index.d.ts.map

@@ -767,77 +767,115 @@ "use strict";

function field2(fieldId) {
const conditions = [];
const addCondition = (rule) => {
conditions.push(rule);
return api;
};
const api = {
isBeforeNow: () => addCondition({
$form: {
type: "object",
properties: {
[fieldId]: {
type: "string",
format: "date",
formatMaximum: { $data: "2/$now" }
}
return {
isBeforeNow: () => ({
type: "object",
properties: {
$form: {
type: "object",
properties: {
[fieldId]: {
type: "string",
format: "date",
// https://ajv.js.org/packages/ajv-formats.html#keywords-to-compare-values-formatmaximum-formatminimum-and-formatexclusivemaximum-formatexclusiveminimum
formatMaximum: { $data: "2/$now" }
}
},
required: [fieldId]
},
required: [fieldId]
$now: {
type: "string",
format: "date"
}
},
$now: {
type: "string",
format: "date"
}
required: ["$form", "$now"]
}),
isEqualTo: (value) => addCondition({
[fieldId]: {
const: value
}
isEqualTo: (value) => ({
type: "object",
properties: {
$form: {
type: "object",
properties: {
[fieldId]: {
const: value
}
},
required: [fieldId]
}
},
required: ["$form"]
}),
isUndefined: () => addCondition({
not: {
type: "object",
required: [fieldId]
}
isInArray: (values) => ({
type: "object",
properties: {
$form: {
type: "object",
properties: {
[fieldId]: {
enum: values
}
},
required: [fieldId]
}
},
required: ["$form"]
}),
inArray: (values) => addCondition({
[fieldId]: {
enum: values
}
isNotInArray: (values) => ({
type: "object",
properties: {
$form: {
type: "object",
properties: {
[fieldId]: {
not: {
enum: values
}
}
},
required: [fieldId]
}
},
required: ["$form"]
}),
not: {
inArray: (values) => addCondition({
[fieldId]: {
not: {
enum: values
}
isUndefinedOrInArray: (values) => ({
type: "object",
properties: {
$form: {
type: "object",
anyOf: [
{
required: [fieldId],
properties: {
[fieldId]: {
enum: values
}
}
},
{ not: { required: [fieldId] } }
]
}
}),
equalTo: (value) => addCondition({
[fieldId]: {
not: {
const: value
}
},
required: ["$form"]
}),
isUndefinedOrNotInArray: (values) => ({
type: "object",
properties: {
$form: {
type: "object",
anyOf: [
{
required: [fieldId],
properties: {
[fieldId]: {
not: {
enum: values
}
}
}
},
{ not: { required: [fieldId] } }
]
}
})
},
or: (callback) => {
const nestedConditions = callback(field2(fieldId))._apply();
return addCondition({
type: "object",
anyOf: nestedConditions
});
},
_apply: () => conditions,
apply: () => {
if (conditions.length === 1) {
return {
type: "object",
properties: { $form: { properties: conditions[0] } },
required: ["$form", fieldId]
};
}
return { type: "object", allOf: conditions, required: ["$form", fieldId] };
}
},
required: ["$form"]
})
};
return api;
}

@@ -1,19 +0,2 @@

export * from './ActionConfig';
export * from './EventConfig';
export * from './FieldConfig';
export * from './FormConfig';
export * from './SummaryConfig';
export * from './WorkqueueConfig';
export * from './EventMetadata';
export * from './EventInput';
export * from './EventDocument';
export * from './ActionInput';
export * from './ActionDocument';
export * from './EventIndex';
export * from './TranslationConfig';
export * from './FieldValue';
export * from './state';
export * from './utils';
export * from './defineConfig';
export * from './DeduplicationConfig';
export * from '../commons/events';
//# sourceMappingURL=index.d.ts.map
{
"name": "@opencrvs/toolkit",
"version": "0.0.22-events-ml",
"version": "0.0.22-scopes",
"description": "OpenCRVS toolkit for building country configurations",

@@ -10,7 +10,7 @@ "license": "MPL-2.0",

"./events": "./dist/events/index.js",
"./scopes": "./dist/scopes/index.js",
"./conditionals": "./dist/conditionals/index.js"
},
"scripts": {
"build": "./build.sh",
"build:all": "lerna run build --include-dependencies --scope @opencrvs/toolkit && ./build.sh"
"build": "./build.sh"
},

@@ -29,4 +29,5 @@ "dependencies": {

"moduleNameMapper": {
"@opencrvs/commons/events": "@opencrvs/commons/build/dist/common/events/index.js"
"@opencrvs/commons/events": "@opencrvs/commons/build/dist/common/events/index.js",
"@opencrvs/commons/scopes": "@opencrvs/commons/build/dist/common/scopes.js"
}
}

@@ -10,4 +10,6 @@ # OpenCRVS toolkit

events/ # re-exports events module from commons package
scopes/ # re-exports scopes module from commons package
conditionals/ # provides tools for easily formulating complex conditionals and deduplication rules
api/ # provides an API wrapper for OpenCRVS APIs with strict typing and validation
lib.ts # standard library. currently empty
```

@@ -27,17 +29,2 @@

### Internal dependencies
When adding internal package as dependency, understand that:
- Internal packages cannot be direct dependencies. Toolkit is published through npm, and dependency cannot be resolved.
- Packages may have dependencies that require strict order of installation. Ensure installations are run in proper order in pipeline and scripts.
#### @opencrvs/events
Toolkit "re-exports" TRPC router to allow for easy client interaction.
#### @opencrvs/commons
Toolkit "re-exports" common definitions (e.g. events, conditionals) and make them available through npm.
### Releasing and buiding

@@ -48,3 +35,3 @@

1. Update version number in `package.json`
2. `yarn build:all`
2. `yarn build`
3. `npm publish`

@@ -62,2 +49,2 @@

- Package is published and should be used without knowledge of rest of the monorepo
- Package exposes `/events` directory, with types, from `packages/commons` through the library, others are excluded.
- Package exposes `/events, /scopes` directory, with types, from `packages/commons` through the library, others are excluded.

@@ -18,2 +18,3 @@ {

],
"@opencrvs/commons/scopes": ["../commons/src/scopes.ts"],
"@opencrvs/commons/events": ["../commons/src/events/index.ts"]

@@ -20,0 +21,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet