@social-mail/social-mail-client 1.2.488 → 1.2.490
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/content/local-db/worker.js +2 -2
- package/dist/admin/AdminAppIndex.pack.js +944 -210
- package/dist/admin/AdminAppIndex.pack.js.map +1 -1
- package/dist/admin/AdminAppIndex.pack.min.js +28 -3
- package/dist/admin/AdminAppIndex.pack.min.js.map +1 -1
- package/dist/model/model.d.ts +9 -5
- package/dist/model/model.d.ts.map +1 -1
- package/dist/model/model.js +907 -207
- package/dist/model/model.js.map +1 -1
- package/dist/public/channel/ChannelView.pack.js +907 -207
- package/dist/public/channel/ChannelView.pack.js.map +1 -1
- package/dist/public/channel/ChannelView.pack.min.js +1 -1
- package/dist/public/channel/ChannelView.pack.min.js.map +1 -1
- package/dist/public/contact-us/ContactUsApp.d.ts +1 -0
- package/dist/public/contact-us/ContactUsApp.d.ts.map +1 -1
- package/dist/public/contact-us/ContactUsApp.js +100 -14
- package/dist/public/contact-us/ContactUsApp.js.map +1 -1
- package/dist/public/contact-us/ContactUsApp.pack.js +100 -14
- package/dist/public/contact-us/ContactUsApp.pack.js.map +1 -1
- package/dist/public/contact-us/ContactUsApp.pack.min.js +82 -14
- package/dist/public/contact-us/ContactUsApp.pack.min.js.map +1 -1
- package/dist/public/store/Store.pack.js +907 -207
- package/dist/public/store/Store.pack.js.map +1 -1
- package/dist/public/store/Store.pack.min.js +1 -1
- package/dist/public/store/Store.pack.min.js.map +1 -1
- package/dist/public/store/cart/ShoppingCart.pack.js +909 -208
- package/dist/public/store/cart/ShoppingCart.pack.js.map +1 -1
- package/dist/public/store/cart/ShoppingCart.pack.min.js +1 -1
- package/dist/public/store/cart/ShoppingCart.pack.min.js.map +1 -1
- package/dist/services/LoginService.d.ts.map +1 -1
- package/dist/services/LoginService.js +2 -1
- package/dist/services/LoginService.js.map +1 -1
- package/dist/services/local-db/LocalDbService.d.ts +12 -5
- package/dist/services/local-db/LocalDbService.d.ts.map +1 -1
- package/dist/services/local-db/LocalDbService.js +57 -21
- package/dist/services/local-db/LocalDbService.js.map +1 -1
- package/dist/services/local-db/core/LocalTable.d.ts +19 -0
- package/dist/services/local-db/core/LocalTable.d.ts.map +1 -0
- package/dist/services/local-db/core/LocalTable.js +120 -0
- package/dist/services/local-db/core/LocalTable.js.map +1 -0
- package/dist/services/local-db/core/TemplateQuery.d.ts +27 -0
- package/dist/services/local-db/core/TemplateQuery.d.ts.map +1 -0
- package/dist/services/local-db/core/TemplateQuery.js +132 -0
- package/dist/services/local-db/core/TemplateQuery.js.map +1 -0
- package/dist/services/local-db/mailboxes/LocalMailbox.d.ts +13 -0
- package/dist/services/local-db/mailboxes/LocalMailbox.d.ts.map +1 -0
- package/dist/services/local-db/mailboxes/LocalMailbox.js +62 -0
- package/dist/services/local-db/mailboxes/LocalMailbox.js.map +1 -0
- package/dist/services/mime-service/MimeNode.js +1 -1
- package/dist/services/mime-service/MimeNode.js.map +1 -1
- package/dist/site-editor/editor/HtmlPageEditor.d.ts.map +1 -1
- package/dist/site-editor/editor/HtmlPageEditor.js +34 -1
- package/dist/site-editor/editor/HtmlPageEditor.js.map +1 -1
- package/dist/tests/template-query/template-queries.test.d.ts +2 -0
- package/dist/tests/template-query/template-queries.test.d.ts.map +1 -0
- package/dist/tests/template-query/template-queries.test.js +27 -0
- package/dist/tests/template-query/template-queries.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/web/AppIndex.pack.js +944 -210
- package/dist/web/AppIndex.pack.js.map +1 -1
- package/dist/web/AppIndex.pack.min.js +29 -4
- package/dist/web/AppIndex.pack.min.js.map +1 -1
- package/dist/web/page/files/shares/AddSharePage.d.ts +0 -1
- package/dist/web/page/files/shares/AddSharePage.d.ts.map +1 -1
- package/node_modules/@web-atoms/entity/dist/services/BaseEntityService.d.ts +2 -0
- package/node_modules/@web-atoms/entity/dist/services/BaseEntityService.d.ts.map +1 -1
- package/node_modules/@web-atoms/entity/dist/services/BaseEntityService.js.map +1 -1
- package/node_modules/@web-atoms/entity/dist/tsconfig.tsbuildinfo +1 -1
- package/node_modules/@web-atoms/entity/package.json +1 -1
- package/node_modules/@web-atoms/entity/src/services/BaseEntityService.ts +2 -0
- package/package.json +2 -2
- package/pg-worker.js +15 -0
- package/src/model/model.ts +84 -82
- package/src/public/contact-us/ContactUsApp.tsx +102 -17
- package/src/services/LoginService.ts +5 -0
- package/src/services/local-db/LocalDbService.ts +68 -32
- package/src/services/local-db/core/LocalTable.ts +113 -0
- package/src/services/local-db/core/TemplateQuery.ts +135 -0
- package/src/services/local-db/mailboxes/LocalMailbox.ts +60 -0
- package/src/services/mime-service/MimeNode.ts +1 -1
- package/src/site-editor/editor/HtmlPageEditor.tsx +31 -1
- package/src/tests/template-query/template-queries.test.ts +22 -0
- package/dist/services/local-db/SqlDbFactory.d.ts +0 -47
- package/dist/services/local-db/SqlDbFactory.d.ts.map +0 -1
- package/dist/services/local-db/SqlDbFactory.js +0 -179
- package/dist/services/local-db/SqlDbFactory.js.map +0 -1
- package/src/services/local-db/SqlDbFactory.ts +0 -181
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
export type ISqlString = any;
|
|
2
|
-
export type IPreparedStatement = any;
|
|
3
|
-
export interface ISqlFactory {
|
|
4
|
-
open_v2(name: string): Promise<any>;
|
|
5
|
-
close(db: any): Promise<void>;
|
|
6
|
-
exec(db: any, text: string, fx: (rows: any[], columns: string[]) => void): Promise<number>;
|
|
7
|
-
str_new(db: any, txt: string): ISqlString;
|
|
8
|
-
str_finish(txt: ISqlString): void;
|
|
9
|
-
str_value(a: any): any;
|
|
10
|
-
prepare_v2(db: any, sql: ISqlString): Promise<{
|
|
11
|
-
sql: number;
|
|
12
|
-
stmt: number;
|
|
13
|
-
}>;
|
|
14
|
-
bind(stmt: number, i: number, value: any): any;
|
|
15
|
-
finalize(stmt: number): Promise<number>;
|
|
16
|
-
step(stmt: number): Promise<number>;
|
|
17
|
-
row(stmt: number): string[];
|
|
18
|
-
column_names(stmt: number): string[];
|
|
19
|
-
bind_parameter_count(stmt: number): number;
|
|
20
|
-
bind_parameter_name(stmt: number, i: number): string;
|
|
21
|
-
changes(stmt: number): number;
|
|
22
|
-
}
|
|
23
|
-
export interface ISqlResult {
|
|
24
|
-
rows: any[];
|
|
25
|
-
updated: number;
|
|
26
|
-
}
|
|
27
|
-
export declare class SqlDb {
|
|
28
|
-
private sqlFactory;
|
|
29
|
-
private name;
|
|
30
|
-
private prev;
|
|
31
|
-
private db;
|
|
32
|
-
constructor(sqlFactory: ISqlFactory, name: string);
|
|
33
|
-
execute(txt: TemplateStringsArray, ...a: any[]): Promise<{
|
|
34
|
-
rows: any[];
|
|
35
|
-
updated: number;
|
|
36
|
-
}>;
|
|
37
|
-
query(text: string): Promise<{
|
|
38
|
-
rows: any[];
|
|
39
|
-
updated: number;
|
|
40
|
-
}>;
|
|
41
|
-
private prepare;
|
|
42
|
-
private newString;
|
|
43
|
-
}
|
|
44
|
-
export default class SqlDbFactory {
|
|
45
|
-
static load(name: string): Promise<SqlDb>;
|
|
46
|
-
}
|
|
47
|
-
//# sourceMappingURL=SqlDbFactory.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SqlDbFactory.d.ts","sourceRoot":"","sources":["../../../src/services/local-db/SqlDbFactory.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,UAAU,GAAG,GAAG,CAAC;AAC7B,MAAM,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAErC,MAAM,WAAW,WAAW;IACxB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IACpC,KAAK,CAAC,EAAE,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,IAAI,EAAC,GAAG,EAAE,EAAE,OAAO,E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EAAE,MAAM;IAElB,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE,GAAI,CAAC,EAAE,GAAG,EAAE;;;;IAmDrD,KAAK,CAAC,IAAI,EAAE,MAAM;;;;YAwBF,OAAO;IA4BvB,OAAO,CAAC,SAAS;CAUpB;AAiBD,MAAM,CAAC,OAAO,OAAO,YAAY;WAEhB,IAAI,CAAC,IAAI,EAAE,MAAM;CAKjC"}
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
System.register(["tslib", "@web-atoms/core/dist/core/types"], function (_export, _context) {
|
|
2
|
-
"use strict";
|
|
3
|
-
|
|
4
|
-
var __asyncGenerator, __asyncValues, __await, __awaiter, UMD, SqlDb, SqlDbFactory, factory, loadSqlFactory;
|
|
5
|
-
_export({
|
|
6
|
-
SqlDb: void 0,
|
|
7
|
-
default: void 0
|
|
8
|
-
});
|
|
9
|
-
return {
|
|
10
|
-
setters: [function (_tslib) {
|
|
11
|
-
__asyncGenerator = _tslib.__asyncGenerator;
|
|
12
|
-
__asyncValues = _tslib.__asyncValues;
|
|
13
|
-
__await = _tslib.__await;
|
|
14
|
-
__awaiter = _tslib.__awaiter;
|
|
15
|
-
}, function (_webAtomsCoreDistCoreTypes) {
|
|
16
|
-
UMD = _webAtomsCoreDistCoreTypes.UMD;
|
|
17
|
-
}],
|
|
18
|
-
execute: function () {
|
|
19
|
-
_export("SqlDb", SqlDb = class SqlDb {
|
|
20
|
-
constructor(sqlFactory, name) {
|
|
21
|
-
this.sqlFactory = sqlFactory;
|
|
22
|
-
this.name = name;
|
|
23
|
-
this.prev = Promise.resolve(null);
|
|
24
|
-
}
|
|
25
|
-
execute(txt, ...a) {
|
|
26
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
let query = "";
|
|
28
|
-
const values = {};
|
|
29
|
-
const names = [];
|
|
30
|
-
let pn = 1;
|
|
31
|
-
for (let index = 0; index < txt.length; index++) {
|
|
32
|
-
const element = txt[index];
|
|
33
|
-
query += element;
|
|
34
|
-
if (index < a.length) {
|
|
35
|
-
const name = `p${pn++}`;
|
|
36
|
-
names.push(name);
|
|
37
|
-
query += `@${name}`;
|
|
38
|
-
values[name] = a[index];
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
const prev = this.prev;
|
|
42
|
-
const {
|
|
43
|
-
sqlFactory
|
|
44
|
-
} = this;
|
|
45
|
-
return yield this.prev = (() => __awaiter(this, void 0, void 0, function* () {
|
|
46
|
-
var _a, e_1, _b, _c;
|
|
47
|
-
try {
|
|
48
|
-
yield prev;
|
|
49
|
-
} catch (error) {}
|
|
50
|
-
const d = yield this.sqlFactory.open_v2(this.name);
|
|
51
|
-
yield using;
|
|
52
|
-
d1 = {
|
|
53
|
-
[Symbol.asyncDispose]: () => this.sqlFactory.close(this.db)
|
|
54
|
-
};
|
|
55
|
-
this.db = d;
|
|
56
|
-
const rows = [];
|
|
57
|
-
let updated = 0;
|
|
58
|
-
try {
|
|
59
|
-
for (var _d = true, _e = __asyncValues(this.prepare({
|
|
60
|
-
query,
|
|
61
|
-
values
|
|
62
|
-
})), _f; _f = yield _e.next(), _a = _f.done, !_a;) {
|
|
63
|
-
_c = _f.value;
|
|
64
|
-
_d = false;
|
|
65
|
-
try {
|
|
66
|
-
const stmt = _c;
|
|
67
|
-
let columns;
|
|
68
|
-
while ((yield sqlFactory.step(stmt)) === SQLite.SQLITE_ROW) {
|
|
69
|
-
columns !== null && columns !== void 0 ? columns : columns = sqlFactory.column_names(stmt);
|
|
70
|
-
const items = sqlFactory.row(stmt);
|
|
71
|
-
const row = {};
|
|
72
|
-
for (let index = 0; index < columns.length; index++) {
|
|
73
|
-
const element = columns[index];
|
|
74
|
-
row[element] = items[index];
|
|
75
|
-
}
|
|
76
|
-
rows.push(row);
|
|
77
|
-
}
|
|
78
|
-
updated = sqlFactory.changes(this.db);
|
|
79
|
-
} finally {
|
|
80
|
-
_d = true;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
} catch (e_1_1) {
|
|
84
|
-
e_1 = {
|
|
85
|
-
error: e_1_1
|
|
86
|
-
};
|
|
87
|
-
} finally {
|
|
88
|
-
try {
|
|
89
|
-
if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
|
|
90
|
-
} finally {
|
|
91
|
-
if (e_1) throw e_1.error;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return {
|
|
95
|
-
rows,
|
|
96
|
-
updated
|
|
97
|
-
};
|
|
98
|
-
}))();
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
query(text) {
|
|
102
|
-
return this.execute([text]);
|
|
103
|
-
}
|
|
104
|
-
prepare({
|
|
105
|
-
query,
|
|
106
|
-
values
|
|
107
|
-
}) {
|
|
108
|
-
return __asyncGenerator(this, arguments, function* prepare_1() {
|
|
109
|
-
const {
|
|
110
|
-
sqlFactory
|
|
111
|
-
} = this;
|
|
112
|
-
using;
|
|
113
|
-
sql = this.newString(query);
|
|
114
|
-
let prepared = {
|
|
115
|
-
stmt: null,
|
|
116
|
-
sql: sqlFactory.str_value(sql.str)
|
|
117
|
-
};
|
|
118
|
-
try {
|
|
119
|
-
while (prepared = yield __await(sqlFactory.prepare_v2(this.db, prepared.sql))) {
|
|
120
|
-
const {
|
|
121
|
-
stmt
|
|
122
|
-
} = prepared;
|
|
123
|
-
const total = sqlFactory.bind_parameter_count(stmt);
|
|
124
|
-
for (let index = 0; index < total; index++) {
|
|
125
|
-
const name = sqlFactory.bind_parameter_name(stmt, index);
|
|
126
|
-
if (values.hasOwnProperty(name)) {
|
|
127
|
-
sqlFactory.bind(stmt, index, values[name]);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
yield yield __await(stmt);
|
|
131
|
-
yield __await(sqlFactory.finalize(stmt));
|
|
132
|
-
prepared.stmt = null;
|
|
133
|
-
}
|
|
134
|
-
} finally {
|
|
135
|
-
if (prepared === null || prepared === void 0 ? void 0 : prepared.stmt) {
|
|
136
|
-
yield __await(sqlFactory.finalize(prepared.stmt));
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
newString(txt) {
|
|
142
|
-
const {
|
|
143
|
-
sqlFactory
|
|
144
|
-
} = this;
|
|
145
|
-
const str = sqlFactory.str_new(this.db, txt);
|
|
146
|
-
return {
|
|
147
|
-
str,
|
|
148
|
-
[Symbol.dispose]() {
|
|
149
|
-
return sqlFactory.str_finish(str);
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
loadSqlFactory = () => {
|
|
155
|
-
return factory !== null && factory !== void 0 ? factory : factory = new Promise((resolve, reject) => {
|
|
156
|
-
const script = document.createElement("script");
|
|
157
|
-
script.type = "module";
|
|
158
|
-
script.src = UMD.resolvePath("@social-mail/social-mail-client/sqlite-loader.mjs");
|
|
159
|
-
script.onerror = reject;
|
|
160
|
-
document.body.addEventListener("sqliteLoaded", ce => {
|
|
161
|
-
resolve(ce.detail);
|
|
162
|
-
}, {
|
|
163
|
-
once: true
|
|
164
|
-
});
|
|
165
|
-
document.body.appendChild(script);
|
|
166
|
-
});
|
|
167
|
-
};
|
|
168
|
-
_export("default", SqlDbFactory = class SqlDbFactory {
|
|
169
|
-
static load(name) {
|
|
170
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
171
|
-
const sqlFactory = yield loadSqlFactory();
|
|
172
|
-
return new SqlDb(sqlFactory, name);
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
});
|
|
179
|
-
//# sourceMappingURL=SqlDbFactory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["SqlDb","SqlDbFactory","factory","loadSqlFactory","_export","default","setters","_tslib","UMD","_webAtomsCoreDistCoreTypes","execute","constructor","sqlFactory","name","prev","Promise","resolve","txt","a","query","values","names","pn","index","length","element","push","__awaiter","error","d","open_v2","using","d1","Symbol","asyncDispose","close","db","rows","updated","_d","_e","__asyncValues","prepare","_f","next","_a","done","_c","value","stmt","columns","step","SQLite","SQLITE_ROW","column_names","items","row","changes","text","sql","newString","prepared","str_value","str","__await","prepare_v2","total","bind_parameter_count","bind_parameter_name","hasOwnProperty","bind","finalize","str_new","dispose","str_finish","reject","script","document","createElement","type","src","resolvePath","onerror","body","addEventListener","ce","detail","once","appendChild","load"],"sources":["../../../src/services/local-db/SqlDbFactory.ts"],"sourcesContent":[null],"mappings":";;;gEAiCaA,KAAK,EA4IGC,YAAY,EAAAC,OAAA,EAAAC,cAAA;EAAAC,OAAA;IAAAJ,KAAA;IAAAK,OAAA;EAAA;EAAA;IAAAC,OAAA,aAAAC,MAAA;;;;;;MA3KxBC,GAAG,GAAAC,0BAAA,CAAHD,GAAG;IAAA;IAAAE,OAAA,WAAAA,CAAA;MAAAN,OAAA,UA+BCJ,KAAK,GAAZ,MAAOA,KAAK;QAMdW,YACYC,UAAuB,EACvBC,IAAY;UADZ,KAAAD,UAAU,GAAVA,UAAU;UACV,KAAAC,IAAI,GAAJA,IAAI;UANR,KAAAC,IAAI,GAAwBC,OAAO,CAACC,OAAO,CAAC,IAAI,CAAC;QAM9B;QAErBN,OAAOA,CAACO,GAAyB,EAAE,GAAIC,CAAQ;;YACjD,IAAIC,KAAK,GAAG,EAAE;YACd,MAAMC,MAAM,GAAG,EAAE;YACjB,MAAMC,KAAK,GAAG,EAAE;YAChB,IAAIC,EAAE,GAAG,CAAC;YACV,KAAK,IAAIC,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAGN,GAAG,CAACO,MAAM,EAAED,KAAK,EAAE,EAAE;cAC7C,MAAME,OAAO,GAAGR,GAAG,CAACM,KAAK,CAAC;cAC1BJ,KAAK,IAAIM,OAAO;cAChB,IAAIF,KAAK,GAAGL,CAAC,CAACM,MAAM,EAAE;gBAClB,MAAMX,IAAI,GAAG,IAAIS,EAAE,EAAE,EAAE;gBACvBD,KAAK,CAACK,IAAI,CAACb,IAAI,CAAC;g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AC,mDAAmD,CAAC;UACjFL,MAAM,CAACM,OAAO,GAAGP,MAAM;UACvBE,QAAQ,CAACM,IAAI,CAACC,gBAAgB,CAAC,cAAc,EAAGC,EAAe,IAAI;YAC/DrE,OAAO,CAACqE,EAAE,CAACC,MAAM,CAAC;UACtB,CAAC,EAAE;YAAEC,IAAI,EAAE;UAAI,CAAE,CAAC;UAClBV,QAAQ,CAACM,IAAI,CAACK,WAAW,CAACZ,MAAM,CAAC;QACrC,CAAC,CAAC;MACN,CAAC;MAAAxE,OAAA,YAEoBH,YAAY,GAAnB,MAAOA,YAAY;QAE7B,OAAawF,IAAIA,CAAC5E,IAAY;;YAC1B,MAAMD,UAAU,GAAG,MAAMT,cAAc,EAAE;YACzC,OAAO,IAAIH,KAAK,CAACY,UAAU,EAAEC,IAAI,CAAC;UACtC,CAAC;;OAEJ;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-cond-assign */
|
|
2
|
-
/* eslint-disable no-var */
|
|
3
|
-
import { UMD } from "@web-atoms/core/dist/core/types";
|
|
4
|
-
|
|
5
|
-
export type ISqlString = any;
|
|
6
|
-
export type IPreparedStatement = any;
|
|
7
|
-
|
|
8
|
-
export interface ISqlFactory {
|
|
9
|
-
open_v2(name: string): Promise<any>;
|
|
10
|
-
close(db: any): Promise<void>;
|
|
11
|
-
exec(db: any, text: string, fx: (rows:any[], columns: string[]) => void): Promise<number>;
|
|
12
|
-
str_new(db: any, txt: string): ISqlString;
|
|
13
|
-
str_finish(txt: ISqlString): void;
|
|
14
|
-
str_value(a: any): any;
|
|
15
|
-
|
|
16
|
-
prepare_v2(db: any, sql: ISqlString): Promise<{ sql: number, stmt: number }>;
|
|
17
|
-
bind(stmt: number, i: number, value: any );
|
|
18
|
-
finalize(stmt: number): Promise<number>;
|
|
19
|
-
step(stmt: number): Promise<number>;
|
|
20
|
-
row(stmt: number): string[];
|
|
21
|
-
column_names(stmt: number): string[];
|
|
22
|
-
bind_parameter_count(stmt: number): number;
|
|
23
|
-
bind_parameter_name(stmt: number, i: number): string;
|
|
24
|
-
changes(stmt: number): number;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface ISqlResult {
|
|
28
|
-
rows: any[];
|
|
29
|
-
updated: number;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
declare var SQLite: any;
|
|
33
|
-
|
|
34
|
-
export class SqlDb {
|
|
35
|
-
|
|
36
|
-
private prev: Promise<ISqlResult> = Promise.resolve(null);
|
|
37
|
-
|
|
38
|
-
private db: any;
|
|
39
|
-
|
|
40
|
-
constructor(
|
|
41
|
-
private sqlFactory: ISqlFactory,
|
|
42
|
-
private name: string) {}
|
|
43
|
-
|
|
44
|
-
async execute(txt: TemplateStringsArray, ... a: any[]) {
|
|
45
|
-
let query = "";
|
|
46
|
-
const values = {};
|
|
47
|
-
const names = [];
|
|
48
|
-
let pn = 1;
|
|
49
|
-
for (let index = 0; index < txt.length; index++) {
|
|
50
|
-
const element = txt[index];
|
|
51
|
-
query += element;
|
|
52
|
-
if (index < a.length) {
|
|
53
|
-
const name = `p${pn++}`;
|
|
54
|
-
names.push(name);
|
|
55
|
-
query += `@${name}`;
|
|
56
|
-
values[name] = a[index];
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
const prev = this.prev;
|
|
60
|
-
const { sqlFactory } = this;
|
|
61
|
-
return await (this.prev = (async () => {
|
|
62
|
-
try {
|
|
63
|
-
await prev;
|
|
64
|
-
} catch (error) {
|
|
65
|
-
// ignore...
|
|
66
|
-
}
|
|
67
|
-
const d = await this.sqlFactory.open_v2(this.name);
|
|
68
|
-
await using d1 = { [Symbol.asyncDispose]: () => this.sqlFactory.close(this.db) };
|
|
69
|
-
this.db = d;
|
|
70
|
-
const rows = [];
|
|
71
|
-
let updated = 0;
|
|
72
|
-
|
|
73
|
-
for await(const stmt of this.prepare({ query, values })) {
|
|
74
|
-
let columns: any[];
|
|
75
|
-
while(await sqlFactory.step(stmt) === SQLite.SQLITE_ROW) {
|
|
76
|
-
columns ??= sqlFactory.column_names(stmt);
|
|
77
|
-
const items = sqlFactory.row(stmt);
|
|
78
|
-
const row = {};
|
|
79
|
-
for (let index = 0; index < columns.length; index++) {
|
|
80
|
-
const element = columns[index];
|
|
81
|
-
row[element] = items[index];
|
|
82
|
-
}
|
|
83
|
-
rows.push(row);
|
|
84
|
-
}
|
|
85
|
-
updated = sqlFactory.changes(this.db);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return {
|
|
89
|
-
rows,
|
|
90
|
-
updated
|
|
91
|
-
};
|
|
92
|
-
})());
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
query(text: string) {
|
|
96
|
-
return this.execute([text] as any);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// async exec(query: string) {
|
|
100
|
-
// const { sqlFactory } = this;
|
|
101
|
-
// const db = await sqlFactory.open_v2(this.name);
|
|
102
|
-
// await using a = { [Symbol.asyncDispose]: () => sqlFactory.close(db)};
|
|
103
|
-
// const rows = [];
|
|
104
|
-
// const updated = 0;
|
|
105
|
-
// await sqlFactory.exec(db, query, (items, columns) => {
|
|
106
|
-
// const row = {};
|
|
107
|
-
// for (let index = 0; index < columns.length; index++) {
|
|
108
|
-
// const element = columns[index];
|
|
109
|
-
// row[element] = items[index];
|
|
110
|
-
// }
|
|
111
|
-
// rows.push(row);
|
|
112
|
-
// });
|
|
113
|
-
// return {
|
|
114
|
-
// rows,
|
|
115
|
-
// updated
|
|
116
|
-
// };
|
|
117
|
-
// }
|
|
118
|
-
|
|
119
|
-
private async * prepare({query, values}:{ query: string, values: any}) {
|
|
120
|
-
const { sqlFactory } = this;
|
|
121
|
-
using sql = this.newString(query);
|
|
122
|
-
let prepared = { stmt: null, sql: sqlFactory.str_value(sql.str) };
|
|
123
|
-
try {
|
|
124
|
-
while(prepared = await sqlFactory.prepare_v2(this.db, prepared.sql)){
|
|
125
|
-
|
|
126
|
-
// bind parameters...
|
|
127
|
-
const { stmt } = prepared;
|
|
128
|
-
// bind parameters...
|
|
129
|
-
const total = sqlFactory.bind_parameter_count(stmt);
|
|
130
|
-
for (let index = 0; index < total; index++) {
|
|
131
|
-
const name = sqlFactory.bind_parameter_name(stmt, index);
|
|
132
|
-
if (values.hasOwnProperty(name)) {
|
|
133
|
-
sqlFactory.bind(stmt, index, values[name]);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
yield stmt;
|
|
137
|
-
await sqlFactory.finalize(stmt);
|
|
138
|
-
prepared.stmt = null;
|
|
139
|
-
}
|
|
140
|
-
} finally {
|
|
141
|
-
if (prepared?.stmt) {
|
|
142
|
-
await sqlFactory.finalize(prepared.stmt);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
private newString(txt: string) {
|
|
148
|
-
const { sqlFactory } = this;
|
|
149
|
-
const str = sqlFactory.str_new(this.db, txt);
|
|
150
|
-
return {
|
|
151
|
-
str,
|
|
152
|
-
[Symbol.dispose]() {
|
|
153
|
-
return sqlFactory.str_finish(str);
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
let factory: Promise<ISqlFactory>;
|
|
160
|
-
|
|
161
|
-
const loadSqlFactory = () => {
|
|
162
|
-
return factory ??= new Promise<ISqlFactory>((resolve, reject) => {
|
|
163
|
-
const script = document.createElement("script");
|
|
164
|
-
script.type = "module";
|
|
165
|
-
script.src = UMD.resolvePath("@social-mail/social-mail-client/sqlite-loader.mjs");
|
|
166
|
-
script.onerror = reject;
|
|
167
|
-
document.body.addEventListener("sqliteLoaded", (ce: CustomEvent) => {
|
|
168
|
-
resolve(ce.detail);
|
|
169
|
-
}, { once: true });
|
|
170
|
-
document.body.appendChild(script);
|
|
171
|
-
});
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
export default class SqlDbFactory {
|
|
175
|
-
|
|
176
|
-
static async load(name: string) {
|
|
177
|
-
const sqlFactory = await loadSqlFactory();
|
|
178
|
-
return new SqlDb(sqlFactory, name);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
}
|