@datapos/datapos-development 0.3.110 → 0.3.114

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 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 | 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
- | buildInformerConfig | Build the informer config.json file for the repository. |
43
- | buildPresenterConfig | Build the presenter config.json file for the repository. |
44
- | buildPublicDirectoryIndex | Build an index for the repositories public directory. |
45
- | bumpVersion | Bump the repositories version number. |
46
- | echoScriptNotImplemented | Echo script not implemented message to console.. |
47
- | sendDeploymentNotice | Send a deployment notice for the repository. |
48
- | syncWithGitHub | Synchronise the local repository with the main GitHub repository. |
49
- | uploadDirectoryToR2 | Upload a directory to Cloudflare R2 storage. |
50
- | uploadModuleConfigToDO | Upload a modules configuration to the Cloudflare `state` durable object. |
51
- | uploadModuleToR2 | Upload a module to Cloudflare R2 storage. |
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 e } from "node:fs";
3
- import { nanoid as w } from "nanoid";
4
- import { promisify as y } from "node:util";
5
- const $ = ["createObject", "dropObject", "removeRecords", "upsertRecords"], h = ["findObject", "getRecord", "listNodes", "previewObject", "retrieveRecords"], g = y(m);
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 e.readFile("package.json", "utf8")), n = JSON.parse(await e.readFile("config.json", "utf8"));
10
- o.name != null && (n.id = o.name.replace("@datapos/", "").replace("@data-positioning/", "")), o.version != null && (n.version = o.version), await e.writeFile("config.json", JSON.stringify(n, void 0, 4), "utf8"), console.info("✅ Configuration built.");
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 n = {};
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
- n[a] = d;
22
+ e[a] = d;
23
23
  for (const c of s) {
24
24
  const l = `${r}/${c}`;
25
25
  try {
26
- const f = await e.stat(l);
26
+ const f = await n.stat(l);
27
27
  if (f.isDirectory()) {
28
- const u = await e.readdir(l), p = { childCount: u.length, name: `${c}`, typeId: "folder" };
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: w(), lastModifiedAt: f.mtimeMs, name: c, size: f.size, typeId: "object" };
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 e.readdir(`public/${o}`);
44
- await i(`public/${o}`, t), await e.writeFile(`./public/${o}Index.json`, JSON.stringify(n), "utf8"), console.info("✅ Public directory index built.");
45
- } catch (n) {
46
- console.error("❌ Error building public directory index.", n);
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 e.readFile("package.json", "utf8")), n = JSON.parse(await e.readFile("config.json", "utf8")), i = await e.readFile("src/index.ts", "utf8");
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 || $.includes(l), r = r || h.includes(l), l;
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 && (n.id = o.name), n.operations = d, n.usageId = a, o.version != null && (n.version = o.version), await e.writeFile("config.json", JSON.stringify(n, void 0, 4), "utf8"), console.info("✅ Connector configuration built.");
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 e.readFile("package.json", "utf8")), n = JSON.parse(await e.readFile("config.json", "utf8")), i = await e.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 && (n.id = o.name), n.operations = r, o.version != null && (n.version = o.version), await e.writeFile("config.json", JSON.stringify(n, void 0, 4), "utf8"), console.info("✅ Context configuration built.");
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 e.readFile("package.json", "utf8")), n = JSON.parse(await e.readFile("config.json", "utf8")), i = await e.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 && (n.id = o.name), n.operations = r, o.version != null && (n.version = o.version), await e.writeFile("config.json", JSON.stringify(n, void 0, 4), "utf8"), console.info("✅ Presenter configuration built.");
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 n = JSON.parse(await e.readFile(`${o}package.json`, "utf8"));
87
- if (n.version != null) {
88
- const i = n.version, t = n.version.split(".");
89
- n.version = `${t[0]}.${t[1]}.${Number(t[2]) + 1}`, await e.writeFile(`${o}package.json`, JSON.stringify(n, void 0, 4), "utf8"), console.info(`✅ Version bumped from ${i} to ${n.version}.`);
90
- } else
91
- n.version = "0.0.001", await e.writeFile(`${o}package.json`, JSON.stringify(n, void 0, 4), "utf8"), console.warn(`âš ī¸ Version initialised to ${n.version}.`);
92
- } catch (n) {
93
- console.error("❌ Error bumping package version.", n);
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 -->", n = "<!-- DEPENDENCY_LICENSES_END -->";
101
+ const o = "<!-- DEPENDENCY_LICENSES_START -->", e = "<!-- DEPENDENCY_LICENSES_END -->";
101
102
  try {
102
- const i = (await e.readFile("./licenses.md", "utf8")).trim(), t = await e.readFile("./README.md", "utf8"), r = t.indexOf(o), s = t.indexOf(n);
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 e.writeFile("README.md", d, "utf8"), console.log("✓ README.md updated with license information");
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-reports/dependency-check-report.json", "utf-8"));
116
+ let e = 0;
117
+ for (const t of o.dependencies)
118
+ t.vulnerabilities != null && (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 e.readFile("config.json", "utf8")), n = {
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}`, n);
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 e.readFile("package.json", "utf8"));
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 D(o, n) {
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 e.stat(c)).isDirectory()) {
142
- const u = await e.readdir(c);
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 e.readdir(`${o}/${n}/`);
152
- await i(`${o}/${n}`, n, t), console.info("✅ Directory uploaded to R2.");
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 A() {
170
+ async function M() {
158
171
  try {
159
172
  console.info("🚀 Uploading module configuration....");
160
- const o = JSON.parse(await e.readFile("config.json", "utf8")), n = o.id, i = {
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/${n}`, i);
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 e.readFile("package.json", "utf8")).version}`;
187
+ const i = `v${JSON.parse(await n.readFile("package.json", "utf8")).version}`;
175
188
  async function t(r, s = "") {
176
- const d = await e.readdir(r, { withFileTypes: !0 });
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 (n) {
189
- console.error("❌ Error uploading module to R2.", n);
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 sendDeploymentNotice,
214
+ k as insertOWASPDependencyCheckBadgeIntoReadme,
215
+ D as sendDeploymentNotice,
202
216
  I as syncWithGitHub,
203
- D as uploadDirectoryToR2,
204
- A as uploadModuleConfigToDO,
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.110",
3
+ "version": "0.3.114",
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>",
@@ -65,11 +65,12 @@
65
65
  "test": "vitest",
66
66
  "update:dataPosDeps": "npm run _update:sharedDep",
67
67
  "_bump:version": "node -e \"import('./dist/datapos-development.es.js').then(m => m.bumpVersion())\"",
68
+ "_check:insertOWASPBadge": "node -e \"import('./dist/datapos-development.es.js').then(m => m.insertOWASPDependencyCheckBadgeIntoReadme())\"",
68
69
  "_check:owasp": "set -a && source .env && set +a && owasp-dependency-check --project \"@datapos/datapos-tool-micromark\" --enableRetired --nvdApiKey \"$NVD_API_KEY\"",
69
70
  "_document:licenceReportJSON": "license-report --only=prod,peer --department.value=n/a --licensePeriod=n/a --material=n/a --relatedTo.value=n/a > licenses.json",
70
71
  "_document:licenceReportMarkdown": "license-report --config license-report-config.json --only=prod,peer --output=markdown > licenses.md",
71
72
  "_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,dev --recurse --output=tree > licenseTree.json",
73
+ "_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
74
  "_document:licenceTreeCheck": "license-report-check --source ./licenseTree.json --allowed 'MIT' --allowed 'n/a' --allowed 'Apache-2.0' --allowed 'CC0-1.0' --output=table",
74
75
  "_document:insertLicensesIntoReadme": "node -e \"import('./dist/datapos-development.es.js').then(m => m.insertLicensesIntoReadme())\"",
75
76
  "_sync:withGitHub": "node -e \"import('./dist/datapos-development.es.js').then(m => m.syncWithGitHub())\"",