@ecrvs/opencrvs-toolkit 1.8.1-rc.11dbd54

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.
Files changed (78) hide show
  1. package/README.md +70 -0
  2. package/build.sh +56 -0
  3. package/dist/api/index.d.ts +11 -0
  4. package/dist/api/index.d.ts.map +1 -0
  5. package/dist/api/index.js +52 -0
  6. package/dist/commons/api/router.d.ts +14568 -0
  7. package/dist/commons/conditionals/abbreviation.d.ts +5 -0
  8. package/dist/commons/conditionals/conditionals.d.ts +200 -0
  9. package/dist/commons/conditionals/ill-defined.d.ts +2 -0
  10. package/dist/commons/conditionals/index.d.ts +2 -0
  11. package/dist/commons/conditionals/validate.d.ts +129 -0
  12. package/dist/commons/events/ActionConfig.d.ts +2034 -0
  13. package/dist/commons/events/ActionDocument.d.ts +14400 -0
  14. package/dist/commons/events/ActionInput.d.ts +11157 -0
  15. package/dist/commons/events/ActionType.d.ts +52 -0
  16. package/dist/commons/events/AdvancedSearchConfig.d.ts +1175 -0
  17. package/dist/commons/events/CompositeFieldValue.d.ts +181 -0
  18. package/dist/commons/events/Conditional.d.ts +55 -0
  19. package/dist/commons/events/Constants.d.ts +3 -0
  20. package/dist/commons/events/CountryConfigQueryInput.d.ts +4494 -0
  21. package/dist/commons/events/CreatedAtLocation.d.ts +2 -0
  22. package/dist/commons/events/DeduplicationConfig.d.ts +209 -0
  23. package/dist/commons/events/Draft.d.ts +814 -0
  24. package/dist/commons/events/EventConfig.d.ts +2237 -0
  25. package/dist/commons/events/EventConfigInput.d.ts +10 -0
  26. package/dist/commons/events/EventDocument.d.ts +8505 -0
  27. package/dist/commons/events/EventIndex.d.ts +3858 -0
  28. package/dist/commons/events/EventInput.d.ts +13 -0
  29. package/dist/commons/events/EventMetadata.d.ts +408 -0
  30. package/dist/commons/events/FieldConfig.d.ts +7125 -0
  31. package/dist/commons/events/FieldType.d.ts +46 -0
  32. package/dist/commons/events/FieldTypeMapping.d.ts +537 -0
  33. package/dist/commons/events/FieldValue.d.ts +250 -0
  34. package/dist/commons/events/FileUtils.d.ts +4 -0
  35. package/dist/commons/events/FormConfig.d.ts +725 -0
  36. package/dist/commons/events/PageConfig.d.ts +336 -0
  37. package/dist/commons/events/SummaryConfig.d.ts +170 -0
  38. package/dist/commons/events/TemplateConfig.d.ts +38 -0
  39. package/dist/commons/events/TranslationConfig.d.ts +15 -0
  40. package/dist/commons/events/User.d.ts +45 -0
  41. package/dist/commons/events/WorkqueueColumnConfig.d.ts +53 -0
  42. package/dist/commons/events/WorkqueueConfig.d.ts +8997 -0
  43. package/dist/commons/events/deduplication.d.ts +32 -0
  44. package/dist/commons/events/defineConfig.d.ts +309 -0
  45. package/dist/commons/events/event.d.ts +109 -0
  46. package/dist/commons/events/field.d.ts +169 -0
  47. package/dist/commons/events/index.d.ts +46 -0
  48. package/dist/commons/events/locations.d.ts +24 -0
  49. package/dist/commons/events/scopes.d.ts +55 -0
  50. package/dist/commons/events/serializer.d.ts +2 -0
  51. package/dist/commons/events/state/availableActions.d.ts +6 -0
  52. package/dist/commons/events/state/flags.d.ts +4 -0
  53. package/dist/commons/events/state/index.d.ts +146 -0
  54. package/dist/commons/events/state/utils.d.ts +1263 -0
  55. package/dist/commons/events/test.utils.d.ts +473 -0
  56. package/dist/commons/events/transactions.d.ts +2 -0
  57. package/dist/commons/events/utils.d.ts +501 -0
  58. package/dist/commons/events/workqueueDefaultColumns.d.ts +3 -0
  59. package/dist/commons/notification/UserNotifications.d.ts +632 -0
  60. package/dist/commons/notification/index.d.ts +2 -0
  61. package/dist/conditionals/index.d.ts +2 -0
  62. package/dist/conditionals/index.d.ts.map +1 -0
  63. package/dist/conditionals/index.js +538 -0
  64. package/dist/events/deduplication.d.ts +32 -0
  65. package/dist/events/deduplication.d.ts.map +1 -0
  66. package/dist/events/deduplication.js +67 -0
  67. package/dist/events/index.d.ts +2 -0
  68. package/dist/events/index.d.ts.map +1 -0
  69. package/dist/events/index.js +9755 -0
  70. package/dist/notification/index.d.ts +2 -0
  71. package/dist/notification/index.d.ts.map +1 -0
  72. package/dist/notification/index.js +7300 -0
  73. package/dist/scopes/index.d.ts +335 -0
  74. package/dist/scopes/index.d.ts.map +1 -0
  75. package/dist/scopes/index.js +379 -0
  76. package/package.json +40 -0
  77. package/tsconfig.json +27 -0
  78. 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
+ }