@optimizely/ocp-local-env 1.0.0-beta.4

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 (160) hide show
  1. package/README.md +165 -0
  2. package/dist/package.json +104 -0
  3. package/dist/public/bundle.da978bb5437cd82e6d37.js +3 -0
  4. package/dist/public/bundle.da978bb5437cd82e6d37.js.LICENSE.txt +49 -0
  5. package/dist/public/bundle.da978bb5437cd82e6d37.js.map +1 -0
  6. package/dist/public/index.html +1 -0
  7. package/dist/src/cli.d.ts +2 -0
  8. package/dist/src/cli.js +88 -0
  9. package/dist/src/cli.js.map +1 -0
  10. package/dist/src/executor/FunctionExecutor.d.ts +56 -0
  11. package/dist/src/executor/FunctionExecutor.js +175 -0
  12. package/dist/src/executor/FunctionExecutor.js.map +1 -0
  13. package/dist/src/executor/JobExecutor.d.ts +60 -0
  14. package/dist/src/executor/JobExecutor.js +203 -0
  15. package/dist/src/executor/JobExecutor.js.map +1 -0
  16. package/dist/src/executor/LifecycleExecutor.d.ts +45 -0
  17. package/dist/src/executor/LifecycleExecutor.js +153 -0
  18. package/dist/src/executor/LifecycleExecutor.js.map +1 -0
  19. package/dist/src/executor/watcher.d.ts +63 -0
  20. package/dist/src/executor/watcher.js +213 -0
  21. package/dist/src/executor/watcher.js.map +1 -0
  22. package/dist/src/functions/hello.d.ts +4 -0
  23. package/dist/src/functions/hello.js +8 -0
  24. package/dist/src/functions/hello.js.map +1 -0
  25. package/dist/src/index.d.ts +1 -0
  26. package/dist/src/index.js +9 -0
  27. package/dist/src/index.js.map +1 -0
  28. package/dist/src/jobs/dailyJob.d.ts +4 -0
  29. package/dist/src/jobs/dailyJob.js +8 -0
  30. package/dist/src/jobs/dailyJob.js.map +1 -0
  31. package/dist/src/local_engine/LocalNotifier.d.ts +10 -0
  32. package/dist/src/local_engine/LocalNotifier.js +26 -0
  33. package/dist/src/local_engine/LocalNotifier.js.map +1 -0
  34. package/dist/src/local_engine/local-engine-child-base.d.ts +79 -0
  35. package/dist/src/local_engine/local-engine-child-base.js +304 -0
  36. package/dist/src/local_engine/local-engine-child-base.js.map +1 -0
  37. package/dist/src/local_engine/local-engine-client.d.ts +80 -0
  38. package/dist/src/local_engine/local-engine-client.js +333 -0
  39. package/dist/src/local_engine/local-engine-client.js.map +1 -0
  40. package/dist/src/local_engine/local-engine-types.d.ts +132 -0
  41. package/dist/src/local_engine/local-engine-types.js +6 -0
  42. package/dist/src/local_engine/local-engine-types.js.map +1 -0
  43. package/dist/src/local_engine/local-engine-unified.d.ts +40 -0
  44. package/dist/src/local_engine/local-engine-unified.js +406 -0
  45. package/dist/src/local_engine/local-engine-unified.js.map +1 -0
  46. package/dist/src/local_engine/local-engine-utils.d.ts +70 -0
  47. package/dist/src/local_engine/local-engine-utils.js +192 -0
  48. package/dist/src/local_engine/local-engine-utils.js.map +1 -0
  49. package/dist/src/local_engine/localSDKConfig.d.ts +30 -0
  50. package/dist/src/local_engine/localSDKConfig.js +392 -0
  51. package/dist/src/local_engine/localSDKConfig.js.map +1 -0
  52. package/dist/src/local_engine/storage/LocalConfigStore.d.ts +56 -0
  53. package/dist/src/local_engine/storage/LocalConfigStore.js +129 -0
  54. package/dist/src/local_engine/storage/LocalConfigStore.js.map +1 -0
  55. package/dist/src/local_engine/storage/LocalJobStore.d.ts +110 -0
  56. package/dist/src/local_engine/storage/LocalJobStore.js +239 -0
  57. package/dist/src/local_engine/storage/LocalJobStore.js.map +1 -0
  58. package/dist/src/local_engine/storage/LocalKVStore.d.ts +105 -0
  59. package/dist/src/local_engine/storage/LocalKVStore.js +1002 -0
  60. package/dist/src/local_engine/storage/LocalKVStore.js.map +1 -0
  61. package/dist/src/local_engine/storage/LocalNotificationStore.d.ts +27 -0
  62. package/dist/src/local_engine/storage/LocalNotificationStore.js +125 -0
  63. package/dist/src/local_engine/storage/LocalNotificationStore.js.map +1 -0
  64. package/dist/src/local_engine/storage/LocalSecretsStore.d.ts +114 -0
  65. package/dist/src/local_engine/storage/LocalSecretsStore.js +319 -0
  66. package/dist/src/local_engine/storage/LocalSecretsStore.js.map +1 -0
  67. package/dist/src/local_engine/storage/LocalSettingsStore.d.ts +161 -0
  68. package/dist/src/local_engine/storage/LocalSettingsStore.js +417 -0
  69. package/dist/src/local_engine/storage/LocalSettingsStore.js.map +1 -0
  70. package/dist/src/local_engine/storage/NumberSet.d.ts +21 -0
  71. package/dist/src/local_engine/storage/NumberSet.js +32 -0
  72. package/dist/src/local_engine/storage/NumberSet.js.map +1 -0
  73. package/dist/src/local_engine/storage/StringSet.d.ts +21 -0
  74. package/dist/src/local_engine/storage/StringSet.js +32 -0
  75. package/dist/src/local_engine/storage/StringSet.js.map +1 -0
  76. package/dist/src/local_engine/types.d.ts +52 -0
  77. package/dist/src/local_engine/types.js +6 -0
  78. package/dist/src/local_engine/types.js.map +1 -0
  79. package/dist/src/local_engine/utils.d.ts +31 -0
  80. package/dist/src/local_engine/utils.js +126 -0
  81. package/dist/src/local_engine/utils.js.map +1 -0
  82. package/dist/src/logging/LogManager.d.ts +89 -0
  83. package/dist/src/logging/LogManager.js +237 -0
  84. package/dist/src/logging/LogManager.js.map +1 -0
  85. package/dist/src/server/api/functions.d.ts +7 -0
  86. package/dist/src/server/api/functions.js +80 -0
  87. package/dist/src/server/api/functions.js.map +1 -0
  88. package/dist/src/server/api/jobs.d.ts +8 -0
  89. package/dist/src/server/api/jobs.js +242 -0
  90. package/dist/src/server/api/jobs.js.map +1 -0
  91. package/dist/src/server/api/lifecycle.d.ts +6 -0
  92. package/dist/src/server/api/lifecycle.js +73 -0
  93. package/dist/src/server/api/lifecycle.js.map +1 -0
  94. package/dist/src/server/api/settings.d.ts +6 -0
  95. package/dist/src/server/api/settings.js +117 -0
  96. package/dist/src/server/api/settings.js.map +1 -0
  97. package/dist/src/server/api/stores.d.ts +2 -0
  98. package/dist/src/server/api/stores.js +341 -0
  99. package/dist/src/server/api/stores.js.map +1 -0
  100. package/dist/src/server/api/v1.d.ts +10 -0
  101. package/dist/src/server/api/v1.js +711 -0
  102. package/dist/src/server/api/v1.js.map +1 -0
  103. package/dist/src/server/api.d.ts +8 -0
  104. package/dist/src/server/api.js +154 -0
  105. package/dist/src/server/api.js.map +1 -0
  106. package/dist/src/server/app-discovery.d.ts +5 -0
  107. package/dist/src/server/app-discovery.js +81 -0
  108. package/dist/src/server/app-discovery.js.map +1 -0
  109. package/dist/src/server/config.d.ts +21 -0
  110. package/dist/src/server/config.js +100 -0
  111. package/dist/src/server/config.js.map +1 -0
  112. package/dist/src/server/websocket.d.ts +0 -0
  113. package/dist/src/server/websocket.js +2 -0
  114. package/dist/src/server/websocket.js.map +1 -0
  115. package/dist/src/server.d.ts +2 -0
  116. package/dist/src/server.js +546 -0
  117. package/dist/src/server.js.map +1 -0
  118. package/dist/src/types/app.d.ts +155 -0
  119. package/dist/src/types/app.js +24 -0
  120. package/dist/src/types/app.js.map +1 -0
  121. package/dist/src/types/kvstore.d.ts +320 -0
  122. package/dist/src/types/kvstore.js +5 -0
  123. package/dist/src/types/kvstore.js.map +1 -0
  124. package/dist/src/ui/components/App.d.ts +6 -0
  125. package/dist/src/ui/components/App.js +255 -0
  126. package/dist/src/ui/components/App.js.map +1 -0
  127. package/dist/src/ui/components/FunctionsView.d.ts +6 -0
  128. package/dist/src/ui/components/FunctionsView.js +217 -0
  129. package/dist/src/ui/components/FunctionsView.js.map +1 -0
  130. package/dist/src/ui/components/JobsView.d.ts +6 -0
  131. package/dist/src/ui/components/JobsView.js +257 -0
  132. package/dist/src/ui/components/JobsView.js.map +1 -0
  133. package/dist/src/ui/components/KVStoreViewer.d.ts +11 -0
  134. package/dist/src/ui/components/KVStoreViewer.js +168 -0
  135. package/dist/src/ui/components/KVStoreViewer.js.map +1 -0
  136. package/dist/src/ui/components/NotificationViewer.d.ts +16 -0
  137. package/dist/src/ui/components/NotificationViewer.js +69 -0
  138. package/dist/src/ui/components/NotificationViewer.js.map +1 -0
  139. package/dist/src/ui/components/SecretsStoreViewer.d.ts +11 -0
  140. package/dist/src/ui/components/SecretsStoreViewer.js +179 -0
  141. package/dist/src/ui/components/SecretsStoreViewer.js.map +1 -0
  142. package/dist/src/ui/components/SettingsStoreViewer.d.ts +24 -0
  143. package/dist/src/ui/components/SettingsStoreViewer.js +132 -0
  144. package/dist/src/ui/components/SettingsStoreViewer.js.map +1 -0
  145. package/dist/src/ui/components/StoreViewer.d.ts +16 -0
  146. package/dist/src/ui/components/StoreViewer.js +86 -0
  147. package/dist/src/ui/components/StoreViewer.js.map +1 -0
  148. package/dist/src/ui/components/TabbedConsole.d.ts +15 -0
  149. package/dist/src/ui/components/TabbedConsole.js +93 -0
  150. package/dist/src/ui/components/TabbedConsole.js.map +1 -0
  151. package/dist/src/ui/components/common/DataTree.d.ts +15 -0
  152. package/dist/src/ui/components/common/DataTree.js +95 -0
  153. package/dist/src/ui/components/common/DataTree.js.map +1 -0
  154. package/dist/src/ui/components/common/EyeIcon.d.ts +11 -0
  155. package/dist/src/ui/components/common/EyeIcon.js +11 -0
  156. package/dist/src/ui/components/common/EyeIcon.js.map +1 -0
  157. package/dist/src/ui/index.d.ts +1 -0
  158. package/dist/src/ui/index.js +20 -0
  159. package/dist/src/ui/index.js.map +1 -0
  160. package/package.json +104 -0
