@squiz/render-runtime-lib 1.2.1-alpha.100

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 (56) hide show
  1. package/README.md +11 -0
  2. package/lib/component-runner/component-runner.spec.d.ts +1 -0
  3. package/lib/component-runner/index.d.ts +22 -0
  4. package/lib/component-runner/worker/WorkerPool.d.ts +50 -0
  5. package/lib/component-runner/worker/getRuntimeModules.d.ts +1 -0
  6. package/lib/component-runner/worker/worker-root.d.ts +1 -0
  7. package/lib/index.d.ts +25 -0
  8. package/lib/index.js +112791 -0
  9. package/lib/index.js.map +7 -0
  10. package/lib/migrations/20220704054051_initial.sql +19 -0
  11. package/lib/migrations/20220718172237_adding_component_sets.sql +23 -0
  12. package/lib/migrations/20220728113941_add_env_vars_field.sql +1 -0
  13. package/lib/migrations/20220817113300_removing_null_props_from_jsonb.sql +41 -0
  14. package/lib/render-runtime-lib.spec.d.ts +1 -0
  15. package/lib/test/helpers/fixtures.d.ts +20 -0
  16. package/lib/test/helpers/stack.d.ts +6 -0
  17. package/lib/test/index.d.ts +2 -0
  18. package/lib/utils/convertFunctionStaticFilesToFqdn.d.ts +1 -0
  19. package/lib/utils/convertFunctionStaticFilesToFqdn.spec.d.ts +1 -0
  20. package/lib/utils/getFunctionDefinitionFromManifest.d.ts +2 -0
  21. package/lib/utils/getManifestPath.d.ts +1 -0
  22. package/lib/utils/getManifestPath.spec.d.ts +1 -0
  23. package/lib/utils/getPreviewFilePath.d.ts +1 -0
  24. package/lib/utils/getPreviewFilePath.spec.d.ts +1 -0
  25. package/lib/utils/isInProductionMode.d.ts +1 -0
  26. package/lib/utils/isInProductionMode.spec.d.ts +1 -0
  27. package/lib/utils/resolvePreviewOutput.d.ts +2 -0
  28. package/lib/utils/resolvePreviewOutput.spec.d.ts +1 -0
  29. package/lib/webserver/app.d.ts +4 -0
  30. package/lib/webserver/controllers/core.d.ts +3 -0
  31. package/lib/webserver/controllers/core.spec.d.ts +1 -0
  32. package/lib/webserver/controllers/definition.d.ts +3 -0
  33. package/lib/webserver/controllers/definition.spec.d.ts +1 -0
  34. package/lib/webserver/controllers/index.d.ts +4 -0
  35. package/lib/webserver/controllers/render.d.ts +3 -0
  36. package/lib/webserver/controllers/render.spec.d.ts +1 -0
  37. package/lib/webserver/controllers/static.d.ts +3 -0
  38. package/lib/webserver/controllers/static.spec.d.ts +1 -0
  39. package/lib/webserver/controllers/test/definition-route-tests.d.ts +1 -0
  40. package/lib/webserver/controllers/test/render-route-tests.d.ts +1 -0
  41. package/lib/webserver/controllers/test/static-route-tests.d.ts +1 -0
  42. package/lib/webserver/index.d.ts +22 -0
  43. package/lib/worker/bridge.js +1010 -0
  44. package/lib/worker/compiler.js +87 -0
  45. package/lib/worker/events.js +977 -0
  46. package/lib/worker/nodevm.js +503 -0
  47. package/lib/worker/resolver-compat.js +342 -0
  48. package/lib/worker/resolver.js +882 -0
  49. package/lib/worker/script.js +388 -0
  50. package/lib/worker/setup-node-sandbox.js +469 -0
  51. package/lib/worker/setup-sandbox.js +456 -0
  52. package/lib/worker/transformer.js +180 -0
  53. package/lib/worker/vm.js +539 -0
  54. package/lib/worker/worker-root.js +41743 -0
  55. package/lib/worker/worker-root.js.map +7 -0
  56. package/package.json +60 -0
