@stoker-platform/node-client 0.5.47 → 0.5.49
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/bundle.cjs +4 -4
- package/dist/bundle.js +31 -20
- package/dist/types/read/getDocumentRefs.d.ts +1 -1
- package/dist/types/read/getOne.d.ts +1 -1
- package/dist/types/read/getSome.d.ts +1 -1
- package/dist/types/write/deleteRecord.d.ts +1 -1
- package/dist/types/write/updateRecord.d.ts +1 -1
- package/package.json +3 -3
package/dist/bundle.js
CHANGED
|
@@ -520,7 +520,7 @@ const jn = (n) => !!n.auth, Se = (n, e) => {
|
|
|
520
520
|
}, Xo = (n, e, t, s, r) => {
|
|
521
521
|
const i = {};
|
|
522
522
|
for (const o of n) {
|
|
523
|
-
const l = e[o].default(t, s, r);
|
|
523
|
+
const l = e[o].default({ sdk: t, utils: s, context: r });
|
|
524
524
|
for (const c in l)
|
|
525
525
|
c === "custom" || c === "admin" || c === "fields" || delete l[c];
|
|
526
526
|
for (const c of l.fields)
|
|
@@ -9483,7 +9483,7 @@ const Tt = {
|
|
|
9483
9483
|
if (!process.env.STOKER_FB_WEB_APP_CONFIG)
|
|
9484
9484
|
throw new Error("STOKER_FB_WEB_APP_CONFIG not set.");
|
|
9485
9485
|
const o = process.env.STOKER_FB_WEB_APP_CONFIG, a = JSON.parse(o), u = (await import(ni(t).href)).default;
|
|
9486
|
-
Yt = u("node", Tt), !r && n === "development" && (process.env.FIREBASE_AUTH_EMULATOR_HOST = "127.0.0.1:9099", process.env.FIREBASE_DATABASE_EMULATOR_HOST = "127.0.0.1:9000", process.env.FIRESTORE_EMULATOR_HOST = "127.0.0.1:8080", process.env.FIREBASE_STORAGE_EMULATOR_HOST = "127.0.0.1:9199");
|
|
9486
|
+
Yt = u({ sdk: "node", utils: Tt }), !r && n === "development" && (process.env.FIREBASE_AUTH_EMULATOR_HOST = "127.0.0.1:9099", process.env.FIREBASE_DATABASE_EMULATOR_HOST = "127.0.0.1:9000", process.env.FIRESTORE_EMULATOR_HOST = "127.0.0.1:8080", process.env.FIREBASE_STORAGE_EMULATOR_HOST = "127.0.0.1:9199");
|
|
9487
9487
|
try {
|
|
9488
9488
|
fs = Xr();
|
|
9489
9489
|
} catch {
|
|
@@ -9824,7 +9824,7 @@ const Tt = {
|
|
|
9824
9824
|
}).catch((y) => {
|
|
9825
9825
|
throw y.code === "permission-denied" && console.info(`PERMISSION_DENIED for subcollection ${p} for document at ${t.join("/")}`), y;
|
|
9826
9826
|
});
|
|
9827
|
-
e[p] = O.
|
|
9827
|
+
e[p] = O.records, i && await Promise.all(
|
|
9828
9828
|
// eslint-disable-next-line security/detect-object-injection
|
|
9829
9829
|
e[p].map((y) => Qs(n, y, [...t, p, y.id], i, r, void 0, a, l, c))
|
|
9830
9830
|
), d > 0 && await Promise.all(
|
|
@@ -9913,7 +9913,7 @@ const Tt = {
|
|
|
9913
9913
|
}
|
|
9914
9914
|
let _ = Fc(s, n, p, e?.userId, O);
|
|
9915
9915
|
if (_.length === 0)
|
|
9916
|
-
return { cursor: {}, pages: 0,
|
|
9916
|
+
return { cursor: {}, pages: 0, records: [] };
|
|
9917
9917
|
if (t && (_ = _.map((w) => (t.forEach(([I, S, R]) => {
|
|
9918
9918
|
w = w.where(I, S, R);
|
|
9919
9919
|
}), w))), o = e?.pagination?.startAfter || e?.pagination?.endBefore || {
|
|
@@ -10008,8 +10008,13 @@ const Tt = {
|
|
|
10008
10008
|
(!z || !ee) && (K(L) ? (delete a.get(w.id)[L.name], delete a.get(w.id)[`${L.name}_Array`], delete a.get(w.id)[`${L.name}_Single`]) : delete a.get(w.id)[L.name]);
|
|
10009
10009
|
}
|
|
10010
10010
|
}
|
|
10011
|
-
const A = {
|
|
10012
|
-
|
|
10011
|
+
const A = {
|
|
10012
|
+
operation: "read",
|
|
10013
|
+
data: w,
|
|
10014
|
+
recordId: w.id,
|
|
10015
|
+
context: Z
|
|
10016
|
+
};
|
|
10017
|
+
await oe("postOperation", y, C, A), await oe("postRead", y, C, { context: Z, refs: _, record: w, listener: !1 });
|
|
10013
10018
|
}
|
|
10014
10019
|
e?.userId && await Jo(
|
|
10015
10020
|
Array.from(a.values()),
|
|
@@ -10022,7 +10027,7 @@ const Tt = {
|
|
|
10022
10027
|
};
|
|
10023
10028
|
return e?.providedTransaction ? await l(e.providedTransaction) : await r.runTransaction(async (c) => {
|
|
10024
10029
|
await l(c);
|
|
10025
|
-
}, { readOnly: !0 }), { cursor: o, pages: i,
|
|
10030
|
+
}, { readOnly: !0 }), { cursor: o, pages: i, records: Array.from(a.values()) };
|
|
10026
10031
|
}, Io = async (n, e, t, s, r, i, o, a) => {
|
|
10027
10032
|
const l = s.at(-2), c = li(i.collections[l], i).map((d) => d.labels.collection);
|
|
10028
10033
|
r.collections ? r.collections.forEach((d) => {
|
|
@@ -10039,7 +10044,7 @@ const Tt = {
|
|
|
10039
10044
|
}).catch((p) => {
|
|
10040
10045
|
throw p.code === "permission-denied" && console.info(`PERMISSION_DENIED for subcollection ${d} for document at ${s.join("/")}`), p;
|
|
10041
10046
|
});
|
|
10042
|
-
t[d] = f.
|
|
10047
|
+
t[d] = f.records, u > 0 && await Promise.all(
|
|
10043
10048
|
// eslint-disable-next-line security/detect-object-injection
|
|
10044
10049
|
t[d].map(async (p) => {
|
|
10045
10050
|
await Io(n, e, p, [...s, d, p.id], { depth: u }, i, o, a);
|
|
@@ -10129,7 +10134,7 @@ const Tt = {
|
|
|
10129
10134
|
if (C.length === 0)
|
|
10130
10135
|
throw new Error("PERMISSION_DENIED");
|
|
10131
10136
|
const _ = {};
|
|
10132
|
-
await oe("preOperation", p, x, { operation: "read",
|
|
10137
|
+
await oe("preOperation", p, x, { operation: "read", recordId: e, context: _ }), await oe("preRead", p, x, { context: _, refs: C, multiple: !1, listener: !1 }), i = {};
|
|
10133
10138
|
const m = C.map((S) => a.get(S)), M = await Promise.all(m);
|
|
10134
10139
|
for (const S of M)
|
|
10135
10140
|
if (S.exists) {
|
|
@@ -10167,7 +10172,7 @@ const Tt = {
|
|
|
10167
10172
|
(!q || !T) && (K(A) ? (delete i[A.name], delete i[`${A.name}_Array`], delete i[`${A.name}_Single`]) : delete i[A.name]);
|
|
10168
10173
|
}
|
|
10169
10174
|
}
|
|
10170
|
-
await oe("postOperation", p, x, { operation: "read", data: i,
|
|
10175
|
+
await oe("postOperation", p, x, { operation: "read", data: i, recordId: e, context: _ }), await oe("postRead", p, x, { context: _, refs: C, record: i, listener: !1 }), t?.userId && await Yo(i, N, d, t.userId, f);
|
|
10171
10176
|
};
|
|
10172
10177
|
return t?.providedTransaction ? await o(t.providedTransaction) : await r.runTransaction(async (a) => {
|
|
10173
10178
|
await o(a);
|
|
@@ -10664,7 +10669,7 @@ ${i}`);
|
|
|
10664
10669
|
const m = Vs("create", n, e, l, N, "Online", s || "System", lt.now(), fe.serverTimestamp());
|
|
10665
10670
|
t?.createdAt && (m.Created_At = t.createdAt), t?.createdBy && (m.Created_By = t.createdBy);
|
|
10666
10671
|
const M = me(m);
|
|
10667
|
-
y && (m[y.archivedField] = !1), Ve(e), O && !t?.providedTransaction && await Mt("create", "started", m, o, n, k, d), await oe("preOperation", a, g, { operation: "create", data: m,
|
|
10672
|
+
y && (m[y.archivedField] = !1), Ve(e), O && !t?.providedTransaction && await Mt("create", "started", m, o, n, k, d), await oe("preOperation", a, g, { operation: "create", data: m, recordId: k, context: i }), await oe("preWrite", a, g, { operation: "create", data: m, recordId: k, context: i }), Tn(d, m, l), Rn(d, m), await sa(m, d, g, C), Ve(m);
|
|
10668
10673
|
try {
|
|
10669
10674
|
if (d.auth && r && !r.password)
|
|
10670
10675
|
throw new Error("Password is required");
|
|
@@ -10773,7 +10778,7 @@ ${i}`);
|
|
|
10773
10778
|
const P = await oe("postWriteError", a, g, {
|
|
10774
10779
|
operation: "create",
|
|
10775
10780
|
data: m,
|
|
10776
|
-
|
|
10781
|
+
recordId: k,
|
|
10777
10782
|
context: i,
|
|
10778
10783
|
error: A
|
|
10779
10784
|
});
|
|
@@ -10787,7 +10792,7 @@ ${i}`);
|
|
|
10787
10792
|
if (t?.providedTransaction ? await I(t.providedTransaction) : await b.runTransaction(async (R) => {
|
|
10788
10793
|
await I(R);
|
|
10789
10794
|
}, { maxAttempts: 10 }), !t?.providedTransaction) {
|
|
10790
|
-
const R = { operation: "create", data: m,
|
|
10795
|
+
const R = { operation: "create", data: m, recordId: k, context: i }, A = { ...R };
|
|
10791
10796
|
await oe("postWrite", a, g, R), await oe("postOperation", a, g, A);
|
|
10792
10797
|
}
|
|
10793
10798
|
return { id: k, ...m };
|
|
@@ -10972,7 +10977,7 @@ ${i}`);
|
|
|
10972
10977
|
const w = {
|
|
10973
10978
|
operation: "update",
|
|
10974
10979
|
data: E,
|
|
10975
|
-
|
|
10980
|
+
recordId: e,
|
|
10976
10981
|
context: o,
|
|
10977
10982
|
originalRecord: me(_)
|
|
10978
10983
|
};
|
|
@@ -10980,7 +10985,7 @@ ${i}`);
|
|
|
10980
10985
|
const I = {
|
|
10981
10986
|
operation: "update",
|
|
10982
10987
|
data: E,
|
|
10983
|
-
|
|
10988
|
+
recordId: e,
|
|
10984
10989
|
context: o,
|
|
10985
10990
|
originalRecord: me(_)
|
|
10986
10991
|
};
|
|
@@ -11112,7 +11117,7 @@ ${i}`);
|
|
|
11112
11117
|
const Q = {
|
|
11113
11118
|
operation: "update",
|
|
11114
11119
|
data: E,
|
|
11115
|
-
|
|
11120
|
+
recordId: e,
|
|
11116
11121
|
context: o,
|
|
11117
11122
|
error: z,
|
|
11118
11123
|
originalRecord: me(_)
|
|
@@ -11153,7 +11158,7 @@ ${i}`);
|
|
|
11153
11158
|
const T = {
|
|
11154
11159
|
operation: "update",
|
|
11155
11160
|
data: E,
|
|
11156
|
-
|
|
11161
|
+
recordId: e,
|
|
11157
11162
|
context: o,
|
|
11158
11163
|
originalRecord: me(_)
|
|
11159
11164
|
}, L = { ...T };
|
|
@@ -11182,7 +11187,7 @@ ${i}`);
|
|
|
11182
11187
|
const v = await at(n, e, { userId: s });
|
|
11183
11188
|
let C = Vs("delete", n, v, a, g, "Online", s || "System", lt.now(), fe.serverTimestamp());
|
|
11184
11189
|
const _ = Sn(C);
|
|
11185
|
-
Ve(C), p && await Mt("delete", "started", C, i, n, e, h), await oe("preOperation", o, y, { operation: "delete", data: C,
|
|
11190
|
+
Ve(C), p && await Mt("delete", "started", C, i, n, e, h), await oe("preOperation", o, y, { operation: "delete", data: C, recordId: e, context: r }), await oe("preWrite", o, y, { operation: "delete", data: C, recordId: e, context: r }), Ve(C);
|
|
11186
11191
|
const m = async (w) => {
|
|
11187
11192
|
const [I, S, R, A] = await Promise.all([
|
|
11188
11193
|
w.get(N.collection("system_deployment").doc("maintenance_mode")),
|
|
@@ -11221,13 +11226,19 @@ ${i}`);
|
|
|
11221
11226
|
Ys("delete", w, n, e, C, a, h, t, I, fe.arrayUnion, fe.arrayRemove, fe.delete, (S) => N.collection("tenants").doc(i).collection("system_fields").doc(d.collection).collection(`${d.collection}-${S.name}`).doc(e), (S, R) => N.collection("tenants").doc(i).collection("system_unique").doc(d.collection).collection(`Unique-${d.collection}-${S.name}`).doc(R), (S) => N.collection("tenants").doc(i).collection("system_fields").doc(d.collection).collection(`${d.collection}-${S}`).doc(e), (S, R) => Ae(N, S, i).doc(R), (S, R, A) => N.collection("tenants").doc(i).collection("system_fields").doc(S.collection).collection(`${S.collection}-${R}`).doc(A), (S, R, A) => N.collection("tenants").doc(i).collection("system_fields").doc(S.collection).collection(`${S.collection}-${R.replaceAll(" ", "-")}`).doc(A)), w.delete(x.doc(e));
|
|
11222
11227
|
}, { maxAttempts: 10 });
|
|
11223
11228
|
} catch (w) {
|
|
11224
|
-
const S = await oe("postWriteError", o, y, {
|
|
11229
|
+
const S = await oe("postWriteError", o, y, {
|
|
11230
|
+
operation: "delete",
|
|
11231
|
+
data: C,
|
|
11232
|
+
recordId: e,
|
|
11233
|
+
context: r,
|
|
11234
|
+
error: w
|
|
11235
|
+
});
|
|
11225
11236
|
if (p && (await new Promise((R) => {
|
|
11226
11237
|
setTimeout(R, 250);
|
|
11227
11238
|
}), await Mt("delete", S?.resolved ? "success" : "failed", C, i, n, e, h, S?.resolved ? void 0 : w)), !S?.resolved)
|
|
11228
11239
|
throw h.auth && C.User_ID && await N.collection("tenants").doc(i).collection(d.collection).doc(e).update({ User_ID: fe.delete() }), w;
|
|
11229
11240
|
}
|
|
11230
|
-
const M = { operation: "delete", data: C,
|
|
11241
|
+
const M = { operation: "delete", data: C, recordId: e, context: r }, E = { ...M };
|
|
11231
11242
|
return await oe("postWrite", o, y, M), await oe("postOperation", o, y, E), { id: e, ...C };
|
|
11232
11243
|
}, mu = async (n, e) => {
|
|
11233
11244
|
const t = ce(), s = ko(), r = process.env.ADMIN_SMS;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { CollectionsSchema, StokerPermissions } from "@stoker-platform/types";
|
|
2
2
|
import { DocumentReference } from "firebase-admin/firestore";
|
|
3
|
-
export declare const getDocumentRefs: (tenantId: string, path: string[],
|
|
3
|
+
export declare const getDocumentRefs: (tenantId: string, path: string[], recordId: string, schema: CollectionsSchema, permissions?: StokerPermissions) => DocumentReference[];
|
|
@@ -20,4 +20,4 @@ export interface GetOneOptions {
|
|
|
20
20
|
noComputedFields?: boolean;
|
|
21
21
|
noEmbeddingFields?: boolean;
|
|
22
22
|
}
|
|
23
|
-
export declare const getOne: (path: string[],
|
|
23
|
+
export declare const getOne: (path: string[], recordId: string, options?: GetOneOptions) => Promise<StokerRecord>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FieldValue } from "firebase-admin/firestore";
|
|
2
|
-
export declare const deleteRecord: (path: string[],
|
|
2
|
+
export declare const deleteRecord: (path: string[], recordId: string, options?: {
|
|
3
3
|
userId?: string;
|
|
4
4
|
force?: boolean;
|
|
5
5
|
context?: any;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FieldValue, Transaction } from "firebase-admin/firestore";
|
|
2
2
|
import { StokerRecord, StokerPermissions, CollectionsSchema } from "@stoker-platform/types";
|
|
3
|
-
export declare const updateRecord: (path: string[],
|
|
3
|
+
export declare const updateRecord: (path: string[], recordId: string, data: Partial<StokerRecord>, options?: {
|
|
4
4
|
userId?: string;
|
|
5
5
|
user?: {
|
|
6
6
|
operation: "create" | "update" | "delete";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stoker-platform/node-client",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.49",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"files": [
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@google-cloud/storage": "^7.19.0",
|
|
27
|
-
"@stoker-platform/types": "0.5.
|
|
28
|
-
"@stoker-platform/utils": "0.5.
|
|
27
|
+
"@stoker-platform/types": "0.5.31",
|
|
28
|
+
"@stoker-platform/utils": "0.5.41",
|
|
29
29
|
"@types/luxon": "^3.7.1",
|
|
30
30
|
"cross-spawn": "^7.0.6",
|
|
31
31
|
"firebase-admin": "^13.8.0",
|