on-zero 0.1.15 → 0.1.16
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/query.cjs +16 -22
- package/dist/cjs/query.js +14 -16
- package/dist/cjs/query.js.map +1 -1
- package/dist/cjs/query.native.js +18 -23
- package/dist/cjs/query.native.js.map +1 -1
- package/dist/esm/query.js +16 -17
- package/dist/esm/query.js.map +1 -1
- package/dist/esm/query.mjs +14 -22
- package/dist/esm/query.mjs.map +1 -1
- package/dist/esm/query.native.js +16 -23
- package/dist/esm/query.native.js.map +1 -1
- package/package.json +2 -2
- package/types/query.d.ts +6 -0
- package/types/query.d.ts.map +1 -0
package/dist/cjs/query.cjs
CHANGED
|
@@ -20,31 +20,25 @@ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
|
20
20
|
}), mod);
|
|
21
21
|
var query_exports = {};
|
|
22
22
|
__export(query_exports, {
|
|
23
|
+
ensureAuth: () => ensureAuth,
|
|
24
|
+
getAuth: () => getAuth,
|
|
23
25
|
query: () => query,
|
|
24
|
-
|
|
26
|
+
queryContext: () => queryContext
|
|
25
27
|
});
|
|
26
28
|
module.exports = __toCommonJS(query_exports);
|
|
27
|
-
var
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
function
|
|
31
|
-
|
|
29
|
+
var import_helpers = require("@take-out/helpers"),
|
|
30
|
+
import_mutatorContext = require("./helpers/mutatorContext.cjs"),
|
|
31
|
+
import_state = require("./state.cjs");
|
|
32
|
+
function getAuth() {
|
|
33
|
+
return (0, import_mutatorContext.isInZeroMutation)() ? (0, import_mutatorContext.mutatorContext)().auth : (0, import_state.getContext)().auth;
|
|
32
34
|
}
|
|
33
|
-
function
|
|
34
|
-
|
|
35
|
-
return
|
|
35
|
+
function ensureAuth() {
|
|
36
|
+
const auth = getAuth();
|
|
37
|
+
return (0, import_helpers.ensure)(auth, "authenticated"), auth;
|
|
36
38
|
}
|
|
37
|
-
function
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
queryRequest = (0, import_resolveQuery.resolveQuery)({
|
|
43
|
-
customQueries,
|
|
44
|
-
fn: fnArg,
|
|
45
|
-
params
|
|
46
|
-
});
|
|
47
|
-
return (0, import_zeroRunner.getRunner)()(queryRequest, {
|
|
48
|
-
type: mode === "cached" ? "unknown" : "complete"
|
|
49
|
-
});
|
|
39
|
+
function queryContext() {
|
|
40
|
+
return (0, import_mutatorContext.isInZeroMutation)() ? (0, import_mutatorContext.mutatorContext)() : (0, import_state.getContext)();
|
|
41
|
+
}
|
|
42
|
+
function query(fn) {
|
|
43
|
+
return props => fn(props, queryContext());
|
|
50
44
|
}
|
package/dist/cjs/query.js
CHANGED
|
@@ -14,26 +14,24 @@ var __export = (target, all) => {
|
|
|
14
14
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
15
|
var query_exports = {};
|
|
16
16
|
__export(query_exports, {
|
|
17
|
+
ensureAuth: () => ensureAuth,
|
|
18
|
+
getAuth: () => getAuth,
|
|
17
19
|
query: () => query,
|
|
18
|
-
|
|
20
|
+
queryContext: () => queryContext
|
|
19
21
|
});
|
|
20
22
|
module.exports = __toCommonJS(query_exports);
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
customQueriesRef = queries;
|
|
23
|
+
var import_helpers = require("@take-out/helpers"), import_mutatorContext = require("./helpers/mutatorContext"), import_state = require("./state");
|
|
24
|
+
function getAuth() {
|
|
25
|
+
return (0, import_mutatorContext.isInZeroMutation)() ? (0, import_mutatorContext.mutatorContext)().auth : (0, import_state.getContext)().auth;
|
|
25
26
|
}
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"Custom queries not initialized. Ensure createZeroClient or createZeroServer has been called."
|
|
30
|
-
);
|
|
31
|
-
return customQueriesRef;
|
|
27
|
+
function ensureAuth() {
|
|
28
|
+
const auth = getAuth();
|
|
29
|
+
return (0, import_helpers.ensure)(auth, "authenticated"), auth;
|
|
32
30
|
}
|
|
33
|
-
function
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
function queryContext() {
|
|
32
|
+
return (0, import_mutatorContext.isInZeroMutation)() ? (0, import_mutatorContext.mutatorContext)() : (0, import_state.getContext)();
|
|
33
|
+
}
|
|
34
|
+
function query(fn) {
|
|
35
|
+
return (props) => fn(props, queryContext());
|
|
38
36
|
}
|
|
39
37
|
//# sourceMappingURL=query.js.map
|
package/dist/cjs/query.js.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/query.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAuB,8BAEvB,wBAAiD,qCACjD,eAA2B;AAKpB,SAAS,UAA2B;AACzC,aAAI,wCAAiB,QACZ,sCAAe,EAAE,WAEnB,yBAAW,EAAE;AACtB;AAGO,SAAS,aAAuB;AACrC,QAAM,OAAO,QAAQ;AACrB,oCAAO,MAAM,eAAe,GACrB;AACT;AAEO,SAAS,eAAwB;AACtC,aAAI,wCAAiB,QACZ,sCAAe,QAEjB,yBAAW;AACpB;AAEO,SAAS,MACd,IAC0B;AAC1B,SAAO,CAAC,UAAiB,GAAG,OAAO,aAAa,CAAC;AACnD;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/dist/cjs/query.native.js
CHANGED
|
@@ -22,33 +22,28 @@ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
|
22
22
|
}), mod);
|
|
23
23
|
var query_exports = {};
|
|
24
24
|
__export(query_exports, {
|
|
25
|
+
ensureAuth: () => ensureAuth,
|
|
26
|
+
getAuth: () => getAuth,
|
|
25
27
|
query: () => query,
|
|
26
|
-
|
|
28
|
+
queryContext: () => queryContext
|
|
27
29
|
});
|
|
28
30
|
module.exports = __toCommonJS(query_exports);
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
function
|
|
33
|
-
|
|
31
|
+
var import_helpers = require("@take-out/helpers"),
|
|
32
|
+
import_mutatorContext = require("./helpers/mutatorContext.native.js"),
|
|
33
|
+
import_state = require("./state.native.js");
|
|
34
|
+
function getAuth() {
|
|
35
|
+
return (0, import_mutatorContext.isInZeroMutation)() ? (0, import_mutatorContext.mutatorContext)().auth : (0, import_state.getContext)().auth;
|
|
34
36
|
}
|
|
35
|
-
function
|
|
36
|
-
|
|
37
|
-
return
|
|
37
|
+
function ensureAuth() {
|
|
38
|
+
var auth = getAuth();
|
|
39
|
+
return (0, import_helpers.ensure)(auth, "authenticated"), auth;
|
|
38
40
|
}
|
|
39
|
-
function
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
fn: fnArg,
|
|
47
|
-
params
|
|
48
|
-
}),
|
|
49
|
-
runner = (0, import_zeroRunner.getRunner)();
|
|
50
|
-
return runner(queryRequest, {
|
|
51
|
-
type: mode === "cached" ? "unknown" : "complete"
|
|
52
|
-
});
|
|
41
|
+
function queryContext() {
|
|
42
|
+
return (0, import_mutatorContext.isInZeroMutation)() ? (0, import_mutatorContext.mutatorContext)() : (0, import_state.getContext)();
|
|
43
|
+
}
|
|
44
|
+
function query(fn) {
|
|
45
|
+
return function (props) {
|
|
46
|
+
return fn(props, queryContext());
|
|
47
|
+
};
|
|
53
48
|
}
|
|
54
49
|
//# sourceMappingURL=query.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","query_exports","__export","
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","query_exports","__export","ensureAuth","getAuth","query","queryContext","module","exports","import_helpers","require","import_mutatorContext","import_state","isInZeroMutation","mutatorContext","auth","getContext","ensure","fn","props"],"sources":["../../src/query.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,QAAA,CAAAD,aAAA;EAAAE,UAAA,EAAAA,CAAA,KAAAA,UAAA;EAAAC,OAAA,EAAAA,CAAA,KAAAA,OAAA;EAAAC,KAAA,EAAAA,CAAA,KAAAA,KAAA;EAAAC,YAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAZ,YAAuB,CAAAK,aAAA;AAQhB,IAAAQ,cAAS,GAA2BC,OAAA;EAAAC,qBAAA,GAAAD,OAAA;EAAAE,YAAA,GAAAF,OAAA;AACzC,SAAAN,OAAIA,CAAA;EAIN,WAAAO,qBAAA,CAAAE,gBAAA,UAAAF,qBAAA,CAAAG,cAAA,IAAAC,IAAA,OAAAH,YAAA,CAAAI,UAAA,IAAAD,IAAA;AAGO;AACL,SAAMZ,UAAOA,CAAA;EACb,IAAAY,IAAA,GAAAX,OAAA;EAEF,WAAAK,cAAA,CAAAQ,MAAA,EAAAF,IAAA,oBAAAA,IAAA;AAEO;AACL,SAAAT,YAAIA,CAAA;EAIN,WAAAK,qBAAA,CAAAE,gBAAA,UAAAF,qBAAA,CAAAG,cAAA,UAAAF,YAAA,CAAAI,UAAA;AAEO;AAGL,SAAOX,KAACA,CAAAa,EAAA;EACV,iBAAAC,KAAA","ignoreList":[]}
|
package/dist/esm/query.js
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
function
|
|
5
|
-
|
|
1
|
+
import { ensure } from "@take-out/helpers";
|
|
2
|
+
import { isInZeroMutation, mutatorContext } from "./helpers/mutatorContext";
|
|
3
|
+
import { getContext } from "./state";
|
|
4
|
+
function getAuth() {
|
|
5
|
+
return isInZeroMutation() ? mutatorContext().auth : getContext().auth;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"Custom queries not initialized. Ensure createZeroClient or createZeroServer has been called."
|
|
11
|
-
);
|
|
12
|
-
return customQueriesRef;
|
|
7
|
+
function ensureAuth() {
|
|
8
|
+
const auth = getAuth();
|
|
9
|
+
return ensure(auth, "authenticated"), auth;
|
|
13
10
|
}
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
function queryContext() {
|
|
12
|
+
return isInZeroMutation() ? mutatorContext() : getContext();
|
|
13
|
+
}
|
|
14
|
+
function query(fn) {
|
|
15
|
+
return (props) => fn(props, queryContext());
|
|
19
16
|
}
|
|
20
17
|
export {
|
|
18
|
+
ensureAuth,
|
|
19
|
+
getAuth,
|
|
21
20
|
query,
|
|
22
|
-
|
|
21
|
+
queryContext
|
|
23
22
|
};
|
|
24
23
|
//# sourceMappingURL=query.js.map
|
package/dist/esm/query.js.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/query.ts"],
|
|
4
|
-
"mappings": "AAAA,SAAS,
|
|
4
|
+
"mappings": "AAAA,SAAS,cAAc;AAEvB,SAAS,kBAAkB,sBAAsB;AACjD,SAAS,kBAAkB;AAKpB,SAAS,UAA2B;AACzC,SAAI,iBAAiB,IACZ,eAAe,EAAE,OAEnB,WAAW,EAAE;AACtB;AAGO,SAAS,aAAuB;AACrC,QAAM,OAAO,QAAQ;AACrB,gBAAO,MAAM,eAAe,GACrB;AACT;AAEO,SAAS,eAAwB;AACtC,SAAI,iBAAiB,IACZ,eAAe,IAEjB,WAAW;AACpB;AAEO,SAAS,MACd,IAC0B;AAC1B,SAAO,CAAC,UAAiB,GAAG,OAAO,aAAa,CAAC;AACnD;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/dist/esm/query.mjs
CHANGED
|
@@ -1,26 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
function
|
|
5
|
-
|
|
1
|
+
import { ensure } from "@take-out/helpers";
|
|
2
|
+
import { isInZeroMutation, mutatorContext } from "./helpers/mutatorContext.mjs";
|
|
3
|
+
import { getContext } from "./state.mjs";
|
|
4
|
+
function getAuth() {
|
|
5
|
+
return isInZeroMutation() ? mutatorContext().auth : getContext().auth;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
return
|
|
7
|
+
function ensureAuth() {
|
|
8
|
+
const auth = getAuth();
|
|
9
|
+
return ensure(auth, "authenticated"), auth;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
params = hasParams ? paramsOrMode : void 0,
|
|
14
|
-
mode = hasParams ? modeArg : paramsOrMode,
|
|
15
|
-
customQueries = getCustomQueries(),
|
|
16
|
-
queryRequest = resolveQuery({
|
|
17
|
-
customQueries,
|
|
18
|
-
fn: fnArg,
|
|
19
|
-
params
|
|
20
|
-
});
|
|
21
|
-
return getRunner()(queryRequest, {
|
|
22
|
-
type: mode === "cached" ? "unknown" : "complete"
|
|
23
|
-
});
|
|
11
|
+
function queryContext() {
|
|
12
|
+
return isInZeroMutation() ? mutatorContext() : getContext();
|
|
24
13
|
}
|
|
25
|
-
|
|
14
|
+
function query(fn) {
|
|
15
|
+
return props => fn(props, queryContext());
|
|
16
|
+
}
|
|
17
|
+
export { ensureAuth, getAuth, query, queryContext };
|
|
26
18
|
//# sourceMappingURL=query.mjs.map
|
package/dist/esm/query.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["ensure","isInZeroMutation","mutatorContext","getContext","getAuth","auth","ensureAuth","queryContext","query","fn","props"],"sources":["../../src/query.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,MAAA,QAAc;AAEvB,SAASC,gBAAA,EAAkBC,cAAA,QAAsB;AACjD,SAASC,UAAA,QAAkB;AAKpB,SAASC,QAAA,EAA2B;EACzC,OAAIH,gBAAA,CAAiB,IACZC,cAAA,CAAe,EAAEG,IAAA,GAEnBF,UAAA,CAAW,EAAEE,IAAA;AACtB;AAGO,SAASC,WAAA,EAAuB;EACrC,MAAMD,IAAA,GAAOD,OAAA,CAAQ;EACrB,OAAAJ,MAAA,CAAOK,IAAA,EAAM,eAAe,GACrBA,IAAA;AACT;AAEO,SAASE,aAAA,EAAwB;EACtC,OAAIN,gBAAA,CAAiB,IACZC,cAAA,CAAe,IAEjBC,UAAA,CAAW;AACpB;AAEO,SAASK,MACdC,EAAA,EAC0B;EAC1B,OAAQC,KAAA,IAAiBD,EAAA,CAAGC,KAAA,EAAOH,YAAA,CAAa,CAAC;AACnD","ignoreList":[]}
|
package/dist/esm/query.native.js
CHANGED
|
@@ -1,27 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
function
|
|
5
|
-
|
|
1
|
+
import { ensure } from "@take-out/helpers";
|
|
2
|
+
import { isInZeroMutation, mutatorContext } from "./helpers/mutatorContext.native.js";
|
|
3
|
+
import { getContext } from "./state.native.js";
|
|
4
|
+
function getAuth() {
|
|
5
|
+
return isInZeroMutation() ? mutatorContext().auth : getContext().auth;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
return
|
|
7
|
+
function ensureAuth() {
|
|
8
|
+
var auth = getAuth();
|
|
9
|
+
return ensure(auth, "authenticated"), auth;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
params = hasParams ? paramsOrMode : void 0,
|
|
14
|
-
mode = hasParams ? modeArg : paramsOrMode,
|
|
15
|
-
customQueries = getCustomQueries(),
|
|
16
|
-
queryRequest = resolveQuery({
|
|
17
|
-
customQueries,
|
|
18
|
-
fn: fnArg,
|
|
19
|
-
params
|
|
20
|
-
}),
|
|
21
|
-
runner = getRunner();
|
|
22
|
-
return runner(queryRequest, {
|
|
23
|
-
type: mode === "cached" ? "unknown" : "complete"
|
|
24
|
-
});
|
|
11
|
+
function queryContext() {
|
|
12
|
+
return isInZeroMutation() ? mutatorContext() : getContext();
|
|
25
13
|
}
|
|
26
|
-
|
|
14
|
+
function query(fn) {
|
|
15
|
+
return function (props) {
|
|
16
|
+
return fn(props, queryContext());
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export { ensureAuth, getAuth, query, queryContext };
|
|
27
20
|
//# sourceMappingURL=query.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["ensure","isInZeroMutation","mutatorContext","getContext","getAuth","auth","ensureAuth","queryContext","query","fn","props"],"sources":["../../src/query.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,MAAA,QAAc;AAEvB,SAASC,gBAAA,EAAkBC,cAAA,QAAsB;AACjD,SAASC,UAAA,QAAkB;AAKpB,SAASC,QAAA,EAA2B;EACzC,OAAIH,gBAAA,CAAiB,IACZC,cAAA,CAAe,EAAEG,IAAA,GAEnBF,UAAA,CAAW,EAAEE,IAAA;AACtB;AAGO,SAASC,WAAA,EAAuB;EACrC,IAAAD,IAAM,GAAAD,OAAO;EACb,OAAAJ,MAAA,CAAOK,IAAA,EAAM,eAAe,GACrBA,IAAA;AACT;AAEO,SAASE,aAAA,EAAwB;EACtC,OAAIN,gBAAA,CAAiB,IACZC,cAAA,CAAe,IAEjBC,UAAA,CAAW;AACpB;AAEO,SAASK,MACdC,EAAA,EAC0B;EAC1B,OAAO,UAACC,KAAoB;IAC9B,OAAAD,EAAA,CAAAC,KAAA,EAAAH,YAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "on-zero",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"description": "A typed layer over @rocicorp/zero with queries, mutations, and permissions",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
}
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@take-out/helpers": "0.1.
|
|
67
|
+
"@take-out/helpers": "0.1.16",
|
|
68
68
|
"@sinclair/typebox-codegen": "^0.11.1",
|
|
69
69
|
"chokidar": "^4.0.3",
|
|
70
70
|
"citty": "^0.1.6",
|
package/types/query.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AuthData, Context } from './types';
|
|
2
|
+
export declare function getAuth(): AuthData | null;
|
|
3
|
+
export declare function ensureAuth(): AuthData;
|
|
4
|
+
export declare function queryContext(): Context;
|
|
5
|
+
export declare function query<Props, Return>(fn: (props: Props, ctx: Context) => Return): (props: Props) => Return;
|
|
6
|
+
//# sourceMappingURL=query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAGhD,wBAAgB,OAAO,IAAI,QAAQ,GAAG,IAAI,CAKzC;AAGD,wBAAgB,UAAU,IAAI,QAAQ,CAIrC;AAED,wBAAgB,YAAY,IAAI,OAAO,CAKtC;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EACjC,EAAE,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,KAAK,MAAM,GACzC,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,CAE1B"}
|