@dxos/functions-runtime-cloudflare 0.8.4-main.66e292d → 0.8.4-main.6fa680abb7
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.
- package/dist/lib/browser/index.mjs +774 -213
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +774 -213
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/functions-client.d.ts +1 -0
- package/dist/types/src/functions-client.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +4 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/internal/data-service-impl.d.ts +8 -7
- package/dist/types/src/internal/data-service-impl.d.ts.map +1 -1
- package/dist/types/src/internal/query-service-impl.d.ts +4 -9
- package/dist/types/src/internal/query-service-impl.d.ts.map +1 -1
- package/dist/types/src/internal/queue-service-impl.d.ts +8 -9
- package/dist/types/src/internal/queue-service-impl.d.ts.map +1 -1
- package/dist/types/src/internal/service-container.d.ts +8 -8
- package/dist/types/src/internal/service-container.d.ts.map +1 -1
- package/dist/types/src/internal/utils.d.ts +2 -0
- package/dist/types/src/internal/utils.d.ts.map +1 -0
- package/dist/types/src/logger.d.ts +2 -0
- package/dist/types/src/logger.d.ts.map +1 -0
- package/dist/types/src/queues-api.d.ts +6 -6
- package/dist/types/src/queues-api.d.ts.map +1 -1
- package/dist/types/src/space-proxy.d.ts +3 -2
- package/dist/types/src/space-proxy.d.ts.map +1 -1
- package/dist/types/src/wrap-handler-for-cloudflare.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +20 -15
- package/src/functions-client.ts +9 -2
- package/src/index.ts +4 -1
- package/src/internal/data-service-impl.ts +67 -18
- package/src/internal/query-service-impl.ts +23 -61
- package/src/internal/queue-service-impl.ts +54 -11
- package/src/internal/service-container.ts +46 -11
- package/src/internal/utils.ts +5 -0
- package/src/logger.ts +42 -0
- package/src/queues-api.ts +6 -6
- package/src/space-proxy.ts +4 -3
- package/src/wrap-handler-for-cloudflare.ts +3 -3
- package/dist/types/src/internal/adapter.d.ts +0 -12
- package/dist/types/src/internal/adapter.d.ts.map +0 -1
- package/src/internal/adapter.ts +0 -48
|
@@ -22,7 +22,6 @@ export const wrapHandlerForCloudflare = (func: FunctionProtocol.Func): ExportedH
|
|
|
22
22
|
// TODO(mykola): Wrap in withNewExecutionContext;
|
|
23
23
|
// Meta route is used to get the input schema of the function by the functions service.
|
|
24
24
|
if (request.headers.get(FUNCTION_ROUTE_HEADER) === FunctionRouteValue.Meta) {
|
|
25
|
-
log.info('>>> meta', { func });
|
|
26
25
|
return handleFunctionMetaCall(func, request);
|
|
27
26
|
}
|
|
28
27
|
|
|
@@ -34,7 +33,7 @@ export const wrapHandlerForCloudflare = (func: FunctionProtocol.Func): ExportedH
|
|
|
34
33
|
}
|
|
35
34
|
}
|
|
36
35
|
|
|
37
|
-
const serviceContainer = new ServiceContainer({}, env.DATA_SERVICE, env.QUEUE_SERVICE);
|
|
36
|
+
const serviceContainer = new ServiceContainer({}, env.DATA_SERVICE, env.QUEUE_SERVICE, env.FUNCTIONS_AI_SERVICE);
|
|
38
37
|
const context = await createFunctionContext({
|
|
39
38
|
serviceContainer,
|
|
40
39
|
contextSpaceId: spaceId as SpaceId | undefined,
|
|
@@ -105,7 +104,7 @@ const createFunctionContext = async ({
|
|
|
105
104
|
serviceContainer: ServiceContainer;
|
|
106
105
|
contextSpaceId: SpaceId | undefined;
|
|
107
106
|
}): Promise<FunctionProtocol.Context> => {
|
|
108
|
-
const { dataService, queryService, queueService } = await serviceContainer.createServices();
|
|
107
|
+
const { dataService, queryService, queueService, functionsAiService } = await serviceContainer.createServices();
|
|
109
108
|
|
|
110
109
|
let spaceKey: string | undefined;
|
|
111
110
|
let rootUrl: string | undefined;
|
|
@@ -124,6 +123,7 @@ const createFunctionContext = async ({
|
|
|
124
123
|
dataService,
|
|
125
124
|
queryService,
|
|
126
125
|
queueService,
|
|
126
|
+
functionsAiService,
|
|
127
127
|
},
|
|
128
128
|
spaceId: contextSpaceId,
|
|
129
129
|
spaceKey,
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type QueryAST } from '@dxos/echo-protocol';
|
|
2
|
-
import { type EdgeFunctionEnv } from '@dxos/protocols';
|
|
3
|
-
export declare const queryToDataServiceRequest: (query: QueryAST.Query) => EdgeFunctionEnv.QueryRequest;
|
|
4
|
-
/**
|
|
5
|
-
* Extracts the filter and options from a query.
|
|
6
|
-
* Supports Select(...) and Options(Select(...)) queries.
|
|
7
|
-
*/
|
|
8
|
-
export declare const isSimpleSelectionQuery: (query: QueryAST.Query) => {
|
|
9
|
-
filter: QueryAST.Filter;
|
|
10
|
-
options?: QueryAST.QueryOptions;
|
|
11
|
-
} | null;
|
|
12
|
-
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../src/internal/adapter.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,eAAO,MAAM,yBAAyB,GAAI,OAAO,QAAQ,CAAC,KAAK,KAAG,eAAe,CAAC,YAajF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,sBAAsB,GACjC,OAAO,QAAQ,CAAC,KAAK,KACpB;IAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,YAAY,CAAA;CAAE,GAAG,IAgBjE,CAAC"}
|
package/src/internal/adapter.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { failUndefined } from '@dxos/debug';
|
|
6
|
-
import { type QueryAST } from '@dxos/echo-protocol';
|
|
7
|
-
import { invariant } from '@dxos/invariant';
|
|
8
|
-
import { SpaceId } from '@dxos/keys';
|
|
9
|
-
import { type EdgeFunctionEnv } from '@dxos/protocols';
|
|
10
|
-
|
|
11
|
-
export const queryToDataServiceRequest = (query: QueryAST.Query): EdgeFunctionEnv.QueryRequest => {
|
|
12
|
-
const { filter, options } = isSimpleSelectionQuery(query) ?? failUndefined();
|
|
13
|
-
invariant(options?.spaceIds?.length === 1, 'Only one space is supported');
|
|
14
|
-
invariant(filter.type === 'object', 'Only object filters are supported');
|
|
15
|
-
|
|
16
|
-
const spaceId = options.spaceIds[0];
|
|
17
|
-
invariant(SpaceId.isValid(spaceId));
|
|
18
|
-
|
|
19
|
-
return {
|
|
20
|
-
spaceId,
|
|
21
|
-
type: filter.typename ?? undefined,
|
|
22
|
-
objectIds: [...(filter.id ?? [])],
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Extracts the filter and options from a query.
|
|
28
|
-
* Supports Select(...) and Options(Select(...)) queries.
|
|
29
|
-
*/
|
|
30
|
-
export const isSimpleSelectionQuery = (
|
|
31
|
-
query: QueryAST.Query,
|
|
32
|
-
): { filter: QueryAST.Filter; options?: QueryAST.QueryOptions } | null => {
|
|
33
|
-
switch (query.type) {
|
|
34
|
-
case 'options': {
|
|
35
|
-
const maybeFilter = isSimpleSelectionQuery(query.query);
|
|
36
|
-
if (!maybeFilter) {
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
return { filter: maybeFilter.filter, options: query.options };
|
|
40
|
-
}
|
|
41
|
-
case 'select': {
|
|
42
|
-
return { filter: query.filter, options: undefined };
|
|
43
|
-
}
|
|
44
|
-
default: {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
};
|