@ankhorage/runtime 4.1.1 → 5.0.1

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 (86) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +6 -6
  3. package/dist/RuntimeRenderer.d.ts +7 -7
  4. package/dist/RuntimeRenderer.d.ts.map +1 -1
  5. package/dist/RuntimeRenderer.js +40 -80
  6. package/dist/RuntimeRenderer.js.map +1 -1
  7. package/dist/RuntimeRendererConfig.d.ts +7 -22
  8. package/dist/RuntimeRendererConfig.d.ts.map +1 -1
  9. package/dist/RuntimeRendererConfig.js +5 -8
  10. package/dist/RuntimeRendererConfig.js.map +1 -1
  11. package/dist/RuntimeScreen.d.ts.map +1 -1
  12. package/dist/RuntimeScreen.js +10 -5
  13. package/dist/RuntimeScreen.js.map +1 -1
  14. package/dist/bindings.d.ts +4 -8
  15. package/dist/bindings.d.ts.map +1 -1
  16. package/dist/bindings.js +2 -4
  17. package/dist/bindings.js.map +1 -1
  18. package/dist/index.d.ts +10 -12
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +5 -6
  21. package/dist/index.js.map +1 -1
  22. package/dist/runtimeActionRegistry.d.ts +19 -24
  23. package/dist/runtimeActionRegistry.d.ts.map +1 -1
  24. package/dist/runtimeActionRegistry.js +90 -306
  25. package/dist/runtimeActionRegistry.js.map +1 -1
  26. package/dist/runtimeApiCapabilities.d.ts +11 -0
  27. package/dist/runtimeApiCapabilities.d.ts.map +1 -0
  28. package/dist/runtimeApiCapabilities.js +67 -0
  29. package/dist/runtimeApiCapabilities.js.map +1 -0
  30. package/dist/runtimeBindings.d.ts +28 -17
  31. package/dist/runtimeBindings.d.ts.map +1 -1
  32. package/dist/runtimeBindings.js +157 -197
  33. package/dist/runtimeBindings.js.map +1 -1
  34. package/dist/runtimeCapabilityExecutor.d.ts +8 -0
  35. package/dist/runtimeCapabilityExecutor.d.ts.map +1 -0
  36. package/dist/runtimeCapabilityExecutor.js +21 -0
  37. package/dist/runtimeCapabilityExecutor.js.map +1 -0
  38. package/dist/runtimeEventExecution.d.ts +1 -4
  39. package/dist/runtimeEventExecution.d.ts.map +1 -1
  40. package/dist/runtimeEventExecution.js.map +1 -1
  41. package/dist/runtimeEventOperationLifecycle.d.ts +4 -3
  42. package/dist/runtimeEventOperationLifecycle.d.ts.map +1 -1
  43. package/dist/runtimeEventOperationLifecycle.js +5 -5
  44. package/dist/runtimeEventOperationLifecycle.js.map +1 -1
  45. package/dist/runtimeNodeProps.d.ts +12 -24
  46. package/dist/runtimeNodeProps.d.ts.map +1 -1
  47. package/dist/runtimeNodeProps.js +27 -121
  48. package/dist/runtimeNodeProps.js.map +1 -1
  49. package/dist/runtimeRepeat.d.ts +6 -2
  50. package/dist/runtimeRepeat.d.ts.map +1 -1
  51. package/dist/runtimeRepeat.js +29 -108
  52. package/dist/runtimeRepeat.js.map +1 -1
  53. package/dist/runtimeScreenLoaders.d.ts +27 -42
  54. package/dist/runtimeScreenLoaders.d.ts.map +1 -1
  55. package/dist/runtimeScreenLoaders.js +113 -273
  56. package/dist/runtimeScreenLoaders.js.map +1 -1
  57. package/package.json +10 -4
  58. package/paradox/badges/npm.svg +3 -3
  59. package/paradox/components.md +6 -7
  60. package/paradox/diagrams/architecture-overview.mmd +25 -79
  61. package/paradox/diagrams/export-graph.mmd +67 -105
  62. package/paradox/diagrams/module-relationships.mmd +19 -59
  63. package/paradox/diagrams/sequences/apply-runtime-binding-data-path.mmd +14 -0
  64. package/paradox/diagrams/sequences/create-component-event-from-handler-args.mmd +0 -13
  65. package/paradox/diagrams/sequences/create-runtime-screen-loader-request-key.mmd +5 -0
  66. package/paradox/diagrams/sequences/execute-runtime-binding-invocation.mmd +19 -0
  67. package/paradox/diagrams/sequences/resolve-binding-input-map-sync.mmd +5 -0
  68. package/paradox/diagrams/sequences/resolve-binding-input-map.mmd +5 -0
  69. package/paradox/diagrams/sequences/runtime-screen.mmd +6 -3
  70. package/paradox/diagrams/sequences/use-runtime-screen-operation-loaders.mmd +6 -3
  71. package/paradox/exports.json +610 -848
  72. package/paradox/exports.md +280 -308
  73. package/paradox/index.html +1120 -2266
  74. package/paradox/paradox.json +2724 -5528
  75. package/dist/runtimeApiOperations.d.ts +0 -8
  76. package/dist/runtimeApiOperations.d.ts.map +0 -1
  77. package/dist/runtimeApiOperations.js +0 -38
  78. package/dist/runtimeApiOperations.js.map +0 -1
  79. package/dist/runtimeApiSelection.d.ts +0 -8
  80. package/dist/runtimeApiSelection.d.ts.map +0 -1
  81. package/dist/runtimeApiSelection.js +0 -52
  82. package/dist/runtimeApiSelection.js.map +0 -1
  83. package/dist/runtimeDbPersist.d.ts +0 -34
  84. package/dist/runtimeDbPersist.d.ts.map +0 -1
  85. package/dist/runtimeDbPersist.js +0 -73
  86. package/dist/runtimeDbPersist.js.map +0 -1
