@3sixty/data-processing-service 0.20.0-next.0 → 0.20.0-next.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.
- package/dist/es/dataProcessingRoutes.js.map +1 -1
- package/dist/es/dataProcessingService.js.map +1 -1
- package/dist/es/entities/extractionRule.js.map +1 -1
- package/dist/es/entities/extractionRuleGroup.js.map +1 -1
- package/dist/es/index.js.map +1 -1
- package/dist/es/models/IDataProcessingServiceConstructorOptions.js.map +1 -1
- package/dist/es/restEntryPoints.js.map +1 -1
- package/dist/es/schema.js.map +1 -1
- package/docs/changelog.md +19 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataProcessingRoutes.js","sourceRoot":"","sources":["../../src/dataProcessingRoutes.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,aAAa,EAKb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAgBvF,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C;;GAEG;AACH,MAAM,aAAa,GAAG,sBAAsB,CAAC;AAE7C;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAW;IACzC;QACC,IAAI,EAAE,iBAAiB;QACvB,WAAW,EAAE,oEAAoE;KACjF;CACD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,gCAAgC,CAC/C,aAAqB,EACrB,aAAqB;IAErB,MAAM,iBAAiB,GAAuE;QAC7F,WAAW,EAAE,4BAA4B;QACzC,OAAO,EAAE,oCAAoC;QAC7C,GAAG,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC,IAAI;QAC/B,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,GAAG,aAAa,iBAAiB;QACvC,OAAO,EAAE,KAAK,EAAE,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AqB,EAClC,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAC7B,CAAC;IAEF,OAAO;QACN,IAAI,EAAE,MAAM;KACZ,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAC1C,kBAAuC,EACvC,aAAqB,EACrB,OAAsC;IAEtC,MAAM,CAAC,MAAM,CAAgC,aAAa,aAAmB,OAAO,CAAC,CAAC;IACtF,MAAM,CAAC,MAAM,CACZ,aAAa,kBAEb,OAAO,CAAC,IAAI,CACZ,CAAC;IACF,MAAM,CAAC,YAAY,CAAC,aAAa,uBAA6B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEjF,MAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,CAA2B,aAAa,CAAC,CAAC;IAChF,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,OAAO,CACrC,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAC1C,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAC7B,CAAC;IAEF,OAAO;QACN,IAAI,EAAE,MAAM;KACZ,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAClC,kBAAuC,EACvC,aAAqB,EACrB,OAA4C;IAE5C,MAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,CAA2B,aAAa,CAAC,CAAC;IAEhF,MAAM,cAAc,GAAG,MAAM,SAAS,CAAC,KAAK,CAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,EACtB,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,CACpC,CAAC;IACF,OAAO;QACN,IAAI,EAAE,cAAc;KACpB,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tHttpBodyLimit,\n\ttype IHttpRequestContext,\n\ttype INoContentResponse,\n\ttype IRestRoute,\n\ttype ITag\n} from \"@3sixty/api-models\";\nimport { Coerce, CoerceType, ComponentFactory, Converter, Guards } from \"@3sixty/core\";\nimport type {\n\tIDataProcessingComponent,\n\tIDataProcessingConvertRequest,\n\tIDataProcessingConvertResponse,\n\tIDataProcessingExtractRequest,\n\tIDataProcessingExtractResponse,\n\tIDataProcessingRuleGroupGetRequest,\n\tIDataProcessingRuleGroupGetResponse,\n\tIDataProcessingRuleGroupListRequest,\n\tIDataProcessingRuleGroupListResponse,\n\tIDataProcessingRuleGroupRemoveRequest,\n\tIDataProcessingRuleGroupSetRequest,\n\tIRule\n} from \"@3sixty/data-processing-models\";\nimport { nameof } from \"@3sixty/nameof\";\nimport { HttpStatusCode } from \"@3sixty/web\";\n\n/**\n * The source used when communicating about these routes.\n */\nconst ROUTES_SOURCE = \"dataProcessingRoutes\";\n\n/**\n * The tag to associate with the routes.\n */\nexport const tagsDataProcessing: ITag[] = [\n\t{\n\t\tname: \"Data Processing\",\n\t\tdescription: \"Endpoints which are modelled to access a data processing contract.\"\n\t}\n];\n\n/**\n * The REST routes for data processing.\n * @param baseRouteName Prefix to prepend to the paths.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @returns The generated routes.\n */\nexport function generateRestRoutesDataProcessing(\n\tbaseRouteName: string,\n\tcomponentName: string\n): IRestRoute[] {\n\tconst setRuleGroupRoute: IRestRoute<IDataProcessingRuleGroupSetRequest, INoContentResponse> = {\n\t\toperationId: \"dataProcessingSetRuleGroup\",\n\t\tsummary: \"Store a rule group for extraction.\",\n\t\ttag: tagsDataProcessing[0].name,\n\t\tmethod: \"PUT\",\n\t\tpath: `${baseRouteName}/rule-group/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tdataProcessingSetRuleGroup(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IDataProcessingRuleGroupSetRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"dataProcessingRuleGroupSetRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"my-rule-group\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\tlabel: \"My Rule Group\",\n\t\t\t\t\t\t\trules: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tsource: \"$.foo\",\n\t\t\t\t\t\t\t\t\ttarget: \"goo\",\n\t\t\t\t\t\t\t\t\tcoerce: CoerceType.BigInt\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<INoContentResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"dataProcessingRuleGroupSetResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tstatusCode: HttpStatusCode.noContent\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\tconst getRuleGroupRoute: IRestRoute<\n\t\tIDataProcessingRuleGroupGetRequest,\n\t\tIDataProcessingRuleGroupGetResponse\n\t> = {\n\t\toperationId: \"dataProcessingGetRuleGroup\",\n\t\tsummary: \"Get a rule group for extraction.\",\n\t\ttag: tagsDataProcessing[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/rule-group/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tdataProcessingGetRuleGroup(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IDataProcessingRuleGroupGetRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"dataProcessingRuleGroupGetRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"my-rule-group\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<IDataProcessingRuleGroupGetResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"dataProcessingRuleGroupSetResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\tid: \"my-rule-group\",\n\t\t\t\t\t\t\t\tlabel: \"My Rule Group\",\n\t\t\t\t\t\t\t\trules: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tsource: \"$.foo\",\n\t\t\t\t\t\t\t\t\t\ttarget: \"goo\",\n\t\t\t\t\t\t\t\t\t\tcoerce: CoerceType.BigInt\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\tconst removeRuleGroupRoute: IRestRoute<\n\t\tIDataProcessingRuleGroupRemoveRequest,\n\t\tINoContentResponse\n\t> = {\n\t\toperationId: \"dataProcessingRemoveRuleGroup\",\n\t\tsummary: \"Remove an extraction rule group.\",\n\t\ttag: tagsDataProcessing[0].name,\n\t\tmethod: \"DELETE\",\n\t\tpath: `${baseRouteName}/rule-group/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tdataProcessingRemoveRuleGroup(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IDataProcessingRuleGroupRemoveRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"dataProcessingRuleGroupRemoveRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"my-rule-group\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<INoContentResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"dataProcessingRuleGroupRemoveResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tstatusCode: HttpStatusCode.noContent\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\tconst extractRoute: IRestRoute<IDataProcessingExtractRequest, IDataProcessingExtractResponse> = {\n\t\toperationId: \"dataProcessingExtract\",\n\t\tsummary: \"Extract data from a binary source using the specified rule group.\",\n\t\ttag: tagsDataProcessing[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/extract`,\n\t\tbodyLimit: HttpBodyLimit.Large,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tdataProcessingExtract(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IDataProcessingExtractRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"dataProcessingExtractRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\truleGroupId: \"my-rule-group\",\n\t\t\t\t\t\t\tdata: \"eyJmb28iOiAiYmFyIn0=\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<IDataProcessingExtractResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"dataProcessingExtractResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: { foo: \"bar\" }\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\tconst convertRoute: IRestRoute<IDataProcessingConvertRequest, IDataProcessingConvertResponse> = {\n\t\toperationId: \"dataProcessingConvert\",\n\t\tsummary: \"Convert data from a binary source and return structured object.\",\n\t\ttag: tagsDataProcessing[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/convert`,\n\t\tbodyLimit: HttpBodyLimit.Large,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tdataProcessingConvert(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IDataProcessingConvertRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"dataProcessingConvertRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\tdata: \"eyJmb28iOiAiYmFyIn0=\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<IDataProcessingConvertResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"dataProcessingConvertResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: { foo: \"bar\" }\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\tconst getRuleGroupListRoute: IRestRoute<\n\t\tIDataProcessingRuleGroupListRequest,\n\t\tIDataProcessingRuleGroupListResponse\n\t> = {\n\t\toperationId: \"dataProcessingListRuleGroup\",\n\t\tsummary: \"Get a list with rule groups for extraction.\",\n\t\ttag: tagsDataProcessing[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/rule-group`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\truleGroupList(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IDataProcessingRuleGroupGetRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"ruleGroupListRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tquery: {\n\t\t\t\t\t\t\tlimit: \"10\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<IDataProcessingRuleGroupListResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"ruleGroupListResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\tentities: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: \"my-rule-group\",\n\t\t\t\t\t\t\t\t\t\tlabel: \"My Rule Group\",\n\t\t\t\t\t\t\t\t\t\trules: [\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tsource: \"$.foo\",\n\t\t\t\t\t\t\t\t\t\t\t\ttarget: \"goo\",\n\t\t\t\t\t\t\t\t\t\t\t\tcoerce: CoerceType.BigInt\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\tcursor: \"1\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\treturn [\n\t\tsetRuleGroupRoute,\n\t\tgetRuleGroupRoute,\n\t\tremoveRuleGroupRoute,\n\t\textractRoute,\n\t\tconvertRoute,\n\t\tgetRuleGroupListRoute\n\t];\n}\n\n/**\n * Store an extraction rule group.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function dataProcessingSetRuleGroup(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IDataProcessingRuleGroupSetRequest\n): Promise<INoContentResponse> {\n\tGuards.object<IDataProcessingRuleGroupSetRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IDataProcessingRuleGroupSetRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.object<IDataProcessingRuleGroupSetRequest[\"body\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.body),\n\t\trequest.body\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.body.label), request.body.label);\n\tGuards.array<IRule>(ROUTES_SOURCE, nameof(request.body.rules), request.body.rules);\n\n\tconst component = ComponentFactory.get<IDataProcessingComponent>(componentName);\n\tawait component.ruleGroupSet({\n\t\tid: request.pathParams.id,\n\t\tlabel: request.body.label,\n\t\trules: request.body.rules\n\t});\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n\n/**\n * Get an extraction rule group.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function dataProcessingGetRuleGroup(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IDataProcessingRuleGroupGetRequest\n): Promise<IDataProcessingRuleGroupGetResponse> {\n\tGuards.object<IDataProcessingRuleGroupGetRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IDataProcessingRuleGroupGetRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\n\tconst component = ComponentFactory.get<IDataProcessingComponent>(componentName);\n\tconst result = await component.ruleGroupGet(request.pathParams.id);\n\n\treturn {\n\t\tbody: result\n\t};\n}\n\n/**\n * Remove an extraction rule group.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function dataProcessingRemoveRuleGroup(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IDataProcessingRuleGroupRemoveRequest\n): Promise<INoContentResponse> {\n\tGuards.object<IDataProcessingRuleGroupGetRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IDataProcessingRuleGroupGetRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\n\tconst component = ComponentFactory.get<IDataProcessingComponent>(componentName);\n\tawait component.ruleGroupRemove(request.pathParams.id);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n\n/**\n * Extract data using the specified rule group.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function dataProcessingExtract(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IDataProcessingExtractRequest\n): Promise<IDataProcessingExtractResponse> {\n\tGuards.object<IDataProcessingExtractRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IDataProcessingExtractRequest[\"body\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.body),\n\t\trequest.body\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.body.ruleGroupId), request.body.ruleGroupId);\n\tGuards.stringBase64(ROUTES_SOURCE, nameof(request.body.data), request.body.data);\n\n\tconst component = ComponentFactory.get<IDataProcessingComponent>(componentName);\n\tconst result = await component.extract(\n\t\trequest.body.ruleGroupId,\n\t\tConverter.base64ToBytes(request.body.data),\n\t\trequest.body.overrideExtractorType,\n\t\trequest.body.overrideMimeType\n\t);\n\n\treturn {\n\t\tbody: result\n\t};\n}\n\n/**\n * Convert data using the specified rule group.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function dataProcessingConvert(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IDataProcessingConvertRequest\n): Promise<IDataProcessingConvertResponse> {\n\tGuards.object<IDataProcessingConvertRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IDataProcessingConvertRequest[\"body\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.body),\n\t\trequest.body\n\t);\n\tGuards.stringBase64(ROUTES_SOURCE, nameof(request.body.data), request.body.data);\n\n\tconst component = ComponentFactory.get<IDataProcessingComponent>(componentName);\n\tconst result = await component.convert(\n\t\tConverter.base64ToBytes(request.body.data),\n\t\trequest.body.overrideMimeType\n\t);\n\n\treturn {\n\t\tbody: result\n\t};\n}\n\n/**\n * Get a list of the rule group entries.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function ruleGroupList(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IDataProcessingRuleGroupListRequest\n): Promise<IDataProcessingRuleGroupListResponse> {\n\tconst component = ComponentFactory.get<IDataProcessingComponent>(componentName);\n\n\tconst itemsAndCursor = await component.query(\n\t\trequest?.query?.cursor,\n\t\tCoerce.number(request?.query?.limit)\n\t);\n\treturn {\n\t\tbody: itemsAndCursor\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dataProcessingRoutes.js","sources":["../../src/dataProcessingRoutes.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,aAAa,EAKb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAgBvF,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C;;GAEG;AAC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B,aAAa,CAAC,CAAC;IAChF,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,OAAO,CACrC,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAC1C,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAC7B,CAAC;IAEF,OAAO;QACN,IAAI,EAAE,MAAM;KACZ,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAClC,kBAAuC,EACvC,aAAqB,EACrB,OAA4C;IAE5C,MAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,CAA2B,aAAa,CAAC,CAAC;IAEhF,MAAM,cAAc,GAAG,MAAM,SAAS,CAAC,KAAK,CAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,EACtB,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,CACpC,CAAC;IACF,OAAO;QACN,IAAI,EAAE,cAAc;KACpB,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tHttpBodyLimit,\n\ttype IHttpRequestContext,\n\ttype INoContentResponse,\n\ttype IRestRoute,\n\ttype ITag\n} from \"@3sixty/api-models\";\nimport { Coerce, CoerceType, ComponentFactory, Converter, Guards } from \"@3sixty/core\";\nimport type {\n\tIDataProcessingComponent,\n\tIDataProcessingConvertRequest,\n\tIDataProcessingConvertResponse,\n\tIDataProcessingExtractRequest,\n\tIDataProcessingExtractResponse,\n\tIDataProcessingRuleGroupGetRequest,\n\tIDataProcessingRuleGroupGetResponse,\n\tIDataProcessingRuleGroupListRequest,\n\tIDataProcessingRuleGroupListResponse,\n\tIDataProcessingRuleGroupRemoveRequest,\n\tIDataProcessingRuleGroupSetRequest,\n\tIRule\n} from \"@3sixty/data-processing-models\";\n\nimport { HttpStatusCode } from \"@3sixty/web\";\n\n/**\n * The source used when communicating about these routes.\n */\nconst ROUTES_SOURCE = \"dataProcessingRoutes\";\n\n/**\n * The tag to associate with the routes.\n */\nexport const tagsDataProcessing: ITag[] = [\n\t{\n\t\tname: \"Data Processing\",\n\t\tdescription: \"Endpoints which are modelled to access a data processing contract.\"\n\t}\n];\n\n/**\n * The REST routes for data processing.\n * @param baseRouteName Prefix to prepend to the paths.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @returns The generated routes.\n */\nexport function generateRestRoutesDataProcessing(\n\tbaseRouteName: string,\n\tcomponentName: string\n): IRestRoute[] {\n\tconst setRuleGroupRoute: IRestRoute<IDataProcessingRuleGroupSetRequest, INoContentResponse> = {\n\t\toperationId: \"dataProcessingSetRuleGroup\",\n\t\tsummary: \"Store a rule group for extraction.\",\n\t\ttag: tagsDataProcessing[0].name,\n\t\tmethod: \"PUT\",\n\t\tpath: `${baseRouteName}/rule-group/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tdataProcessingSetRuleGroup(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: \"IDataProcessingRuleGroupSetRequest\",\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"dataProcessingRuleGroupSetRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"my-rule-group\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\tlabel: \"My Rule Group\",\n\t\t\t\t\t\t\trules: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tsource: \"$.foo\",\n\t\t\t\t\t\t\t\t\ttarget: \"goo\",\n\t\t\t\t\t\t\t\t\tcoerce: CoerceType.BigInt\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: \"INoContentResponse\",\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"dataProcessingRuleGroupSetResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tstatusCode: HttpStatusCode.noContent\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\tconst getRuleGroupRoute: IRestRoute<\n\t\tIDataProcessingRuleGroupGetRequest,\n\t\tIDataProcessingRuleGroupGetResponse\n\t> = {\n\t\toperationId: \"dataProcessingGetRuleGroup\",\n\t\tsummary: \"Get a rule group for extraction.\",\n\t\ttag: tagsDataProcessing[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/rule-group/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tdataProcessingGetRuleGroup(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: \"IDataProcessingRuleGroupGetRequest\",\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"dataProcessingRuleGroupGetRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"my-rule-group\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: \"IDataProcessingRuleGroupGetResponse\",\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"dataProcessingRuleGroupSetResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\tid: \"my-rule-group\",\n\t\t\t\t\t\t\t\tlabel: \"My Rule Group\",\n\t\t\t\t\t\t\t\trules: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tsource: \"$.foo\",\n\t\t\t\t\t\t\t\t\t\ttarget: \"goo\",\n\t\t\t\t\t\t\t\t\t\tcoerce: CoerceType.BigInt\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\tconst removeRuleGroupRoute: IRestRoute<\n\t\tIDataProcessingRuleGroupRemoveRequest,\n\t\tINoContentResponse\n\t> = {\n\t\toperationId: \"dataProcessingRemoveRuleGroup\",\n\t\tsummary: \"Remove an extraction rule group.\",\n\t\ttag: tagsDataProcessing[0].name,\n\t\tmethod: \"DELETE\",\n\t\tpath: `${baseRouteName}/rule-group/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tdataProcessingRemoveRuleGroup(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: \"IDataProcessingRuleGroupRemoveRequest\",\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"dataProcessingRuleGroupRemoveRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"my-rule-group\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: \"INoContentResponse\",\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"dataProcessingRuleGroupRemoveResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tstatusCode: HttpStatusCode.noContent\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\tconst extractRoute: IRestRoute<IDataProcessingExtractRequest, IDataProcessingExtractResponse> = {\n\t\toperationId: \"dataProcessingExtract\",\n\t\tsummary: \"Extract data from a binary source using the specified rule group.\",\n\t\ttag: tagsDataProcessing[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/extract`,\n\t\tbodyLimit: HttpBodyLimit.Large,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tdataProcessingExtract(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: \"IDataProcessingExtractRequest\",\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"dataProcessingExtractRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\truleGroupId: \"my-rule-group\",\n\t\t\t\t\t\t\tdata: \"eyJmb28iOiAiYmFyIn0=\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: \"IDataProcessingExtractResponse\",\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"dataProcessingExtractResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: { foo: \"bar\" }\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\tconst convertRoute: IRestRoute<IDataProcessingConvertRequest, IDataProcessingConvertResponse> = {\n\t\toperationId: \"dataProcessingConvert\",\n\t\tsummary: \"Convert data from a binary source and return structured object.\",\n\t\ttag: tagsDataProcessing[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/convert`,\n\t\tbodyLimit: HttpBodyLimit.Large,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tdataProcessingConvert(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: \"IDataProcessingConvertRequest\",\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"dataProcessingConvertRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\tdata: \"eyJmb28iOiAiYmFyIn0=\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: \"IDataProcessingConvertResponse\",\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"dataProcessingConvertResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: { foo: \"bar\" }\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\tconst getRuleGroupListRoute: IRestRoute<\n\t\tIDataProcessingRuleGroupListRequest,\n\t\tIDataProcessingRuleGroupListResponse\n\t> = {\n\t\toperationId: \"dataProcessingListRuleGroup\",\n\t\tsummary: \"Get a list with rule groups for extraction.\",\n\t\ttag: tagsDataProcessing[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/rule-group`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\truleGroupList(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: \"IDataProcessingRuleGroupGetRequest\",\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"ruleGroupListRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tquery: {\n\t\t\t\t\t\t\tlimit: \"10\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: \"IDataProcessingRuleGroupListResponse\",\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"ruleGroupListResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\tentities: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tid: \"my-rule-group\",\n\t\t\t\t\t\t\t\t\t\tlabel: \"My Rule Group\",\n\t\t\t\t\t\t\t\t\t\trules: [\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\tsource: \"$.foo\",\n\t\t\t\t\t\t\t\t\t\t\t\ttarget: \"goo\",\n\t\t\t\t\t\t\t\t\t\t\t\tcoerce: CoerceType.BigInt\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\tcursor: \"1\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\treturn [\n\t\tsetRuleGroupRoute,\n\t\tgetRuleGroupRoute,\n\t\tremoveRuleGroupRoute,\n\t\textractRoute,\n\t\tconvertRoute,\n\t\tgetRuleGroupListRoute\n\t];\n}\n\n/**\n * Store an extraction rule group.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function dataProcessingSetRuleGroup(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IDataProcessingRuleGroupSetRequest\n): Promise<INoContentResponse> {\n\tGuards.object<IDataProcessingRuleGroupSetRequest>(ROUTES_SOURCE, \"request\", request);\n\tGuards.object<IDataProcessingRuleGroupSetRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\t\"request.pathParams\",\n\t\trequest.pathParams\n\t);\n\tGuards.object<IDataProcessingRuleGroupSetRequest[\"body\"]>(\n\t\tROUTES_SOURCE,\n\t\t\"request.body\",\n\t\trequest.body\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, \"request.pathParams.id\", request.pathParams.id);\n\tGuards.stringValue(ROUTES_SOURCE, \"request.body.label\", request.body.label);\n\tGuards.array<IRule>(ROUTES_SOURCE, \"request.body.rules\", request.body.rules);\n\n\tconst component = ComponentFactory.get<IDataProcessingComponent>(componentName);\n\tawait component.ruleGroupSet({\n\t\tid: request.pathParams.id,\n\t\tlabel: request.body.label,\n\t\trules: request.body.rules\n\t});\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n\n/**\n * Get an extraction rule group.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function dataProcessingGetRuleGroup(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IDataProcessingRuleGroupGetRequest\n): Promise<IDataProcessingRuleGroupGetResponse> {\n\tGuards.object<IDataProcessingRuleGroupGetRequest>(ROUTES_SOURCE, \"request\", request);\n\tGuards.object<IDataProcessingRuleGroupGetRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\t\"request.pathParams\",\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, \"request.pathParams.id\", request.pathParams.id);\n\n\tconst component = ComponentFactory.get<IDataProcessingComponent>(componentName);\n\tconst result = await component.ruleGroupGet(request.pathParams.id);\n\n\treturn {\n\t\tbody: result\n\t};\n}\n\n/**\n * Remove an extraction rule group.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function dataProcessingRemoveRuleGroup(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IDataProcessingRuleGroupRemoveRequest\n): Promise<INoContentResponse> {\n\tGuards.object<IDataProcessingRuleGroupGetRequest>(ROUTES_SOURCE, \"request\", request);\n\tGuards.object<IDataProcessingRuleGroupGetRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\t\"request.pathParams\",\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, \"request.pathParams.id\", request.pathParams.id);\n\n\tconst component = ComponentFactory.get<IDataProcessingComponent>(componentName);\n\tawait component.ruleGroupRemove(request.pathParams.id);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n\n/**\n * Extract data using the specified rule group.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function dataProcessingExtract(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IDataProcessingExtractRequest\n): Promise<IDataProcessingExtractResponse> {\n\tGuards.object<IDataProcessingExtractRequest>(ROUTES_SOURCE, \"request\", request);\n\tGuards.object<IDataProcessingExtractRequest[\"body\"]>(\n\t\tROUTES_SOURCE,\n\t\t\"request.body\",\n\t\trequest.body\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, \"request.body.ruleGroupId\", request.body.ruleGroupId);\n\tGuards.stringBase64(ROUTES_SOURCE, \"request.body.data\", request.body.data);\n\n\tconst component = ComponentFactory.get<IDataProcessingComponent>(componentName);\n\tconst result = await component.extract(\n\t\trequest.body.ruleGroupId,\n\t\tConverter.base64ToBytes(request.body.data),\n\t\trequest.body.overrideExtractorType,\n\t\trequest.body.overrideMimeType\n\t);\n\n\treturn {\n\t\tbody: result\n\t};\n}\n\n/**\n * Convert data using the specified rule group.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function dataProcessingConvert(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IDataProcessingConvertRequest\n): Promise<IDataProcessingConvertResponse> {\n\tGuards.object<IDataProcessingConvertRequest>(ROUTES_SOURCE, \"request\", request);\n\tGuards.object<IDataProcessingConvertRequest[\"body\"]>(\n\t\tROUTES_SOURCE,\n\t\t\"request.body\",\n\t\trequest.body\n\t);\n\tGuards.stringBase64(ROUTES_SOURCE, \"request.body.data\", request.body.data);\n\n\tconst component = ComponentFactory.get<IDataProcessingComponent>(componentName);\n\tconst result = await component.convert(\n\t\tConverter.base64ToBytes(request.body.data),\n\t\trequest.body.overrideMimeType\n\t);\n\n\treturn {\n\t\tbody: result\n\t};\n}\n\n/**\n * Get a list of the rule group entries.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function ruleGroupList(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IDataProcessingRuleGroupListRequest\n): Promise<IDataProcessingRuleGroupListResponse> {\n\tconst component = ComponentFactory.get<IDataProcessingComponent>(componentName);\n\n\tconst itemsAndCursor = await component.query(\n\t\trequest?.query?.cursor,\n\t\tCoerce.number(request?.query?.limit)\n\t);\n\treturn {\n\t\tbody: itemsAndCursor\n\t};\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataProcessingService.js","sourceRoot":"","sources":["../../src/dataProcessingService.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACrF,OAAO,EACN,6BAA6B,EAC7B,6BAA6B,EAK7B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EACN,6BAA6B,EAE7B,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAI7C;;GAEG;AACH,MAAM,OAAO,qBAAqB;IACjC;;OAEG;IACI,MAAM,CAAU,UAAU,2BAA2C;IAE5E;;;OAGG;IACc,2BAA2B,CAA+C;IAE3F;;;OAGG;IACc,mBAAmB,CAA0B;IAE9D;;;;OAIG;IACH,YAAY,OAAkD;QAC7D,IAAI,CAAC,2BAA2B,GAAG,6BAA6B,CAAC,GAAG,CACnE,OAAO,EAAE,uCAAuC,IAAI,uBAAuB,CAC3E,CAAC;QAEF,IAAI,EAAE,CAAC,WAAW,CAAC,OAAO,EAAE,oBAAoB,CAAC,EAAE,CAAC;YACnD,IAAI,CAAC,mBAAmB,GAAG,6BAA6B,CAAC,GAAG,CAAC,OAAO,CAAC,oB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DX-License-Identifier: Apache-2.0.\nimport { GeneralError, Guards, Is, NotFoundError, ObjectHelper } from \"@3sixty/core\";\nimport {\n\tDataConverterConnectorFactory,\n\tDataExtractorConnectorFactory,\n\ttype IDataExtractorConnector,\n\ttype IDataProcessingComponent,\n\ttype IRule,\n\ttype IRuleGroup\n} from \"@3sixty/data-processing-models\";\nimport { SortDirection } from \"@3sixty/entity\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@3sixty/entity-storage-models\";\nimport { nameof } from \"@3sixty/nameof\";\nimport { MimeTypeHelper } from \"@3sixty/web\";\nimport type { ExtractionRuleGroup } from \"./entities/extractionRuleGroup.js\";\nimport type { IDataProcessingServiceConstructorOptions } from \"./models/IDataProcessingServiceConstructorOptions.js\";\n\n/**\n * Class for processing data from a source.\n */\nexport class DataProcessingService implements IDataProcessingComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<DataProcessingService>();\n\n\t/**\n\t * The entity storage for the extraction rule groups.\n\t * @internal\n\t */\n\tprivate readonly _extractionRuleGroupStorage: IEntityStorageConnector<ExtractionRuleGroup>;\n\n\t/**\n\t * The extractor connection to use.\n\t * @internal\n\t */\n\tprivate readonly _extractorConnector: IDataExtractorConnector;\n\n\t/**\n\t * Create a new instance of DataExtractionService.\n\t * @param options The options for the connector.\n\t * @throws GeneralError If no extractor connector is registered.\n\t */\n\tconstructor(options?: IDataProcessingServiceConstructorOptions) {\n\t\tthis._extractionRuleGroupStorage = EntityStorageConnectorFactory.get(\n\t\t\toptions?.extractionRuleGroupStorageConnectorType ?? \"extraction-rule-group\"\n\t\t);\n\n\t\tif (Is.stringValue(options?.defaultExtractorType)) {\n\t\t\tthis._extractorConnector = DataExtractorConnectorFactory.get(options.defaultExtractorType);\n\t\t} else {\n\t\t\tconst names = DataExtractorConnectorFactory.names();\n\t\t\tif (names.length > 0) {\n\t\t\t\tthis._extractorConnector = DataExtractorConnectorFactory.get(names[0]);\n\t\t\t} else {\n\t\t\t\tthrow new GeneralError(DataProcessingService.CLASS_NAME, \"noExtractorFound\");\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn DataProcessingService.CLASS_NAME;\n\t}\n\n\t/**\n\t * Set an extraction rule group.\n\t * @param ruleGroup The rule group to store.\n\t * @returns A promise that resolves when the rule group has been stored.\n\t */\n\tpublic async ruleGroupSet(ruleGroup: IRuleGroup): Promise<void> {\n\t\tGuards.object<IRuleGroup>(DataProcessingService.CLASS_NAME, nameof(ruleGroup), ruleGroup);\n\t\tGuards.stringValue(DataProcessingService.CLASS_NAME, nameof(ruleGroup.id), ruleGroup.id);\n\t\tGuards.stringValue(DataProcessingService.CLASS_NAME, nameof(ruleGroup.label), ruleGroup.label);\n\t\tGuards.array<IRule>(DataProcessingService.CLASS_NAME, nameof(ruleGroup.rules), ruleGroup.rules);\n\n\t\tfor (const rule of ruleGroup.rules) {\n\t\t\tGuards.stringValue(DataProcessingService.CLASS_NAME, nameof(rule.source), rule.source);\n\t\t\tGuards.stringValue(DataProcessingService.CLASS_NAME, nameof(rule.target), rule.source);\n\t\t}\n\n\t\tconst extractionRuleGroup: ExtractionRuleGroup = {\n\t\t\tid: ruleGroup.id,\n\t\t\tlabel: ruleGroup.label,\n\t\t\trules: ruleGroup.rules.map(rule => ({\n\t\t\t\tsource: rule.source,\n\t\t\t\ttarget: rule.target,\n\t\t\t\tretainPathDepth: rule.retainPathDepth,\n\t\t\t\tcoerce: rule.coerce\n\t\t\t}))\n\t\t};\n\n\t\tawait this._extractionRuleGroupStorage.set(extractionRuleGroup);\n\t}\n\n\t/**\n\t * Get a rule group for extraction.\n\t * @param ruleGroupId The id of the rule group to get.\n\t * @returns The rule group.\n\t */\n\tpublic async ruleGroupGet(ruleGroupId: string): Promise<IRuleGroup> {\n\t\tGuards.stringValue(DataProcessingService.CLASS_NAME, nameof(ruleGroupId), ruleGroupId);\n\n\t\tconst extractRuleGroup = await this._extractionRuleGroupStorage.get(ruleGroupId);\n\n\t\tif (Is.empty(extractRuleGroup)) {\n\t\t\tthrow new NotFoundError(DataProcessingService.CLASS_NAME, \"ruleGroupNotFound\", ruleGroupId);\n\t\t}\n\n\t\treturn {\n\t\t\tid: extractRuleGroup.id,\n\t\t\tlabel: extractRuleGroup.label,\n\t\t\trules: extractRuleGroup.rules.map(rule => ({\n\t\t\t\tsource: rule.source,\n\t\t\t\ttarget: rule.target,\n\t\t\t\tretainPathDepth: rule.retainPathDepth,\n\t\t\t\tcoerce: rule.coerce\n\t\t\t}))\n\t\t};\n\t}\n\n\t/**\n\t * Remove a rule group.\n\t * @param ruleGroupId The id of the rule group to remove.\n\t * @returns A promise that resolves when the rule group has been removed.\n\t */\n\tpublic async ruleGroupRemove(ruleGroupId: string): Promise<void> {\n\t\tGuards.stringValue(DataProcessingService.CLASS_NAME, nameof(ruleGroupId), ruleGroupId);\n\n\t\tconst extractRuleGroup = await this._extractionRuleGroupStorage.get(ruleGroupId);\n\n\t\tif (Is.empty(extractRuleGroup)) {\n\t\t\tthrow new NotFoundError(DataProcessingService.CLASS_NAME, \"ruleGroupNotFound\", ruleGroupId);\n\t\t}\n\n\t\tawait this._extractionRuleGroupStorage.remove(ruleGroupId);\n\t}\n\n\t/**\n\t * Extracts data from the provided input.\n\t * @param ruleGroupId The id of the rule group to use to extract data.\n\t * @param data The data to extract from.\n\t * @param overrideExtractorType An optional override for the extractor type.\n\t * @param overrideMimeType An optional override for the mime type for conversion, will auto detect if not provided.\n\t * @returns The extracted data.\n\t */\n\tpublic async extract(\n\t\truleGroupId: string,\n\t\tdata: Uint8Array,\n\t\toverrideExtractorType?: string,\n\t\toverrideMimeType?: string\n\t): Promise<unknown> {\n\t\tGuards.stringValue(DataProcessingService.CLASS_NAME, nameof(ruleGroupId), ruleGroupId);\n\t\tGuards.uint8Array(DataProcessingService.CLASS_NAME, nameof(data), data);\n\n\t\tconst extractRuleGroup = await this._extractionRuleGroupStorage.get(ruleGroupId);\n\n\t\tif (Is.empty(extractRuleGroup)) {\n\t\t\tthrow new NotFoundError(DataProcessingService.CLASS_NAME, \"ruleGroupNotFound\", ruleGroupId);\n\t\t}\n\n\t\tconst converted = await this.convert(data, overrideMimeType);\n\n\t\tconst extractor = Is.empty(overrideExtractorType)\n\t\t\t? this._extractorConnector\n\t\t\t: DataExtractorConnectorFactory.get(overrideExtractorType);\n\n\t\tconst extracted = await extractor.extract(converted, extractRuleGroup.rules);\n\t\treturn ObjectHelper.toExtended(extracted);\n\t}\n\n\t/**\n\t * Converts data from the provided input to a structured JSON document.\n\t * @param data The data to convert.\n\t * @param overrideMimeType An optional override for the mime type, will auto detect if empty.\n\t * @returns The converted data.\n\t */\n\tpublic async convert(data: Uint8Array, overrideMimeType?: string): Promise<unknown> {\n\t\tGuards.uint8Array(DataProcessingService.CLASS_NAME, nameof(data), data);\n\n\t\tconst mimeType = overrideMimeType ?? (await MimeTypeHelper.detect(data));\n\t\tif (Is.empty(mimeType)) {\n\t\t\tthrow new GeneralError(DataProcessingService.CLASS_NAME, \"mimeTypeNotFound\");\n\t\t}\n\n\t\tconst converters = DataConverterConnectorFactory.instancesList();\n\n\t\tconst converter = converters.find(c => c.mimeTypes().includes(mimeType));\n\t\tif (Is.empty(converter)) {\n\t\t\tthrow new NotFoundError(DataProcessingService.CLASS_NAME, \"converterNotFound\", mimeType);\n\t\t}\n\n\t\treturn converter.convert(data);\n\t}\n\n\t/**\n\t * Query the rule group entries.\n\t * @param cursor The cursor to request the next chunk of entities.\n\t * @param limit Limit the number of entities to return.\n\t * @returns All the entities for the storage matching the conditions,\n\t * and a cursor which can be used to request more entities.\n\t */\n\tpublic async query(\n\t\tcursor?: string,\n\t\tlimit?: number\n\t): Promise<{\n\t\t/**\n\t\t * The entities, which can be partial if a limited keys list was provided.\n\t\t */\n\t\tentities: IRuleGroup[];\n\t\t/**\n\t\t * An optional cursor, when defined can be used to call find to get more entities.\n\t\t */\n\t\tcursor?: string;\n\t}> {\n\t\tconst result = await this._extractionRuleGroupStorage.query(\n\t\t\tundefined,\n\t\t\t[\n\t\t\t\t{\n\t\t\t\t\tproperty: \"id\",\n\t\t\t\t\tsortDirection: SortDirection.Descending\n\t\t\t\t}\n\t\t\t],\n\t\t\tundefined,\n\t\t\tcursor,\n\t\t\tlimit\n\t\t);\n\n\t\treturn {\n\t\t\tentities: result.entities as IRuleGroup[],\n\t\t\tcursor: result.cursor\n\t\t};\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dataProcessingService.js","sources":["../../src/dataProcessingService.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACrF,OAAO,EACN,6BAA6B,EAC7B,6BAA6B,EAK7B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EACN,6BAA6B,EAE7B,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAI7C;;GAEG;AACH,MAAM,OAAO,qBAAqB;IACjC;;OAEG;IACI,MAAM,CAAU,UAAU,GAAW,uBAAuB,CAAC;IAEpE;;;OAGG;IACc,2BAA2B,CAA+C;IAE3F;;;OAGG;IACc,mBAAmB,CAA0B;IAE9D;;;;OAIG;IACH,YAAY,OAAkD;QAC7D,IAAI,CAAC,2BAA2B,GAAG,6BAA6B,CAAC,GAAG,CACnE,OAAO,EAAE,uCAAuC,IAAI,uBAAuB,CAC3E,CAAC;QAEF,IAAI,EAAE,CAAC,WAAW,CAAC,OAAO,EAAE,oBAAoB,CAAC,EAAE,CAAC;YACnD,IAAI,CAAC,mBAAmB,GAAG,6BAA6B,CAAC,GAAG,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC;QAC5F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M,EAAE,MAAM,CAAC,MAAM;SACrB,CAAC;IACH,CAAC;CACD","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { GeneralError, Guards, Is, NotFoundError, ObjectHelper } from \"@3sixty/core\";\nimport {\n\tDataConverterConnectorFactory,\n\tDataExtractorConnectorFactory,\n\ttype IDataExtractorConnector,\n\ttype IDataProcessingComponent,\n\ttype IRule,\n\ttype IRuleGroup\n} from \"@3sixty/data-processing-models\";\nimport { SortDirection } from \"@3sixty/entity\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageConnector\n} from \"@3sixty/entity-storage-models\";\n\nimport { MimeTypeHelper } from \"@3sixty/web\";\nimport type { ExtractionRuleGroup } from \"./entities/extractionRuleGroup.js\";\nimport type { IDataProcessingServiceConstructorOptions } from \"./models/IDataProcessingServiceConstructorOptions.js\";\n\n/**\n * Class for processing data from a source.\n */\nexport class DataProcessingService implements IDataProcessingComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = \"DataProcessingService\";\n\n\t/**\n\t * The entity storage for the extraction rule groups.\n\t * @internal\n\t */\n\tprivate readonly _extractionRuleGroupStorage: IEntityStorageConnector<ExtractionRuleGroup>;\n\n\t/**\n\t * The extractor connection to use.\n\t * @internal\n\t */\n\tprivate readonly _extractorConnector: IDataExtractorConnector;\n\n\t/**\n\t * Create a new instance of DataExtractionService.\n\t * @param options The options for the connector.\n\t * @throws GeneralError If no extractor connector is registered.\n\t */\n\tconstructor(options?: IDataProcessingServiceConstructorOptions) {\n\t\tthis._extractionRuleGroupStorage = EntityStorageConnectorFactory.get(\n\t\t\toptions?.extractionRuleGroupStorageConnectorType ?? \"extraction-rule-group\"\n\t\t);\n\n\t\tif (Is.stringValue(options?.defaultExtractorType)) {\n\t\t\tthis._extractorConnector = DataExtractorConnectorFactory.get(options.defaultExtractorType);\n\t\t} else {\n\t\t\tconst names = DataExtractorConnectorFactory.names();\n\t\t\tif (names.length > 0) {\n\t\t\t\tthis._extractorConnector = DataExtractorConnectorFactory.get(names[0]);\n\t\t\t} else {\n\t\t\t\tthrow new GeneralError(DataProcessingService.CLASS_NAME, \"noExtractorFound\");\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn DataProcessingService.CLASS_NAME;\n\t}\n\n\t/**\n\t * Set an extraction rule group.\n\t * @param ruleGroup The rule group to store.\n\t * @returns A promise that resolves when the rule group has been stored.\n\t */\n\tpublic async ruleGroupSet(ruleGroup: IRuleGroup): Promise<void> {\n\t\tGuards.object<IRuleGroup>(DataProcessingService.CLASS_NAME, \"ruleGroup\", ruleGroup);\n\t\tGuards.stringValue(DataProcessingService.CLASS_NAME, \"ruleGroup.id\", ruleGroup.id);\n\t\tGuards.stringValue(DataProcessingService.CLASS_NAME, \"ruleGroup.label\", ruleGroup.label);\n\t\tGuards.array<IRule>(DataProcessingService.CLASS_NAME, \"ruleGroup.rules\", ruleGroup.rules);\n\n\t\tfor (const rule of ruleGroup.rules) {\n\t\t\tGuards.stringValue(DataProcessingService.CLASS_NAME, \"rule.source\", rule.source);\n\t\t\tGuards.stringValue(DataProcessingService.CLASS_NAME, \"rule.target\", rule.source);\n\t\t}\n\n\t\tconst extractionRuleGroup: ExtractionRuleGroup = {\n\t\t\tid: ruleGroup.id,\n\t\t\tlabel: ruleGroup.label,\n\t\t\trules: ruleGroup.rules.map(rule => ({\n\t\t\t\tsource: rule.source,\n\t\t\t\ttarget: rule.target,\n\t\t\t\tretainPathDepth: rule.retainPathDepth,\n\t\t\t\tcoerce: rule.coerce\n\t\t\t}))\n\t\t};\n\n\t\tawait this._extractionRuleGroupStorage.set(extractionRuleGroup);\n\t}\n\n\t/**\n\t * Get a rule group for extraction.\n\t * @param ruleGroupId The id of the rule group to get.\n\t * @returns The rule group.\n\t */\n\tpublic async ruleGroupGet(ruleGroupId: string): Promise<IRuleGroup> {\n\t\tGuards.stringValue(DataProcessingService.CLASS_NAME, \"ruleGroupId\", ruleGroupId);\n\n\t\tconst extractRuleGroup = await this._extractionRuleGroupStorage.get(ruleGroupId);\n\n\t\tif (Is.empty(extractRuleGroup)) {\n\t\t\tthrow new NotFoundError(DataProcessingService.CLASS_NAME, \"ruleGroupNotFound\", ruleGroupId);\n\t\t}\n\n\t\treturn {\n\t\t\tid: extractRuleGroup.id,\n\t\t\tlabel: extractRuleGroup.label,\n\t\t\trules: extractRuleGroup.rules.map(rule => ({\n\t\t\t\tsource: rule.source,\n\t\t\t\ttarget: rule.target,\n\t\t\t\tretainPathDepth: rule.retainPathDepth,\n\t\t\t\tcoerce: rule.coerce\n\t\t\t}))\n\t\t};\n\t}\n\n\t/**\n\t * Remove a rule group.\n\t * @param ruleGroupId The id of the rule group to remove.\n\t * @returns A promise that resolves when the rule group has been removed.\n\t */\n\tpublic async ruleGroupRemove(ruleGroupId: string): Promise<void> {\n\t\tGuards.stringValue(DataProcessingService.CLASS_NAME, \"ruleGroupId\", ruleGroupId);\n\n\t\tconst extractRuleGroup = await this._extractionRuleGroupStorage.get(ruleGroupId);\n\n\t\tif (Is.empty(extractRuleGroup)) {\n\t\t\tthrow new NotFoundError(DataProcessingService.CLASS_NAME, \"ruleGroupNotFound\", ruleGroupId);\n\t\t}\n\n\t\tawait this._extractionRuleGroupStorage.remove(ruleGroupId);\n\t}\n\n\t/**\n\t * Extracts data from the provided input.\n\t * @param ruleGroupId The id of the rule group to use to extract data.\n\t * @param data The data to extract from.\n\t * @param overrideExtractorType An optional override for the extractor type.\n\t * @param overrideMimeType An optional override for the mime type for conversion, will auto detect if not provided.\n\t * @returns The extracted data.\n\t */\n\tpublic async extract(\n\t\truleGroupId: string,\n\t\tdata: Uint8Array,\n\t\toverrideExtractorType?: string,\n\t\toverrideMimeType?: string\n\t): Promise<unknown> {\n\t\tGuards.stringValue(DataProcessingService.CLASS_NAME, \"ruleGroupId\", ruleGroupId);\n\t\tGuards.uint8Array(DataProcessingService.CLASS_NAME, \"data\", data);\n\n\t\tconst extractRuleGroup = await this._extractionRuleGroupStorage.get(ruleGroupId);\n\n\t\tif (Is.empty(extractRuleGroup)) {\n\t\t\tthrow new NotFoundError(DataProcessingService.CLASS_NAME, \"ruleGroupNotFound\", ruleGroupId);\n\t\t}\n\n\t\tconst converted = await this.convert(data, overrideMimeType);\n\n\t\tconst extractor = Is.empty(overrideExtractorType)\n\t\t\t? this._extractorConnector\n\t\t\t: DataExtractorConnectorFactory.get(overrideExtractorType);\n\n\t\tconst extracted = await extractor.extract(converted, extractRuleGroup.rules);\n\t\treturn ObjectHelper.toExtended(extracted);\n\t}\n\n\t/**\n\t * Converts data from the provided input to a structured JSON document.\n\t * @param data The data to convert.\n\t * @param overrideMimeType An optional override for the mime type, will auto detect if empty.\n\t * @returns The converted data.\n\t */\n\tpublic async convert(data: Uint8Array, overrideMimeType?: string): Promise<unknown> {\n\t\tGuards.uint8Array(DataProcessingService.CLASS_NAME, \"data\", data);\n\n\t\tconst mimeType = overrideMimeType ?? (await MimeTypeHelper.detect(data));\n\t\tif (Is.empty(mimeType)) {\n\t\t\tthrow new GeneralError(DataProcessingService.CLASS_NAME, \"mimeTypeNotFound\");\n\t\t}\n\n\t\tconst converters = DataConverterConnectorFactory.instancesList();\n\n\t\tconst converter = converters.find(c => c.mimeTypes().includes(mimeType));\n\t\tif (Is.empty(converter)) {\n\t\t\tthrow new NotFoundError(DataProcessingService.CLASS_NAME, \"converterNotFound\", mimeType);\n\t\t}\n\n\t\treturn converter.convert(data);\n\t}\n\n\t/**\n\t * Query the rule group entries.\n\t * @param cursor The cursor to request the next chunk of entities.\n\t * @param limit Limit the number of entities to return.\n\t * @returns All the entities for the storage matching the conditions,\n\t * and a cursor which can be used to request more entities.\n\t */\n\tpublic async query(\n\t\tcursor?: string,\n\t\tlimit?: number\n\t): Promise<{\n\t\t/**\n\t\t * The entities, which can be partial if a limited keys list was provided.\n\t\t */\n\t\tentities: IRuleGroup[];\n\t\t/**\n\t\t * An optional cursor, when defined can be used to call find to get more entities.\n\t\t */\n\t\tcursor?: string;\n\t}> {\n\t\tconst result = await this._extractionRuleGroupStorage.query(\n\t\t\tundefined,\n\t\t\t[\n\t\t\t\t{\n\t\t\t\t\tproperty: \"id\",\n\t\t\t\t\tsortDirection: SortDirection.Descending\n\t\t\t\t}\n\t\t\t],\n\t\t\tundefined,\n\t\t\tcursor,\n\t\t\tlimit\n\t\t);\n\n\t\treturn {\n\t\t\tentities: result.entities as IRuleGroup[],\n\t\t\tcursor: result.cursor\n\t\t};\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractionRule.js","
|
|
1
|
+
{"version":3,"file":"extractionRule.js","sources":["../../../src/entities/extractionRule.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAElD;;GAEG;AAEI,IAAM,cAAc,GAApB,MAAM,cAAc;IAC1B;;OAEG;IAEI,MAAM,CAAU;IAEvB;;OAEG;IAEI,MAAM,CAAU;IAEvB;;OAEG;IAEI,eAAe,CAAU;IAEhC;;OAEG;IAEI,MAAM,CAAc;CAC3B,CAAA;AAnBO;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;;8CACvB;AAMhB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;;8CACvB;AAMhB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;uDACb;AAMzB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CACjC;AAvBf,cAAc;IAD1B,MAAM,EAAE;GACI,cAAc,CAwB1B","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { CoerceType } from \"@3sixty/core\";\nimport { entity, property } from \"@3sixty/entity\";\n\n/**\n * Class defining an extraction rule.\n */\n@entity()\nexport class ExtractionRule {\n\t/**\n\t * The JSONPath expression identifying the source field in the input document.\n\t */\n\t@property({ type: \"string\", maxLength: 2048 })\n\tpublic source!: string;\n\n\t/**\n\t * The dotted path identifying where to store the extracted value in the output.\n\t */\n\t@property({ type: \"string\", maxLength: 2048 })\n\tpublic target!: string;\n\n\t/**\n\t * The number of path segments from the source location to preserve in the target path.\n\t */\n\t@property({ type: \"number\", optional: true })\n\tpublic retainPathDepth?: number;\n\n\t/**\n\t * The type to coerce the extracted value to.\n\t */\n\t@property({ type: \"string\", maxLength: 16, optional: true })\n\tpublic coerce?: CoerceType;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractionRuleGroup.js","
|
|
1
|
+
{"version":3,"file":"extractionRuleGroup.js","sources":["../../../src/entities/extractionRuleGroup.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAGlD;;GAEG;AAEI,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAC/B;;OAEG;IAEI,EAAE,CAAU;IAEnB;;OAEG;IAEI,KAAK,CAAU;IAEtB;;OAEG;IAEI,KAAK,CAAoB;CAChC,CAAA;AAbO;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC;;+CAC3C;AAMZ;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC;;kDACvB;AAMf;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;;kDAC/C;AAjBpB,mBAAmB;IAD/B,MAAM,EAAE;GACI,mBAAmB,CAkB/B","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { entity, property } from \"@3sixty/entity\";\nimport type { ExtractionRule } from \"./extractionRule.js\";\n\n/**\n * Class defining an extraction rule group.\n */\n@entity()\nexport class ExtractionRuleGroup {\n\t/**\n\t * The unique identifier for the rule group.\n\t */\n\t@property({ type: \"string\", isPrimary: true, maxLength: 255 })\n\tpublic id!: string;\n\n\t/**\n\t * The human-readable label for the rule group.\n\t */\n\t@property({ type: \"string\", maxLength: 256 })\n\tpublic label!: string;\n\n\t/**\n\t * The extraction rules that belong to this group.\n\t */\n\t@property({ type: \"array\", itemTypeRef: \"ExtractionRule\", itemType: \"object\" })\n\tpublic rules!: ExtractionRule[];\n}\n"]}
|
package/dist/es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,mCAAmC,CAAC;AAClD,cAAc,sDAAsD,CAAC;AACrE,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./dataProcessingRoutes.js\";\nexport * from \"./dataProcessingService.js\";\nexport * from \"./entities/extractionRule.js\";\nexport * from \"./entities/extractionRuleGroup.js\";\nexport * from \"./models/IDataProcessingServiceConstructorOptions.js\";\nexport * from \"./restEntryPoints.js\";\nexport * from \"./schema.js\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IDataProcessingServiceConstructorOptions.js","
|
|
1
|
+
{"version":3,"file":"IDataProcessingServiceConstructorOptions.js","sources":["../../../src/models/IDataProcessingServiceConstructorOptions.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * The options for the data processing service constructor.\n */\nexport interface IDataProcessingServiceConstructorOptions {\n\t/**\n\t * The type of the entity storage connector to use for extraction rule groups.\n\t * @default extraction-rule-group\n\t */\n\textractionRuleGroupStorageConnectorType?: string;\n\n\t/**\n\t * The default extractor type to use, if not provided uses the first in the factory.\n\t */\n\tdefaultExtractorType?: string;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restEntryPoints.js","
|
|
1
|
+
{"version":3,"file":"restEntryPoints.js","sources":["../../src/restEntryPoints.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gCAAgC,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEjG;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAA2B;IACtD;QACC,IAAI,EAAE,iBAAiB;QACvB,gBAAgB,EAAE,iBAAiB;QACnC,IAAI,EAAE,kBAAkB;QACxB,cAAc,EAAE,gCAAgC;KAChD;CACD,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IRestRouteEntryPoint } from \"@3sixty/api-models\";\nimport { generateRestRoutesDataProcessing, tagsDataProcessing } from \"./dataProcessingRoutes.js\";\n\n/**\n * The REST entry points for the data processing service.\n */\nexport const restEntryPoints: IRestRouteEntryPoint[] = [\n\t{\n\t\tname: \"data-processing\",\n\t\tdefaultBaseRoute: \"data-processing\",\n\t\ttags: tagsDataProcessing,\n\t\tgenerateRoutes: generateRestRoutesDataProcessing\n\t}\n];\n"]}
|
package/dist/es/schema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","
|
|
1
|
+
{"version":3,"file":"schema.js","sources":["../../src/schema.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEzE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAExE;;GAEG;AACH,MAAM,UAAU,UAAU;IACzB,mBAAmB,CAAC,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE,CACxD,kBAAkB,CAAC,SAAS,CAAC,mBAAmB,CAAC,CACjD,CAAC;IACF,mBAAmB,CAAC,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE,CACnD,kBAAkB,CAAC,SAAS,CAAC,cAAc,CAAC,CAC5C,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { EntitySchemaFactory, EntitySchemaHelper } from \"@3sixty/entity\";\n\nimport { ExtractionRule } from \"./entities/extractionRule.js\";\nimport { ExtractionRuleGroup } from \"./entities/extractionRuleGroup.js\";\n\n/**\n * Registers entity schemas for the data extraction connector entity storage.\n */\nexport function initSchema(): void {\n\tEntitySchemaFactory.register(\"ExtractionRuleGroup\", () =>\n\t\tEntitySchemaHelper.getSchema(ExtractionRuleGroup)\n\t);\n\tEntitySchemaFactory.register(\"ExtractionRule\", () =>\n\t\tEntitySchemaHelper.getSchema(ExtractionRule)\n\t);\n}\n"]}
|
package/docs/changelog.md
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.20.0-next.1](https://github.com/3sixtyglobal/data-processing/compare/data-processing-service-v0.20.0-next.0...data-processing-service-v0.20.0-next.1) (2026-10-23)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* publish packages under the [@3sixty](https://github.com/3sixty) namespace ([e62a15f](https://github.com/3sixtyglobal/data-processing/commit/e62a15f0f619ee7161c1f881a10a2d7db48dbc4d))
|
|
9
|
+
* updated ts compile ([ba5bfb7](https://github.com/3sixtyglobal/data-processing/commit/ba5bfb7ce9fa96b17952fe0074192e73ccb4b1d6))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Dependencies
|
|
13
|
+
|
|
14
|
+
* The following workspace dependencies were updated
|
|
15
|
+
* dependencies
|
|
16
|
+
* @3sixty/data-processing-models bumped from 0.20.0-next.0 to 0.20.0-next.1
|
|
17
|
+
* devDependencies
|
|
18
|
+
* @3sixty/data-processing-converters bumped from 0.20.0-next.0 to 0.20.0-next.1
|
|
19
|
+
* @3sixty/data-processing-extractors bumped from 0.20.0-next.0 to 0.20.0-next.1
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@3sixty/data-processing-service",
|
|
3
|
-
"version": "0.20.0-next.
|
|
3
|
+
"version": "0.20.0-next.1",
|
|
4
4
|
"description": "Service routes and orchestration logic for extraction and conversion workflows",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@3sixty/api-models": "next",
|
|
18
18
|
"@3sixty/core": "next",
|
|
19
|
-
"@3sixty/data-processing-models": "0.20.0-next.
|
|
19
|
+
"@3sixty/data-processing-models": "0.20.0-next.1",
|
|
20
20
|
"@3sixty/entity": "next",
|
|
21
21
|
"@3sixty/entity-storage-models": "next",
|
|
22
22
|
"@3sixty/nameof": "next",
|