over-zero 0.0.0 → 0.0.2
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/cjs/createPermissions.cjs +43 -57
- package/dist/cjs/createPermissions.js +46 -48
- package/dist/cjs/createPermissions.js.map +2 -2
- package/dist/cjs/createPermissions.native.js +46 -53
- package/dist/cjs/createPermissions.native.js.map +2 -2
- package/dist/cjs/createZero.cjs +128 -0
- package/dist/cjs/createZero.js +107 -0
- package/dist/cjs/createZero.js.map +6 -0
- package/dist/cjs/createZero.native.js +115 -0
- package/dist/cjs/createZero.native.js.map +6 -0
- package/dist/cjs/createZeroClient.cjs +128 -0
- package/dist/cjs/createZeroClient.js +103 -0
- package/dist/cjs/createZeroClient.js.map +6 -0
- package/dist/cjs/createZeroClient.native.js +115 -0
- package/dist/cjs/createZeroClient.native.js.map +6 -0
- package/dist/cjs/createZeroServer.cjs +131 -0
- package/dist/cjs/createZeroServer.js +108 -0
- package/dist/cjs/createZeroServer.js.map +6 -0
- package/dist/cjs/createZeroServer.native.js +107 -0
- package/dist/cjs/createZeroServer.native.js.map +6 -0
- package/dist/cjs/helpers/context.js.map +1 -1
- package/dist/cjs/helpers/context.native.js.map +1 -1
- package/dist/cjs/helpers/createMutators.cjs +11 -11
- package/dist/cjs/helpers/createMutators.js +9 -7
- package/dist/cjs/helpers/createMutators.js.map +1 -1
- package/dist/cjs/helpers/createMutators.native.js +8 -6
- package/dist/cjs/helpers/createMutators.native.js.map +1 -1
- package/dist/cjs/helpers/ensureLoggedIn.cjs +1 -1
- package/dist/cjs/helpers/ensureLoggedIn.js +1 -1
- package/dist/cjs/helpers/ensureLoggedIn.js.map +1 -1
- package/dist/cjs/helpers/ensureLoggedIn.native.js +1 -1
- package/dist/cjs/helpers/ensureLoggedIn.native.js.map +1 -1
- package/dist/cjs/helpers/getAuthData.cjs +0 -36
- package/dist/cjs/helpers/getAuthData.js +0 -28
- package/dist/cjs/helpers/getAuthData.js.map +2 -2
- package/dist/cjs/helpers/getAuthData.native.js +0 -31
- package/dist/cjs/helpers/getAuthData.native.js.map +2 -2
- package/dist/cjs/helpers/useAuthData.cjs +0 -32
- package/dist/cjs/helpers/useAuthData.js +0 -24
- package/dist/cjs/helpers/useAuthData.js.map +2 -2
- package/dist/cjs/helpers/useAuthData.native.js +0 -31
- package/dist/cjs/helpers/useAuthData.native.js.map +2 -2
- package/dist/cjs/helpers/useZeroDebug.cjs +68 -0
- package/dist/cjs/helpers/useZeroDebug.js +49 -0
- package/dist/cjs/helpers/useZeroDebug.js.map +6 -0
- package/dist/cjs/helpers/useZeroDebug.native.js +66 -0
- package/dist/cjs/helpers/useZeroDebug.native.js.map +6 -0
- package/dist/cjs/helpers/zeroEmitter.cjs +2 -2
- package/dist/cjs/helpers/zeroEmitter.js +2 -2
- package/dist/cjs/helpers/zeroEmitter.native.js +1 -1
- package/dist/cjs/helpers/zeroEmitter.native.js.map +1 -1
- package/dist/cjs/index.cjs +3 -1
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.native.js +6 -2
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/mutations.cjs +50 -0
- package/dist/cjs/mutations.js +43 -0
- package/dist/cjs/mutations.js.map +6 -0
- package/dist/cjs/mutations.native.js +50 -0
- package/dist/cjs/mutations.native.js.map +6 -0
- package/dist/cjs/server.cjs +18 -0
- package/dist/cjs/server.js +15 -0
- package/dist/cjs/server.js.map +6 -0
- package/dist/cjs/server.native.js +20 -0
- package/dist/cjs/server.native.js.map +6 -0
- package/dist/cjs/where.cjs +33 -0
- package/dist/cjs/where.js +28 -0
- package/dist/cjs/where.js.map +6 -0
- package/dist/cjs/where.native.js +34 -0
- package/dist/cjs/where.native.js.map +6 -0
- package/dist/esm/createPermissions.js +48 -47
- package/dist/esm/createPermissions.js.map +2 -2
- package/dist/esm/createPermissions.mjs +41 -55
- package/dist/esm/createPermissions.mjs.map +1 -1
- package/dist/esm/createPermissions.native.js +55 -69
- package/dist/esm/createPermissions.native.js.map +1 -1
- package/dist/esm/createZero.js +99 -0
- package/dist/esm/createZero.js.map +6 -0
- package/dist/esm/createZero.mjs +105 -0
- package/dist/esm/createZero.mjs.map +1 -0
- package/dist/esm/createZero.native.js +119 -0
- package/dist/esm/createZero.native.js.map +1 -0
- package/dist/esm/createZeroClient.js +95 -0
- package/dist/esm/createZeroClient.js.map +6 -0
- package/dist/esm/createZeroClient.mjs +105 -0
- package/dist/esm/createZeroClient.mjs.map +1 -0
- package/dist/esm/createZeroClient.native.js +119 -0
- package/dist/esm/createZeroClient.native.js.map +1 -0
- package/dist/esm/createZeroServer.js +90 -0
- package/dist/esm/createZeroServer.js.map +6 -0
- package/dist/esm/createZeroServer.mjs +97 -0
- package/dist/esm/createZeroServer.mjs.map +1 -0
- package/dist/esm/createZeroServer.native.js +104 -0
- package/dist/esm/createZeroServer.native.js.map +1 -0
- package/dist/esm/helpers/context.js.map +1 -1
- package/dist/esm/helpers/context.mjs.map +1 -1
- package/dist/esm/helpers/context.native.js.map +1 -1
- package/dist/esm/helpers/createMutators.js +6 -7
- package/dist/esm/helpers/createMutators.js.map +1 -1
- package/dist/esm/helpers/createMutators.mjs +7 -7
- package/dist/esm/helpers/createMutators.mjs.map +1 -1
- package/dist/esm/helpers/createMutators.native.js +9 -7
- package/dist/esm/helpers/createMutators.native.js.map +1 -1
- package/dist/esm/helpers/ensureLoggedIn.js +1 -1
- package/dist/esm/helpers/ensureLoggedIn.js.map +1 -1
- package/dist/esm/helpers/ensureLoggedIn.mjs +1 -1
- package/dist/esm/helpers/ensureLoggedIn.mjs.map +1 -1
- package/dist/esm/helpers/ensureLoggedIn.native.js +1 -1
- package/dist/esm/helpers/ensureLoggedIn.native.js.map +1 -1
- package/dist/esm/helpers/getAuthData.js +0 -12
- package/dist/esm/helpers/getAuthData.js.map +2 -2
- package/dist/esm/helpers/getAuthData.mjs +1 -12
- package/dist/esm/helpers/getAuthData.mjs.map +1 -1
- package/dist/esm/helpers/getAuthData.native.js +1 -12
- package/dist/esm/helpers/getAuthData.native.js.map +1 -1
- package/dist/esm/helpers/useAuthData.js +0 -10
- package/dist/esm/helpers/useAuthData.js.map +2 -2
- package/dist/esm/helpers/useAuthData.mjs +1 -8
- package/dist/esm/helpers/useAuthData.mjs.map +1 -1
- package/dist/esm/helpers/useAuthData.native.js +1 -12
- package/dist/esm/helpers/useAuthData.native.js.map +1 -1
- package/dist/esm/helpers/useZeroDebug.js +35 -0
- package/dist/esm/helpers/useZeroDebug.js.map +6 -0
- package/dist/esm/helpers/useZeroDebug.mjs +45 -0
- package/dist/esm/helpers/useZeroDebug.mjs.map +1 -0
- package/dist/esm/helpers/useZeroDebug.native.js +53 -0
- package/dist/esm/helpers/useZeroDebug.native.js.map +1 -0
- package/dist/esm/helpers/zeroEmitter.js +1 -1
- package/dist/esm/helpers/zeroEmitter.mjs +1 -1
- package/dist/esm/helpers/zeroEmitter.native.js +1 -1
- package/dist/esm/index.js +3 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +3 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +3 -1
- package/dist/esm/index.native.js.map +1 -1
- package/dist/esm/mutations.js +27 -0
- package/dist/esm/mutations.js.map +6 -0
- package/dist/esm/mutations.mjs +27 -0
- package/dist/esm/mutations.mjs.map +1 -0
- package/dist/esm/mutations.native.js +29 -0
- package/dist/esm/mutations.native.js.map +1 -0
- package/dist/esm/server.js +2 -0
- package/dist/esm/server.js.map +6 -0
- package/dist/esm/server.mjs +2 -0
- package/dist/esm/server.mjs.map +1 -0
- package/dist/esm/server.native.js +2 -0
- package/dist/esm/server.native.js.map +1 -0
- package/dist/esm/where.js +12 -0
- package/dist/esm/where.js.map +6 -0
- package/dist/esm/where.mjs +9 -0
- package/dist/esm/where.mjs.map +1 -0
- package/dist/esm/where.native.js +9 -0
- package/dist/esm/where.native.js.map +1 -0
- package/package.json +12 -6
- package/src/createPermissions.ts +17 -77
- package/src/createZeroClient.tsx +29 -26
- package/src/createZeroServer.ts +43 -43
- package/src/helpers/createMutators.ts +19 -29
- package/src/helpers/ensureLoggedIn.ts +2 -1
- package/src/helpers/prettyFormatZeroQuery.ts +1 -1
- package/src/helpers/useZeroDebug.ts +1 -0
- package/src/index.ts +1 -5
- package/src/mutations.ts +20 -7
- package/src/server.ts +1 -0
- package/src/types.ts +74 -7
- package/src/where.ts +28 -0
- package/src/helpers/clearZeroDatabase.ts +0 -68
- package/src/helpers/getAuthData.tsx +0 -12
- package/src/helpers/useAuthData.ts +0 -13
- package/src/helpers/zeroEmitter.ts +0 -5
- package/types/createMutations.d.ts +0 -20
- package/types/createMutations.d.ts.map +0 -1
- package/types/createPermissions.d.ts +0 -37
- package/types/createPermissions.d.ts.map +0 -1
- package/types/createZeroClient.d.ts +0 -45
- package/types/createZeroClient.d.ts.map +0 -1
- package/types/createZeroServer.d.ts +0 -61
- package/types/createZeroServer.d.ts.map +0 -1
- package/types/helpers/batchQuery.d.ts +0 -7
- package/types/helpers/batchQuery.d.ts.map +0 -1
- package/types/helpers/clearZeroDatabase.d.ts +0 -2
- package/types/helpers/clearZeroDatabase.d.ts.map +0 -1
- package/types/helpers/context.d.ts +0 -5
- package/types/helpers/context.d.ts.map +0 -1
- package/types/helpers/createMutators.d.ts +0 -16
- package/types/helpers/createMutators.d.ts.map +0 -1
- package/types/helpers/ensureLoggedIn.d.ts +0 -2
- package/types/helpers/ensureLoggedIn.d.ts.map +0 -1
- package/types/helpers/getAuthData.d.ts +0 -1
- package/types/helpers/getAuthData.d.ts.map +0 -1
- package/types/helpers/prettyFormatZeroQuery.d.ts +0 -3
- package/types/helpers/prettyFormatZeroQuery.d.ts.map +0 -1
- package/types/helpers/useAuthData.d.ts +0 -1
- package/types/helpers/useAuthData.d.ts.map +0 -1
- package/types/helpers/useZeroDebug.d.ts +0 -3
- package/types/helpers/useZeroDebug.d.ts.map +0 -1
- package/types/helpers/zeroEmitter.d.ts +0 -2
- package/types/helpers/zeroEmitter.d.ts.map +0 -1
- package/types/index.d.ts +0 -9
- package/types/index.d.ts.map +0 -1
- package/types/types.d.ts +0 -21
- package/types/types.d.ts.map +0 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
function mutations(table, permissions, mutations2) {
|
|
2
|
+
if (permissions) {
|
|
3
|
+
const tableName = table.schema.name,
|
|
4
|
+
createCRUDMutation = action => async (ctx, obj) => {
|
|
5
|
+
const runServerPermissionCheck = async () => {
|
|
6
|
+
ctx.didCanPermissionsRun || process.env.VITE_ENVIRONMENT === "ssr" && (await ctx.can(permissions, action, obj));
|
|
7
|
+
};
|
|
8
|
+
action !== "insert" && (await runServerPermissionCheck());
|
|
9
|
+
const existing = mutations2?.[action];
|
|
10
|
+
existing ? await existing(ctx, obj) : await ctx.tx.mutate[tableName][action](obj), action === "insert" && (await runServerPermissionCheck());
|
|
11
|
+
},
|
|
12
|
+
crudMutations = {
|
|
13
|
+
insert: createCRUDMutation("insert"),
|
|
14
|
+
update: createCRUDMutation("update"),
|
|
15
|
+
delete: createCRUDMutation("delete"),
|
|
16
|
+
upsert: createCRUDMutation("upsert")
|
|
17
|
+
};
|
|
18
|
+
return {
|
|
19
|
+
...mutations2,
|
|
20
|
+
// overwrite regular mutations but call them if they are defined by user
|
|
21
|
+
...crudMutations
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
return table;
|
|
25
|
+
}
|
|
26
|
+
export { mutations };
|
|
27
|
+
//# sourceMappingURL=mutations.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["mutations","table","permissions","mutations2","tableName","schema","name","createCRUDMutation","action","ctx","obj","runServerPermissionCheck","didCanPermissionsRun","process","env","VITE_ENVIRONMENT","can","existing","tx","mutate","crudMutations","insert","update","delete","upsert"],"sources":["../../src/mutations.ts"],"sourcesContent":[null],"mappings":"AAoEO,SAASA,UAGdC,KAAA,EAA0BC,WAAA,EAAqBC,UAAA,EAAkC;EACjF,IAAID,WAAA,EAAa;IACf,MAAME,SAAA,GAAaH,KAAA,CAAgBI,MAAA,CAAOC,IAAA;MAEpCC,kBAAA,GAAsBC,MAAA,IACnB,OAAOC,GAAA,EAAqBC,GAAA,KAAa;QAS9C,MAAMC,wBAAA,GAA2B,MAAAA,CAAA,KAAY;UACvCF,GAAA,CAAIG,oBAAA,IAMJC,OAAA,CAAQC,GAAA,CAAIC,gBAAA,KAAqB,UACnC,MAAMN,GAAA,CAAIO,GAAA,CAAId,WAAA,EAAaM,MAAA,EAAQE,GAAG;QAE1C;QAEIF,MAAA,KAAW,aACb,MAAMG,wBAAA,CAAyB;QAIjC,MAAMM,QAAA,GAAWd,UAAA,GAAYK,MAAM;QAE/BS,QAAA,GACF,MAAMA,QAAA,CAASR,GAAA,EAAKC,GAAG,IAGvB,MAAMD,GAAA,CAAIS,EAAA,CAAGC,MAAA,CAAOf,SAAsB,EAAGI,MAAM,EAAEE,GAAG,GAGtDF,MAAA,KAAW,aACb,MAAMG,wBAAA,CAAyB;MAEnC;MAGIS,aAAA,GAAoC;QACxCC,MAAA,EAAQd,kBAAA,CAAmB,QAAQ;QACnCe,MAAA,EAAQf,kBAAA,CAAmB,QAAQ;QACnCgB,MAAA,EAAQhB,kBAAA,CAAmB,QAAQ;QACnCiB,MAAA,EAAQjB,kBAAA,CAAmB,QAAQ;MACrC;IAEA,OAAO;MACL,GAAGJ,UAAA;MAAA;MAEH,GAAGiB;IACL;EACF;EAGA,OAAOnB,KAAA;AACT","ignoreList":[]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
function mutations(table, permissions, mutations2) {
|
|
2
|
+
if (permissions) {
|
|
3
|
+
var tableName = table.schema.name,
|
|
4
|
+
createCRUDMutation = function (action) {
|
|
5
|
+
return async function (ctx, obj) {
|
|
6
|
+
var runServerPermissionCheck = async function () {
|
|
7
|
+
ctx.didCanPermissionsRun || process.env.VITE_ENVIRONMENT === "ssr" && (await ctx.can(permissions, action, obj));
|
|
8
|
+
};
|
|
9
|
+
action !== "insert" && (await runServerPermissionCheck());
|
|
10
|
+
var existing = mutations2?.[action];
|
|
11
|
+
existing ? await existing(ctx, obj) : await ctx.tx.mutate[tableName][action](obj), action === "insert" && (await runServerPermissionCheck());
|
|
12
|
+
};
|
|
13
|
+
},
|
|
14
|
+
crudMutations = {
|
|
15
|
+
insert: createCRUDMutation("insert"),
|
|
16
|
+
update: createCRUDMutation("update"),
|
|
17
|
+
delete: createCRUDMutation("delete"),
|
|
18
|
+
upsert: createCRUDMutation("upsert")
|
|
19
|
+
};
|
|
20
|
+
return {
|
|
21
|
+
...mutations2,
|
|
22
|
+
// overwrite regular mutations but call them if they are defined by user
|
|
23
|
+
...crudMutations
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return table;
|
|
27
|
+
}
|
|
28
|
+
export { mutations };
|
|
29
|
+
//# sourceMappingURL=mutations.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["mutations","table","permissions","mutations2","tableName","schema","name","createCRUDMutation","action","ctx","obj","runServerPermissionCheck","didCanPermissionsRun","process","env","VITE_ENVIRONMENT","can","existing","tx","mutate","crudMutations","insert","update","delete","upsert"],"sources":["../../src/mutations.ts"],"sourcesContent":[null],"mappings":"AAoEO,SAASA,UAGdC,KAAA,EAA0BC,WAAA,EAAqBC,UAAA,EAAkC;EACjF,IAAID,WAAA,EAAa;IACf,IAAAE,SAAM,GAAAH,KAAa,CAAAI,MAAgB,CAAAC,IAAO;MAAAC,kBAEpC,YAAAA,CAAsBC,MACnB;QASL,OAAM,gBAAAC,GAAA,EAAAC,GAAA;UACA,IAAIC,wBAMJ,kBAAAA,CAAA,EAAY;YAGlBF,GAAA,CAAAG,oBAAA,IAAAC,OAAA,CAAAC,GAAA,CAAAC,gBAAA,qBAAAN,GAAA,CAAAO,GAAA,CAAAd,WAAA,EAAAM,MAAA,EAAAE,GAAA;UAEI;UAKJF,MAAM,aAAW,WAAYG,wBAAM;UAE/B,IAAAM,QACF,GAAMd,UAAS,GAAAK,MAAQ;UAYvBS,QAAA,SAAoCA,QAAA,CAAAR,GAAA,EAAAC,GAAA,UAAAD,GAAA,CAAAS,EAAA,CAAAC,MAAA,CAAAf,SAAA,EAAAI,MAAA,EAAAE,GAAA,GAAAF,MAAA,wBAAAG,wBAAA;QACxC;MAAmC;MACnCS,aAAQ;QACRC,MAAA,EAAQd,kBAAA,CAAmB,QAAQ;QACnCe,MAAA,EAAQf,kBAAA,CAAmB,QAAQ;QACrCgB,MAAA,EAAAhB,kBAAA;QAEAiB,MAAO,EAAAjB,kBAAA;MAAA;IACF;MAEH,GAAGJ,UAAA;MACL;MACF,GAAAiB;IAGA;EACF","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["../../src/server.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["../../src/server.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
function where(a, b) {
|
|
2
|
+
return b && WhereTableNameMap.set(b, a), b || a;
|
|
3
|
+
}
|
|
4
|
+
const WhereTableNameMap = /* @__PURE__ */ new WeakMap();
|
|
5
|
+
function getWhereTableName(where2) {
|
|
6
|
+
return WhereTableNameMap.get(where2);
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
getWhereTableName,
|
|
10
|
+
where
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=where.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
function where(a, b) {
|
|
2
|
+
return b && WhereTableNameMap.set(b, a), b || a;
|
|
3
|
+
}
|
|
4
|
+
const WhereTableNameMap = /* @__PURE__ */new WeakMap();
|
|
5
|
+
function getWhereTableName(where2) {
|
|
6
|
+
return WhereTableNameMap.get(where2);
|
|
7
|
+
}
|
|
8
|
+
export { getWhereTableName, where };
|
|
9
|
+
//# sourceMappingURL=where.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["where","a","b","WhereTableNameMap","set","WeakMap","getWhereTableName","where2","get"],"sources":["../../src/where.ts"],"sourcesContent":[null],"mappings":"AAWO,SAASA,MACdC,CAAA,EACAC,CAAA,EACS;EACT,OAAIA,CAAA,IACFC,iBAAA,CAAkBC,GAAA,CAAIF,CAAA,EAAGD,CAAU,GAE7BC,CAAA,IAAKD,CAAA;AACf;AAIA,MAAME,iBAAA,GAAoB,mBAAIE,OAAA,CAA0B;AAEjD,SAASC,kBAAkBC,MAAA,EAAc;EAC9C,OAAOJ,iBAAA,CAAkBK,GAAA,CAAID,MAAK;AACpC","ignoreList":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
function where(a, b) {
|
|
2
|
+
return b && WhereTableNameMap.set(b, a), b || a;
|
|
3
|
+
}
|
|
4
|
+
var WhereTableNameMap = /* @__PURE__ */new WeakMap();
|
|
5
|
+
function getWhereTableName(where2) {
|
|
6
|
+
return WhereTableNameMap.get(where2);
|
|
7
|
+
}
|
|
8
|
+
export { getWhereTableName, where };
|
|
9
|
+
//# sourceMappingURL=where.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["where","a","b","WhereTableNameMap","set","WeakMap","getWhereTableName","where2","get"],"sources":["../../src/where.ts"],"sourcesContent":[null],"mappings":"AAWO,SAASA,MACdC,CAAA,EACAC,CAAA,EACS;EACT,OAAIA,CAAA,IACFC,iBAAA,CAAkBC,GAAA,CAAIF,CAAA,EAAGD,CAAU,GAE7BC,CAAA,IAAKD,CAAA;AACf;AAIA,IAAAE,iBAAM,kBAAoB,IAAAE,OAAI;AAEvB,SAASC,kBAAkBC,MAAA,EAAc;EAC9C,OAAOJ,iBAAA,CAAkBK,GAAA,CAAID,MAAK;AACpC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "over-zero",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"source": "src/index.ts",
|
|
6
|
-
"types": "./types/index.d.ts",
|
|
7
6
|
"main": "dist/cjs",
|
|
8
7
|
"module": "dist/esm",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"types": "./src/index.ts",
|
|
9
10
|
"files": [
|
|
10
11
|
"src",
|
|
11
12
|
"types",
|
|
12
13
|
"dist"
|
|
13
14
|
],
|
|
14
15
|
"scripts": {
|
|
15
|
-
"build": "tamagui-build",
|
|
16
|
-
"watch": "tamagui-build --watch",
|
|
16
|
+
"build": "tamagui-build --skip-types",
|
|
17
|
+
"watch": "tamagui-build --skip-types --watch",
|
|
17
18
|
"lint": "biome check src",
|
|
18
19
|
"lint:fix": "biome check --write src",
|
|
19
20
|
"clean": "tamagui-build clean",
|
|
@@ -26,14 +27,19 @@
|
|
|
26
27
|
"import": "./dist/esm/index.native.js",
|
|
27
28
|
"require": "./dist/cjs/index.native.js"
|
|
28
29
|
},
|
|
29
|
-
"types": "./
|
|
30
|
+
"types": "./src/index.ts",
|
|
30
31
|
"import": "./dist/esm/index.mjs",
|
|
31
32
|
"require": "./dist/cjs/index.cjs",
|
|
32
33
|
"default": "./dist/cjs/index.native.js"
|
|
34
|
+
},
|
|
35
|
+
"./server": {
|
|
36
|
+
"types": "./src/server.ts",
|
|
37
|
+
"import": "./dist/esm/server.mjs",
|
|
38
|
+
"require": "./dist/cjs/server.cjs"
|
|
33
39
|
}
|
|
34
40
|
},
|
|
35
41
|
"dependencies": {
|
|
36
|
-
"@vxrn/helpers": "
|
|
42
|
+
"@vxrn/helpers": "0.0.0"
|
|
37
43
|
},
|
|
38
44
|
"peerDependencies": {
|
|
39
45
|
"@rocicorp/zero": "*",
|
package/src/createPermissions.ts
CHANGED
|
@@ -2,66 +2,26 @@ import type {
|
|
|
2
2
|
Condition,
|
|
3
3
|
ExpressionBuilder,
|
|
4
4
|
Query,
|
|
5
|
-
Transaction,
|
|
6
5
|
Schema as ZeroSchema,
|
|
7
6
|
} from '@rocicorp/zero'
|
|
8
7
|
import { ANYONE_CAN, definePermissions } from '@rocicorp/zero'
|
|
9
8
|
import { ensure, EnsureError, objectEntries } from '@vxrn/helpers'
|
|
10
|
-
import
|
|
11
|
-
// import { models } from '~/data/models'
|
|
12
|
-
// import { objectEntries } from '~/helpers/types/object'
|
|
9
|
+
import { runWithContext } from './helpers/context'
|
|
13
10
|
import { prettyFormatZeroQuery } from './helpers/prettyFormatZeroQuery'
|
|
14
|
-
import type { MutatorContext, Where } from './types'
|
|
11
|
+
import type { AuthData, MutatorContext, TableName, Transaction, Where } from './types'
|
|
12
|
+
import { getWhereTableName } from './where'
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export function createPermissions<Schema extends ZeroSchema, TableName extends string>({
|
|
14
|
+
export function createPermissions<Schema extends ZeroSchema>({
|
|
15
|
+
environment,
|
|
19
16
|
schema,
|
|
17
|
+
models,
|
|
20
18
|
getContext,
|
|
21
19
|
}: {
|
|
20
|
+
environment: 'client' | 'server'
|
|
22
21
|
schema: Schema
|
|
22
|
+
models: any
|
|
23
23
|
getContext: () => MutatorContext
|
|
24
24
|
}) {
|
|
25
|
-
runEnvironmentSafetyCheck()
|
|
26
|
-
|
|
27
|
-
// we don't want flickers as you move around and these queries are re-run
|
|
28
|
-
// and things generally aren't changing with permissions rapidly, so lets
|
|
29
|
-
// cache the last results and use that when first rendering, they will
|
|
30
|
-
// always update once the query resolves
|
|
31
|
-
|
|
32
|
-
// Where defaults to letting you return basically anything because we want to allow it to be usable
|
|
33
|
-
// flexibly, one example is for permissions where you can return an Object with multiple wheres as values
|
|
34
|
-
// for example, PermissionsWhere below
|
|
35
|
-
|
|
36
|
-
function where<Table extends TableName, Builder extends Where = Where<Table>>(
|
|
37
|
-
tableName: Table,
|
|
38
|
-
builder: Builder
|
|
39
|
-
): Builder
|
|
40
|
-
|
|
41
|
-
function where<Table extends TableName, Builder extends Where = Where<Table>>(
|
|
42
|
-
builder: Builder
|
|
43
|
-
): Builder
|
|
44
|
-
|
|
45
|
-
function where<Table extends TableName, Builder extends Where = Where<Table>>(
|
|
46
|
-
a: Table | Builder,
|
|
47
|
-
b?: Builder
|
|
48
|
-
): Builder {
|
|
49
|
-
if (b) {
|
|
50
|
-
WhereTableNameMap.set(b, a as Table)
|
|
51
|
-
}
|
|
52
|
-
return (b || a) as any
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// permissions where:
|
|
56
|
-
|
|
57
|
-
const WhereTableNameMap = new WeakMap<Where, TableName>()
|
|
58
|
-
|
|
59
|
-
function getWhereTableName(where: Where) {
|
|
60
|
-
return WhereTableNameMap.get(where)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// example of a custom where we use for permissions
|
|
64
|
-
|
|
65
25
|
type PermissionPresetActions =
|
|
66
26
|
| 'read'
|
|
67
27
|
| 'write'
|
|
@@ -105,6 +65,11 @@ export function createPermissions<Schema extends ZeroSchema, TableName extends s
|
|
|
105
65
|
}
|
|
106
66
|
|
|
107
67
|
const tableSchema = schema.tables[tableName]
|
|
68
|
+
|
|
69
|
+
if (!tableSchema) {
|
|
70
|
+
throw new Error(`No schema?`)
|
|
71
|
+
}
|
|
72
|
+
|
|
108
73
|
const primaryKeys = tableSchema.primaryKey
|
|
109
74
|
const permissionQueryBuilder = permissionWhere(eb, authData)
|
|
110
75
|
const fallbackAction = fallbackActions[action]
|
|
@@ -145,8 +110,8 @@ export function createPermissions<Schema extends ZeroSchema, TableName extends s
|
|
|
145
110
|
throw new Error(`Must use where('table') style where to pass to can()`)
|
|
146
111
|
}
|
|
147
112
|
|
|
148
|
-
// on client we always allow!
|
|
149
|
-
if (
|
|
113
|
+
// on client we always allow! we only check on server (like zero does)
|
|
114
|
+
if (environment === 'server') {
|
|
150
115
|
await ensurePermission(
|
|
151
116
|
ctx.tx,
|
|
152
117
|
ctx.authData,
|
|
@@ -159,13 +124,11 @@ export function createPermissions<Schema extends ZeroSchema, TableName extends s
|
|
|
159
124
|
}
|
|
160
125
|
}
|
|
161
126
|
|
|
162
|
-
type TX = Transaction<Schema>
|
|
163
|
-
|
|
164
127
|
async function ensurePermission<
|
|
165
128
|
PW extends PermissionsWhere,
|
|
166
129
|
Action extends keyof ReturnType<PW>,
|
|
167
130
|
>(
|
|
168
|
-
tx:
|
|
131
|
+
tx: Transaction,
|
|
169
132
|
authData: AuthData | null,
|
|
170
133
|
tableName: TableName,
|
|
171
134
|
where: Where,
|
|
@@ -179,6 +142,7 @@ export function createPermissions<Schema extends ZeroSchema, TableName extends s
|
|
|
179
142
|
|
|
180
143
|
const action = String(actionIn)
|
|
181
144
|
const name = `${tableName}.${action}`
|
|
145
|
+
// @ts-expect-error TODO its the right type but need to figure out better way to get TableName
|
|
182
146
|
const queryBase = tx.query[tableName] as Query<any, any>
|
|
183
147
|
let query: Query<any, any, any> | null = null
|
|
184
148
|
|
|
@@ -250,32 +214,8 @@ export function createPermissions<Schema extends ZeroSchema, TableName extends s
|
|
|
250
214
|
})
|
|
251
215
|
|
|
252
216
|
return {
|
|
253
|
-
where,
|
|
254
217
|
can,
|
|
255
218
|
buildPermissionQuery,
|
|
256
219
|
readPermissions,
|
|
257
220
|
}
|
|
258
221
|
}
|
|
259
|
-
|
|
260
|
-
// this is just so we have some assurance that we aren't skipping permissions
|
|
261
|
-
// checks due to bad VITE_ENVIRONMENT variable
|
|
262
|
-
function runEnvironmentSafetyCheck() {
|
|
263
|
-
if (typeof document !== 'undefined') {
|
|
264
|
-
// web!
|
|
265
|
-
} else if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
|
|
266
|
-
// react-native!
|
|
267
|
-
} else {
|
|
268
|
-
// server!
|
|
269
|
-
if (process.env.VITE_ENVIRONMENT !== 'ssr') {
|
|
270
|
-
console.error(`❌❌❌❌
|
|
271
|
-
|
|
272
|
-
ERROR: VITE_ENVIRONMENT is not set to "ssr" on server, which means permissions checks won't run when they should
|
|
273
|
-
This is makes Zero entirely insecure and needs to be fixed immediately.
|
|
274
|
-
|
|
275
|
-
This is likely a One framework issue, unless the user Vite config is overwriting the value.
|
|
276
|
-
One automatically sets this value.
|
|
277
|
-
|
|
278
|
-
`)
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
}
|
package/src/createZeroClient.tsx
CHANGED
|
@@ -1,45 +1,47 @@
|
|
|
1
|
-
import type { Row, ZeroOptions, Schema as ZeroSchema } from '@rocicorp/zero'
|
|
1
|
+
import type { Row, Zero, ZeroOptions, Schema as ZeroSchema } from '@rocicorp/zero'
|
|
2
2
|
import { useZero, ZeroProvider, useQuery as zeroUseQuery } from '@rocicorp/zero/react'
|
|
3
|
-
import { createLocalStorage, mapObject } from '@vxrn/helpers'
|
|
3
|
+
import { createEmitter, createLocalStorage, mapObject } from '@vxrn/helpers'
|
|
4
4
|
import { createContext, use, useMemo, type ReactNode } from 'react'
|
|
5
5
|
import { createPermissions } from './createPermissions'
|
|
6
6
|
import { context } from './helpers/context'
|
|
7
7
|
import { createMutators } from './helpers/createMutators'
|
|
8
8
|
import { prettyFormatZeroQuery } from './helpers/prettyFormatZeroQuery'
|
|
9
9
|
import { useZeroDebug } from './helpers/useZeroDebug'
|
|
10
|
-
|
|
11
|
-
import type { AuthData } from './types'
|
|
12
|
-
|
|
13
|
-
export function
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
disable?: boolean
|
|
21
|
-
}) {
|
|
22
|
-
// TODO
|
|
23
|
-
type TableName = string
|
|
24
|
-
type Mutators = any // typeof mutators
|
|
25
|
-
type ZeroInstance = ReturnType<typeof useZero<Schema, Mutators>>
|
|
10
|
+
|
|
11
|
+
import type { AuthData, GenericModels, GetZeroMutators, ZeroEvent } from './types'
|
|
12
|
+
|
|
13
|
+
export function createZeroClient<
|
|
14
|
+
Schema extends ZeroSchema,
|
|
15
|
+
Models extends GenericModels,
|
|
16
|
+
>({ schema, models, disable }: { schema: Schema; models: Models; disable?: boolean }) {
|
|
17
|
+
type ZeroMutators = GetZeroMutators<Models>
|
|
18
|
+
type ZeroInstance = Zero<Schema, ZeroMutators>
|
|
19
|
+
type TableName = keyof ZeroInstance['query']
|
|
26
20
|
|
|
27
21
|
const modelPermissions = mapObject(models, (val) => val.permissions) as {
|
|
28
|
-
[K in keyof
|
|
22
|
+
[K in TableName]: K extends keyof Models ? Models[K]['permissions'] : never
|
|
29
23
|
}
|
|
30
24
|
|
|
31
|
-
const permissionsHelpers = createPermissions<Schema
|
|
25
|
+
const permissionsHelpers = createPermissions<Schema>({
|
|
32
26
|
schema,
|
|
27
|
+
models,
|
|
33
28
|
getContext: context,
|
|
29
|
+
environment: 'client',
|
|
34
30
|
})
|
|
35
31
|
|
|
36
32
|
const permissionCache = createLocalStorage<string, boolean>('permissions-cache', {
|
|
37
33
|
storageLimit: 24,
|
|
38
34
|
})
|
|
39
35
|
|
|
40
|
-
const
|
|
36
|
+
const zeroEvents = createEmitter<ZeroEvent | null>('zero', null)
|
|
37
|
+
|
|
38
|
+
const AuthDataContext = createContext<AuthData>({} as AuthData)
|
|
41
39
|
const useAuthData = () => use(AuthDataContext)
|
|
42
40
|
|
|
41
|
+
// we don't want flickers as you move around and these queries are re-run
|
|
42
|
+
// and things generally aren't changing with permissions rapidly, so lets
|
|
43
|
+
// cache the last results and use that when first rendering, they will
|
|
44
|
+
// always update once the query resolves
|
|
43
45
|
function usePermission<
|
|
44
46
|
K extends TableName,
|
|
45
47
|
Action extends 'insert' | 'update' | 'delete' | 'select',
|
|
@@ -51,7 +53,7 @@ export function createZero<Schema extends ZeroSchema>({
|
|
|
51
53
|
debug = false
|
|
52
54
|
): boolean | null {
|
|
53
55
|
// we fallback to just table.action, to avoid flickers for now
|
|
54
|
-
const keyBase = `${table}${action}`
|
|
56
|
+
const keyBase = `${String(table)}${action}`
|
|
55
57
|
const key = `${keyBase}${typeof objOrId === 'string' ? objOrId : JSON.stringify(objOrId)}`
|
|
56
58
|
const cacheVal = permissionCache.get(key) ?? permissionCache.get(keyBase)
|
|
57
59
|
const authData = useAuthData()
|
|
@@ -127,7 +129,7 @@ export function createZero<Schema extends ZeroSchema>({
|
|
|
127
129
|
children,
|
|
128
130
|
authData,
|
|
129
131
|
...props
|
|
130
|
-
}: Omit<ZeroOptions<Schema,
|
|
132
|
+
}: Omit<ZeroOptions<Schema, ZeroMutators>, 'schema' | 'mutators'> & {
|
|
131
133
|
children: ReactNode
|
|
132
134
|
authData?: any
|
|
133
135
|
}) => {
|
|
@@ -148,10 +150,10 @@ export function createZero<Schema extends ZeroSchema>({
|
|
|
148
150
|
<AuthDataContext.Provider value={authData}>
|
|
149
151
|
<ZeroProvider
|
|
150
152
|
schema={schema}
|
|
151
|
-
kvStore=
|
|
153
|
+
kvStore="mem"
|
|
152
154
|
onError={(error) => {
|
|
153
155
|
console.error(`Zero Error:`, error)
|
|
154
|
-
|
|
156
|
+
zeroEvents.emit({
|
|
155
157
|
type: 'error',
|
|
156
158
|
message: error,
|
|
157
159
|
})
|
|
@@ -167,7 +169,7 @@ export function createZero<Schema extends ZeroSchema>({
|
|
|
167
169
|
}
|
|
168
170
|
|
|
169
171
|
const SetZeroInstance = () => {
|
|
170
|
-
const zero = useZero<Schema,
|
|
172
|
+
const zero = useZero<Schema, ZeroMutators>()
|
|
171
173
|
|
|
172
174
|
// TODO last hack zero wants us to use useZero but its a big migration
|
|
173
175
|
// and has some downsides (global zero import leads to simpler code)
|
|
@@ -183,6 +185,7 @@ export function createZero<Schema extends ZeroSchema>({
|
|
|
183
185
|
}
|
|
184
186
|
|
|
185
187
|
return {
|
|
188
|
+
zeroEvents,
|
|
186
189
|
ProvideZero,
|
|
187
190
|
useQuery,
|
|
188
191
|
usePermission,
|
package/src/createZeroServer.ts
CHANGED
|
@@ -1,46 +1,33 @@
|
|
|
1
1
|
import type { Schema as ZeroSchema } from '@rocicorp/zero'
|
|
2
2
|
import type { TransactionProviderInput } from '@rocicorp/zero/pg'
|
|
3
|
-
import { PostgresJSConnection } from '@rocicorp/zero/pg'
|
|
3
|
+
import { PostgresJSConnection, PushProcessor } from '@rocicorp/zero/pg'
|
|
4
4
|
import { ZQLDatabase } from '@rocicorp/zero/server'
|
|
5
|
-
import postgres from 'postgres'
|
|
6
|
-
// import { context, isInZeroMutation } from 'src/context'
|
|
7
|
-
import type { AuthData } from './types'
|
|
8
|
-
// import { type Mutators, createMutators } from '~/data/helpers/createMutators'
|
|
9
|
-
// import { schema } from '~/data/schema'
|
|
10
|
-
// import { createServerActions } from '~/data/server/createServerActions'
|
|
11
|
-
// import type { TX } from '~/data/types'
|
|
12
|
-
import { PushProcessor } from '@rocicorp/zero/pg'
|
|
13
5
|
import { assertString, randomId } from '@vxrn/helpers'
|
|
6
|
+
import postgres from 'postgres'
|
|
7
|
+
import { createPermissions } from './createPermissions'
|
|
8
|
+
import { context, isInZeroMutation } from './helpers/context'
|
|
14
9
|
import { createMutators } from './helpers/createMutators'
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
// this sets up custom server-side mutators
|
|
24
|
-
// see: https://zero.rocicorp.dev/docs/custom-mutators
|
|
10
|
+
import type {
|
|
11
|
+
AsyncAction,
|
|
12
|
+
AuthData,
|
|
13
|
+
GenericModels,
|
|
14
|
+
GetZeroMutators,
|
|
15
|
+
Transaction,
|
|
16
|
+
} from './types'
|
|
25
17
|
|
|
26
18
|
export function createZeroServer<
|
|
27
19
|
Schema extends ZeroSchema,
|
|
28
|
-
|
|
20
|
+
Models extends GenericModels,
|
|
21
|
+
ServerActions extends Record<string, unknown>,
|
|
29
22
|
>({
|
|
30
23
|
createServerActions,
|
|
31
24
|
schema,
|
|
32
25
|
models,
|
|
33
|
-
disable,
|
|
34
26
|
}: {
|
|
35
27
|
schema: Schema
|
|
36
|
-
models:
|
|
37
|
-
createServerActions: (
|
|
38
|
-
disable?: boolean
|
|
28
|
+
models: Models
|
|
29
|
+
createServerActions: () => ServerActions
|
|
39
30
|
}) {
|
|
40
|
-
// TODO
|
|
41
|
-
type TX = any
|
|
42
|
-
type Mutators = any
|
|
43
|
-
|
|
44
31
|
const dbString = assertString(process.env.ZERO_UPSTREAM_DB)
|
|
45
32
|
|
|
46
33
|
const zeroServerDatabase = new ZQLDatabase(
|
|
@@ -48,6 +35,13 @@ export function createZeroServer<
|
|
|
48
35
|
schema
|
|
49
36
|
)
|
|
50
37
|
|
|
38
|
+
const permissions = createPermissions<Schema>({
|
|
39
|
+
environment: 'server',
|
|
40
|
+
schema,
|
|
41
|
+
models,
|
|
42
|
+
getContext: context,
|
|
43
|
+
})
|
|
44
|
+
|
|
51
45
|
const processor = new PushProcessor(zeroServerDatabase)
|
|
52
46
|
|
|
53
47
|
const handleMutationRequest = async ({
|
|
@@ -55,22 +49,24 @@ export function createZeroServer<
|
|
|
55
49
|
request,
|
|
56
50
|
skipAsyncTasks,
|
|
57
51
|
}: {
|
|
58
|
-
authData: AuthData
|
|
52
|
+
authData: AuthData | null
|
|
59
53
|
request: Request
|
|
60
54
|
skipAsyncTasks?: boolean
|
|
61
55
|
}) => {
|
|
62
56
|
// since mutations do DB work in transaction, avoid any async tasks during
|
|
63
|
-
const asyncTasks:
|
|
57
|
+
const asyncTasks: AsyncAction[] = []
|
|
58
|
+
|
|
59
|
+
const mutators = createMutators({
|
|
60
|
+
asyncTasks,
|
|
61
|
+
can: permissions.can,
|
|
62
|
+
createServerActions,
|
|
63
|
+
environment: 'server',
|
|
64
|
+
models,
|
|
65
|
+
authData,
|
|
66
|
+
})
|
|
64
67
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
environment: 'server',
|
|
68
|
-
asyncTasks,
|
|
69
|
-
authData,
|
|
70
|
-
createServerActions,
|
|
71
|
-
}),
|
|
72
|
-
request
|
|
73
|
-
)
|
|
68
|
+
// @ts-expect-error TODO regressed moving into package
|
|
69
|
+
const response = await processor.process(mutators, request)
|
|
74
70
|
|
|
75
71
|
// now finish
|
|
76
72
|
if (!skipAsyncTasks && asyncTasks.length) {
|
|
@@ -92,12 +88,13 @@ export function createZeroServer<
|
|
|
92
88
|
}
|
|
93
89
|
|
|
94
90
|
const serverMutate = async (
|
|
95
|
-
run: (tx:
|
|
91
|
+
run: (tx: Transaction, mutators: GetZeroMutators<Models>) => Promise<void>,
|
|
96
92
|
authData?: Pick<AuthData, 'email' | 'id'> & Partial<AuthData>
|
|
97
93
|
) => {
|
|
98
94
|
const asyncTasks: Array<() => Promise<void>> = []
|
|
99
95
|
|
|
100
96
|
const mutators = createMutators({
|
|
97
|
+
models,
|
|
101
98
|
environment: 'server',
|
|
102
99
|
asyncTasks,
|
|
103
100
|
authData: {
|
|
@@ -107,6 +104,7 @@ export function createZeroServer<
|
|
|
107
104
|
...authData,
|
|
108
105
|
},
|
|
109
106
|
createServerActions,
|
|
107
|
+
can: permissions.can,
|
|
110
108
|
})
|
|
111
109
|
|
|
112
110
|
await serverTransaction(async (tx) => {
|
|
@@ -129,15 +127,17 @@ export function createZeroServer<
|
|
|
129
127
|
}
|
|
130
128
|
|
|
131
129
|
async function serverTransaction<
|
|
132
|
-
CB extends (tx:
|
|
133
|
-
Returns extends CB extends (tx:
|
|
130
|
+
CB extends (tx: Transaction) => Promise<any>,
|
|
131
|
+
Returns extends CB extends (tx: Transaction) => Promise<infer X> ? X : never,
|
|
134
132
|
>(query: CB): Promise<Returns> {
|
|
135
133
|
try {
|
|
136
134
|
if (isInZeroMutation()) {
|
|
137
135
|
const { tx } = context()
|
|
138
136
|
return await query(tx)
|
|
139
137
|
}
|
|
140
|
-
|
|
138
|
+
// @ts-expect-error TODO regressed moving into package
|
|
139
|
+
const output = await zeroServerDatabase.transaction(query, dummyTransactionInput)
|
|
140
|
+
return output as any
|
|
141
141
|
} catch (err) {
|
|
142
142
|
console.error(`Error running serverTransaction(): ${err}`)
|
|
143
143
|
throw err
|