@@ -1,8 +0,0 @@
1
- import type { EndpointTestCredentialResolver, EndpointTestFetch } from '@ankhorage/data-sources';
2
- import type { RuntimeBindingOperationExecutor } from './runtimeBindings';
3
- export interface RuntimeApiOperationExecutorOptions {
4
- readonly fetch?: EndpointTestFetch;
5
- readonly credentialResolver?: EndpointTestCredentialResolver;
6
- }
7
- export declare function createRuntimeApiOperationExecutor(options: RuntimeApiOperationExecutorOptions): RuntimeBindingOperationExecutor;
8
- //# sourceMappingURL=runtimeApiOperations.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtimeApiOperations.d.ts","sourceRoot":"","sources":["../src/runtimeApiOperations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,8BAA8B,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAGjG,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,mBAAmB,CAAC;AAEzE,MAAM,WAAW,kCAAkC;IACjD,QAAQ,CAAC,KAAK,CAAC,EAAE,iBAAiB,CAAC;IACnC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,8BAA8B,CAAC;CAC9D;AAED,wBAAgB,iCAAiC,CAC/C,OAAO,EAAE,kCAAkC,GAC1C,+BAA+B,CAoBjC"}
@@ -1,38 +0,0 @@
1
- import { testEndpoint } from '@ankhorage/data-sources';
2
- export function createRuntimeApiOperationExecutor(options) {
3
- return async ({ api, endpoint, input, operation }) => {
4
- const values = asBindingValueRecord(input);
5
- if (input !== undefined && values === undefined) {
6
- return invalidInput(operation.apiId, endpoint.id, operation.operationId);
7
- }
8
- const result = await testEndpoint({
9
- api,
10
- credentialResolver: options.credentialResolver,
11
- endpointId: endpoint.id,
12
- fetch: options.fetch,
13
- operationId: operation.operationId,
14
- values,
15
- });
16
- return result.ok
17
- ? { ok: true, data: result.data ?? null, diagnostics: result.diagnostics }
18
- : { ok: false, diagnostics: result.diagnostics };
19
- };
20
- }
21
- function invalidInput(apiId, endpointId, operationId) {
22
- const diagnostic = {
23
- apiId,
24
- code: 'invalid-config',
25
- endpointId,
26
- message: 'API operation input must resolve to an object.',
27
- operationId,
28
- severity: 'error',
29
- };
30
- return { ok: false, diagnostics: [diagnostic] };
31
- }
32
- function asBindingValueRecord(value) {
33
- return isBindingValueRecord(value) ? value : undefined;
34
- }
35
- function isBindingValueRecord(value) {
36
- return typeof value === 'object' && value !== null && !Array.isArray(value);
37
- }
38
- //# sourceMappingURL=runtimeApiOperations.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtimeApiOperations.js","sourceRoot":"","sources":["../src/runtimeApiOperations.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AASvD,MAAM,UAAU,iCAAiC,CAC/C,OAA2C;IAE3C,OAAO,KAAK,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE;QACnD,MAAM,MAAM,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;QAC3C,IAAI,KAAK,KAAK,SAAS,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YAChD,OAAO,YA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type { BindingValue, DataSourceDiagnostic } from '@ankhorage/contracts';\nimport type { EndpointTestCredentialResolver, EndpointTestFetch } from '@ankhorage/data-sources';\nimport { testEndpoint } from '@ankhorage/data-sources';\n\nimport type { RuntimeBindingOperationExecutor } from './runtimeBindings';\n\nexport interface RuntimeApiOperationExecutorOptions {\n readonly fetch?: EndpointTestFetch;\n readonly credentialResolver?: EndpointTestCredentialResolver;\n}\n\nexport function createRuntimeApiOperationExecutor(\n options: RuntimeApiOperationExecutorOptions,\n): RuntimeBindingOperationExecutor {\n return async ({ api, endpoint, input, operation }) => {\n const values = asBindingValueRecord(input);\n if (input !== undefined && values === undefined) {\n return invalidInput(operation.apiId, endpoint.id, operation.operationId);\n }\n\n const result = await testEndpoint({\n api,\n credentialResolver: options.credentialResolver,\n endpointId: endpoint.id,\n fetch: options.fetch,\n operationId: operation.operationId,\n values,\n });\n\n return result.ok\n ? { ok: true, data: result.data ?? null, diagnostics: result.diagnostics }\n : { ok: false, diagnostics: result.diagnostics };\n };\n}\n\nfunction invalidInput(apiId: string, endpointId: string, operationId: string) {\n const diagnostic: DataSourceDiagnostic = {\n apiId,\n code: 'invalid-config',\n endpointId,\n message: 'API operation input must resolve to an object.',\n operationId,\n severity: 'error',\n };\n return { ok: false as const, diagnostics: [diagnostic] };\n}\n\nfunction asBindingValueRecord(\n value: BindingValue | undefined,\n): Readonly<Record<string, BindingValue>> | undefined {\n return isBindingValueRecord(value) ? value : undefined;\n}\n\nfunction isBindingValueRecord(\n value: BindingValue | undefined,\n): value is Readonly<Record<string, BindingValue>> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n"]}
@@ -1,8 +0,0 @@
1
- import type { ApiDefinition, ApiDefinitionRegistry, BindingOperationRef, DataEndpointConfig, DataSourceDiagnostic } from '@ankhorage/contracts';
2
- export interface RuntimeApiOperationSelection {
3
- readonly api: ApiDefinition;
4
- readonly endpoint: DataEndpointConfig;
5
- }
6
- export declare function validateRuntimeBindingOperationRef(operation: BindingOperationRef, apis: ApiDefinitionRegistry | undefined): readonly DataSourceDiagnostic[];
7
- export declare function resolveRuntimeBindingOperationSelection(operation: BindingOperationRef, apis: ApiDefinitionRegistry | undefined, diagnostics: DataSourceDiagnostic[]): RuntimeApiOperationSelection | undefined;
8
- //# sourceMappingURL=runtimeApiSelection.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtimeApiSelection.d.ts","sourceRoot":"","sources":["../src/runtimeApiSelection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACrB,MAAM,sBAAsB,CAAC;AAG9B,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,GAAG,EAAE,aAAa,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAC;CACvC;AAED,wBAAgB,kCAAkC,CAChD,SAAS,EAAE,mBAAmB,EAC9B,IAAI,EAAE,qBAAqB,GAAG,SAAS,GACtC,SAAS,oBAAoB,EAAE,CA+BjC;AAED,wBAAgB,uCAAuC,CACrD,SAAS,EAAE,mBAAmB,EAC9B,IAAI,EAAE,qBAAqB,GAAG,SAAS,EACvC,WAAW,EAAE,oBAAoB,EAAE,GAClC,4BAA4B,GAAG,SAAS,CAS1C"}
@@ -1,52 +0,0 @@
1
- import { readOwnProperty } from '@ankhorage/utility/object';
2
- export function validateRuntimeBindingOperationRef(operation, apis) {
3
- const api = findRuntimeApi(apis, operation.apiId);
4
- if (api === undefined) {
5
- return [
6
- createApiDiagnostic(operation, 'missing-api', `API '${operation.apiId}' could not be found.`),
7
- ];
8
- }
9
- const endpoint = resolveRuntimeApiEndpoint(operation, api);
10
- if (endpoint === undefined) {
11
- return [
12
- createApiDiagnostic(operation, 'missing-endpoint', `Endpoint '${operation.endpointId ?? '<default>'}' could not be found.`),
13
- ];
14
- }
15
- if (readOwnProperty(endpoint.operations, operation.operationId) === undefined) {
16
- return [
17
- createApiDiagnostic(operation, 'missing-operation', `Operation '${operation.operationId}' could not be found.`, endpoint.id),
18
- ];
19
- }
20
- return [];
21
- }
22
- export function resolveRuntimeBindingOperationSelection(operation, apis, diagnostics) {
23
- const validationDiagnostics = validateRuntimeBindingOperationRef(operation, apis);
24
- diagnostics.push(...validationDiagnostics);
25
- if (validationDiagnostics.length > 0)
26
- return undefined;
27
- const api = findRuntimeApi(apis, operation.apiId);
28
- if (api === undefined)
29
- return undefined;
30
- const endpoint = resolveRuntimeApiEndpoint(operation, api);
31
- return endpoint === undefined ? undefined : { api, endpoint };
32
- }
33
- function findRuntimeApi(apis, apiId) {
34
- return apis ? readOwnProperty(apis, apiId) : undefined;
35
- }
36
- function resolveRuntimeApiEndpoint(operation, api) {
37
- if (operation.endpointId !== undefined) {
38
- return readOwnProperty(api.endpoints, operation.endpointId);
39
- }
40
- return Object.values(api.endpoints).find((endpoint) => readOwnProperty(endpoint.operations, operation.operationId) !== undefined);
41
- }
42
- function createApiDiagnostic(operation, code, message, endpointId = operation.endpointId) {
43
- return {
44
- apiId: operation.apiId,
45
- code,
46
- endpointId,
47
- message,
48
- operationId: operation.operationId,
49
- severity: 'error',
50
- };
51
- }
52
- //# sourceMappingURL=runtimeApiSelection.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtimeApiSelection.js","sourceRoot":"","sources":["../src/runtimeApiSelection.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAO5D,MAAM,UAAU,kCAAkC,CAChD,SAA8B,EAC9B,IAAuC;IAEvC,MAAM,GAAG,GAAG,cAAc,CAAC,IAAI,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC;IAClD,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtB,OAAO;YACL,mBAAmB,CAAC,SAAS,EAAE,aAAa,EAAE,QAAQ,SAAS,CAAC,KAAK,uBAAuB,CAAC;SAC9F,CAAC;IACJ,CAAC;IAED,MAAM,QAAQ,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S,CAAC;AACxE,CAAC;AAED,SAAS,yBAAyB,CAChC,SAA8B,EAC9B,GAAkB;IAElB,IAAI,SAAS,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QACvC,OAAO,eAAe,CAAqB,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC;IAClF,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,CACtC,CAAC,QAAQ,EAAE,EAAE,CAAC,eAAe,CAAC,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC,WAAW,CAAC,KAAK,SAAS,CACxF,CAAC;AACJ,CAAC;AAED,SAAS,mBAAmB,CAC1B,SAA8B,EAC9B,IAAkC,EAClC,OAAe,EACf,UAAU,GAAG,SAAS,CAAC,UAAU;IAEjC,OAAO;QACL,KAAK,EAAE,SAAS,CAAC,KAAK;QACtB,IAAI;QACJ,UAAU;QACV,OAAO;QACP,WAAW,EAAE,SAAS,CAAC,WAAW;QAClC,QAAQ,EAAE,OAAO;KAClB,CAAC;AACJ,CAAC","sourcesContent":["import type {\n ApiDefinition,\n ApiDefinitionRegistry,\n BindingOperationRef,\n DataEndpointConfig,\n DataSourceDiagnostic,\n} from '@ankhorage/contracts';\nimport { readOwnProperty } from '@ankhorage/utility/object';\n\nexport interface RuntimeApiOperationSelection {\n readonly api: ApiDefinition;\n readonly endpoint: DataEndpointConfig;\n}\n\nexport function validateRuntimeBindingOperationRef(\n operation: BindingOperationRef,\n apis: ApiDefinitionRegistry | undefined,\n): readonly DataSourceDiagnostic[] {\n const api = findRuntimeApi(apis, operation.apiId);\n if (api === undefined) {\n return [\n createApiDiagnostic(operation, 'missing-api', `API '${operation.apiId}' could not be found.`),\n ];\n }\n\n const endpoint = resolveRuntimeApiEndpoint(operation, api);\n if (endpoint === undefined) {\n return [\n createApiDiagnostic(\n operation,\n 'missing-endpoint',\n `Endpoint '${operation.endpointId ?? '<default>'}' could not be found.`,\n ),\n ];\n }\n\n if (readOwnProperty(endpoint.operations, operation.operationId) === undefined) {\n return [\n createApiDiagnostic(\n operation,\n 'missing-operation',\n `Operation '${operation.operationId}' could not be found.`,\n endpoint.id,\n ),\n ];\n }\n\n return [];\n}\n\nexport function resolveRuntimeBindingOperationSelection(\n operation: BindingOperationRef,\n apis: ApiDefinitionRegistry | undefined,\n diagnostics: DataSourceDiagnostic[],\n): RuntimeApiOperationSelection | undefined {\n const validationDiagnostics = validateRuntimeBindingOperationRef(operation, apis);\n diagnostics.push(...validationDiagnostics);\n if (validationDiagnostics.length > 0) return undefined;\n\n const api = findRuntimeApi(apis, operation.apiId);\n if (api === undefined) return undefined;\n const endpoint = resolveRuntimeApiEndpoint(operation, api);\n return endpoint === undefined ? undefined : { api, endpoint };\n}\n\nfunction findRuntimeApi(\n apis: ApiDefinitionRegistry | undefined,\n apiId: string,\n): ApiDefinition | undefined {\n return apis ? readOwnProperty<ApiDefinition>(apis, apiId) : undefined;\n}\n\nfunction resolveRuntimeApiEndpoint(\n operation: BindingOperationRef,\n api: ApiDefinition,\n): DataEndpointConfig | undefined {\n if (operation.endpointId !== undefined) {\n return readOwnProperty<DataEndpointConfig>(api.endpoints, operation.endpointId);\n }\n\n return Object.values(api.endpoints).find(\n (endpoint) => readOwnProperty(endpoint.operations, operation.operationId) !== undefined,\n );\n}\n\nfunction createApiDiagnostic(\n operation: BindingOperationRef,\n code: DataSourceDiagnostic['code'],\n message: string,\n endpointId = operation.endpointId,\n): DataSourceDiagnostic {\n return {\n apiId: operation.apiId,\n code,\n endpointId,\n message,\n operationId: operation.operationId,\n severity: 'error',\n };\n}\n"]}
@@ -1,34 +0,0 @@
1
- import type { DbAdapter, DbAdapterError, DbInsertInput, DbRecord, DbResult } from '@ankhorage/contracts';
2
- import type { RuntimeActionHandler, RuntimeActionHandlerArgs } from './RuntimeRendererConfig';
3
- export interface RuntimeDbPersistResult {
4
- readonly input: DbInsertInput;
5
- readonly result: DbResult<DbRecord[]>;
6
- }
7
- export interface RuntimeDbPersistError {
8
- readonly code: string;
9
- readonly message: string;
10
- }
11
- export type RuntimeDbPersistExecutionResult = {
12
- readonly ok: true;
13
- readonly data: RuntimeDbPersistResult;
14
- } | {
15
- readonly ok: false;
16
- readonly error: RuntimeDbPersistError;
17
- };
18
- export declare function createDbPersistActionHandler(args: {
19
- readonly dbAdapter: DbAdapter;
20
- readonly onResult?: (result: RuntimeDbPersistExecutionResult) => void;
21
- }): RuntimeActionHandler;
22
- export declare function executeDbPersistAction(args: {
23
- readonly dbAdapter: DbAdapter;
24
- readonly handlerArgs: RuntimeActionHandlerArgs;
25
- }): Promise<RuntimeDbPersistExecutionResult>;
26
- export declare function resolveDbPersistInput(payload: object | undefined): {
27
- readonly ok: true;
28
- readonly data: DbInsertInput;
29
- } | {
30
- readonly ok: false;
31
- readonly error: RuntimeDbPersistError;
32
- };
33
- export declare function createDbPersistAdapterError(error: RuntimeDbPersistError): DbAdapterError;
34
- //# sourceMappingURL=runtimeDbPersist.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtimeDbPersist.d.ts","sourceRoot":"","sources":["../src/runtimeDbPersist.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,cAAc,EACd,aAAa,EACb,QAAQ,EACR,QAAQ,EACT,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAE9F,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,MAAM,+BAA+B,GACvC;IACE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAClB,QAAQ,CAAC,IAAI,EAAE,sBAAsB,CAAC;CACvC,GACD;IACE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IACnB,QAAQ,CAAC,KAAK,EAAE,qBAAqB,CAAC;CACvC,CAAC;AAON,wBAAgB,4BAA4B,CAAC,IAAI,EAAE;IACjD,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,+BAA+B,KAAK,IAAI,CAAC;CACvE,GAAG,oBAAoB,CAOvB;AAED,wBAAsB,sBAAsB,CAAC,IAAI,EAAE;IACjD,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,WAAW,EAAE,wBAAwB,CAAC;CAChD,GAAG,OAAO,CAAC,+BAA+B,CAAC,CAe3C;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAC7D;IACE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAClB,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;CAC9B,GACD;IACE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IACnB,QAAQ,CAAC,KAAK,EAAE,qBAAqB,CAAC;CACvC,CAsCJ;AAYD,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,qBAAqB,GAAG,cAAc,CAKxF"}
@@ -1,73 +0,0 @@
1
- export function createDbPersistActionHandler(args) {
2
- const { dbAdapter, onResult } = args;
3
- return async (handlerArgs) => {
4
- const result = await executeDbPersistAction({ dbAdapter, handlerArgs });
5
- onResult?.(result);
6
- };
7
- }
8
- export async function executeDbPersistAction(args) {
9
- const inputResult = resolveDbPersistInput(args.handlerArgs.resolvedPayload);
10
- if (!inputResult.ok) {
11
- return inputResult;
12
- }
13
- const result = await args.dbAdapter.insert(inputResult.data);
14
- return {
15
- ok: true,
16
- data: {
17
- input: inputResult.data,
18
- result,
19
- },
20
- };
21
- }
22
- export function resolveDbPersistInput(payload) {
23
- if (!isRecord(payload)) {
24
- return createError('invalid_payload', 'db.persist requires a resolved payload object.');
25
- }
26
- const { collection } = payload;
27
- if (typeof collection !== 'string' || collection.trim().length === 0) {
28
- return createError('missing_collection', 'db.persist requires a non-empty collection.');
29
- }
30
- const { values } = payload;
31
- if (!Array.isArray(values) || values.length === 0) {
32
- return createError('missing_values', 'db.persist requires at least one value mapping.');
33
- }
34
- const record = {};
35
- for (const value of values) {
36
- if (!isFieldValueEntry(value)) {
37
- return createError('invalid_value_mapping', 'db.persist value mappings must resolve to { field, value } entries.');
38
- }
39
- if (value.field.trim().length === 0) {
40
- return createError('invalid_field', 'db.persist value field must be non-empty.');
41
- }
42
- record[value.field] = value.value;
43
- }
44
- return {
45
- ok: true,
46
- data: {
47
- table: collection.trim(),
48
- values: record,
49
- },
50
- };
51
- }
52
- function createError(code, message) {
53
- return {
54
- ok: false,
55
- error: { code, message },
56
- };
57
- }
58
- export function createDbPersistAdapterError(error) {
59
- return {
60
- code: error.code,
61
- message: error.message,
62
- };
63
- }
64
- function isFieldValueEntry(value) {
65
- if (!isRecord(value)) {
66
- return false;
67
- }
68
- return typeof value.field === 'string' && 'value' in value;
69
- }
70
- function isRecord(value) {
71
- return typeof value === 'object' && value !== null && !Array.isArray(value);
72
- }
73
- //# sourceMappingURL=runtimeDbPersist.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtimeDbPersist.js","sourceRoot":"","sources":["../src/runtimeDbPersist.ts"],"names":[],"mappings":"AAmCA,MAAM,UAAU,4BAA4B,CAAC,IAG5C;IACC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IAErC,OAAO,KAAK,EAAE,WAAW,EAAE,EAAE;QAC3B,MAAM,MAAM,GAAG,MAAM,sBAAsB,CAAC,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,CAAC;QACxE,QAAQ,EAAE,CAAC,MAAM,CAAC,CAAC;IACrB,CAAC,C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AChB,uBAAuB,EACvB,qEAAqE,CACtE,CAAC;QACJ,CAAC;QAED,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACpC,OAAO,WAAW,CAAC,eAAe,EAAE,2CAA2C,CAAC,CAAC;QACnF,CAAC;QAED,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC;IACpC,CAAC;IAED,OAAO;QACL,EAAE,EAAE,IAAI;QACR,IAAI,EAAE;YACJ,KAAK,EAAE,UAAU,CAAC,IAAI,EAAE;YACxB,MAAM,EAAE,MAAM;SACf;KACF,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAClB,IAAmC,EACnC,OAAyC;IAEzC,OAAO;QACL,EAAE,EAAE,KAAK;QACT,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;KACzB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,KAA4B;IACtE,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,OAAO,EAAE,KAAK,CAAC,OAAO;KACvB,CAAC;AACJ,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAc;IACvC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,IAAI,OAAO,IAAI,KAAK,CAAC;AAC7D,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC","sourcesContent":["import type {\n DbAdapter,\n DbAdapterError,\n DbInsertInput,\n DbRecord,\n DbResult,\n} from '@ankhorage/contracts';\n\nimport type { RuntimeActionHandler, RuntimeActionHandlerArgs } from './RuntimeRendererConfig';\n\nexport interface RuntimeDbPersistResult {\n readonly input: DbInsertInput;\n readonly result: DbResult<DbRecord[]>;\n}\n\nexport interface RuntimeDbPersistError {\n readonly code: string;\n readonly message: string;\n}\n\nexport type RuntimeDbPersistExecutionResult =\n | {\n readonly ok: true;\n readonly data: RuntimeDbPersistResult;\n }\n | {\n readonly ok: false;\n readonly error: RuntimeDbPersistError;\n };\n\ninterface FieldValueEntry {\n readonly field: string;\n readonly value: unknown;\n}\n\nexport function createDbPersistActionHandler(args: {\n readonly dbAdapter: DbAdapter;\n readonly onResult?: (result: RuntimeDbPersistExecutionResult) => void;\n}): RuntimeActionHandler {\n const { dbAdapter, onResult } = args;\n\n return async (handlerArgs) => {\n const result = await executeDbPersistAction({ dbAdapter, handlerArgs });\n onResult?.(result);\n };\n}\n\nexport async function executeDbPersistAction(args: {\n readonly dbAdapter: DbAdapter;\n readonly handlerArgs: RuntimeActionHandlerArgs;\n}): Promise<RuntimeDbPersistExecutionResult> {\n const inputResult = resolveDbPersistInput(args.handlerArgs.resolvedPayload);\n if (!inputResult.ok) {\n return inputResult;\n }\n\n const result = await args.dbAdapter.insert(inputResult.data);\n\n return {\n ok: true,\n data: {\n input: inputResult.data,\n result,\n },\n };\n}\n\nexport function resolveDbPersistInput(payload: object | undefined):\n | {\n readonly ok: true;\n readonly data: DbInsertInput;\n }\n | {\n readonly ok: false;\n readonly error: RuntimeDbPersistError;\n } {\n if (!isRecord(payload)) {\n return createError('invalid_payload', 'db.persist requires a resolved payload object.');\n }\n\n const { collection } = payload;\n if (typeof collection !== 'string' || collection.trim().length === 0) {\n return createError('missing_collection', 'db.persist requires a non-empty collection.');\n }\n\n const { values } = payload;\n if (!Array.isArray(values) || values.length === 0) {\n return createError('missing_values', 'db.persist requires at least one value mapping.');\n }\n\n const record: DbRecord = {};\n for (const value of values) {\n if (!isFieldValueEntry(value)) {\n return createError(\n 'invalid_value_mapping',\n 'db.persist value mappings must resolve to { field, value } entries.',\n );\n }\n\n if (value.field.trim().length === 0) {\n return createError('invalid_field', 'db.persist value field must be non-empty.');\n }\n\n record[value.field] = value.value;\n }\n\n return {\n ok: true,\n data: {\n table: collection.trim(),\n values: record,\n },\n };\n}\n\nfunction createError(\n code: RuntimeDbPersistError['code'],\n message: RuntimeDbPersistError['message'],\n): { readonly ok: false; readonly error: RuntimeDbPersistError } {\n return {\n ok: false,\n error: { code, message },\n };\n}\n\nexport function createDbPersistAdapterError(error: RuntimeDbPersistError): DbAdapterError {\n return {\n code: error.code,\n message: error.message,\n };\n}\n\nfunction isFieldValueEntry(value: unknown): value is FieldValueEntry {\n if (!isRecord(value)) {\n return false;\n }\n\n return typeof value.field === 'string' && 'value' in value;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n"]}