@dxos/functions 0.8.4-main.b97322e → 0.8.4-main.bc674ce

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 (164) hide show
  1. package/dist/lib/browser/index.mjs +1098 -372
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node-esm/index.mjs +1098 -372
  5. package/dist/lib/node-esm/index.mjs.map +4 -4
  6. package/dist/lib/node-esm/meta.json +1 -1
  7. package/dist/types/src/errors.d.ts +91 -38
  8. package/dist/types/src/errors.d.ts.map +1 -1
  9. package/dist/types/src/example/fib.d.ts +7 -0
  10. package/dist/types/src/example/fib.d.ts.map +1 -0
  11. package/dist/types/src/example/forex-effect.d.ts +3 -0
  12. package/dist/types/src/example/forex-effect.d.ts.map +1 -0
  13. package/dist/types/src/example/index.d.ts +12 -0
  14. package/dist/types/src/example/index.d.ts.map +1 -0
  15. package/dist/types/src/example/reply.d.ts +3 -0
  16. package/dist/types/src/example/reply.d.ts.map +1 -0
  17. package/dist/types/src/example/sleep.d.ts +5 -0
  18. package/dist/types/src/example/sleep.d.ts.map +1 -0
  19. package/dist/types/src/index.d.ts +5 -7
  20. package/dist/types/src/index.d.ts.map +1 -1
  21. package/dist/types/src/operation-compatibility.test.d.ts +2 -0
  22. package/dist/types/src/operation-compatibility.test.d.ts.map +1 -0
  23. package/dist/types/src/protocol/functions-ai-http-client.d.ts +12 -0
  24. package/dist/types/src/protocol/functions-ai-http-client.d.ts.map +1 -0
  25. package/dist/types/src/protocol/index.d.ts +2 -0
  26. package/dist/types/src/protocol/index.d.ts.map +1 -0
  27. package/dist/types/src/protocol/protocol.d.ts +7 -0
  28. package/dist/types/src/protocol/protocol.d.ts.map +1 -0
  29. package/dist/types/src/protocol/protocol.test.d.ts +2 -0
  30. package/dist/types/src/protocol/protocol.test.d.ts.map +1 -0
  31. package/dist/types/src/sdk.d.ts +114 -0
  32. package/dist/types/src/sdk.d.ts.map +1 -0
  33. package/dist/types/src/services/credentials.d.ts +22 -3
  34. package/dist/types/src/services/credentials.d.ts.map +1 -1
  35. package/dist/types/src/services/event-logger.d.ts +74 -30
  36. package/dist/types/src/services/event-logger.d.ts.map +1 -1
  37. package/dist/types/src/services/function-invocation-service.d.ts +16 -0
  38. package/dist/types/src/services/function-invocation-service.d.ts.map +1 -0
  39. package/dist/types/src/services/index.d.ts +5 -5
  40. package/dist/types/src/services/index.d.ts.map +1 -1
  41. package/dist/types/src/services/queues.d.ts +23 -6
  42. package/dist/types/src/services/queues.d.ts.map +1 -1
  43. package/dist/types/src/services/tracing.d.ts +70 -7
  44. package/dist/types/src/services/tracing.d.ts.map +1 -1
  45. package/dist/types/src/types/Function.d.ts +52 -0
  46. package/dist/types/src/types/Function.d.ts.map +1 -0
  47. package/dist/types/src/types/Script.d.ts +21 -0
  48. package/dist/types/src/types/Script.d.ts.map +1 -0
  49. package/dist/types/src/types/Trigger.d.ts +121 -0
  50. package/dist/types/src/types/Trigger.d.ts.map +1 -0
  51. package/dist/types/src/types/TriggerEvent.d.ts +74 -0
  52. package/dist/types/src/types/TriggerEvent.d.ts.map +1 -0
  53. package/dist/types/src/types/index.d.ts +6 -0
  54. package/dist/types/src/types/index.d.ts.map +1 -0
  55. package/dist/types/src/types/url.d.ts +13 -0
  56. package/dist/types/src/types/url.d.ts.map +1 -0
  57. package/dist/types/tsconfig.tsbuildinfo +1 -1
  58. package/package.json +26 -68
  59. package/src/errors.ts +13 -5
  60. package/src/example/fib.ts +32 -0
  61. package/src/example/forex-effect.ts +40 -0
  62. package/src/example/index.ts +13 -0
  63. package/src/example/reply.ts +21 -0
  64. package/src/example/sleep.ts +24 -0
  65. package/src/index.ts +5 -9
  66. package/src/operation-compatibility.test.ts +185 -0
  67. package/src/protocol/functions-ai-http-client.ts +67 -0
  68. package/src/{executor → protocol}/index.ts +1 -1
  69. package/src/protocol/protocol.test.ts +59 -0
  70. package/src/protocol/protocol.ts +262 -0
  71. package/src/sdk.ts +289 -0
  72. package/src/services/credentials.ts +101 -3
  73. package/src/services/event-logger.ts +77 -37
  74. package/src/services/function-invocation-service.ts +37 -0
  75. package/src/services/index.ts +5 -5
  76. package/src/services/queues.ts +37 -10
  77. package/src/services/tracing.ts +142 -17
  78. package/src/types/Function.ts +82 -0
  79. package/src/types/Script.ts +34 -0
  80. package/src/types/Trigger.ts +143 -0
  81. package/src/types/TriggerEvent.ts +62 -0
  82. package/src/types/index.ts +9 -0
  83. package/src/types/url.ts +32 -0
  84. package/dist/lib/browser/bundler/index.mjs +0 -247
  85. package/dist/lib/browser/bundler/index.mjs.map +0 -7
  86. package/dist/lib/browser/chunk-3NGCSUEW.mjs +0 -328
  87. package/dist/lib/browser/chunk-3NGCSUEW.mjs.map +0 -7
  88. package/dist/lib/browser/edge/index.mjs +0 -69
  89. package/dist/lib/browser/edge/index.mjs.map +0 -7
  90. package/dist/lib/browser/testing/index.mjs +0 -91
  91. package/dist/lib/browser/testing/index.mjs.map +0 -7
  92. package/dist/lib/node-esm/bundler/index.mjs +0 -249
  93. package/dist/lib/node-esm/bundler/index.mjs.map +0 -7
  94. package/dist/lib/node-esm/chunk-FJ2MU7TL.mjs +0 -330
  95. package/dist/lib/node-esm/chunk-FJ2MU7TL.mjs.map +0 -7
  96. package/dist/lib/node-esm/edge/index.mjs +0 -71
  97. package/dist/lib/node-esm/edge/index.mjs.map +0 -7
  98. package/dist/lib/node-esm/testing/index.mjs +0 -92
  99. package/dist/lib/node-esm/testing/index.mjs.map +0 -7
  100. package/dist/types/src/bundler/bundler.d.ts +0 -50
  101. package/dist/types/src/bundler/bundler.d.ts.map +0 -1
  102. package/dist/types/src/bundler/bundler.test.d.ts +0 -2
  103. package/dist/types/src/bundler/bundler.test.d.ts.map +0 -1
  104. package/dist/types/src/bundler/index.d.ts +0 -2
  105. package/dist/types/src/bundler/index.d.ts.map +0 -1
  106. package/dist/types/src/edge/functions.d.ts +0 -16
  107. package/dist/types/src/edge/functions.d.ts.map +0 -1
  108. package/dist/types/src/edge/index.d.ts +0 -2
  109. package/dist/types/src/edge/index.d.ts.map +0 -1
  110. package/dist/types/src/executor/executor.d.ts +0 -8
  111. package/dist/types/src/executor/executor.d.ts.map +0 -1
  112. package/dist/types/src/executor/index.d.ts +0 -2
  113. package/dist/types/src/executor/index.d.ts.map +0 -1
  114. package/dist/types/src/handler.d.ts +0 -62
  115. package/dist/types/src/handler.d.ts.map +0 -1
  116. package/dist/types/src/schema.d.ts +0 -38
  117. package/dist/types/src/schema.d.ts.map +0 -1
  118. package/dist/types/src/services/database.d.ts +0 -29
  119. package/dist/types/src/services/database.d.ts.map +0 -1
  120. package/dist/types/src/services/function-call-service.d.ts +0 -16
  121. package/dist/types/src/services/function-call-service.d.ts.map +0 -1
  122. package/dist/types/src/services/service-container.d.ts +0 -56
  123. package/dist/types/src/services/service-container.d.ts.map +0 -1
  124. package/dist/types/src/services/service-registry.d.ts +0 -29
  125. package/dist/types/src/services/service-registry.d.ts.map +0 -1
  126. package/dist/types/src/services/service-registry.test.d.ts +0 -2
  127. package/dist/types/src/services/service-registry.test.d.ts.map +0 -1
  128. package/dist/types/src/testing/index.d.ts +0 -3
  129. package/dist/types/src/testing/index.d.ts.map +0 -1
  130. package/dist/types/src/testing/layer.d.ts +0 -10
  131. package/dist/types/src/testing/layer.d.ts.map +0 -1
  132. package/dist/types/src/testing/logger.d.ts +0 -5
  133. package/dist/types/src/testing/logger.d.ts.map +0 -1
  134. package/dist/types/src/testing/services.d.ts +0 -70
  135. package/dist/types/src/testing/services.d.ts.map +0 -1
  136. package/dist/types/src/trace.d.ts +0 -124
  137. package/dist/types/src/trace.d.ts.map +0 -1
  138. package/dist/types/src/translations.d.ts +0 -12
  139. package/dist/types/src/translations.d.ts.map +0 -1
  140. package/dist/types/src/types.d.ts +0 -411
  141. package/dist/types/src/types.d.ts.map +0 -1
  142. package/dist/types/src/url.d.ts +0 -17
  143. package/dist/types/src/url.d.ts.map +0 -1
  144. package/src/bundler/bundler.test.ts +0 -59
  145. package/src/bundler/bundler.ts +0 -292
  146. package/src/bundler/index.ts +0 -5
  147. package/src/edge/functions.ts +0 -64
  148. package/src/edge/index.ts +0 -9
  149. package/src/executor/executor.ts +0 -54
  150. package/src/handler.ts +0 -120
  151. package/src/schema.ts +0 -57
  152. package/src/services/database.ts +0 -70
  153. package/src/services/function-call-service.ts +0 -64
  154. package/src/services/service-container.ts +0 -113
  155. package/src/services/service-registry.test.ts +0 -42
  156. package/src/services/service-registry.ts +0 -56
  157. package/src/testing/index.ts +0 -6
  158. package/src/testing/layer.ts +0 -31
  159. package/src/testing/logger.ts +0 -16
  160. package/src/testing/services.ts +0 -168
  161. package/src/trace.ts +0 -180
  162. package/src/translations.ts +0 -20
  163. package/src/types.ts +0 -211
  164. package/src/url.ts +0 -52
