@datapos/datapos-development 0.3.120 → 0.3.122

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.
@@ -2,24 +2,24 @@ import { exec as h } from "node:child_process";
2
2
  import { promises as t } from "node:fs";
3
3
  import { nanoid as b } from "nanoid";
4
4
  import { promisify as $ } from "node:util";
5
- const E = ["createObject", "dropObject", "removeRecords", "upsertRecords"], v = ["findObject", "getRecord", "listNodes", "previewObject", "retrieveRecords"], w = $(h);
5
+ const v = ["createObject", "dropObject", "removeRecords", "upsertRecords"], O = ["findObject", "getRecord", "listNodes", "previewObject", "retrieveRecords"], w = $(h);
6
6
  async function j() {
7
7
  try {
8
8
  console.info("🚀 Building configuration...");
9
- const o = JSON.parse(await t.readFile("package.json", "utf8")), e = JSON.parse(await t.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 t.writeFile("config.json", JSON.stringify(e, void 0, 4), "utf8"), console.info("✅ Configuration built.");
11
- } catch (o) {
12
- console.error("❌ Error building configuration.", o);
9
+ const e = JSON.parse(await t.readFile("package.json", "utf8")), o = JSON.parse(await t.readFile("config.json", "utf8"));
10
+ e.name != null && (o.id = e.name.replace("@datapos/", "").replace("@data-positioning/", "")), e.version != null && (o.version = e.version), await t.writeFile("config.json", JSON.stringify(o, void 0, 4), "utf8"), console.info("✅ Configuration built.");
11
+ } catch (e) {
12
+ console.error("❌ Error building configuration.", e);
13
13
  }
14
14
  }
15
- async function C(o) {
15
+ async function C(e) {
16
16
  try {
17
- console.info(`🚀 Building public directory index for identifier '${o}'...`);
18
- const e = {};
17
+ console.info(`🚀 Building public directory index for identifier '${e}'...`);
18
+ const o = {};
19
19
  async function i(s, r) {
20
20
  console.info(`âš™ī¸ Processing directory '${s}'...`);
21
- const d = [], a = s.substring(`public/${o}`.length);
22
- e[a] = d;
21
+ const d = [], a = s.substring(`public/${e}`.length);
22
+ o[a] = d;
23
23
  for (const c of r) {
24
24
  const l = `${s}/${c}`;
25
25
  try {
@@ -40,78 +40,78 @@ async function C(o) {
40
40
  return f === 0 ? c.name.localeCompare(l.name) : f;
41
41
  });
42
42
  }
43
- const n = await t.readdir(`public/${o}`);
44
- await i(`public/${o}`, n), await t.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);
43
+ const n = await t.readdir(`public/${e}`);
44
+ await i(`public/${e}`, n), await t.writeFile(`./public/${e}Index.json`, JSON.stringify(o), "utf8"), console.info("✅ Public directory index built.");
45
+ } catch (o) {
46
+ console.error("❌ Error building public directory index.", o);
47
47
  }
48
48
  }
49
- async function R() {
49
+ async function k() {
50
50
  try {
51
51
  console.info("🚀 Building connector configuration...");
52
- const o = JSON.parse(await t.readFile("package.json", "utf8")), e = JSON.parse(await t.readFile("config.json", "utf8")), i = await t.readFile("src/index.ts", "utf8");
52
+ const e = JSON.parse(await t.readFile("package.json", "utf8")), o = JSON.parse(await t.readFile("config.json", "utf8")), i = await t.readFile("src/index.ts", "utf8");
53
53
  let n = !1, s = !1;
54
54
  const r = /^\s{4}(?:async\s+)?(private\s+)?(?:public\s+|protected\s+)?([A-Za-z_]\w*)\s*\(/gm, d = [...i.matchAll(r)].filter((c) => c[1] == null && c[2] !== "constructor").map((c) => {
55
55
  const l = c[2];
56
- return n = n || E.includes(l), s = s || v.includes(l), l;
56
+ return n = n || v.includes(l), s = s || O.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 = s && n ? "bidirectional" : s ? "source" : n ? "destination" : "unknown";
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 t.writeFile("config.json", JSON.stringify(e, void 0, 4), "utf8"), console.info("✅ Connector configuration built.");
61
- } catch (o) {
62
- console.error("❌ Error building connector configuration.", o);
60
+ a && console.info(`â„šī¸ Supports ${a} usage.`), e.name != null && (o.id = e.name), o.operations = d, o.usageId = a, e.version != null && (o.version = e.version), await t.writeFile("config.json", JSON.stringify(o, void 0, 4), "utf8"), console.info("✅ Connector configuration built.");
61
+ } catch (e) {
62
+ console.error("❌ Error building connector configuration.", e);
63
63
  }
64
64
  }
65
- async function k() {
65
+ async function J() {
66
66
  try {
67
67
  console.info("🚀 Building context configuration...");
68
- const o = JSON.parse(await t.readFile("package.json", "utf8")), e = JSON.parse(await t.readFile("config.json", "utf8")), i = await t.readFile("src/index.ts", "utf8"), n = /^\s{4}(?:async\s+)?(private\s+)?(?:public\s+|protected\s+)?([A-Za-z_]\w*)\s*\(/gm, s = [...i.matchAll(n)].filter((r) => r[1] == null && r[2] !== "constructor").map((r) => r[2]);
69
- o.name != null && (e.id = o.name), e.operations = s, o.version != null && (e.version = o.version), await t.writeFile("config.json", JSON.stringify(e, void 0, 4), "utf8"), console.info("✅ Context configuration built.");
70
- } catch (o) {
71
- console.error("❌ Error building context configuration.", o);
68
+ const e = JSON.parse(await t.readFile("package.json", "utf8")), o = JSON.parse(await t.readFile("config.json", "utf8")), i = await t.readFile("src/index.ts", "utf8"), n = /^\s{4}(?:async\s+)?(private\s+)?(?:public\s+|protected\s+)?([A-Za-z_]\w*)\s*\(/gm, s = [...i.matchAll(n)].filter((r) => r[1] == null && r[2] !== "constructor").map((r) => r[2]);
69
+ e.name != null && (o.id = e.name), o.operations = s, e.version != null && (o.version = e.version), await t.writeFile("config.json", JSON.stringify(o, void 0, 4), "utf8"), console.info("✅ Context configuration built.");
70
+ } catch (e) {
71
+ console.error("❌ Error building context configuration.", e);
72
72
  }
73
73
  }
74
- async function J() {
74
+ async function R() {
75
75
  try {
76
76
  console.info("🚀 Building presenter configuration...");
77
- const o = JSON.parse(await t.readFile("package.json", "utf8")), e = JSON.parse(await t.readFile("config.json", "utf8")), i = await t.readFile("src/index.ts", "utf8"), n = /^\s{4}(?:async\s+)?(private\s+)?(?:public\s+|protected\s+)?([A-Za-z_]\w*)\s*\(/gm, s = [...i.matchAll(n)].filter((r) => !r[1] && r[2] !== "constructor").map((r) => r[2]);
78
- o.name != null && (e.id = o.name), e.operations = s, o.version != null && (e.version = o.version), await t.writeFile("config.json", JSON.stringify(e, void 0, 4), "utf8"), console.info("✅ Presenter configuration built.");
79
- } catch (o) {
80
- console.error("❌ Error building context configuration.", o);
77
+ const e = JSON.parse(await t.readFile("package.json", "utf8")), o = JSON.parse(await t.readFile("config.json", "utf8")), i = await t.readFile("src/index.ts", "utf8"), n = /^\s{4}(?:async\s+)?(private\s+)?(?:public\s+|protected\s+)?([A-Za-z_]\w*)\s*\(/gm, s = [...i.matchAll(n)].filter((r) => !r[1] && r[2] !== "constructor").map((r) => r[2]);
78
+ e.name != null && (o.id = e.name), o.operations = s, e.version != null && (o.version = e.version), await t.writeFile("config.json", JSON.stringify(o, void 0, 4), "utf8"), console.info("✅ Presenter configuration built.");
79
+ } catch (e) {
80
+ console.error("❌ Error building context configuration.", e);
81
81
  }
82
82
  }
83
- async function A(o = "./") {
83
+ async function A(e = "./") {
84
84
  try {
85
85
  console.info("🚀 Bumping version...");
86
- const e = JSON.parse(await t.readFile(`${o}package.json`, "utf8"));
87
- if (e.version == null)
88
- e.version = "0.0.001", await t.writeFile(`${o}package.json`, JSON.stringify(e, void 0, 4), "utf8"), console.warn(`âš ī¸ Version initialised to ${e.version}.`);
86
+ const o = JSON.parse(await t.readFile(`${e}package.json`, "utf8"));
87
+ if (o.version == null)
88
+ o.version = "0.0.001", await t.writeFile(`${e}package.json`, JSON.stringify(o, void 0, 4), "utf8"), console.warn(`âš ī¸ Version initialised to ${o.version}.`);
89
89
  else {
90
- const i = e.version, n = e.version.split(".");
91
- e.version = `${n[0]}.${n[1]}.${Number(n[2]) + 1}`, await t.writeFile(`${o}package.json`, JSON.stringify(e, void 0, 4), "utf8"), console.info(`✅ Version bumped from ${i} to ${e.version}.`);
90
+ const i = o.version, n = o.version.split(".");
91
+ o.version = `${n[0]}.${n[1]}.${Number(n[2]) + 1}`, await t.writeFile(`${e}package.json`, JSON.stringify(o, void 0, 4), "utf8"), console.info(`✅ Version bumped from ${i} to ${o.version}.`);
92
92
  }
93
- } catch (e) {
94
- console.error("❌ Error bumping package version.", e);
93
+ } catch (o) {
94
+ console.error("❌ Error bumping package version.", o);
95
95
  }
96
96
  }
97
- function F(o) {
98
- console.error(`❌ ${o} script not implemented.`);
97
+ function F(e) {
98
+ console.error(`❌ ${e} script not implemented.`);
99
99
  }
100
100
  async function D() {
101
- const o = "<!-- DEPENDENCY_LICENSES_START -->", e = "<!-- DEPENDENCY_LICENSES_END -->";
101
+ const e = "<!-- DEPENDENCY_LICENSES_START -->", o = "<!-- DEPENDENCY_LICENSES_END -->";
102
102
  try {
103
- const i = (await t.readFile("./licenses.md", "utf8")).trim(), n = await t.readFile("./README.md", "utf8"), s = n.indexOf(o), r = n.indexOf(e);
104
- (s === -1 || r === -1) && (console.error("Error: Markers not found in README.md"), process.exit(1));
105
- const d = n.substring(0, s + o.length) + `
103
+ const i = (await t.readFile("./licenses.md", "utf8")).trim(), n = await t.readFile("./README.md", "utf8"), s = n.indexOf(e), r = n.indexOf(o);
104
+ (s === -1 || r === -1) && (console.error("❌ Dependency license markers not found in readme file."), process.exit(1));
105
+ const d = n.substring(0, s + e.length) + `
106
106
  ` + i + `
107
107
  ` + n.substring(r);
108
- await t.writeFile("README.md", d, "utf8"), console.log("✓ README.md updated with license information");
108
+ await t.writeFile("README.md", d, "utf8"), console.log("✅ Readme file updated with license information");
109
109
  } catch (i) {
110
- console.error("Error updating README:", i), process.exit(1);
110
+ console.error("❌ Error updating readme file.", i), process.exit(1);
111
111
  }
112
112
  }
113
- async function M() {
114
- const o = "<!-- OWASP_BADGE_START -->", e = "<!-- OWASP_BADGE_END -->";
113
+ async function I() {
114
+ const e = "<!-- OWASP_BADGE_START -->", o = "<!-- OWASP_BADGE_END -->";
115
115
  try {
116
116
  const i = JSON.parse(await t.readFile("./dependency-check-reports/dependency-check-report.json", "utf-8")), n = { critical: 0, high: 0, moderate: 0, low: 0, unknown: 0 };
117
117
  for (const u of i.dependencies)
@@ -136,38 +136,38 @@ async function M() {
136
136
  console.info(`✅ Total vulnerabilities found: ${d}`), console.info(
137
137
  ` Critical: ${n.critical}, High: ${n.high}, Moderate: ${n.moderate}, Low: ${n.low}, Unknown: ${n.unknown}`
138
138
  );
139
- const a = await t.readFile("./README.md", "utf8"), c = a.indexOf(o), l = a.indexOf(e);
140
- (c === -1 || l === -1) && (console.error("❌ Markers not found in README.md."), process.exit(1));
141
- const f = r.join(" "), p = a.substring(0, c + o.length) + f + a.substring(l);
139
+ const a = await t.readFile("./README.md", "utf8"), c = a.indexOf(e), l = a.indexOf(o);
140
+ (c === -1 || l === -1) && (console.error("❌ OWASP badge markers not found in README.md."), process.exit(1));
141
+ const f = r.join(" "), p = a.substring(0, c + e.length) + f + a.substring(l);
142
142
  await t.writeFile("README.md", p, "utf8"), console.info("✅ OWASP dependency check badges inserted into README.md");
143
143
  } catch (i) {
144
144
  console.error("❌ Error updating README with OWASP badges:", i), process.exit(1);
145
145
  }
146
146
  }
147
- async function I() {
147
+ async function P() {
148
148
  try {
149
149
  console.info("🚀 Sending deployment notice...");
150
- const o = JSON.parse(await t.readFile("config.json", "utf8")), e = {
151
- body: JSON.stringify(o),
150
+ const e = JSON.parse(await t.readFile("config.json", "utf8")), o = {
151
+ body: JSON.stringify(e),
152
152
  headers: { "Content-Type": "application/json" },
153
153
  method: "PUT"
154
- }, i = await fetch(`https://api.datapos.app/states/${o.id}`, e);
154
+ }, i = await fetch(`https://api.datapos.app/states/${e.id}`, o);
155
155
  if (!i.ok) throw new Error(await i.text());
156
156
  console.info("✅ Deployment notice sent.");
157
- } catch (o) {
158
- console.error("❌ Error sending deployment notice.", o);
157
+ } catch (e) {
158
+ console.error("❌ Error sending deployment notice.", e);
159
159
  }
160
160
  }
161
- async function P() {
161
+ async function M() {
162
162
  try {
163
163
  console.info("🚀 Synchronising with GitHub....");
164
- const o = JSON.parse(await t.readFile("package.json", "utf8"));
165
- await w("git add ."), await w(`git commit -m "v${o.version}"`), await w("git push origin main:main"), console.info(`✅ Synchronised version ${o.version} with GitHub.`);
166
- } catch (o) {
167
- console.error("❌ Error synchronising with GitHub.", o);
164
+ const e = JSON.parse(await t.readFile("package.json", "utf8"));
165
+ await w("git add ."), await w(`git commit -m "v${e.version}"`), await w("git push origin main:main"), console.info(`✅ Synchronised version ${e.version} with GitHub.`);
166
+ } catch (e) {
167
+ console.error("❌ Error synchronising with GitHub.", e);
168
168
  }
169
169
  }
170
- async function T(o, e) {
170
+ async function T(e, o) {
171
171
  try {
172
172
  console.info("🚀 Uploading directory to R2....");
173
173
  async function i(s, r, d) {
@@ -183,8 +183,8 @@ async function T(o, e) {
183
183
  }
184
184
  }
185
185
  }
186
- const n = await t.readdir(`${o}/${e}/`);
187
- await i(`${o}/${e}`, e, n), console.info("✅ Directory uploaded to R2.");
186
+ const n = await t.readdir(`${e}/${o}/`);
187
+ await i(`${e}/${o}`, o, n), console.info("✅ Directory uploaded to R2.");
188
188
  } catch (i) {
189
189
  console.error("❌ Error uploading directory to R2.", i);
190
190
  }
@@ -192,18 +192,18 @@ async function T(o, e) {
192
192
  async function _() {
193
193
  try {
194
194
  console.info("🚀 Uploading module configuration....");
195
- const o = JSON.parse(await t.readFile("config.json", "utf8")), e = o.id, i = {
196
- body: JSON.stringify(o),
195
+ const e = JSON.parse(await t.readFile("config.json", "utf8")), o = e.id, i = {
196
+ body: JSON.stringify(e),
197
197
  headers: { "Content-Type": "application/json" },
198
198
  method: "PUT"
199
- }, n = await fetch(`https://api.datapos.app/states/${e}`, i);
199
+ }, n = await fetch(`https://api.datapos.app/states/${o}`, i);
200
200
  if (!n.ok) throw new Error(await n.text());
201
201
  console.info("✅ Module configuration uploaded.");
202
- } catch (o) {
203
- console.error("❌ Error uploading module configuration.", o);
202
+ } catch (e) {
203
+ console.error("❌ Error uploading module configuration.", e);
204
204
  }
205
205
  }
206
- async function U(o) {
206
+ async function U(e) {
207
207
  try {
208
208
  console.info("🚀 Uploading module to R2...");
209
209
  const i = `v${JSON.parse(await t.readFile("package.json", "utf8")).version}`;
@@ -212,7 +212,7 @@ async function U(o) {
212
212
  for (const a of d) {
213
213
  const c = `${s}/${a.name}`, l = r ? `${r}/${a.name}` : a.name;
214
214
  if (!a.isDirectory()) {
215
- const f = `${o}_${i}/${l}`.replace(/\\/g, "/"), p = a.name.endsWith(".js") ? "application/javascript" : a.name.endsWith(".css") ? "text/css" : "application/octet-stream";
215
+ const f = `${e}_${i}/${l}`.replace(/\\/g, "/"), p = a.name.endsWith(".js") ? "application/javascript" : a.name.endsWith(".css") ? "text/css" : "application/octet-stream";
216
216
  console.info(`âš™ī¸ Uploading '${l}' → '${f}'...`);
217
217
  const { stderr: u } = await w(`wrangler r2 object put "${f}" --file="${c}" --content-type ${p} --jurisdiction=eu --remote`);
218
218
  if (u) throw new Error(u);
@@ -220,22 +220,22 @@ async function U(o) {
220
220
  }
221
221
  }
222
222
  await n("dist"), console.info("✅ Module uploaded to R2.");
223
- } catch (e) {
224
- console.error("❌ Error uploading module to R2.", e);
223
+ } catch (o) {
224
+ console.error("❌ Error uploading module to R2.", o);
225
225
  }
226
226
  }
227
227
  export {
228
228
  j as buildConfig,
229
- R as buildConnectorConfig,
230
- k as buildContextConfig,
231
- J as buildPresenterConfig,
229
+ k as buildConnectorConfig,
230
+ J as buildContextConfig,
231
+ R as buildPresenterConfig,
232
232
  C as buildPublicDirectoryIndex,
233
233
  A as bumpVersion,
234
234
  F as echoScriptNotImplemented,
235
235
  D as insertLicensesIntoReadme,
236
- M as insertOWASPDependencyCheckBadgeIntoReadme,
237
- I as sendDeploymentNotice,
238
- P as syncWithGitHub,
236
+ I as insertOWASPDependencyCheckBadgeIntoReadme,
237
+ P as sendDeploymentNotice,
238
+ M as syncWithGitHub,
239
239
  T as uploadDirectoryToR2,
240
240
  _ as uploadModuleConfigToDO,
241
241
  U as uploadModuleToR2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datapos/datapos-development",
3
- "version": "0.3.120",
3
+ "version": "0.3.122",
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>",