@datapos/datapos-development 0.3.110 â 0.3.113
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/README.md +16 -15
- package/dist/datapos-development.es.js +65 -51
- package/dist/types/src/index.d.ts +2 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -34,21 +34,22 @@ registry=https://registry.npmjs.org/
|
|
|
34
34
|
|
|
35
35
|
The `src/index.ts' file exposes the following utilities:
|
|
36
36
|
|
|
37
|
-
| Name
|
|
38
|
-
|
|
|
39
|
-
| buildConfig
|
|
40
|
-
| buildConnectorConfig
|
|
41
|
-
| buildContextConfig
|
|
42
|
-
|
|
|
43
|
-
|
|
|
44
|
-
|
|
|
45
|
-
|
|
|
46
|
-
|
|
|
47
|
-
|
|
|
48
|
-
|
|
|
49
|
-
|
|
|
50
|
-
|
|
|
51
|
-
|
|
|
37
|
+
| Name | Notes |
|
|
38
|
+
| ----------------------------------------- | ---------------------------------------------------------------------------- |
|
|
39
|
+
| buildConfig | Build the config.json file for the repository. |
|
|
40
|
+
| buildConnectorConfig | Build the connector config.json file for the repository. |
|
|
41
|
+
| buildContextConfig | Build the context config.json file for the repository. |
|
|
42
|
+
| buildPresenterConfig | Build the presenter config.json file for the repository. |
|
|
43
|
+
| buildPublicDirectoryIndex | Build an index for the repositories public directory. |
|
|
44
|
+
| bumpVersion | Bump the repositories version number. |
|
|
45
|
+
| echoScriptNotImplemented | Echo script not implemented message to console.. |
|
|
46
|
+
| insertLicensesIntoReadme | Insert the licenses for all production dependencies into the README.md file. |
|
|
47
|
+
| insertOWASPDependencyCheckBadgeIntoReadme | |
|
|
48
|
+
| sendDeploymentNotice | Send a deployment notice for the repository. |
|
|
49
|
+
| syncWithGitHub | Synchronise the local repository with the main GitHub repository. |
|
|
50
|
+
| uploadDirectoryToR2 | Upload a directory to Cloudflare R2 storage. |
|
|
51
|
+
| uploadModuleConfigToDO | Upload a modules configuration to the Cloudflare `state` durable object. |
|
|
52
|
+
| uploadModuleToR2 | Upload a module to Cloudflare R2 storage. |
|
|
52
53
|
|
|
53
54
|
## Reports & Compliance
|
|
54
55
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { exec as m } from "node:child_process";
|
|
2
|
-
import { promises as
|
|
3
|
-
import { nanoid as
|
|
4
|
-
import { promisify as
|
|
5
|
-
const
|
|
2
|
+
import { promises as n } from "node:fs";
|
|
3
|
+
import { nanoid as y } from "nanoid";
|
|
4
|
+
import { promisify as w } from "node:util";
|
|
5
|
+
const h = ["createObject", "dropObject", "removeRecords", "upsertRecords"], b = ["findObject", "getRecord", "listNodes", "previewObject", "retrieveRecords"], g = w(m);
|
|
6
6
|
async function S() {
|
|
7
7
|
try {
|
|
8
8
|
console.info("đ Building configuration...");
|
|
9
|
-
const o = JSON.parse(await
|
|
10
|
-
o.name != null && (
|
|
9
|
+
const o = JSON.parse(await n.readFile("package.json", "utf8")), e = JSON.parse(await n.readFile("config.json", "utf8"));
|
|
10
|
+
o.name != null && (e.id = o.name.replace("@datapos/", "").replace("@data-positioning/", "")), o.version != null && (e.version = o.version), await n.writeFile("config.json", JSON.stringify(e, void 0, 4), "utf8"), console.info("â
Configuration built.");
|
|
11
11
|
} catch (o) {
|
|
12
12
|
console.error("â Error building configuration.", o);
|
|
13
13
|
}
|
|
@@ -15,20 +15,20 @@ async function S() {
|
|
|
15
15
|
async function O(o) {
|
|
16
16
|
try {
|
|
17
17
|
console.info(`đ Building public directory index for identifier '${o}'...`);
|
|
18
|
-
const
|
|
18
|
+
const e = {};
|
|
19
19
|
async function i(r, s) {
|
|
20
20
|
console.info(`âī¸ Processing directory '${r}'...`);
|
|
21
21
|
const d = [], a = r.substring(`public/${o}`.length);
|
|
22
|
-
|
|
22
|
+
e[a] = d;
|
|
23
23
|
for (const c of s) {
|
|
24
24
|
const l = `${r}/${c}`;
|
|
25
25
|
try {
|
|
26
|
-
const f = await
|
|
26
|
+
const f = await n.stat(l);
|
|
27
27
|
if (f.isDirectory()) {
|
|
28
|
-
const u = await
|
|
28
|
+
const u = await n.readdir(l), p = { childCount: u.length, name: `${c}`, typeId: "folder" };
|
|
29
29
|
d.push(p), await i(l, u);
|
|
30
30
|
} else {
|
|
31
|
-
const u = { id:
|
|
31
|
+
const u = { id: y(), lastModifiedAt: f.mtimeMs, name: c, size: f.size, typeId: "object" };
|
|
32
32
|
d.push(u);
|
|
33
33
|
}
|
|
34
34
|
} catch (f) {
|
|
@@ -40,24 +40,24 @@ async function O(o) {
|
|
|
40
40
|
return f === 0 ? c.name.localeCompare(l.name) : f;
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
|
-
const t = await
|
|
44
|
-
await i(`public/${o}`, t), await
|
|
45
|
-
} catch (
|
|
46
|
-
console.error("â Error building public directory index.",
|
|
43
|
+
const t = await n.readdir(`public/${o}`);
|
|
44
|
+
await i(`public/${o}`, t), await n.writeFile(`./public/${o}Index.json`, JSON.stringify(e), "utf8"), console.info("â
Public directory index built.");
|
|
45
|
+
} catch (e) {
|
|
46
|
+
console.error("â Error building public directory index.", e);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
async function J() {
|
|
50
50
|
try {
|
|
51
51
|
console.info("đ Building connector configuration...");
|
|
52
|
-
const o = JSON.parse(await
|
|
52
|
+
const o = JSON.parse(await n.readFile("package.json", "utf8")), e = JSON.parse(await n.readFile("config.json", "utf8")), i = await n.readFile("src/index.ts", "utf8");
|
|
53
53
|
let t = !1, r = !1;
|
|
54
54
|
const s = /^\s{4}(?:async\s+)?(private\s+)?(?:public\s+|protected\s+)?([A-Za-z_]\w*)\s*\(/gm, d = [...i.matchAll(s)].filter((c) => c[1] == null && c[2] !== "constructor").map((c) => {
|
|
55
55
|
const l = c[2];
|
|
56
|
-
return t = t ||
|
|
56
|
+
return t = t || h.includes(l), r = r || b.includes(l), l;
|
|
57
57
|
});
|
|
58
58
|
d.length > 0 ? console.info(`âšī¸ Implements ${d.length} operations.`) : console.warn("â ī¸ Implements no operations.");
|
|
59
59
|
const a = r && t ? "bidirectional" : r ? "source" : t ? "destination" : "unknown";
|
|
60
|
-
a && console.info(`âšī¸ Supports ${a} usage.`), o.name != null && (
|
|
60
|
+
a && console.info(`âšī¸ Supports ${a} usage.`), o.name != null && (e.id = o.name), e.operations = d, e.usageId = a, o.version != null && (e.version = o.version), await n.writeFile("config.json", JSON.stringify(e, void 0, 4), "utf8"), console.info("â
Connector configuration built.");
|
|
61
61
|
} catch (o) {
|
|
62
62
|
console.error("â Error building connector configuration.", o);
|
|
63
63
|
}
|
|
@@ -65,8 +65,8 @@ async function J() {
|
|
|
65
65
|
async function x() {
|
|
66
66
|
try {
|
|
67
67
|
console.info("đ Building context configuration...");
|
|
68
|
-
const o = JSON.parse(await
|
|
69
|
-
o.name != null && (
|
|
68
|
+
const o = JSON.parse(await n.readFile("package.json", "utf8")), e = JSON.parse(await n.readFile("config.json", "utf8")), i = await n.readFile("src/index.ts", "utf8"), t = /^\s{4}(?:async\s+)?(private\s+)?(?:public\s+|protected\s+)?([A-Za-z_]\w*)\s*\(/gm, r = [...i.matchAll(t)].filter((s) => s[1] == null && s[2] !== "constructor").map((s) => s[2]);
|
|
69
|
+
o.name != null && (e.id = o.name), e.operations = r, o.version != null && (e.version = o.version), await n.writeFile("config.json", JSON.stringify(e, void 0, 4), "utf8"), console.info("â
Context configuration built.");
|
|
70
70
|
} catch (o) {
|
|
71
71
|
console.error("â Error building context configuration.", o);
|
|
72
72
|
}
|
|
@@ -74,8 +74,8 @@ async function x() {
|
|
|
74
74
|
async function j() {
|
|
75
75
|
try {
|
|
76
76
|
console.info("đ Building presenter configuration...");
|
|
77
|
-
const o = JSON.parse(await
|
|
78
|
-
o.name != null && (
|
|
77
|
+
const o = JSON.parse(await n.readFile("package.json", "utf8")), e = JSON.parse(await n.readFile("config.json", "utf8")), i = await n.readFile("src/index.ts", "utf8"), t = /^\s{4}(?:async\s+)?(private\s+)?(?:public\s+|protected\s+)?([A-Za-z_]\w*)\s*\(/gm, r = [...i.matchAll(t)].filter((s) => !s[1] && s[2] !== "constructor").map((s) => s[2]);
|
|
78
|
+
o.name != null && (e.id = o.name), e.operations = r, o.version != null && (e.version = o.version), await n.writeFile("config.json", JSON.stringify(e, void 0, 4), "utf8"), console.info("â
Presenter configuration built.");
|
|
79
79
|
} catch (o) {
|
|
80
80
|
console.error("â Error building context configuration.", o);
|
|
81
81
|
}
|
|
@@ -83,40 +83,53 @@ async function j() {
|
|
|
83
83
|
async function C(o = "./") {
|
|
84
84
|
try {
|
|
85
85
|
console.info("đ Bumping version...");
|
|
86
|
-
const
|
|
87
|
-
if (
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
86
|
+
const e = JSON.parse(await n.readFile(`${o}package.json`, "utf8"));
|
|
87
|
+
if (e.version == null)
|
|
88
|
+
e.version = "0.0.001", await n.writeFile(`${o}package.json`, JSON.stringify(e, void 0, 4), "utf8"), console.warn(`â ī¸ Version initialised to ${e.version}.`);
|
|
89
|
+
else {
|
|
90
|
+
const i = e.version, t = e.version.split(".");
|
|
91
|
+
e.version = `${t[0]}.${t[1]}.${Number(t[2]) + 1}`, await n.writeFile(`${o}package.json`, JSON.stringify(e, void 0, 4), "utf8"), console.info(`â
Version bumped from ${i} to ${e.version}.`);
|
|
92
|
+
}
|
|
93
|
+
} catch (e) {
|
|
94
|
+
console.error("â Error bumping package version.", e);
|
|
94
95
|
}
|
|
95
96
|
}
|
|
96
97
|
function F(o) {
|
|
97
98
|
console.error(`â ${o} script not implemented.`);
|
|
98
99
|
}
|
|
99
100
|
async function R() {
|
|
100
|
-
const o = "<!-- DEPENDENCY_LICENSES_START -->",
|
|
101
|
+
const o = "<!-- DEPENDENCY_LICENSES_START -->", e = "<!-- DEPENDENCY_LICENSES_END -->";
|
|
101
102
|
try {
|
|
102
|
-
const i = (await
|
|
103
|
+
const i = (await n.readFile("./licenses.md", "utf8")).trim(), t = await n.readFile("./README.md", "utf8"), r = t.indexOf(o), s = t.indexOf(e);
|
|
103
104
|
(r === -1 || s === -1) && (console.error("Error: Markers not found in README.md"), process.exit(1));
|
|
104
105
|
const d = t.substring(0, r + o.length) + `
|
|
105
106
|
` + i + `
|
|
106
107
|
` + t.substring(s);
|
|
107
|
-
await
|
|
108
|
+
await n.writeFile("README.md", d, "utf8"), console.log("â README.md updated with license information");
|
|
108
109
|
} catch (i) {
|
|
109
110
|
console.error("Error updating README:", i), process.exit(1);
|
|
110
111
|
}
|
|
111
112
|
}
|
|
112
113
|
async function k() {
|
|
114
|
+
try {
|
|
115
|
+
const o = JSON.parse(await n.readFile("./dependency-check-report.json", "utf-8"));
|
|
116
|
+
let e = 0;
|
|
117
|
+
for (const t of o.dependencies)
|
|
118
|
+
e += t.vulnerabilities.length;
|
|
119
|
+
console.log("vulnerabilityCount", e);
|
|
120
|
+
const i = await n.readFile("./README.md", "utf8");
|
|
121
|
+
} catch (o) {
|
|
122
|
+
console.error("Error updating README:", o), process.exit(1);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
async function D() {
|
|
113
126
|
try {
|
|
114
127
|
console.info("đ Sending deployment notice...");
|
|
115
|
-
const o = JSON.parse(await
|
|
128
|
+
const o = JSON.parse(await n.readFile("config.json", "utf8")), e = {
|
|
116
129
|
body: JSON.stringify(o),
|
|
117
130
|
headers: { "Content-Type": "application/json" },
|
|
118
131
|
method: "PUT"
|
|
119
|
-
}, i = await fetch(`https://api.datapos.app/states/${o.id}`,
|
|
132
|
+
}, i = await fetch(`https://api.datapos.app/states/${o.id}`, e);
|
|
120
133
|
if (!i.ok) throw new Error(await i.text());
|
|
121
134
|
console.info("â
Deployment notice sent.");
|
|
122
135
|
} catch (o) {
|
|
@@ -126,20 +139,20 @@ async function k() {
|
|
|
126
139
|
async function I() {
|
|
127
140
|
try {
|
|
128
141
|
console.info("đ Synchronising with GitHub....");
|
|
129
|
-
const o = JSON.parse(await
|
|
142
|
+
const o = JSON.parse(await n.readFile("package.json", "utf8"));
|
|
130
143
|
await g("git add ."), await g(`git commit -m "v${o.version}"`), await g("git push origin main:main"), console.info(`â
Synchronised version ${o.version} with GitHub.`);
|
|
131
144
|
} catch (o) {
|
|
132
145
|
console.error("â Error synchronising with GitHub.", o);
|
|
133
146
|
}
|
|
134
147
|
}
|
|
135
|
-
async function
|
|
148
|
+
async function A(o, e) {
|
|
136
149
|
try {
|
|
137
150
|
console.info("đ Uploading directory to R2....");
|
|
138
151
|
async function i(r, s, d) {
|
|
139
152
|
for (const a of d) {
|
|
140
153
|
const c = `${r}/${a}`, l = `${s}/${a}`;
|
|
141
|
-
if ((await
|
|
142
|
-
const u = await
|
|
154
|
+
if ((await n.stat(c)).isDirectory()) {
|
|
155
|
+
const u = await n.readdir(c);
|
|
143
156
|
await i(c, l, u);
|
|
144
157
|
} else {
|
|
145
158
|
console.info(`âī¸ Uploading '${r}/${a}'...`);
|
|
@@ -148,20 +161,20 @@ async function D(o, n) {
|
|
|
148
161
|
}
|
|
149
162
|
}
|
|
150
163
|
}
|
|
151
|
-
const t = await
|
|
152
|
-
await i(`${o}/${
|
|
164
|
+
const t = await n.readdir(`${o}/${e}/`);
|
|
165
|
+
await i(`${o}/${e}`, e, t), console.info("â
Directory uploaded to R2.");
|
|
153
166
|
} catch (i) {
|
|
154
167
|
console.error("â Error uploading directory to R2.", i);
|
|
155
168
|
}
|
|
156
169
|
}
|
|
157
|
-
async function
|
|
170
|
+
async function M() {
|
|
158
171
|
try {
|
|
159
172
|
console.info("đ Uploading module configuration....");
|
|
160
|
-
const o = JSON.parse(await
|
|
173
|
+
const o = JSON.parse(await n.readFile("config.json", "utf8")), e = o.id, i = {
|
|
161
174
|
body: JSON.stringify(o),
|
|
162
175
|
headers: { "Content-Type": "application/json" },
|
|
163
176
|
method: "PUT"
|
|
164
|
-
}, t = await fetch(`https://api.datapos.app/states/${
|
|
177
|
+
}, t = await fetch(`https://api.datapos.app/states/${e}`, i);
|
|
165
178
|
if (!t.ok) throw new Error(await t.text());
|
|
166
179
|
console.info("â
Module configuration uploaded.");
|
|
167
180
|
} catch (o) {
|
|
@@ -171,9 +184,9 @@ async function A() {
|
|
|
171
184
|
async function P(o) {
|
|
172
185
|
try {
|
|
173
186
|
console.info("đ Uploading module to R2...");
|
|
174
|
-
const i = `v${JSON.parse(await
|
|
187
|
+
const i = `v${JSON.parse(await n.readFile("package.json", "utf8")).version}`;
|
|
175
188
|
async function t(r, s = "") {
|
|
176
|
-
const d = await
|
|
189
|
+
const d = await n.readdir(r, { withFileTypes: !0 });
|
|
177
190
|
for (const a of d) {
|
|
178
191
|
const c = `${r}/${a.name}`, l = s ? `${s}/${a.name}` : a.name;
|
|
179
192
|
if (!a.isDirectory()) {
|
|
@@ -185,8 +198,8 @@ async function P(o) {
|
|
|
185
198
|
}
|
|
186
199
|
}
|
|
187
200
|
await t("dist"), console.info("â
Module uploaded to R2.");
|
|
188
|
-
} catch (
|
|
189
|
-
console.error("â Error uploading module to R2.",
|
|
201
|
+
} catch (e) {
|
|
202
|
+
console.error("â Error uploading module to R2.", e);
|
|
190
203
|
}
|
|
191
204
|
}
|
|
192
205
|
export {
|
|
@@ -198,9 +211,10 @@ export {
|
|
|
198
211
|
C as bumpVersion,
|
|
199
212
|
F as echoScriptNotImplemented,
|
|
200
213
|
R as insertLicensesIntoReadme,
|
|
201
|
-
k as
|
|
214
|
+
k as insertOWASPDependencyCheckBadgeIntoReadme,
|
|
215
|
+
D as sendDeploymentNotice,
|
|
202
216
|
I as syncWithGitHub,
|
|
203
|
-
|
|
204
|
-
|
|
217
|
+
A as uploadDirectoryToR2,
|
|
218
|
+
M as uploadModuleConfigToDO,
|
|
205
219
|
P as uploadModuleToR2
|
|
206
220
|
};
|
|
@@ -9,9 +9,10 @@ declare function buildPresenterConfig(): Promise<void>;
|
|
|
9
9
|
declare function bumpVersion(path?: string): Promise<void>;
|
|
10
10
|
declare function echoScriptNotImplemented(name: string): void;
|
|
11
11
|
declare function insertLicensesIntoReadme(): Promise<void>;
|
|
12
|
+
declare function insertOWASPDependencyCheckBadgeIntoReadme(): Promise<void>;
|
|
12
13
|
declare function sendDeploymentNotice(): Promise<void>;
|
|
13
14
|
declare function syncWithGitHub(): Promise<void>;
|
|
14
15
|
declare function uploadDirectoryToR2(sourceDirectory: string, uploadDirectory: string): Promise<void>;
|
|
15
16
|
declare function uploadModuleConfigToDO(): Promise<void>;
|
|
16
17
|
declare function uploadModuleToR2(uploadDirPath: string): Promise<void>;
|
|
17
|
-
export { buildConfig, buildConnectorConfig, buildContextConfig, buildPresenterConfig, buildPublicDirectoryIndex, bumpVersion, echoScriptNotImplemented, insertLicensesIntoReadme, sendDeploymentNotice, syncWithGitHub, uploadDirectoryToR2, uploadModuleConfigToDO, uploadModuleToR2 };
|
|
18
|
+
export { buildConfig, buildConnectorConfig, buildContextConfig, buildPresenterConfig, buildPublicDirectoryIndex, bumpVersion, echoScriptNotImplemented, insertLicensesIntoReadme, insertOWASPDependencyCheckBadgeIntoReadme, sendDeploymentNotice, syncWithGitHub, uploadDirectoryToR2, uploadModuleConfigToDO, uploadModuleToR2 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datapos/datapos-development",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.113",
|
|
4
4
|
"description": "A library of utilities for managing the Data Positioning repositories.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Jonathan Terrell <terrell.jm@gmail.com>",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"_document:licenceReportJSON": "license-report --only=prod,peer --department.value=n/a --licensePeriod=n/a --material=n/a --relatedTo.value=n/a > licenses.json",
|
|
70
70
|
"_document:licenceReportMarkdown": "license-report --config license-report-config.json --only=prod,peer --output=markdown > licenses.md",
|
|
71
71
|
"_document:licenceReportCheck": "license-report-check --source ./licenses.json --allowed 'MIT' --allowed 'n/a' --allowed 'Apache-2.0' --allowed 'CC0-1.0' --output=table",
|
|
72
|
-
"_document:licenceTree": "license-report-recursive --only=prod,peer
|
|
72
|
+
"_document:licenceTree": "license-report-recursive --only=prod,peer --department.value=n/a --licensePeriod=n/a --material=n/a --relatedTo.value=n/a --recurse --output=tree > licenseTree.json",
|
|
73
73
|
"_document:licenceTreeCheck": "license-report-check --source ./licenseTree.json --allowed 'MIT' --allowed 'n/a' --allowed 'Apache-2.0' --allowed 'CC0-1.0' --output=table",
|
|
74
74
|
"_document:insertLicensesIntoReadme": "node -e \"import('./dist/datapos-development.es.js').then(m => m.insertLicensesIntoReadme())\"",
|
|
75
75
|
"_sync:withGitHub": "node -e \"import('./dist/datapos-development.es.js').then(m => m.syncWithGitHub())\"",
|