@datapos/datapos-development 0.3.58 → 0.3.59

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,77 +1,197 @@
1
- import { exec as u } from "child_process";
2
- import { promises as i } from "fs";
3
- import { promisify as d } from "util";
4
- const p = ["createObject", "dropObject", "removeRecords", "upsertRecords"], m = ["findObject", "getRecord", "listNodes", "previewObject", "retrieveRecords"], f = d(u);
5
- async function S() {
1
+ import { exec as m } from "child_process";
2
+ import { promises as n } from "fs";
3
+ import { promisify as w } from "util";
4
+ const y = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
5
+ let b = (o = 21) => {
6
+ let e = "", i = crypto.getRandomValues(new Uint8Array(o |= 0));
7
+ for (; o--; )
8
+ e += y[i[o] & 63];
9
+ return e;
10
+ };
11
+ const v = ["createObject", "dropObject", "removeRecords", "upsertRecords"], h = ["findObject", "getRecord", "listNodes", "previewObject", "retrieveRecords"], f = w(m);
12
+ async function $() {
13
+ try {
14
+ console.log("🚀 Building configuration...");
15
+ const o = JSON.parse(await n.readFile("package.json", "utf8")), e = JSON.parse(await n.readFile("config.json", "utf8"));
16
+ o.name && (e.id = o.name), o.version && (e.version = o.version), await n.writeFile("config.json", JSON.stringify(e, void 0, 4), "utf8"), console.log("✅ Configuration built.");
17
+ } catch (o) {
18
+ console.warn("❌ Error building configuration.", o);
19
+ }
20
+ }
21
+ async function J(o) {
22
+ try {
23
+ console.log(`🚀 Building public directory index for identifier '${o}'...`);
24
+ const e = {};
25
+ async function i(r, t) {
26
+ console.log(`âš™ī¸ Processing directory '${r}'...`);
27
+ const g = [], c = r.substring(`public/${o}`.length);
28
+ e[c] = g;
29
+ for (const a of t) {
30
+ const l = `${r}/${a}`;
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);
36
+ } else {
37
+ const p = { id: b(), lastModifiedAt: d.mtimeMs, name: a, size: d.size, typeId: "object" };
38
+ g.push(p);
39
+ }
40
+ } catch (d) {
41
+ console.error(`Unable to get information for '${a}' in 'buildPublicDirectoryIndex'.`, d);
42
+ }
43
+ }
44
+ g.sort((a, l) => {
45
+ const d = a.typeId.localeCompare(l.typeId);
46
+ return d !== 0 ? d : a.name.localeCompare(l.name);
47
+ });
48
+ }
49
+ const s = await n.readdir(`public/${o}`);
50
+ await i(`public/${o}`, s), await n.writeFile(`./public/${o}Index.json`, JSON.stringify(e), "utf8"), console.log("✅ Public directory index built.");
51
+ } catch (e) {
52
+ console.warn("❌ Error building public directory index.", e);
53
+ }
54
+ }
55
+ async function j() {
6
56
  try {
7
57
  console.log("🚀 Building connector configuration...");
8
- const o = JSON.parse(await i.readFile("package.json", "utf8")), e = JSON.parse(await i.readFile("config.json", "utf8")), t = await i.readFile("src/index.ts", "utf8");
9
- let r = !1, s = !1;
10
- const n = /^\s{4}(?:async\s+)?(private\s+)?(?:public\s+|protected\s+)?([A-Za-z_]\w*)\s*\(/gm, c = [...t.matchAll(n)].filter((a) => !a[1] && a[2] !== "constructor").map((a) => {
11
- const g = a[2];
12
- return r = r || p.includes(g), s = s || m.includes(g), g;
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
+ 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;
13
63
  });
14
- c.length > 0 ? console.log(`â„šī¸ Implements ${c.length} operations.`) : console.log("âš ī¸ Implements no operations.");
15
- const l = s && r ? "bidirectional" : s ? "source" : r ? "destination" : null;
16
- console.log(l ? `â„šī¸ Supports ${l} usage.` : "âš ī¸ No usage identified."), o.name && (e.id = o.name), e.operations = c, e.usageId = l, o.version && (e.version = o.version), await i.writeFile("config.json", JSON.stringify(e, void 0, 4), "utf8"), console.log("✅ Connector configuration built.");
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.");
17
67
  } catch (o) {
18
68
  console.warn("❌ Error building connector configuration.", o);
19
69
  }
20
70
  }
21
- async function N() {
71
+ async function x() {
22
72
  try {
23
73
  console.log("🚀 Building context configuration...");
24
- const o = JSON.parse(await i.readFile("package.json", "utf8")), e = JSON.parse(await i.readFile("config.json", "utf8")), t = await i.readFile("src/index.ts", "utf8"), r = /^\s{4}(?:async\s+)?(private\s+)?(?:public\s+|protected\s+)?([A-Za-z_]\w*)\s*\(/gm, s = [...t.matchAll(r)].filter((n) => !n[1] && n[2] !== "constructor").map((n) => n[2]);
25
- o.name && (e.id = o.name), e.operations = s, o.version && (e.version = o.version), await i.writeFile("config.json", JSON.stringify(e, void 0, 4), "utf8");
74
+ 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"), s = /^\s{4}(?:async\s+)?(private\s+)?(?:public\s+|protected\s+)?([A-Za-z_]\w*)\s*\(/gm, r = [...i.matchAll(s)].filter((t) => !t[1] && t[2] !== "constructor").map((t) => t[2]);
75
+ o.name && (e.id = o.name), e.operations = r, o.version && (e.version = o.version), await n.writeFile("config.json", JSON.stringify(e, void 0, 4), "utf8");
26
76
  } catch (o) {
27
77
  console.warn("❌ Error building context configuration.", o);
28
78
  }
29
79
  }
30
- async function y() {
80
+ async function F() {
31
81
  try {
32
82
  console.log("🚀 Building informer configuration...");
33
- const o = JSON.parse(await i.readFile("package.json", "utf8")), e = JSON.parse(await i.readFile("config.json", "utf8")), t = await i.readFile("src/index.ts", "utf8"), r = /^\s{4}(?:async\s+)?(private\s+)?(?:public\s+|protected\s+)?([A-Za-z_]\w*)\s*\(/gm, s = [...t.matchAll(r)].filter((n) => !n[1] && n[2] !== "constructor").map((n) => n[2]);
34
- o.name && (e.id = o.name), e.operations = s, o.version && (e.version = o.version), await i.writeFile("config.json", JSON.stringify(e, void 0, 4), "utf8");
83
+ 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"), s = /^\s{4}(?:async\s+)?(private\s+)?(?:public\s+|protected\s+)?([A-Za-z_]\w*)\s*\(/gm, r = [...i.matchAll(s)].filter((t) => !t[1] && t[2] !== "constructor").map((t) => t[2]);
84
+ o.name && (e.id = o.name), e.operations = r, o.version && (e.version = o.version), await n.writeFile("config.json", JSON.stringify(e, void 0, 4), "utf8");
35
85
  } catch (o) {
36
86
  console.warn("❌ Error building informer configuration.", o);
37
87
  }
38
88
  }
39
- async function b() {
89
+ async function C() {
40
90
  try {
41
91
  console.log("🚀 Building presenter configuration...");
42
- const o = JSON.parse(await i.readFile("package.json", "utf8")), e = JSON.parse(await i.readFile("config.json", "utf8")), t = await i.readFile("src/index.ts", "utf8"), r = /^\s{4}(?:async\s+)?(private\s+)?(?:public\s+|protected\s+)?([A-Za-z_]\w*)\s*\(/gm, s = [...t.matchAll(r)].filter((n) => !n[1] && n[2] !== "constructor").map((n) => n[2]);
43
- o.name && (e.id = o.name), e.operations = s, o.version && (e.version = o.version), await i.writeFile("config.json", JSON.stringify(e, void 0, 4), "utf8");
92
+ 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"), s = /^\s{4}(?:async\s+)?(private\s+)?(?:public\s+|protected\s+)?([A-Za-z_]\w*)\s*\(/gm, r = [...i.matchAll(s)].filter((t) => !t[1] && t[2] !== "constructor").map((t) => t[2]);
93
+ o.name && (e.id = o.name), e.operations = r, o.version && (e.version = o.version), await n.writeFile("config.json", JSON.stringify(e, void 0, 4), "utf8");
44
94
  } catch (o) {
45
95
  console.warn("❌ Error building context configuration.", o);
46
96
  }
47
97
  }
48
- async function J() {
98
+ async function k() {
49
99
  try {
50
100
  console.log("🚀 Bumping version...");
51
- const o = JSON.parse(await i.readFile("package.json", "utf8"));
101
+ const o = JSON.parse(await n.readFile("package.json", "utf8"));
52
102
  if (o.version) {
53
- const e = o.version, t = o.version.split(".");
54
- o.version = `${t[0]}.${t[1]}.${Number(t[2]) + 1}`, await i.writeFile("package.json", JSON.stringify(o, void 0, 4), "utf8"), console.log(`✅ Version bumped from ${e} to ${o.version}.`);
103
+ const e = o.version, i = o.version.split(".");
104
+ o.version = `${i[0]}.${i[1]}.${Number(i[2]) + 1}`, await n.writeFile("package.json", JSON.stringify(o, void 0, 4), "utf8"), console.log(`✅ Version bumped from ${e} to ${o.version}.`);
55
105
  } else
56
- o.version = "0.0.001", await i.writeFile("package.json", JSON.stringify(o, void 0, 4), "utf8"), console.log(`âš ī¸ Version initialised to ${o.version}.`);
106
+ o.version = "0.0.001", await n.writeFile("package.json", JSON.stringify(o, void 0, 4), "utf8"), console.log(`âš ī¸ Version initialised to ${o.version}.`);
57
107
  } catch (o) {
58
108
  console.warn("❌ Error bumping package version.", o);
59
109
  }
60
110
  }
61
- async function h() {
111
+ async function E() {
112
+ try {
113
+ console.log("🚀 Sending deployment notice...");
114
+ const o = JSON.parse(await n.readFile("config.json", "utf8")), e = {
115
+ body: JSON.stringify(o),
116
+ headers: { "Content-Type": "application/json" },
117
+ method: "PUT"
118
+ }, i = await fetch(`https://api.datapos.app/states/${o.id}`, e);
119
+ if (!i.ok)
120
+ throw console.log(await i.text()), new Error("Fetch error.");
121
+ console.log("✅ Deployment notice sent.");
122
+ } catch (o) {
123
+ console.warn("❌ Error sending deployment notice.", o);
124
+ }
125
+ }
126
+ async function I() {
62
127
  try {
63
128
  console.log("🚀 Synchronising with GitHub....");
64
- const o = JSON.parse(await i.readFile("package.json", "utf8"));
129
+ const o = JSON.parse(await n.readFile("package.json", "utf8"));
65
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.`);
66
131
  } catch (o) {
67
132
  console.warn("❌ Error synchronising with GitHub.", o);
68
133
  }
69
134
  }
135
+ async function R(o, e) {
136
+ try {
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);
151
+ }
152
+ }
153
+ }
154
+ const s = await n.readdir(`${o}/${e}/`);
155
+ await i(`${o}/${e}`, e, s), console.log("✅ Directory cleared.");
156
+ } catch (i) {
157
+ console.warn("❌ Error uploading directory to R2.", i);
158
+ }
159
+ }
160
+ async function _() {
161
+ try {
162
+ console.log("🚀 Uploading module configuration....");
163
+ const o = JSON.parse(await n.readFile("config.json", "utf8")), e = o.id, i = {
164
+ body: JSON.stringify(o),
165
+ headers: { "Content-Type": "application/json" },
166
+ method: "PUT"
167
+ }, s = await fetch(`https://api.datapos.app/states/${e}`, i);
168
+ s.ok || console.log(await s.text()), console.log("✅ Directory cleared.");
169
+ } catch (o) {
170
+ console.warn("❌ Error uploading module configuration.", o);
171
+ }
172
+ }
173
+ async function A(o, e) {
174
+ try {
175
+ 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(
177
+ `wrangler r2 object put ${s} --file=dist/${o} --content-type application/javascript --jurisdiction=eu --remote`
178
+ );
179
+ r && console.log(r), t && console.error(t), console.log("✅ Directory cleared.");
180
+ } catch (i) {
181
+ console.warn("❌ Error uploading module to R2.", i);
182
+ }
183
+ }
70
184
  export {
71
- S as buildConnectorConfig,
72
- N as buildContextConfig,
73
- y as buildInformerConfig,
74
- b as buildPresenterConfig,
75
- J as bumpVersion,
76
- h as syncWithGitHub
185
+ $ as buildConfig,
186
+ j as buildConnectorConfig,
187
+ x as buildContextConfig,
188
+ F as buildInformerConfig,
189
+ C as buildPresenterConfig,
190
+ J as buildPublicDirectoryIndex,
191
+ k as bumpVersion,
192
+ E as sendDeploymentNotice,
193
+ I as syncWithGitHub,
194
+ R as uploadDirectoryToR2,
195
+ _ as uploadModuleConfig,
196
+ A as uploadModuleToR2
77
197
  };
@@ -1,9 +1,16 @@
1
1
  /**
2
2
  * Development utilities.
3
3
  */
4
- export declare function buildConnectorConfig(): Promise<void>;
5
- export declare function buildContextConfig(): Promise<void>;
6
- export declare function buildInformerConfig(): Promise<void>;
7
- export declare function buildPresenterConfig(): Promise<void>;
8
- export declare function bumpVersion(): Promise<void>;
9
- export declare function syncWithGitHub(): Promise<void>;
4
+ declare function buildConfig(): Promise<void>;
5
+ declare function buildPublicDirectoryIndex(id: string): Promise<void>;
6
+ declare function buildConnectorConfig(): Promise<void>;
7
+ declare function buildContextConfig(): Promise<void>;
8
+ declare function buildInformerConfig(): Promise<void>;
9
+ declare function buildPresenterConfig(): Promise<void>;
10
+ declare function bumpVersion(): Promise<void>;
11
+ declare function sendDeploymentNotice(): Promise<void>;
12
+ declare function syncWithGitHub(): Promise<void>;
13
+ declare function uploadDirectoryToR2(sourceDirectory: string, uploadDirectory: string): Promise<void>;
14
+ declare function uploadModuleConfig(): Promise<void>;
15
+ declare function uploadModuleToR2(fromPath: string, toPath: string): Promise<void>;
16
+ export { buildConfig, buildConnectorConfig, buildContextConfig, buildInformerConfig, buildPresenterConfig, buildPublicDirectoryIndex, bumpVersion, sendDeploymentNotice, syncWithGitHub, uploadDirectoryToR2, uploadModuleConfig, uploadModuleToR2 };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "license": "MIT",
4
4
  "private": false,
5
5
  "type": "module",
6
- "version": "0.3.58",
6
+ "version": "0.3.59",
7
7
  "files": [
8
8
  "dist"
9
9
  ],