@comunica/actor-dereference-file 2.0.1-alpha.5.0
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/LICENSE.txt +22 -0
- package/README.md +35 -0
- package/components/ActorDereferenceFile.jsonld +145 -0
- package/components/components.jsonld +11 -0
- package/components/context.jsonld +35 -0
- package/lib/ActorDereferenceFile.d.ts +11 -0
- package/lib/ActorDereferenceFile.js +36 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +14 -0
- package/package.json +42 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright © 2017–now Ruben Taelman, Joachim Van Herwegen
|
|
4
|
+
Comunica Association and Ghent University – imec, Belgium
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in
|
|
14
|
+
all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
22
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Comunica File Dereference Actor
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@comunica/actor-dereference-file)
|
|
4
|
+
|
|
5
|
+
A comunica File Dereference Actor.
|
|
6
|
+
|
|
7
|
+
An [Dereference](https://github.com/comunica/comunica/tree/master/packages/bus-dereference) actor that
|
|
8
|
+
resolves an URL to a local file (optionally starting with `file://`).
|
|
9
|
+
|
|
10
|
+
[Click here if you just want to query with Comunica](https://comunica.dev/docs/query/).
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
$ yarn add @comunica/actor-dereference-file
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Configure
|
|
19
|
+
|
|
20
|
+
After installing, this package can be added to your engine's configuration as follows:
|
|
21
|
+
```text
|
|
22
|
+
{
|
|
23
|
+
"@context": [
|
|
24
|
+
...
|
|
25
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-dereference-file/^2.0.0/components/context.jsonld"
|
|
26
|
+
],
|
|
27
|
+
"actors": [
|
|
28
|
+
...
|
|
29
|
+
{
|
|
30
|
+
"@id": "urn:comunica:default:dereference/actors#file",
|
|
31
|
+
"@type": "ActorRdfDereferenceFile"
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
```
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
{
|
|
2
|
+
"@context": [
|
|
3
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-dereference-file/^2.0.0/components/context.jsonld",
|
|
4
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/bus-dereference/^2.0.0/components/context.jsonld",
|
|
5
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/core/^2.0.0/components/context.jsonld"
|
|
6
|
+
],
|
|
7
|
+
"@id": "npmd:@comunica/actor-dereference-file",
|
|
8
|
+
"components": [
|
|
9
|
+
{
|
|
10
|
+
"@id": "cadf:components/ActorDereferenceFile.jsonld#ActorDereferenceFile",
|
|
11
|
+
"@type": "Class",
|
|
12
|
+
"requireElement": "ActorDereferenceFile",
|
|
13
|
+
"extends": [
|
|
14
|
+
"cbd:components/ActorDereference.jsonld#ActorDereference"
|
|
15
|
+
],
|
|
16
|
+
"comment": "A comunica File Dereference Actor.",
|
|
17
|
+
"parameters": [
|
|
18
|
+
{
|
|
19
|
+
"@id": "cadf:components/ActorDereferenceFile.jsonld#ActorDereferenceFile_args_name",
|
|
20
|
+
"range": "xsd:string",
|
|
21
|
+
"default": {
|
|
22
|
+
"@id": "rdf:subject"
|
|
23
|
+
},
|
|
24
|
+
"comment": "The name for this actor."
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"@id": "cadf:components/ActorDereferenceFile.jsonld#ActorDereferenceFile_args_bus",
|
|
28
|
+
"range": {
|
|
29
|
+
"@type": "ParameterRangeGenericComponent",
|
|
30
|
+
"component": "cc:components/Bus.jsonld#Bus",
|
|
31
|
+
"genericTypeInstances": [
|
|
32
|
+
{
|
|
33
|
+
"@type": "ParameterRangeGenericComponent",
|
|
34
|
+
"component": "cc:components/Actor.jsonld#Actor",
|
|
35
|
+
"genericTypeInstances": [
|
|
36
|
+
{
|
|
37
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
38
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
42
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
46
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
52
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
56
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
60
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
"default": {
|
|
65
|
+
"@id": "cbd:components/ActorDereference.jsonld#ActorDereference_default_bus",
|
|
66
|
+
"@type": "cc:components/Bus.jsonld#Bus"
|
|
67
|
+
},
|
|
68
|
+
"comment": "The bus this actor subscribes to."
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"@id": "cadf:components/ActorDereferenceFile.jsonld#ActorDereferenceFile_args_beforeActors",
|
|
72
|
+
"range": {
|
|
73
|
+
"@type": "ParameterRangeUnion",
|
|
74
|
+
"parameterRangeElements": [
|
|
75
|
+
{
|
|
76
|
+
"@type": "ParameterRangeArray",
|
|
77
|
+
"parameterRangeValue": {
|
|
78
|
+
"@type": "ParameterRangeGenericComponent",
|
|
79
|
+
"component": "cc:components/Actor.jsonld#Actor",
|
|
80
|
+
"genericTypeInstances": [
|
|
81
|
+
{
|
|
82
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
83
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
87
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
91
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"@type": "ParameterRangeUndefined"
|
|
98
|
+
}
|
|
99
|
+
]
|
|
100
|
+
},
|
|
101
|
+
"comment": "Actor that must be registered in the bus before this actor."
|
|
102
|
+
}
|
|
103
|
+
],
|
|
104
|
+
"memberFields": [
|
|
105
|
+
{
|
|
106
|
+
"@id": "cadf:components/ActorDereferenceFile.jsonld#ActorDereferenceFile__member_constructor",
|
|
107
|
+
"memberFieldName": "constructor"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"@id": "cadf:components/ActorDereferenceFile.jsonld#ActorDereferenceFile__member_test",
|
|
111
|
+
"memberFieldName": "test"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"@id": "cadf:components/ActorDereferenceFile.jsonld#ActorDereferenceFile__member_run",
|
|
115
|
+
"memberFieldName": "run"
|
|
116
|
+
}
|
|
117
|
+
],
|
|
118
|
+
"constructorArguments": [
|
|
119
|
+
{
|
|
120
|
+
"@id": "cadf:components/ActorDereferenceFile.jsonld#ActorDereferenceFile_args__constructorArgument",
|
|
121
|
+
"fields": [
|
|
122
|
+
{
|
|
123
|
+
"keyRaw": "name",
|
|
124
|
+
"value": {
|
|
125
|
+
"@id": "cadf:components/ActorDereferenceFile.jsonld#ActorDereferenceFile_args_name"
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"keyRaw": "bus",
|
|
130
|
+
"value": {
|
|
131
|
+
"@id": "cadf:components/ActorDereferenceFile.jsonld#ActorDereferenceFile_args_bus"
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"keyRaw": "beforeActors",
|
|
136
|
+
"value": {
|
|
137
|
+
"@id": "cadf:components/ActorDereferenceFile.jsonld#ActorDereferenceFile_args_beforeActors"
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
]
|
|
141
|
+
}
|
|
142
|
+
]
|
|
143
|
+
}
|
|
144
|
+
]
|
|
145
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"@context": [
|
|
3
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-dereference-file/^2.0.0/components/context.jsonld"
|
|
4
|
+
],
|
|
5
|
+
"@id": "npmd:@comunica/actor-dereference-file",
|
|
6
|
+
"@type": "Module",
|
|
7
|
+
"requireName": "@comunica/actor-dereference-file",
|
|
8
|
+
"import": [
|
|
9
|
+
"cadf:components/ActorDereferenceFile.jsonld"
|
|
10
|
+
]
|
|
11
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"@context": [
|
|
3
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/componentsjs/^4.0.0/components/context.jsonld",
|
|
4
|
+
{
|
|
5
|
+
"npmd": "https://linkedsoftwaredependencies.org/bundles/npm/",
|
|
6
|
+
"cadf": "npmd:@comunica/actor-dereference-file/^2.0.0/",
|
|
7
|
+
"ActorDereferenceFile": {
|
|
8
|
+
"@id": "cadf:components/ActorDereferenceFile.jsonld#ActorDereferenceFile",
|
|
9
|
+
"@prefix": true,
|
|
10
|
+
"@context": {
|
|
11
|
+
"args_name": {
|
|
12
|
+
"@id": "cadf:components/ActorDereferenceFile.jsonld#ActorDereferenceFile_args_name"
|
|
13
|
+
},
|
|
14
|
+
"args_bus": {
|
|
15
|
+
"@id": "cadf:components/ActorDereferenceFile.jsonld#ActorDereferenceFile_args_bus"
|
|
16
|
+
},
|
|
17
|
+
"args_beforeActors": {
|
|
18
|
+
"@id": "cadf:components/ActorDereferenceFile.jsonld#ActorDereferenceFile_args_beforeActors",
|
|
19
|
+
"@container": "@list"
|
|
20
|
+
},
|
|
21
|
+
"name": {
|
|
22
|
+
"@id": "cadf:components/ActorDereferenceFile.jsonld#ActorDereferenceFile_args_name"
|
|
23
|
+
},
|
|
24
|
+
"bus": {
|
|
25
|
+
"@id": "cadf:components/ActorDereferenceFile.jsonld#ActorDereferenceFile_args_bus"
|
|
26
|
+
},
|
|
27
|
+
"beforeActors": {
|
|
28
|
+
"@id": "cadf:components/ActorDereferenceFile.jsonld#ActorDereferenceFile_args_beforeActors",
|
|
29
|
+
"@container": "@list"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IActionDereference, IActorDereferenceArgs, IActorDereferenceOutput } from '@comunica/bus-dereference';
|
|
2
|
+
import { ActorDereference } from '@comunica/bus-dereference';
|
|
3
|
+
import type { IActorTest } from '@comunica/core';
|
|
4
|
+
/**
|
|
5
|
+
* A comunica File Dereference Actor.
|
|
6
|
+
*/
|
|
7
|
+
export declare class ActorDereferenceFile extends ActorDereference {
|
|
8
|
+
constructor(args: IActorDereferenceArgs);
|
|
9
|
+
test({ url }: IActionDereference): Promise<IActorTest>;
|
|
10
|
+
run({ url }: IActionDereference): Promise<IActorDereferenceOutput>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ActorDereferenceFile = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const url_1 = require("url");
|
|
6
|
+
const bus_dereference_1 = require("@comunica/bus-dereference");
|
|
7
|
+
/**
|
|
8
|
+
* A comunica File Dereference Actor.
|
|
9
|
+
*/
|
|
10
|
+
class ActorDereferenceFile extends bus_dereference_1.ActorDereference {
|
|
11
|
+
constructor(args) {
|
|
12
|
+
super(args);
|
|
13
|
+
}
|
|
14
|
+
async test({ url }) {
|
|
15
|
+
try {
|
|
16
|
+
(0, fs_1.accessSync)(getPath(url), fs_1.constants.F_OK);
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
throw new Error(`This actor only works on existing local files. (${error})`);
|
|
20
|
+
}
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
async run({ url }) {
|
|
24
|
+
const requestTimeStart = Date.now();
|
|
25
|
+
return {
|
|
26
|
+
data: (0, fs_1.createReadStream)(getPath(url)),
|
|
27
|
+
// This should always be after the creation of the read stream
|
|
28
|
+
requestTime: Date.now() - requestTimeStart,
|
|
29
|
+
exists: true,
|
|
30
|
+
url,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.ActorDereferenceFile = ActorDereferenceFile;
|
|
35
|
+
const getPath = (url) => url.startsWith('file://') ? (0, url_1.fileURLToPath)(url) : url;
|
|
36
|
+
//# sourceMappingURL=ActorDereferenceFile.js.map
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ActorDereferenceFile';
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./ActorDereferenceFile"), exports);
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@comunica/actor-dereference-file",
|
|
3
|
+
"version": "2.0.1-alpha.5.0",
|
|
4
|
+
"description": "A file dereference actor",
|
|
5
|
+
"lsd:module": true,
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"typings": "lib/index",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/comunica/comunica.git",
|
|
11
|
+
"directory": "packages/actor-dereference-file"
|
|
12
|
+
},
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"comunica",
|
|
18
|
+
"actor",
|
|
19
|
+
"dereference",
|
|
20
|
+
"file"
|
|
21
|
+
],
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/comunica/comunica/issues"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://comunica.dev/",
|
|
27
|
+
"files": [
|
|
28
|
+
"components",
|
|
29
|
+
"lib/**/*.d.ts",
|
|
30
|
+
"lib/**/*.js"
|
|
31
|
+
],
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@comunica/bus-dereference": "2.0.1-alpha.5.0",
|
|
34
|
+
"@comunica/core": "2.0.1-alpha.5.0"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "npm run build:ts && npm run build:components",
|
|
38
|
+
"build:ts": "node \"../../node_modules/typescript/bin/tsc\"",
|
|
39
|
+
"build:components": "componentsjs-generator"
|
|
40
|
+
},
|
|
41
|
+
"gitHead": "e2ae2e9e924bf0656df60cc99774f7e560d47695"
|
|
42
|
+
}
|