@ecrvs/opencrvs-toolkit 1.8.1-rc.3059ff8
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/README.md +70 -0
- package/build.sh +56 -0
- package/dist/api/index.d.ts +11 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +52 -0
- package/dist/commons/api/router.d.ts +14568 -0
- package/dist/commons/conditionals/conditionals.d.ts +196 -0
- package/dist/commons/conditionals/index.d.ts +2 -0
- package/dist/commons/conditionals/validate.d.ts +129 -0
- package/dist/commons/events/ActionConfig.d.ts +2034 -0
- package/dist/commons/events/ActionDocument.d.ts +14400 -0
- package/dist/commons/events/ActionInput.d.ts +11157 -0
- package/dist/commons/events/ActionType.d.ts +52 -0
- package/dist/commons/events/AdvancedSearchConfig.d.ts +1175 -0
- package/dist/commons/events/CompositeFieldValue.d.ts +181 -0
- package/dist/commons/events/Conditional.d.ts +55 -0
- package/dist/commons/events/Constants.d.ts +3 -0
- package/dist/commons/events/CountryConfigQueryInput.d.ts +4494 -0
- package/dist/commons/events/CreatedAtLocation.d.ts +2 -0
- package/dist/commons/events/DeduplicationConfig.d.ts +209 -0
- package/dist/commons/events/Draft.d.ts +814 -0
- package/dist/commons/events/EventConfig.d.ts +2237 -0
- package/dist/commons/events/EventConfigInput.d.ts +10 -0
- package/dist/commons/events/EventDocument.d.ts +8505 -0
- package/dist/commons/events/EventIndex.d.ts +3858 -0
- package/dist/commons/events/EventInput.d.ts +13 -0
- package/dist/commons/events/EventMetadata.d.ts +408 -0
- package/dist/commons/events/FieldConfig.d.ts +7125 -0
- package/dist/commons/events/FieldType.d.ts +46 -0
- package/dist/commons/events/FieldTypeMapping.d.ts +537 -0
- package/dist/commons/events/FieldValue.d.ts +250 -0
- package/dist/commons/events/FileUtils.d.ts +4 -0
- package/dist/commons/events/FormConfig.d.ts +725 -0
- package/dist/commons/events/PageConfig.d.ts +336 -0
- package/dist/commons/events/SummaryConfig.d.ts +170 -0
- package/dist/commons/events/TemplateConfig.d.ts +38 -0
- package/dist/commons/events/TranslationConfig.d.ts +15 -0
- package/dist/commons/events/User.d.ts +45 -0
- package/dist/commons/events/WorkqueueColumnConfig.d.ts +53 -0
- package/dist/commons/events/WorkqueueConfig.d.ts +8997 -0
- package/dist/commons/events/deduplication.d.ts +32 -0
- package/dist/commons/events/defineConfig.d.ts +309 -0
- package/dist/commons/events/event.d.ts +109 -0
- package/dist/commons/events/field.d.ts +161 -0
- package/dist/commons/events/index.d.ts +46 -0
- package/dist/commons/events/locations.d.ts +24 -0
- package/dist/commons/events/scopes.d.ts +55 -0
- package/dist/commons/events/serializer.d.ts +2 -0
- package/dist/commons/events/state/availableActions.d.ts +6 -0
- package/dist/commons/events/state/flags.d.ts +4 -0
- package/dist/commons/events/state/index.d.ts +146 -0
- package/dist/commons/events/state/utils.d.ts +1263 -0
- package/dist/commons/events/test.utils.d.ts +473 -0
- package/dist/commons/events/transactions.d.ts +2 -0
- package/dist/commons/events/utils.d.ts +501 -0
- package/dist/commons/events/workqueueDefaultColumns.d.ts +3 -0
- package/dist/commons/notification/UserNotifications.d.ts +632 -0
- package/dist/commons/notification/index.d.ts +2 -0
- package/dist/conditionals/index.d.ts +2 -0
- package/dist/conditionals/index.d.ts.map +1 -0
- package/dist/conditionals/index.js +509 -0
- package/dist/events/deduplication.d.ts +32 -0
- package/dist/events/deduplication.d.ts.map +1 -0
- package/dist/events/deduplication.js +67 -0
- package/dist/events/index.d.ts +2 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +8419 -0
- package/dist/notification/index.d.ts +2 -0
- package/dist/notification/index.d.ts.map +1 -0
- package/dist/notification/index.js +5964 -0
- package/dist/scopes/index.d.ts +335 -0
- package/dist/scopes/index.d.ts.map +1 -0
- package/dist/scopes/index.js +379 -0
- package/package.json +40 -0
- package/tsconfig.json +27 -0
- package/tsconfig.tsbuildinfo +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# OpenCRVS toolkit
|
|
2
|
+
|
|
3
|
+
OpenCRVS toolkit for building country configurations.
|
|
4
|
+
|
|
5
|
+
## File structure
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
src/
|
|
9
|
+
events/ # re-exports events module from commons package
|
|
10
|
+
scopes/ # re-exports scopes module from commons package
|
|
11
|
+
conditionals/ # provides tools for easily formulating complex conditionals and deduplication rules
|
|
12
|
+
api/ # provides an API wrapper for OpenCRVS APIs with strict typing and validation
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Getting started
|
|
16
|
+
|
|
17
|
+
### Development using yarn link
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
# tsconfig.json references commons. when `tsc --build` is run, both are built.
|
|
21
|
+
> yarn build:all
|
|
22
|
+
# If you miss this part you might face issues with types.
|
|
23
|
+
> cd dist
|
|
24
|
+
> yarn link
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Internal dependencies
|
|
28
|
+
|
|
29
|
+
When adding internal package as dependency, understand that:
|
|
30
|
+
|
|
31
|
+
- Internal packages cannot be direct dependencies. Toolkit is published through npm, and dependency cannot be resolved.
|
|
32
|
+
- Packages may have dependencies that require strict order of installation. Ensure installations are run in proper order in pipeline and scripts.
|
|
33
|
+
|
|
34
|
+
#### @opencrvs/events
|
|
35
|
+
|
|
36
|
+
Toolkit "re-exports" TRPC router to allow for easy client interaction.
|
|
37
|
+
|
|
38
|
+
#### @opencrvs/commons
|
|
39
|
+
|
|
40
|
+
Toolkit "re-exports" common definitions (e.g. events, conditionals) and make them available through npm.
|
|
41
|
+
|
|
42
|
+
### Releasing and buiding
|
|
43
|
+
|
|
44
|
+
#### While developing
|
|
45
|
+
|
|
46
|
+
1. Update version number in `package.json`
|
|
47
|
+
2. `yarn build:all`
|
|
48
|
+
3. `npm publish`
|
|
49
|
+
|
|
50
|
+
#### Through version control
|
|
51
|
+
|
|
52
|
+
1. Update version number in `package.json`
|
|
53
|
+
2. Create a pull request
|
|
54
|
+
3. Once merged, github action will get triggered.
|
|
55
|
+
|
|
56
|
+
#### Gotchas, good to know
|
|
57
|
+
|
|
58
|
+
- All dependencies of the functions and moduless used from `packages/commons` **must** be also defined in the package.json of the toolkit. Otherwise someone installing the package will get errors.
|
|
59
|
+
- Package is published and should be used without knowledge of rest of the monorepo
|
|
60
|
+
- Package exposes `/events, /scopes` directory, with types, from `packages/commons` through the library, others are excluded.
|
|
61
|
+
- If the above directories have subdirectories, the types are not exposed by default. The compiled JavaScript is available though through `esbuild`. See `build.sh` on how to expose subdirectories:
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
# Build common events
|
|
65
|
+
npx esbuild src/events/index.ts --bundle --format=cjs --outdir=./dist/events --allow-overwrite --packages=external
|
|
66
|
+
mkdir -p ./dist/commons/events
|
|
67
|
+
cp -r ../commons/build/dist/common/events/*.d.ts ./dist/commons/events
|
|
68
|
+
mkdir -p ./dist/commons/events/state # <-- create the subdirectory
|
|
69
|
+
cp -r ../commons/build/dist/common/events/state/*.d.ts ./dist/commons/events/state # <-- copy the types over
|
|
70
|
+
```
|
package/build.sh
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
4
|
+
#
|
|
5
|
+
# OpenCRVS is also distributed under the terms of the Civil Registration
|
|
6
|
+
# & Healthcare Disclaimer located at http://opencrvs.org/license.
|
|
7
|
+
#
|
|
8
|
+
# Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
|
|
9
|
+
|
|
10
|
+
#!/bin/bash
|
|
11
|
+
|
|
12
|
+
set -e
|
|
13
|
+
|
|
14
|
+
rm -rf dist
|
|
15
|
+
|
|
16
|
+
npx tsc --build
|
|
17
|
+
|
|
18
|
+
# Build common events
|
|
19
|
+
npx esbuild src/events/index.ts --bundle --format=cjs --outdir=./dist/events --allow-overwrite --packages=external
|
|
20
|
+
mkdir -p ./dist/commons/events
|
|
21
|
+
cp -r ../commons/build/dist/common/events/*.d.ts ./dist/commons/events
|
|
22
|
+
mkdir -p ./dist/commons/events/state
|
|
23
|
+
cp -r ../commons/build/dist/common/events/state/*.d.ts ./dist/commons/events/state
|
|
24
|
+
|
|
25
|
+
# Build common conditionals
|
|
26
|
+
npx esbuild src/conditionals/index.ts --bundle --format=cjs --outdir=./dist/conditionals --allow-overwrite --packages=external
|
|
27
|
+
mkdir -p ./dist/commons/conditionals
|
|
28
|
+
cp -r ../commons/build/dist/common/conditionals/*.d.ts ./dist/commons/conditionals
|
|
29
|
+
|
|
30
|
+
# Build common scopes
|
|
31
|
+
npx esbuild src/scopes/index.ts --bundle --format=cjs --outdir=./dist/scopes --allow-overwrite --packages=external
|
|
32
|
+
cp -r ../commons/build/dist/common/scopes.d.ts ./dist/scopes/index.d.ts
|
|
33
|
+
|
|
34
|
+
# Build api client
|
|
35
|
+
npx esbuild src/api/index.ts --bundle --format=cjs --outdir=./dist/api --allow-overwrite --packages=external
|
|
36
|
+
mkdir -p ./dist/commons/api
|
|
37
|
+
cp -r ../events/build/types/router/router.d.ts ./dist/commons/api
|
|
38
|
+
|
|
39
|
+
# Build deduplication api
|
|
40
|
+
npx esbuild src/events/deduplication.ts --bundle --format=cjs --outdir=./dist/events --allow-overwrite --packages=external
|
|
41
|
+
cp -r ../commons/build/dist/common/events/deduplication.d.ts ./dist/events/deduplication.d.ts
|
|
42
|
+
|
|
43
|
+
# Build common notifications
|
|
44
|
+
npx esbuild src/notification/index.ts --bundle --format=cjs --outdir=./dist/notification --allow-overwrite --packages=external
|
|
45
|
+
mkdir -p ./dist/commons/notification
|
|
46
|
+
cp -r ../commons/build/dist/common/notification/*.d.ts ./dist/commons/notification
|
|
47
|
+
|
|
48
|
+
if [[ "$OSTYPE" == "darwin"* ]]; then
|
|
49
|
+
sed -i '' 's|@opencrvs/events/build/types|../commons/api|g' dist/api/index.d.ts
|
|
50
|
+
find dist -type f -exec sed -i '' 's|@opencrvs/commons|../commons|g' {} +
|
|
51
|
+
else
|
|
52
|
+
sed -i 's|@opencrvs/events/build/types|../commons/api|g' dist/api/index.d.ts
|
|
53
|
+
find dist -type f -exec sed -i 's|@opencrvs/commons|../commons|g' {} +
|
|
54
|
+
fi
|
|
55
|
+
|
|
56
|
+
echo "Build completed successfully."
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CreateTRPCClient } from '@trpc/client';
|
|
2
|
+
import { AppRouter } from '../commons/api/router';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a tRPC client with the specified base URL and authorization token.
|
|
5
|
+
*
|
|
6
|
+
* @param baseUrl - The base URL where the tRPC server can be found, e.g., 'https://farajaland.opencrvs.org/api/trpc'.
|
|
7
|
+
* @param token - The authorization token to be used in the request headers.
|
|
8
|
+
* @returns A tRPC client configured with the provided base URL and authorization token.
|
|
9
|
+
*/
|
|
10
|
+
export declare function createClient(baseUrl: string, token: `Bearer ${string}`): CreateTRPCClient<AppRouter>;
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,gBAAgB,EAAmC,MAAM,cAAc,CAAA;AAEhF,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAA;AAE/D;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,UAAU,MAAM,EAAE,GACxB,gBAAgB,CAAC,SAAS,CAAC,CAc7B"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/api/index.ts
|
|
31
|
+
var api_exports = {};
|
|
32
|
+
__export(api_exports, {
|
|
33
|
+
createClient: () => createClient
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(api_exports);
|
|
36
|
+
var import_client = require("@trpc/client");
|
|
37
|
+
var import_superjson = __toESM(require("superjson"));
|
|
38
|
+
function createClient(baseUrl, token) {
|
|
39
|
+
return (0, import_client.createTRPCClient)({
|
|
40
|
+
links: [
|
|
41
|
+
(0, import_client.httpBatchLink)({
|
|
42
|
+
url: baseUrl,
|
|
43
|
+
transformer: import_superjson.default,
|
|
44
|
+
headers() {
|
|
45
|
+
return {
|
|
46
|
+
Authorization: token
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
]
|
|
51
|
+
});
|
|
52
|
+
}
|