@@ -0,0 +1,19 @@
1
+ -- CreateTable
2
+
3
+ CREATE TABLE "component" ("name" VARCHAR(128) NOT NULL,
4
+ CONSTRAINT "component_pkey" PRIMARY KEY ("name"));
5
+
6
+ -- CreateTable
7
+
8
+ CREATE TABLE "component_version" ("component_name" VARCHAR(128) NOT NULL,
9
+ "version" VARCHAR(128) NOT NULL,
10
+ CONSTRAINT "component_version_pkey" PRIMARY KEY ("component_name",
11
+ "version"));
12
+
13
+ -- AddForeignKey
14
+
15
+ ALTER TABLE "component_version" ADD CONSTRAINT "component_version_component_name_fkey"
16
+ FOREIGN KEY ("component_name") REFERENCES "component"("name") ON
17
+ DELETE CASCADE ON
18
+ UPDATE CASCADE;
19
+
@@ -0,0 +1,23 @@
1
+ -- CreateTable
2
+ CREATE TABLE "component_set" (
3
+ "web_path" VARCHAR(128) NOT NULL,
4
+ "display_name" VARCHAR(128) NOT NULL,
5
+ "description" VARCHAR,
6
+ "env_vars" JSONB,
7
+ "headers" JSONB,
8
+
9
+ CONSTRAINT "component_set_pkey" PRIMARY KEY ("web_path")
10
+ );
11
+
12
+ -- CreateTable
13
+ CREATE TABLE "component_set_component_version" (
14
+ "component_set_web_path" VARCHAR(128) NOT NULL,
15
+ "component_name" VARCHAR(128) NOT NULL,
16
+ "component_version" VARCHAR(128) NOT NULL,
17
+
18
+ CONSTRAINT "component_set_component_version_pkey" PRIMARY KEY ("component_set_web_path", "component_name", "component_version")
19
+ );
20
+
21
+ -- AddForeignKey
22
+ ALTER TABLE "component_set_component_version" ADD CONSTRAINT "component_set_web_path_fkey" FOREIGN KEY ("component_set_web_path") REFERENCES "component_set"("web_path") ON DELETE CASCADE ON UPDATE CASCADE;
23
+ ALTER TABLE "component_set_component_version" ADD CONSTRAINT "component_version_componet_name_version_fkey" FOREIGN KEY ("component_name", "component_version") REFERENCES "component_version"("component_name", "version") ON DELETE CASCADE ON UPDATE CASCADE;
@@ -0,0 +1 @@
1
+ ALTER TABLE "component_set_component_version" ADD COLUMN "env_vars" jsonb;
@@ -0,0 +1,41 @@
1
+ UPDATE component_set as rc
2
+ set env_vars = (
3
+
4
+ -- subtract non string properties, resulting object is all keys have values
5
+ select COALESCE((o2.env_vars - od.nonStringProps), '{}'::jsonb) as stringProps
6
+ from component_set as o2 , (
7
+
8
+ -- select get an array of all properties whos value is not a string, as an array
9
+ select web_path, array(
10
+ select envK
11
+ from component_set, jsonb_object_keys(env_vars) as envK
12
+ where jsonb_typeof(component_set.env_vars->envk) <> 'string' and o.web_path = component_set.web_path
13
+ ) as nonStringProps
14
+ from component_set as o
15
+ ) as od
16
+
17
+ -- make sure all the web_paths are the same
18
+ where o2.web_path = od.web_path and rc.web_path = o2.web_path
19
+ ),
20
+ headers = (
21
+ -- subtract non string properties resulting object is all keys have values
22
+ select COALESCE((o2.headers - od.nonStringProps), '{}'::jsonb) as stringProps
23
+ from component_set as o2 , (
24
+
25
+ -- select get an array of all properties whos value is not a string, as an array
26
+ select web_path, array(
27
+ select headerK
28
+ from component_set, jsonb_object_keys(headers) as headerK
29
+ where jsonb_typeof(component_set.headers->headerK) <> 'string' and o.web_path = component_set.web_path
30
+ ) as nonStringProps
31
+ from component_set as o
32
+ ) as od
33
+
34
+ -- make sure all the web_paths are the same
35
+ where o2.web_path = od.web_path and rc.web_path = o2.web_path
36
+ );
37
+
38
+ -- make columns not nullable
39
+ ALTER TABLE component_set ALTER COLUMN env_vars SET NOT NULL;
40
+ ALTER TABLE component_set ALTER COLUMN headers SET NOT NULL;
41
+
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,20 @@
1
+ import { ExecuteComponentTask } from '@squiz/component-lib';
2
+ declare type ComponentReturn = string | object;
3
+ export declare class ComponentFixture {
4
+ static fixtureRootDirectory: string | undefined;
5
+ protected static getFixtureRootDirectory(): string;
6
+ static setupFullComponentDirectory(returnObj: ComponentReturn): Promise<{
7
+ fixtureDirectory: string;
8
+ version: string;
9
+ componentName: string;
10
+ }>;
11
+ static new(returnObj: string | object, { raw, environment }?: {
12
+ raw?: boolean | undefined;
13
+ environment?: string[] | undefined;
14
+ }): Promise<ExecuteComponentTask>;
15
+ static updateComponent(component: ExecuteComponentTask, output: string | object): Promise<ExecuteComponentTask>;
16
+ private static createFixtureDirectory;
17
+ private static createVersionDirectory;
18
+ private static createManifest;
19
+ }
20
+ export {};
@@ -0,0 +1,6 @@
1
+ import supertest from 'supertest';
2
+ import { type RenderRuntimeConfig } from '../../';
3
+ import { Logger } from '@squiz/dx-logger-lib';
4
+ export declare const testLogger: Logger;
5
+ export declare function getTestConfig(port: number): RenderRuntimeConfig;
6
+ export declare function getTestServer(): supertest.SuperTest<supertest.Test>;
@@ -0,0 +1,2 @@
1
+ export * from './helpers/fixtures';
2
+ export * from './helpers/stack';
@@ -0,0 +1 @@
1
+ export declare function convertFunctionStaticFilesToFqdn(file: string, componentName: string, version: string): string;
@@ -0,0 +1,2 @@
1
+ import { ComponentFunction, Manifest } from '@squiz/component-lib';
2
+ export declare function getFunctionDefinitionFromManifest(functionName: string, manifest: Manifest): ComponentFunction | undefined;
@@ -0,0 +1 @@
1
+ export declare function getManifestPath(componentName: string, version: string, isInProductionMode: boolean): Promise<string>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare function getPreviewFilePath(manifestPath: string): string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare function isInProductionMode(): boolean;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import { HtmlStaticFile } from '@squiz/component-lib';
2
+ export declare function resolvePreviewOutput(html: string, componentOutput: string, files: HtmlStaticFile[]): string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import { type Express } from 'express';
2
+ import { Logger } from '@squiz/dx-logger-lib';
3
+ import { ComponentConnectionManager } from '@squiz/component-db-lib';
4
+ export declare function setupApp(logger: Logger, db?: ComponentConnectionManager): Express;
@@ -0,0 +1,3 @@
1
+ import { type Router } from 'express';
2
+ declare const router: Router;
3
+ export default router;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { type Router } from 'express';
2
+ declare const router: Router;
3
+ export default router;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export { default as renderRoutes } from './render';
2
+ export { default as definitionRoutes } from './definition';
3
+ export { default as staticRoutes } from './static';
4
+ export { default as coreRoutes } from './core';
@@ -0,0 +1,3 @@
1
+ import { type Router } from 'express';
2
+ declare const router: Router;
3
+ export default router;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { type Router } from 'express';
2
+ declare const router: Router;
3
+ export default router;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare function definitionRouteTests(rootUrl: string, accessingUrl: string): void;
@@ -0,0 +1 @@
1
+ export declare function renderRouteTests(rootUrl: string, accessingUrl: string): void;
@@ -0,0 +1 @@
1
+ export declare function staticRouteTests(url: string): void;
@@ -0,0 +1,22 @@
1
+ /// <reference types="node" />
2
+ import { type Server } from 'http';
3
+ import { Logger } from '@squiz/dx-logger-lib';
4
+ import { ComponentConnectionManager } from '@squiz/component-db-lib';
5
+ export interface WebserverConfig {
6
+ port?: number;
7
+ rootUrl: string;
8
+ shouldRunMigrations: boolean;
9
+ compiledConfig?: {
10
+ buildVersion?: string;
11
+ buildBranch?: string;
12
+ };
13
+ }
14
+ export declare class Webserver {
15
+ private static singleton;
16
+ private static config;
17
+ static get(): Server;
18
+ static getConfig(): WebserverConfig;
19
+ static start(config: Omit<WebserverConfig, 'compiledConfig'>, logger: Logger, db?: ComponentConnectionManager, compiledConfig?: Record<string, string>): Promise<Server>;
20
+ static stop(): void;
21
+ private static mergeConfig;
22
+ }