@@ -1,68 +1,121 @@
1
- import { BaseError } from '@dxos/errors';
1
+ import { BaseError, type BaseErrorOptions } from '@dxos/errors';
2
2
  declare const ServiceNotAvailableError_base: {
3
- new (message: string, options?: import("@dxos/errors").BaseErrorOptions): {
4
- "__#1@#code": "SERVICE_NOT_AVAILABLE";
5
- "__#1@#context": Record<string, unknown>;
6
- readonly name: "SERVICE_NOT_AVAILABLE";
7
- readonly code: "SERVICE_NOT_AVAILABLE";
8
- readonly _tag: "SERVICE_NOT_AVAILABLE";
9
- readonly context: Record<string, unknown>;
10
- message: string;
3
+ new (options?: BaseErrorOptions): {
4
+ name: "ServiceNotAvailable";
5
+ context: Record<string, unknown>;
6
+ readonly message: string;
7
+ readonly _tag: "ServiceNotAvailable";
11
8
  stack?: string;
12
9
  cause?: unknown;
13
10
  };
14
- code: "SERVICE_NOT_AVAILABLE";
11
+ name: "ServiceNotAvailable";
15
12
  is(error: unknown): error is BaseError;
16
- wrap(message: string, options?: Omit<import("@dxos/errors").BaseErrorOptions, "cause">): (error: unknown) => {
17
- "__#1@#code": "SERVICE_NOT_AVAILABLE";
18
- "__#1@#context": Record<string, unknown>;
19
- readonly name: "SERVICE_NOT_AVAILABLE";
20
- readonly code: "SERVICE_NOT_AVAILABLE";
21
- readonly _tag: "SERVICE_NOT_AVAILABLE";
22
- readonly context: Record<string, unknown>;
23
- message: string;
13
+ wrap(options?: Omit<BaseErrorOptions, "cause"> & {
14
+ ifTypeDiffers?: boolean;
15
+ }): (error: unknown) => {
16
+ name: "ServiceNotAvailable";
17
+ context: Record<string, unknown>;
18
+ readonly message: string;
19
+ readonly _tag: "ServiceNotAvailable";
24
20
  stack?: string;
25
21
  cause?: unknown;
26
22
  };
27
- extend<Code extends string>(code: Code): any;
23
+ extend<Name extends string = string>(name: Name, message?: string): any;
24
+ isError(error: unknown): error is Error;
28
25
  captureStackTrace(targetObject: object, constructorOpt?: Function): void;
29
26
  prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
30
27
  stackTraceLimit: number;
31
28
  };
32
29
  export declare class ServiceNotAvailableError extends ServiceNotAvailableError_base {
33
- constructor(serviceName: string);
30
+ constructor(service: string, options?: Omit<BaseErrorOptions, 'context'>);
31
+ }
32
+ declare const FunctionNotFoundError_base: {
33
+ new (options?: BaseErrorOptions): {
34
+ name: "FunctionNotFound";
35
+ context: Record<string, unknown>;
36
+ readonly message: string;
37
+ readonly _tag: "FunctionNotFound";
38
+ stack?: string;
39
+ cause?: unknown;
40
+ };
41
+ name: "FunctionNotFound";
42
+ is(error: unknown): error is BaseError;
43
+ wrap(options?: Omit<BaseErrorOptions, "cause"> & {
44
+ ifTypeDiffers?: boolean;
45
+ }): (error: unknown) => {
46
+ name: "FunctionNotFound";
47
+ context: Record<string, unknown>;
48
+ readonly message: string;
49
+ readonly _tag: "FunctionNotFound";
50
+ stack?: string;
51
+ cause?: unknown;
52
+ };
53
+ extend<Name extends string = string>(name: Name, message?: string): any;
54
+ isError(error: unknown): error is Error;
55
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
56
+ prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
57
+ stackTraceLimit: number;
58
+ };
59
+ export declare class FunctionNotFoundError extends FunctionNotFoundError_base {
60
+ constructor(functionKey: string, options?: Omit<BaseErrorOptions, 'context'>);
34
61
  }
35
62
  declare const FunctionError_base: {
36
- new (message: string, options?: import("@dxos/errors").BaseErrorOptions): {
37
- "__#1@#code": "FUNCTION_ERROR";
38
- "__#1@#context": Record<string, unknown>;
39
- readonly name: "FUNCTION_ERROR";
40
- readonly code: "FUNCTION_ERROR";
41
- readonly _tag: "FUNCTION_ERROR";
42
- readonly context: Record<string, unknown>;
43
- message: string;
63
+ new (options?: BaseErrorOptions): {
64
+ name: "FunctionError";
65
+ context: Record<string, unknown>;
66
+ readonly message: string;
67
+ readonly _tag: "FunctionError";
44
68
  stack?: string;
45
69
  cause?: unknown;
46
70
  };
47
- code: "FUNCTION_ERROR";
71
+ name: "FunctionError";
48
72
  is(error: unknown): error is BaseError;
49
- wrap(message: string, options?: Omit<import("@dxos/errors").BaseErrorOptions, "cause">): (error: unknown) => {
50
- "__#1@#code": "FUNCTION_ERROR";
51
- "__#1@#context": Record<string, unknown>;
52
- readonly name: "FUNCTION_ERROR";
53
- readonly code: "FUNCTION_ERROR";
54
- readonly _tag: "FUNCTION_ERROR";
55
- readonly context: Record<string, unknown>;
56
- message: string;
73
+ wrap(options?: Omit<BaseErrorOptions, "cause"> & {
74
+ ifTypeDiffers?: boolean;
75
+ }): (error: unknown) => {
76
+ name: "FunctionError";
77
+ context: Record<string, unknown>;
78
+ readonly message: string;
79
+ readonly _tag: "FunctionError";
57
80
  stack?: string;
58
81
  cause?: unknown;
59
82
  };
60
- extend<Code extends string>(code: Code): any;
83
+ extend<Name extends string = string>(name: Name, message?: string): any;
84
+ isError(error: unknown): error is Error;
61
85
  captureStackTrace(targetObject: object, constructorOpt?: Function): void;
62
86
  prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
63
87
  stackTraceLimit: number;
64
88
  };
65
89
  export declare class FunctionError extends FunctionError_base {
66
90
  }
91
+ declare const TriggerStateNotFoundError_base: {
92
+ new (options?: BaseErrorOptions): {
93
+ name: "TriggerStateNotFound";
94
+ context: Record<string, unknown>;
95
+ readonly message: string;
96
+ readonly _tag: "TriggerStateNotFound";
97
+ stack?: string;
98
+ cause?: unknown;
99
+ };
100
+ name: "TriggerStateNotFound";
101
+ is(error: unknown): error is BaseError;
102
+ wrap(options?: Omit<BaseErrorOptions, "cause"> & {
103
+ ifTypeDiffers?: boolean;
104
+ }): (error: unknown) => {
105
+ name: "TriggerStateNotFound";
106
+ context: Record<string, unknown>;
107
+ readonly message: string;
108
+ readonly _tag: "TriggerStateNotFound";
109
+ stack?: string;
110
+ cause?: unknown;
111
+ };
112
+ extend<Name extends string = string>(name: Name, message?: string): any;
113
+ isError(error: unknown): error is Error;
114
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
115
+ prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
116
+ stackTraceLimit: number;
117
+ };
118
+ export declare class TriggerStateNotFoundError extends TriggerStateNotFoundError_base {
119
+ }
67
120
  export {};
68
121
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/errors.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEzC,qBAAa,wBAAyB,SAAQ,6BAAyC;gBACzE,WAAW,EAAE,MAAM;CAGhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAED,qBAAa,aAAc,SAAQ,kBAAkC;CAAG"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/errors.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;;;;;;;;;;;;;qBAiB4O,CAAC;;;;;;;;;;;;;;;AAf7S,qBAAa,wBAAyB,SAAQ,6BAAgE;gBAChG,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,SAAS,CAAC;CAGzE;;;;;;;;;;;;;qBAW2S,CAAC;;;;;;;;;;;;;;;AAT7S,qBAAa,qBAAsB,SAAQ,0BAA0D;gBACvF,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,SAAS,CAAC;CAG7E;;;;;;;;;;;;;qBAK2S,CAAC;;;;;;;;;;;;;;;AAH7S,qBAAa,aAAc,SAAQ,kBAA8D;CAAG;;;;;;;;;;;;;qBAGwM,CAAC;;;;;;;;;;;;;;;AAD7S,qBAAa,yBAA0B,SAAQ,8BAAmE;CAAG"}
@@ -0,0 +1,7 @@
1
+ declare const _default: import("..").FunctionDefinition<{
2
+ readonly iterations?: number | undefined;
3
+ }, {
4
+ readonly result: string;
5
+ }, import("..").FunctionServices>;
6
+ export default _default;
7
+ //# sourceMappingURL=fib.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fib.d.ts","sourceRoot":"","sources":["../../../../src/example/fib.ts"],"names":[],"mappings":";;;;;AASA,wBAsBG"}
@@ -0,0 +1,3 @@
1
+ declare const _default: any;
2
+ export default _default;
3
+ //# sourceMappingURL=forex-effect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forex-effect.d.ts","sourceRoot":"","sources":["../../../../src/example/forex-effect.ts"],"names":[],"mappings":";AAeA,wBAwBG"}
@@ -0,0 +1,12 @@
1
+ export declare namespace Example {
2
+ const fib: import("..").FunctionDefinition<{
3
+ readonly iterations?: number | undefined;
4
+ }, {
5
+ readonly result: string;
6
+ }, import("..").FunctionServices>;
7
+ const reply: import("..").FunctionDefinition<any, any, import("..").FunctionServices>;
8
+ const sleep: import("..").FunctionDefinition<{
9
+ readonly duration?: number | undefined;
10
+ }, void, import("..").FunctionServices>;
11
+ }
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/example/index.ts"],"names":[],"mappings":"AAQA,yBAAiB,OAAO,CAAC;IAChB,MAAM,GAAG;;;;qCAAO,CAAC;IACjB,MAAM,KAAK,0EAAS,CAAC;IACrB,MAAM,KAAK;;2CAAS,CAAC;CAC7B"}
@@ -0,0 +1,3 @@
1
+ declare const _default: import("..").FunctionDefinition<any, any, import("..").FunctionServices>;
2
+ export default _default;
3
+ //# sourceMappingURL=reply.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reply.d.ts","sourceRoot":"","sources":["../../../../src/example/reply.ts"],"names":[],"mappings":";AAUA,wBAUG"}
@@ -0,0 +1,5 @@
1
+ declare const _default: import("..").FunctionDefinition<{
2
+ readonly duration?: number | undefined;
3
+ }, void, import("..").FunctionServices>;
4
+ export default _default;
5
+ //# sourceMappingURL=sleep.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sleep.d.ts","sourceRoot":"","sources":["../../../../src/example/sleep.ts"],"names":[],"mappings":";;;AASA,wBAcG"}
@@ -1,9 +1,7 @@
1
- export * from './handler';
2
- export * from './schema';
3
- export * from './trace';
4
- export * from './types';
5
- export * from './url';
6
- export * from './services';
7
- export * from './executor';
8
1
  export * from './errors';
2
+ export * from './example';
3
+ export * from './sdk';
4
+ export * from './services';
5
+ export * from './types';
6
+ export * from './protocol';
9
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=operation-compatibility.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operation-compatibility.test.d.ts","sourceRoot":"","sources":["../../../src/operation-compatibility.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,12 @@
1
+ import * as HttpClient from '@effect/platform/HttpClient';
2
+ import * as Layer from 'effect/Layer';
3
+ import { type EdgeFunctionEnv } from '@dxos/protocols';
4
+ /**
5
+ * Copy pasted from https://github.com/Effect-TS/effect/blob/main/packages/platform/src/internal/fetchHttpClient.ts
6
+ */
7
+ export declare const requestInitTagKey = "@effect/platform/FetchHttpClient/FetchOptions";
8
+ export declare class FunctionsAiHttpClient {
9
+ static make: (service: EdgeFunctionEnv.FunctionsAiService) => HttpClient.HttpClient;
10
+ static layer: (service: EdgeFunctionEnv.FunctionsAiService) => Layer.Layer<HttpClient.HttpClient, never, never>;
11
+ }
12
+ //# sourceMappingURL=functions-ai-http-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"functions-ai-http-client.d.ts","sourceRoot":"","sources":["../../../../src/protocol/functions-ai-http-client.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,UAAU,MAAM,6BAA6B,CAAC;AAK1D,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAItC,OAAO,EAAE,KAAK,eAAe,EAAc,MAAM,iBAAiB,CAAC;AACnE;;GAEG;AACH,eAAO,MAAM,iBAAiB,kDAAkD,CAAC;AAEjF,qBAAa,qBAAqB;IAChC,MAAM,CAAC,IAAI,GAAI,SAAS,eAAe,CAAC,kBAAkB,2BAyCrD;IAEL,MAAM,CAAC,KAAK,GAAI,SAAS,eAAe,CAAC,kBAAkB,sDACiB;CAC7E"}
@@ -0,0 +1,2 @@
1
+ export * from './protocol';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/protocol/index.ts"],"names":[],"mappings":"AAIA,cAAc,YAAY,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { type FunctionProtocol } from '@dxos/protocols';
2
+ import { FunctionDefinition } from '../sdk';
3
+ /**
4
+ * Wraps a function handler made with `defineFunction` to a protocol that the functions-runtime expects.
5
+ */
6
+ export declare const wrapFunctionHandler: (func: FunctionDefinition) => FunctionProtocol.Func;
7
+ //# sourceMappingURL=protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../../../src/protocol/protocol.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAGxD,OAAO,EAAE,kBAAkB,EAAyB,MAAM,QAAQ,CAAC;AAKnE;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAAI,MAAM,kBAAkB,KAAG,gBAAgB,CAAC,IAwE/E,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=protocol.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.test.d.ts","sourceRoot":"","sources":["../../../../src/protocol/protocol.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,114 @@
1
+ import type * as Context from 'effect/Context';
2
+ import * as Effect from 'effect/Effect';
3
+ import * as Schema from 'effect/Schema';
4
+ import { type AiService } from '@dxos/ai';
5
+ import { Type } from '@dxos/echo';
6
+ import { type Database } from '@dxos/echo';
7
+ import { Operation } from '@dxos/operation';
8
+ import { type CredentialsService, type FunctionInvocationService, type QueueService, type TracingService } from './services';
9
+ import { Function } from './types';
10
+ /**
11
+ * Services that are provided at the function call site by the caller.
12
+ */
13
+ export type InvocationServices = TracingService;
14
+ /**
15
+ * Services that are available to invoked functions.
16
+ */
17
+ export type FunctionServices = InvocationServices | AiService.AiService | CredentialsService | Database.Service | QueueService | FunctionInvocationService;
18
+ /**
19
+ * Function handler.
20
+ */
21
+ export type FunctionHandler<TData = {}, TOutput = any, S extends FunctionServices = FunctionServices> = (params: {
22
+ /**
23
+ * Context available to the function.
24
+ */
25
+ context: FunctionContext;
26
+ /**
27
+ * Data passed as the input to the function.
28
+ * Must match the function's input schema.
29
+ * This will be the payload from the trigger or other data passed into the function in a workflow.
30
+ */
31
+ data: TData;
32
+ }) => TOutput | Promise<TOutput> | Effect.Effect<TOutput, any, S>;
33
+ /**
34
+ * Function context.
35
+ */
36
+ export interface FunctionContext {
37
+ }
38
+ declare const typeId: unique symbol;
39
+ export type FunctionDefinition<T = any, O = any, S extends FunctionServices = FunctionServices> = {
40
+ [typeId]: true;
41
+ key: string;
42
+ name: string;
43
+ description?: string;
44
+ inputSchema: Schema.Schema<T, any>;
45
+ outputSchema?: Schema.Schema<O, any>;
46
+ /**
47
+ * List of types the function uses.
48
+ * This is used to ensure that the types are available when the function is executed.
49
+ */
50
+ types: readonly Type.Entity.Any[];
51
+ /**
52
+ * Keys of the required services.
53
+ */
54
+ services: readonly string[];
55
+ handler: FunctionHandler<T, O, S>;
56
+ meta?: {
57
+ /**
58
+ * Tools that are projected from functions have this annotation.
59
+ *
60
+ * deployedFunctionId:
61
+ * - Backend deployment ID assigned by the EDGE function service (typically a UUID).
62
+ * - Used for remote invocation via `FunctionInvocationService` → `RemoteFunctionExecutionService`.
63
+ * - Persisted on the corresponding ECHO `Function.Function` object's metadata under the
64
+ * `FUNCTIONS_META_KEY` and retrieved with `getUserFunctionIdInMetadata`.
65
+ */
66
+ deployedFunctionId?: string;
67
+ };
68
+ };
69
+ export declare namespace FunctionDefinition {
70
+ type Any = FunctionDefinition<any, any, any>;
71
+ type Input<T extends Any> = T extends FunctionDefinition<infer I, infer _O, infer _S> ? I : never;
72
+ type Output<T extends Any> = T extends FunctionDefinition<infer _I, infer O, infer _S> ? O : never;
73
+ type Services<T extends Any> = T extends FunctionDefinition<infer _I, infer _O, infer S> ? S : never;
74
+ }
75
+ export type FunctionProps<T, O> = {
76
+ key: string;
77
+ name: string;
78
+ description?: string;
79
+ inputSchema: Schema.Schema<T, any>;
80
+ outputSchema?: Schema.Schema<O, any>;
81
+ /**
82
+ * List of types the function uses.
83
+ * This is used to ensure that the types are available when the function is executed.
84
+ */
85
+ types?: readonly Type.Entity.Any[];
86
+ services?: readonly Context.Tag<any, any>[];
87
+ handler: FunctionHandler<T, O, FunctionServices>;
88
+ };
89
+ export declare const defineFunction: {
90
+ <I, O>(params: FunctionProps<I, O>): FunctionDefinition<I, O, FunctionServices>;
91
+ };
92
+ /**
93
+ * Converts a FunctionDefinition to an OperationDefinition with handler.
94
+ * The function handler is adapted to the OperationHandler format.
95
+ *
96
+ * Note: FunctionDefinition stores service keys as strings, not Tag types,
97
+ * so we can't use Operation.withHandler's type inference here.
98
+ */
99
+ export declare const toOperation: <T, O, S extends FunctionServices = FunctionServices>(functionDef: FunctionDefinition<T, O, S>) => Operation.Definition<T, O> & {
100
+ handler: Operation.Handler<T, O, any, S>;
101
+ };
102
+ export declare const FunctionDefinition: {
103
+ make: <I, O>(params: FunctionProps<I, O>) => FunctionDefinition<I, O, FunctionServices>;
104
+ isFunction: (value: unknown) => value is FunctionDefinition.Any;
105
+ serialize: (functionDef: FunctionDefinition.Any) => Function.Function;
106
+ deserialize: (functionObj: Function.Function) => FunctionDefinition.Any;
107
+ toOperation: <T, O, S extends FunctionServices = FunctionServices>(functionDef: FunctionDefinition<T, O, S>) => Operation.Definition<T, O> & {
108
+ handler: Operation.Handler<T, O, any, S>;
109
+ };
110
+ };
111
+ export declare const serializeFunction: (functionDef: FunctionDefinition.Any) => Function.Function;
112
+ export declare const deserializeFunction: (functionObj: Function.Function) => FunctionDefinition<unknown, unknown>;
113
+ export {};
114
+ //# sourceMappingURL=sdk.d.ts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AAM,kBAAkB;WA5G5B,CAAC,EAAE,CAAC,UAAU,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,kBAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,gBAAgB,CAAC;wBA8G3D,OAAO,KAAG,KAAK,IAAI,kBAAkB,CAAC,GAAG;6BAGpC,kBAAkB,CAAC,GAAG,KAAG,QAAQ,CAAC,QAAQ;+BAIxC,QAAQ,CAAC,QAAQ,KAAG,kBAAkB,CAAC,GAAG;kBAlD3C,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,gBAAgB,kCAC7C,kBAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KACvC,SAAS,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;QAAE,OAAO,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAA;KAAE;CAqD3E,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,aAAa,kBAAkB,CAAC,GAAG,KAAG,QAAQ,CAAC,QAchF,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,aAAa,QAAQ,CAAC,QAAQ,KAAG,kBAAkB,CAAC,OAAO,EAAE,OAAO,CAiBvG,CAAC"}
@@ -1,12 +1,18 @@
1
- import { Context, Effect } from 'effect';
2
- type CredentialQuery = {
1
+ import * as HttpClient from '@effect/platform/HttpClient';
2
+ import type * as Config from 'effect/Config';
3
+ import * as Context from 'effect/Context';
4
+ import * as Effect from 'effect/Effect';
5
+ import * as Layer from 'effect/Layer';
6
+ import * as Redacted from 'effect/Redacted';
7
+ import { Database } from '@dxos/echo';
8
+ export type CredentialQuery = {
3
9
  service?: string;
4
10
  };
5
11
  export type ServiceCredential = {
6
12
  service: string;
7
13
  apiKey?: string;
8
14
  };
9
- declare const CredentialsService_base: Context.TagClass<CredentialsService, "CredentialsService", {
15
+ declare const CredentialsService_base: Context.TagClass<CredentialsService, "@dxos/functions/CredentialsService", {
10
16
  /**
11
17
  * Query all.
12
18
  */
@@ -19,6 +25,15 @@ declare const CredentialsService_base: Context.TagClass<CredentialsService, "Cre
19
25
  }>;
20
26
  export declare class CredentialsService extends CredentialsService_base {
21
27
  static getCredential: (query: CredentialQuery) => Effect.Effect<ServiceCredential, never, CredentialsService>;
28
+ static getApiKey: (query: CredentialQuery) => Effect.Effect<Redacted.Redacted<string>, never, CredentialsService>;
29
+ static configuredLayer: (credentials: ServiceCredential[]) => Layer.Layer<CredentialsService, never, never>;
30
+ static layerConfig: (credentials: {
31
+ service: string;
32
+ apiKey: Config.Config<Redacted.Redacted<string>>;
33
+ }[]) => Layer.Layer<CredentialsService, import("effect/ConfigError").ConfigError, never>;
34
+ static layerFromDatabase: ({ caching }?: {
35
+ caching?: boolean;
36
+ }) => Layer.Layer<CredentialsService, never, Database.Service>;
22
37
  }
23
38
  export declare class ConfiguredCredentialsService implements Context.Tag.Service<CredentialsService> {
24
39
  private readonly credentials;
@@ -27,5 +42,9 @@ export declare class ConfiguredCredentialsService implements Context.Tag.Service
27
42
  queryCredentials(query: CredentialQuery): Promise<ServiceCredential[]>;
28
43
  getCredential(query: CredentialQuery): Promise<ServiceCredential>;
29
44
  }
45
+ /**
46
+ * Maps the request to include the given token in the Authorization header.
47
+ */
48
+ export declare const withAuthorization: (token: string, kind?: "Bearer" | "Basic") => <E, R>(self: HttpClient.HttpClient.With<E, R>) => HttpClient.HttpClient.With<E, R>;
30
49
  export {};
31
50
  //# sourceMappingURL=credentials.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../../../src/services/credentials.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEzC,KAAK,eAAe,GAAG;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAIF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,MAA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,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAQxE;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,OAAO,MAAM,EAAE,OAAO,QAAQ,GAAG,OAAO,uFAItE,CAAC"}
@@ -1,37 +1,81 @@
1
- import { Effect, Context } from 'effect';
1
+ import * as Context from 'effect/Context';
2
+ import * as Effect from 'effect/Effect';
3
+ import * as Layer from 'effect/Layer';
4
+ import * as Schema from 'effect/Schema';
5
+ import { Type } from '@dxos/echo';
2
6
  import { LogLevel } from '@dxos/log';
3
- export type ComputeEvent = {
4
- type: 'begin-compute';
5
- nodeId: string;
6
- inputs: Record<string, any>;
7
- } | {
8
- type: 'end-compute';
9
- nodeId: string;
10
- outputs: Record<string, any>;
11
- } | {
12
- type: 'compute-input';
13
- nodeId: string;
14
- property: string;
15
- value: any;
16
- } | {
17
- type: 'compute-output';
18
- nodeId: string;
19
- property: string;
20
- value: any;
21
- } | {
22
- type: 'custom';
23
- nodeId: string;
24
- event: any;
25
- };
26
- declare const EventLogger_base: Context.TagClass<EventLogger, "EventLogger", {
27
- readonly log: (event: ComputeEvent) => void;
7
+ import { TracingService } from './tracing';
8
+ export declare const ComputeEventPayload: Schema.Union<[Schema.Struct<{
9
+ type: Schema.Literal<["begin-compute"]>;
10
+ nodeId: typeof Schema.String;
11
+ /**
12
+ * Names of the inputs begin computed.
13
+ */
14
+ inputs: Schema.Array$<typeof Schema.String>;
15
+ }>, Schema.Struct<{
16
+ type: Schema.Literal<["end-compute"]>;
17
+ nodeId: typeof Schema.String;
18
+ /**
19
+ * Names of the outputs computed.
20
+ */
21
+ outputs: Schema.Array$<typeof Schema.String>;
22
+ }>, Schema.Struct<{
23
+ type: Schema.Literal<["compute-input"]>;
24
+ nodeId: typeof Schema.String;
25
+ property: typeof Schema.String;
26
+ value: typeof Schema.Any;
27
+ }>, Schema.Struct<{
28
+ type: Schema.Literal<["compute-output"]>;
29
+ nodeId: typeof Schema.String;
30
+ property: typeof Schema.String;
31
+ value: typeof Schema.Any;
32
+ }>, Schema.Struct<{
33
+ type: Schema.Literal<["custom"]>;
34
+ nodeId: typeof Schema.String;
35
+ event: typeof Schema.Any;
36
+ }>]>;
37
+ export type ComputeEventPayload = Schema.Schema.Type<typeof ComputeEventPayload>;
38
+ export declare const ComputeEvent: Type.Obj<{
39
+ readonly payload: {
40
+ readonly type: "begin-compute";
41
+ readonly nodeId: string;
42
+ readonly inputs: readonly string[];
43
+ } | {
44
+ readonly type: "end-compute";
45
+ readonly nodeId: string;
46
+ readonly outputs: readonly string[];
47
+ } | {
48
+ readonly value: any;
49
+ readonly type: "compute-input";
50
+ readonly nodeId: string;
51
+ readonly property: string;
52
+ } | {
53
+ readonly value: any;
54
+ readonly type: "compute-output";
55
+ readonly nodeId: string;
56
+ readonly property: string;
57
+ } | {
58
+ readonly type: "custom";
59
+ readonly nodeId: string;
60
+ readonly event: any;
61
+ };
62
+ }, Schema.Struct.Fields>;
63
+ declare const ComputeEventLogger_base: Context.TagClass<ComputeEventLogger, "@dxos/functions/ComputeEventLogger", {
64
+ readonly log: (event: ComputeEventPayload) => void;
28
65
  readonly nodeId: string | undefined;
29
66
  }>;
30
- export declare class EventLogger extends EventLogger_base {
31
- static noop: Context.Tag.Service<EventLogger>;
67
+ /**
68
+ * Logs event for the compute workflows.
69
+ */
70
+ export declare class ComputeEventLogger extends ComputeEventLogger_base {
71
+ static noop: Context.Tag.Service<ComputeEventLogger>;
72
+ /**
73
+ * Implements ComputeEventLogger using TracingService.
74
+ */
75
+ static layerFromTracing: Layer.Layer<ComputeEventLogger, never, TracingService>;
32
76
  }
33
- export declare const logCustomEvent: (data: any) => Effect.Effect<void, never, EventLogger>;
77
+ export declare const logCustomEvent: (data: any) => Effect.Effect<void, never, ComputeEventLogger>;
34
78
  export declare const createDefectLogger: <A, E, R>() => ((self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>);
35
- export declare const createEventLogger: (level: LogLevel, message?: string) => Context.Tag.Service<EventLogger>;
79
+ export declare const createEventLogger: (level: LogLevel, message?: string) => Context.Tag.Service<ComputeEventLogger>;
36
80
  export {};
37
81
  //# sourceMappingURL=event-logger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"event-logger.d.ts","sourceRoot":"","sources":["../../../../src/services/event-logger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAGzC,OAAO,EAAO,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,MAAM,YAAY,GACpB;IACE,IAAI,EAAE,eAAe,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC7B,GACD;IACE,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC9B,GACD;IACE,IAAI,EAAE,eAAe,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,GAAG,CAAC;CACZ,GACD;IACE,IAAI,EAAE,gBAAgB,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,GAAG,CAAC;CACZ,GACD;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,GAAG,CAAC;CACZ,CAAC;;kBAIY,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI;qBAAmB,MAAM,GAAG,SAAS;;AAFpF,qBAAa,WAAY,SAAQ,gBAG9B;IACD,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,CAG3C;CACH;AAED,eAAO,MAAM,cAAc,GAAI,MAAM,GAAG,4CAWpC,CAAC;AAEL,eAAO,MAAM,kBAA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AAC,gBAAgB,yDAWrB;CACH;AAED,eAAO,MAAM,cAAc,GAAI,MAAM,GAAG,mDAWpC,CAAC;AAEL,eAAO,MAAM,kBAAkB,GAAI,CAAC,EAAE,CAAC,EAAE,CAAC,OAAK,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAMrG,CAAC;AAEJ,eAAO,MAAM,iBAAiB,GAC5B,OAAO,QAAQ,EACf,UAAS,MAAgB,KACxB,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,kBAAkB,CAiBxC,CAAC"}
@@ -0,0 +1,16 @@
1
+ import * as Context from 'effect/Context';
2
+ import * as Effect from 'effect/Effect';
3
+ import * as Layer from 'effect/Layer';
4
+ import type { FunctionNotFoundError } from '../errors';
5
+ import { type FunctionDefinition, type InvocationServices } from '../sdk';
6
+ declare const FunctionInvocationService_base: Context.TagClass<FunctionInvocationService, "@dxos/functions/FunctionInvocationService", {
7
+ invokeFunction<I, O>(functionDef: FunctionDefinition<I, O, any>, input: I): Effect.Effect<O, never, InvocationServices>;
8
+ resolveFunction(key: string): Effect.Effect<FunctionDefinition.Any, FunctionNotFoundError>;
9
+ }>;
10
+ export declare class FunctionInvocationService extends FunctionInvocationService_base {
11
+ static layerNotAvailable: Layer.Layer<FunctionInvocationService, never, never>;
12
+ static invokeFunction: <I, O>(functionDef: FunctionDefinition<I, O, any>, input: I) => Effect.Effect<O, never, FunctionInvocationService | InvocationServices>;
13
+ static resolveFunction: (key: string) => Effect.Effect<FunctionDefinition.Any, FunctionNotFoundError, FunctionInvocationService>;
14
+ }
15
+ export {};
16
+ //# sourceMappingURL=function-invocation-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"function-invocation-service.d.ts","sourceRoot":"","sources":["../../../../src/services/function-invocation-service.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,kBAAkB,EAAE,MAAM,QAAQ,CAAC;;mBAKvD,CAAC,EAAE,CAAC,eACJ,kBAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,SACnC,CAAC,GACP,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,kBAAkB,CAAC;yBAEzB,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,GAAG,EAAE,qBAAqB,CAAC;;AAR9F,qBAAa,yBAA0B,SAAQ,8BAU5C;IACD,MAAM,CAAC,iBAAiB,uDAGrB;IAEH,MAAM,CAAC,cAAc,GAAI,CAAC,EAAE,CAAC,EAC3B,aAAa,kBAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,EAC1C,OAAO,CAAC,KACP,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,yBAAyB,GAAG,kBAAkB,CAAC,CACyC;IAEnH,MAAM,CAAC,eAAe,GACpB,KAAK,MAAM,KACV,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,GAAG,EAAE,qBAAqB,EAAE,yBAAyB,CAAC,CACW;CACtG"}