@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.
- package/dist/datapos-development.es.js +43 -46
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { exec as
|
|
1
|
+
import { exec as w } from "child_process";
|
|
2
2
|
import { promises as n } from "fs";
|
|
3
|
-
import { promisify as
|
|
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"],
|
|
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
|
|
28
|
-
e[
|
|
27
|
+
const d = [], l = r.substring(`public/${o}`.length);
|
|
28
|
+
e[l] = d;
|
|
29
29
|
for (const a of t) {
|
|
30
|
-
const
|
|
30
|
+
const c = `${r}/${a}`;
|
|
31
31
|
try {
|
|
32
|
-
const
|
|
33
|
-
if (
|
|
34
|
-
const p = await n.readdir(
|
|
35
|
-
|
|
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:
|
|
38
|
-
|
|
37
|
+
const p = { id: b(), lastModifiedAt: g.mtimeMs, name: a, size: g.size, typeId: "object" };
|
|
38
|
+
d.push(p);
|
|
39
39
|
}
|
|
40
|
-
} catch (
|
|
41
|
-
console.error(`Unable to get information for '${a}' in 'buildPublicDirectoryIndex'.`,
|
|
40
|
+
} catch (g) {
|
|
41
|
+
console.error(`Unable to get information for '${a}' in 'buildPublicDirectoryIndex'.`, g);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
return
|
|
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,
|
|
61
|
-
const
|
|
62
|
-
return s = s || v.includes(
|
|
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
|
-
|
|
65
|
-
const
|
|
66
|
-
console.log(
|
|
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
|
|
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,
|
|
139
|
-
for (const
|
|
140
|
-
const a = `${r}/${
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
console.log("
|
|
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
|
|
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("â
|
|
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
|
|
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
|
|
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("â
|
|
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
|
-
|
|
196
|
-
|
|
192
|
+
A as uploadModuleConfig,
|
|
193
|
+
P as uploadModuleToR2
|
|
197
194
|
};
|