@datapos/datapos-development 0.3.60 → 0.3.61

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.
@@ -1,6 +1,6 @@
1
- import { exec as m } from "child_process";
1
+ import { exec as w } from "child_process";
2
2
  import { promises as n } from "fs";
3
- import { promisify as w } from "util";
3
+ import { promisify as m } from "util";
4
4
  const y = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
5
5
  let b = (o = 21) => {
6
6
  let e = "", i = crypto.getRandomValues(new Uint8Array(o |= 0));
@@ -8,7 +8,7 @@ let b = (o = 21) => {
8
8
  e += y[i[o] & 63];
9
9
  return e;
10
10
  };
11
- const v = ["createObject", "dropObject", "removeRecords", "upsertRecords"], h = ["findObject", "getRecord", "listNodes", "previewObject", "retrieveRecords"], f = w(m);
11
+ const v = ["createObject", "dropObject", "removeRecords", "upsertRecords"], h = ["findObject", "getRecord", "listNodes", "previewObject", "retrieveRecords"], u = m(w);
12
12
  async function $() {
13
13
  try {
14
14
  console.log("🚀 Building configuration...");
@@ -24,26 +24,26 @@ async function J(o) {
24
24
  const e = {};
25
25
  async function i(r, t) {
26
26
  console.log(`âš™ī¸ Processing directory '${r}'...`);
27
- const g = [], c = r.substring(`public/${o}`.length);
28
- e[c] = g;
27
+ const d = [], l = r.substring(`public/${o}`.length);
28
+ e[l] = d;
29
29
  for (const a of t) {
30
- const l = `${r}/${a}`;
30
+ const c = `${r}/${a}`;
31
31
  try {
32
- const d = await n.stat(l);
33
- if (d.isDirectory()) {
34
- const p = await n.readdir(l), u = { childCount: p.length, name: `${a}`, typeId: "folder" };
35
- g.push(u), await i(l, p);
32
+ const g = await n.stat(c);
33
+ if (g.isDirectory()) {
34
+ const p = await n.readdir(c), f = { childCount: p.length, name: `${a}`, typeId: "folder" };
35
+ d.push(f), await i(c, p);
36
36
  } else {
37
- const p = { id: b(), lastModifiedAt: d.mtimeMs, name: a, size: d.size, typeId: "object" };
38
- g.push(p);
37
+ const p = { id: b(), lastModifiedAt: g.mtimeMs, name: a, size: g.size, typeId: "object" };
38
+ d.push(p);
39
39
  }
40
- } catch (d) {
41
- console.error(`Unable to get information for '${a}' in 'buildPublicDirectoryIndex'.`, d);
40
+ } catch (g) {
41
+ console.error(`Unable to get information for '${a}' in 'buildPublicDirectoryIndex'.`, g);
42
42
  }
43
43
  }
44
- g.sort((a, l) => {
45
- const d = a.typeId.localeCompare(l.typeId);
46
- return d !== 0 ? d : a.name.localeCompare(l.name);
44
+ d.sort((a, c) => {
45
+ const g = a.typeId.localeCompare(c.typeId);
46
+ return g !== 0 ? g : a.name.localeCompare(c.name);
47
47
  });
48
48
  }
49
49
  const s = await n.readdir(`public/${o}`);
@@ -57,13 +57,13 @@ async function j() {
57
57
  console.log("🚀 Building connector configuration...");
58
58
  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");
59
59
  let s = !1, r = !1;
60
- const t = /^\s{4}(?:async\s+)?(private\s+)?(?:public\s+|protected\s+)?([A-Za-z_]\w*)\s*\(/gm, g = [...i.matchAll(t)].filter((a) => !a[1] && a[2] !== "constructor").map((a) => {
61
- const l = a[2];
62
- return s = s || v.includes(l), r = r || h.includes(l), l;
60
+ const t = /^\s{4}(?:async\s+)?(private\s+)?(?:public\s+|protected\s+)?([A-Za-z_]\w*)\s*\(/gm, d = [...i.matchAll(t)].filter((a) => !a[1] && a[2] !== "constructor").map((a) => {
61
+ const c = a[2];
62
+ return s = s || v.includes(c), r = r || h.includes(c), c;
63
63
  });
64
- g.length > 0 ? console.log(`â„šī¸ Implements ${g.length} operations.`) : console.log("âš ī¸ Implements no operations.");
65
- const c = r && s ? "bidirectional" : r ? "source" : s ? "destination" : null;
66
- console.log(c ? `â„šī¸ Supports ${c} usage.` : "âš ī¸ No usage identified."), o.name && (e.id = o.name), e.operations = g, e.usageId = c, o.version && (e.version = o.version), await n.writeFile("config.json", JSON.stringify(e, void 0, 4), "utf8"), console.log("✅ Connector configuration built.");
64
+ d.length > 0 ? console.log(`â„šī¸ Implements ${d.length} operations.`) : console.log("âš ī¸ Implements no operations.");
65
+ const l = r && s ? "bidirectional" : r ? "source" : s ? "destination" : null;
66
+ console.log(l ? `â„šī¸ Supports ${l} usage.` : "âš ī¸ No usage identified."), o.name && (e.id = o.name), e.operations = d, e.usageId = l, o.version && (e.version = o.version), await n.writeFile("config.json", JSON.stringify(e, void 0, 4), "utf8"), console.log("✅ Connector configuration built.");
67
67
  } catch (o) {
68
68
  console.warn("❌ Error building connector configuration.", o);
69
69
  }
@@ -117,7 +117,7 @@ async function E() {
117
117
  method: "PUT"
118
118
  }, i = await fetch(`https://api.datapos.app/states/${o.id}`, e);
119
119
  if (!i.ok)
120
- throw console.log(await i.text()), new Error("Fetch error.");
120
+ throw console.log("❌", await i.text()), new Error("Fetch error.");
121
121
  console.log("✅ Deployment notice sent.");
122
122
  } catch (o) {
123
123
  console.warn("❌ Error sending deployment notice.", o);
@@ -127,7 +127,7 @@ async function I() {
127
127
  try {
128
128
  console.log("🚀 Synchronising with GitHub....");
129
129
  const o = JSON.parse(await n.readFile("package.json", "utf8"));
130
- await f("git add ."), await f(`git commit -m "v${o.version}"`), await f("git push origin main:main"), console.log(`✅ Synchronised version ${o.version} with GitHub.`);
130
+ await u("git add ."), await u(`git commit -m "v${o.version}"`), await u("git push origin main:main"), console.log(`✅ Synchronised version ${o.version} with GitHub.`);
131
131
  } catch (o) {
132
132
  console.warn("❌ Error synchronising with GitHub.", o);
133
133
  }
@@ -135,29 +135,26 @@ async function I() {
135
135
  async function R(o, e) {
136
136
  try {
137
137
  console.log("🚀 Uploading directory to R2....");
138
- async function i(r, t, g) {
139
- for (const c of g) {
140
- const a = `${r}/${c}`, l = `${t}/${c}`;
141
- try {
142
- if ((await n.stat(a)).isDirectory()) {
143
- const p = await n.readdir(a);
144
- await i(a, l, p);
145
- } else {
146
- const p = `wrangler r2 object put "datapos-sample-data-eu/${t}/${c}" --file="${r}/${c}" --jurisdiction=eu --remote`, u = await f(p);
147
- console.log("Uploading:", `${r}/${c}`), u.stderr && (console.log("Command___:", p), console.log("Error_____:", u.stderr));
148
- }
149
- } catch (d) {
150
- console.error(`Unable to get information for '${c}' in 'uploadDirectoryToR2'.`, d);
138
+ async function i(r, t, d) {
139
+ for (const l of d) {
140
+ const a = `${r}/${l}`, c = `${t}/${l}`;
141
+ if ((await n.stat(a)).isDirectory()) {
142
+ const p = await n.readdir(a);
143
+ await i(a, c, p);
144
+ } else {
145
+ const p = `wrangler r2 object put "datapos-sample-data-eu/${t}/${l}" --file="${r}/${l}" --jurisdiction=eu --remote`, f = await u(p);
146
+ if (console.log(`âš™ī¸ Uploading '${r}/${l}'.`), f.stderr)
147
+ throw console.log("❌", f.stderr), new Error("Upload error.");
151
148
  }
152
149
  }
153
150
  }
154
151
  const s = await n.readdir(`${o}/${e}/`);
155
- await i(`${o}/${e}`, e, s), console.log("✅ Directory cleared.");
152
+ await i(`${o}/${e}`, e, s), console.log("✅ Directory uploaded to R2.");
156
153
  } catch (i) {
157
154
  console.warn("❌ Error uploading directory to R2.", i);
158
155
  }
159
156
  }
160
- async function _() {
157
+ async function A() {
161
158
  try {
162
159
  console.log("🚀 Uploading module configuration....");
163
160
  const o = JSON.parse(await n.readFile("config.json", "utf8")), e = o.id, i = {
@@ -165,18 +162,18 @@ async function _() {
165
162
  headers: { "Content-Type": "application/json" },
166
163
  method: "PUT"
167
164
  }, s = await fetch(`https://api.datapos.app/states/${e}`, i);
168
- s.ok || console.log(await s.text()), console.log("✅ Directory cleared.");
165
+ s.ok || console.log(await s.text()), console.log("✅ Module configuration uploaded.");
169
166
  } catch (o) {
170
167
  console.warn("❌ Error uploading module configuration.", o);
171
168
  }
172
169
  }
173
- async function A(o, e) {
170
+ async function P(o, e) {
174
171
  try {
175
172
  console.log("🚀 Uploading module to R2....");
176
- const i = JSON.parse(await n.readFile("package.json", "utf8")), s = e.replace(/^(.*?\.)/, `$1v${i.version}.`), { stdout: r, stderr: t } = await f(
173
+ const i = JSON.parse(await n.readFile("package.json", "utf8")), s = e.replace(/^(.*?\.)/, `$1v${i.version}.`), { stdout: r, stderr: t } = await u(
177
174
  `wrangler r2 object put ${s} --file=dist/${o} --content-type application/javascript --jurisdiction=eu --remote`
178
175
  );
179
- r && console.log(r), t && console.error(t), console.log("✅ Directory cleared.");
176
+ r && console.log(r), t && console.error(t), console.log("✅ Module uploaded to R2.");
180
177
  } catch (i) {
181
178
  console.warn("❌ Error uploading module to R2.", i);
182
179
  }
@@ -192,6 +189,6 @@ export {
192
189
  E as sendDeploymentNotice,
193
190
  I as syncWithGitHub,
194
191
  R as uploadDirectoryToR2,
195
- _ as uploadModuleConfig,
196
- A as uploadModuleToR2
192
+ A as uploadModuleConfig,
193
+ P as uploadModuleToR2
197
194
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "license": "MIT",
4
4
  "private": false,
5
5
  "type": "module",
6
- "version": "0.3.60",
6
+ "version": "0.3.61",
7
7
  "files": [
8
8
  "dist"
9
9
  ],