package/README.md ADDED
@@ -0,0 +1,165 @@
1
+ # OCP Local Testing Tool
2
+
3
+ A comprehensive local development and testing environment for Optimizely Connect Platform (OCP) applications.
4
+
5
+ ## Overview
6
+
7
+ The OCP Local Testing Tool enables developers to build, test, and debug OCP applications locally before publishing them to the Optimizely Connect Platform. It provides a simulated OCP environment with real-time code reloading, interactive testing interfaces, and detailed logging.
8
+
9
+ ## Features
10
+
11
+ - **Local OCP Environment**: Run your OCP apps locally without deploying to the cloud
12
+ - **Real-time Code Reloading**: Changes to your app code are detected and automatically rebuilt
13
+ - **Interactive UI**: Test functions, jobs, and lifecycle hooks through an intuitive web interface
14
+ - **Configurable Settings**: Simulate different app configurations with a dynamic settings interface
15
+ - **Detailed Logging**: View comprehensive logs for all app activities
16
+ - **Webhook Testing**: Test webhook functions with customizable payloads
17
+ - **Job Simulation**: Manually trigger jobs or simulate scheduled execution
18
+ - **Lifecycle Testing**: Test install, upgrade, and uninstall hooks
19
+
20
+ ## Prerequisites
21
+
22
+ - Node.js v14 or later
23
+ - Yarn or npm
24
+ - Modern web browser (Chrome, Firefox, Edge, or Safari)
25
+
26
+ ## Installation
27
+
28
+ ```bash
29
+ # Install the OCP Local Testing Tool globally
30
+ npm install -g @optimizely/ocp-local-env
31
+ ```
32
+
33
+ If you run nodeJS with `nvm`, you can just run `ocp-local-env` command in your terminal. You will need to run `npm install -g @optimizely/ocp-local-env` command for every node version you are using.
34
+
35
+ If you are not using `nvm`, you might need to add the output of `npm bin -g` command to your `PATH` environment variable, open you terminal and then run `ocp-local-env` command.
36
+
37
+ ## Quick Start
38
+
39
+ 1. Navigate to your OCP app directory (containing app.yml)
40
+ 2. Run the local testing tool
41
+ ```bash
42
+ ocp-local-env
43
+ ```
44
+ 3. The tool will automatically open your browser to http://localhost:3000
45
+ 4. Start developing and testing your OCP app
46
+
47
+ ## Configuration
48
+
49
+ The OCP Local Testing Tool can be configured through environment variables and configuration files.
50
+
51
+ ### Environment Variables
52
+
53
+ Create a `.env.local` file in your project root to configure the tool:
54
+
55
+ ```bash
56
+ # Copy the example file
57
+ cp .env.example .env.local
58
+ ```
59
+
60
+ Available configuration options:
61
+
62
+ - `APP_ROOT_DIR`: Root directory for the OCP app (default: current directory)
63
+ - `OCP_LOCAL_PORT`: Port to run the server on (default: 3000)
64
+ - `OCP_LOCAL_VERBOSE`: Enable verbose logging (default: false)
65
+
66
+ ### Command Line Options
67
+
68
+ The `ocp-local-env` command supports several options:
69
+
70
+ ```bash
71
+ ocp-local-env [options]
72
+
73
+ Options:
74
+ -p, --port <port> Port to run the server on (default: 3000)
75
+ -c, --config <path> Path to custom config file
76
+ --path <path> Path to the OCP app root directory
77
+ -v, --verbose Enable verbose logging
78
+ --no-open Don't automatically open browser
79
+ -h, --help Display help for command
80
+ ```
81
+
82
+ You can also use the explicit `start` command:
83
+
84
+ ```bash
85
+ ocp-local-env start [options]
86
+ ```
87
+
88
+ ### Examples
89
+
90
+ ```bash
91
+ # Start with a specific app directory
92
+ ocp-local-env --path /path/to/my-ocp-app
93
+
94
+ # Start on a different port
95
+ ocp-local-env --port 8080
96
+
97
+ # Enable verbose logging
98
+ ocp-local-env --verbose
99
+
100
+ # Don't open browser automatically
101
+ ocp-local-env --no-open
102
+
103
+ # Combine options
104
+ ocp-local-env --path /path/to/my-ocp-app --port 8080 --verbose
105
+ ```
106
+
107
+ ## Documentation
108
+
109
+ For detailed documentation, see the following guides:
110
+
111
+ - [Design Document](docs/design-document.md) - Overall architecture and design
112
+ - [Technical Specifications](docs/technical-specifications.md) - Detailed implementation specifications
113
+ - [Usage Guide](docs/usage-guide.md) - How to use the OCP Local Testing Tool
114
+ - [Project Structure](docs/project-structure.md) - Code organization and architecture
115
+ - [Implementation Plan](docs/implementation-plan.md) - Phased approach to building the tool
116
+
117
+ ## Development
118
+
119
+ ### Setting Up the Development Environment
120
+
121
+ ```bash
122
+ # Clone the repository
123
+ git clone https://github.com/optimizely/ocp-local-env.git
124
+ cd ocp-local-env
125
+
126
+ # Crate .env.local file and set `APP_ROOT_DIR` variable - this should be the full path to the app directory you want to test
127
+ cp .env.example .env.local
128
+
129
+ # Install dependencies
130
+ yarn install
131
+
132
+ # Build the project
133
+ yarn build
134
+
135
+ # Start the development server
136
+ yarn dev
137
+ ```
138
+
139
+ ### Project Structure
140
+
141
+ The project follows a modular structure with clear separation of concerns:
142
+
143
+ - `src/server`: Server-side code for simulating the OCP platform
144
+ - `src/ui`: React-based user interface
145
+ - `src/executor`: Code execution and file watching
146
+ - `docs`: Documentation files
147
+
148
+ For more details, see the [Project Structure](docs/project-structure.md) document.
149
+
150
+ ## Contributing
151
+
152
+ Contributions are welcome! Please read the [Contributing Guide](CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests.
153
+
154
+ ## License
155
+
156
+ This project is licensed under the [MIT License](LICENSE).
157
+
158
+ ## Support
159
+
160
+ For support, please create an issue on the [GitHub repository](https://github.com/optimizely/ocp-local-env/issues) or contact the Optimizely Connect Platform team.
161
+
162
+ ## Acknowledgements
163
+
164
+ - Optimizely Connect Platform Team
165
+ - OCP App Developers Community
@@ -0,0 +1,104 @@
1
+ {
2
+ "name": "@optimizely/ocp-local-env",
3
+ "version": "1.0.0-beta.4",
4
+ "description": "Local testing environment for Optimizely Connect Platform (OCP) applications",
5
+ "main": "dist/src/index.js",
6
+ "types": "dist/src/index.d.ts",
7
+ "bin": {
8
+ "ocp-local-env": "dist/src/cli.js"
9
+ },
10
+ "files": [
11
+ "dist/"
12
+ ],
13
+ "scripts": {
14
+ "build": "tsc && webpack --mode production",
15
+ "dev": "concurrently \"tsc --watch\" \"webpack --mode development --watch\" \"nodemon dist/src/server.js\"",
16
+ "dev:server": "tsc --watch && nodemon dist/src/server.js",
17
+ "dev:ui": "webpack --mode development --watch",
18
+ "start": "node dist/src/server.js",
19
+ "test": "jest",
20
+ "lint": "npx eslint 'src/**'",
21
+ "format": "prettier --write \"src/**/*.{ts,tsx}\"",
22
+ "prepare": "npm run build",
23
+ "release": "release-it"
24
+ },
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git://github.com/ZaiusInc/ocp-local-env.git"
28
+ },
29
+ "keywords": [
30
+ "optimizely",
31
+ "ocp",
32
+ "local",
33
+ "development",
34
+ "testing"
35
+ ],
36
+ "author": "Optimizely",
37
+ "license": "MIT",
38
+ "bugs": {
39
+ "url": "https://github.com/optimizelyZaiusInc/ocp-local-env/issues"
40
+ },
41
+ "homepage": "https://github.com/ZaiusInc/ocp-local-env#readme",
42
+ "dependencies": {
43
+ "@zaiusinc/app-sdk": "^2.2.1",
44
+ "@zaiusinc/node-sdk": "^2.0.0",
45
+ "chalk": "^4.1.2",
46
+ "chokidar": "^3.5.3",
47
+ "commander": "^9.4.1",
48
+ "dotenv": "^17.2.1",
49
+ "express": "^4.18.2",
50
+ "http-proxy-middleware": "^3.0.5",
51
+ "js-yaml": "^4.1.0",
52
+ "open": "^8.4.2",
53
+ "react": ">=17.0.0",
54
+ "react-dom": ">=17.0.0",
55
+ "uuid": "^9.0.0"
56
+ },
57
+ "devDependencies": {
58
+ "@types/express": "^4.17.23",
59
+ "@types/jest": "^29.2.5",
60
+ "@types/js-yaml": "^4.0.9",
61
+ "@types/node": "^18.19.122",
62
+ "@types/react": "^18.3.23",
63
+ "@types/react-dom": "^18.3.7",
64
+ "@types/uuid": "^9.0.0",
65
+ "@typescript-eslint/eslint-plugin": "^5.48.0",
66
+ "@typescript-eslint/parser": "^5.48.0",
67
+ "concurrently": "^7.6.0",
68
+ "css-loader": "^6.7.3",
69
+ "eslint": "^8.31.0",
70
+ "eslint-config-prettier": "^8.6.0",
71
+ "eslint-plugin-react": "^7.31.11",
72
+ "html-webpack-plugin": "^5.5.0",
73
+ "husky": "^8.0.3",
74
+ "jest": "^29.3.1",
75
+ "lint-staged": "^16.2.0",
76
+ "nodemon": "^3.1.10",
77
+ "parse-path": "^7.0.0",
78
+ "prettier": "^2.8.1",
79
+ "release-it": "^19.0.5",
80
+ "style-loader": "^3.3.1",
81
+ "ts-jest": "^29.0.3",
82
+ "ts-loader": "^9.4.2",
83
+ "typescript": "^4.9.4",
84
+ "webpack": "^5.75.0",
85
+ "webpack-cli": "^5.0.1"
86
+ },
87
+ "peerDependencies": {
88
+ "react": ">=17.0.0",
89
+ "react-dom": ">=17.0.0"
90
+ },
91
+ "engines": {
92
+ "node": ">=14.0.0"
93
+ },
94
+ "lint-staged": {
95
+ "*.{ts,tsx}": [
96
+ "eslint --fix",
97
+ "prettier --write"
98
+ ]
99
+ },
100
+ "publishConfig": {
101
+ "registry": "https://registry.npmjs.org",
102
+ "access": "public"
103
+ }
104
+ }