@sanity/client 3.3.3-esm.6 → 3.3.3-esm.9
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/sanityClient.browser.mjs +901 -1162
- package/dist/sanityClient.browser.mjs.map +4 -4
- package/lib/assets/assetsClient.js +25 -12
- package/lib/auth/authClient.js +8 -1
- package/lib/config.js +14 -8
- package/lib/data/dataMethods.js +36 -23
- package/lib/data/encodeQueryString.js +9 -2
- package/lib/data/listen.js +24 -18
- package/lib/data/patch.js +18 -12
- package/lib/data/transaction.js +23 -8
- package/lib/datasets/datasetsClient.js +16 -3
- package/lib/http/browserMiddleware.js +7 -1
- package/lib/http/errors.js +7 -3
- package/lib/http/nodeMiddleware.js +8 -1
- package/lib/http/queryString.js +10 -2
- package/lib/http/request.js +20 -14
- package/lib/http/requestOptions.js +10 -2
- package/lib/projects/projectsClient.js +8 -1
- package/lib/sanityClient.js +49 -43
- package/lib/users/usersClient.js +8 -1
- package/lib/util/defaults.js +10 -2
- package/lib/util/getSelection.js +9 -2
- package/lib/util/once.js +10 -2
- package/lib/util/pick.js +10 -2
- package/lib/validators.js +38 -15
- package/lib/warnings.js +16 -6
- package/package.json +4 -3
- package/umd/sanityClient.js +54 -57
- package/umd/sanityClient.min.js +1 -1
package/lib/sanityClient.js
CHANGED
|
@@ -1,65 +1,69 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
var _observable = require("./util/observable");
|
|
8
11
|
|
|
9
|
-
|
|
12
|
+
var _patch = _interopRequireDefault(require("./data/patch"));
|
|
10
13
|
|
|
11
|
-
|
|
14
|
+
var _transaction = _interopRequireDefault(require("./data/transaction"));
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
var _dataMethods = _interopRequireDefault(require("./data/dataMethods"));
|
|
17
|
+
|
|
18
|
+
var _datasetsClient = _interopRequireDefault(require("./datasets/datasetsClient"));
|
|
14
19
|
|
|
15
|
-
var
|
|
16
|
-
Observable = _require.Observable,
|
|
17
|
-
map = _require.map,
|
|
18
|
-
filter = _require.filter;
|
|
20
|
+
var _projectsClient = _interopRequireDefault(require("./projects/projectsClient"));
|
|
19
21
|
|
|
20
|
-
var
|
|
22
|
+
var _assetsClient = _interopRequireDefault(require("./assets/assetsClient"));
|
|
21
23
|
|
|
22
|
-
var
|
|
24
|
+
var _usersClient = _interopRequireDefault(require("./users/usersClient"));
|
|
23
25
|
|
|
24
|
-
var
|
|
26
|
+
var _authClient = _interopRequireDefault(require("./auth/authClient"));
|
|
25
27
|
|
|
26
|
-
var
|
|
28
|
+
var _request = _interopRequireDefault(require("./http/request"));
|
|
27
29
|
|
|
28
|
-
var
|
|
30
|
+
var _requestOptions = _interopRequireDefault(require("./http/requestOptions"));
|
|
29
31
|
|
|
30
|
-
var
|
|
32
|
+
var _config = require("./config");
|
|
31
33
|
|
|
32
|
-
var
|
|
34
|
+
var validate = _interopRequireWildcard(require("./validators"));
|
|
33
35
|
|
|
34
|
-
var
|
|
36
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
35
37
|
|
|
36
|
-
var
|
|
38
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
37
39
|
|
|
38
|
-
|
|
40
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
41
|
+
|
|
42
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
39
43
|
|
|
40
|
-
var
|
|
41
|
-
defaultConfig = _require2.defaultConfig,
|
|
42
|
-
initConfig = _require2.initConfig;
|
|
44
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
43
45
|
|
|
44
|
-
|
|
46
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
47
|
+
|
|
48
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
45
49
|
|
|
46
50
|
var toPromise = function toPromise(observable) {
|
|
47
51
|
return observable.toPromise();
|
|
48
52
|
};
|
|
49
53
|
|
|
50
54
|
function SanityClient() {
|
|
51
|
-
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultConfig;
|
|
55
|
+
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _config.defaultConfig;
|
|
52
56
|
|
|
53
57
|
if (!(this instanceof SanityClient)) {
|
|
54
58
|
return new SanityClient(config);
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
this.config(config);
|
|
58
|
-
this.assets = new
|
|
59
|
-
this.datasets = new
|
|
60
|
-
this.projects = new
|
|
61
|
-
this.users = new
|
|
62
|
-
this.auth = new
|
|
62
|
+
this.assets = new _assetsClient.default(this);
|
|
63
|
+
this.datasets = new _datasetsClient.default(this);
|
|
64
|
+
this.projects = new _projectsClient.default(this);
|
|
65
|
+
this.users = new _usersClient.default(this);
|
|
66
|
+
this.auth = new _authClient.default(this);
|
|
63
67
|
|
|
64
68
|
if (this.clientConfig.isPromiseAPI) {
|
|
65
69
|
var observableConfig = _extends({}, this.clientConfig, {
|
|
@@ -70,7 +74,7 @@ function SanityClient() {
|
|
|
70
74
|
}
|
|
71
75
|
}
|
|
72
76
|
|
|
73
|
-
_extends(SanityClient.prototype,
|
|
77
|
+
_extends(SanityClient.prototype, _dataMethods.default);
|
|
74
78
|
|
|
75
79
|
_extends(SanityClient.prototype, {
|
|
76
80
|
clone: function clone() {
|
|
@@ -89,7 +93,7 @@ _extends(SanityClient.prototype, {
|
|
|
89
93
|
this.observable.config(observableConfig);
|
|
90
94
|
}
|
|
91
95
|
|
|
92
|
-
this.clientConfig = initConfig(newConfig, this.clientConfig || {});
|
|
96
|
+
this.clientConfig = (0, _config.initConfig)(newConfig, this.clientConfig || {});
|
|
93
97
|
return this;
|
|
94
98
|
},
|
|
95
99
|
withConfig: function withConfig(newConfig) {
|
|
@@ -119,17 +123,17 @@ _extends(SanityClient.prototype, {
|
|
|
119
123
|
}, options.query);
|
|
120
124
|
}
|
|
121
125
|
|
|
122
|
-
var reqOptions =
|
|
126
|
+
var reqOptions = (0, _requestOptions.default)(this.clientConfig, _extends({}, options, {
|
|
123
127
|
url: this.getUrl(uri, useCdn)
|
|
124
128
|
}));
|
|
125
|
-
return new Observable(function (subscriber) {
|
|
126
|
-
return
|
|
129
|
+
return new _observable.Observable(function (subscriber) {
|
|
130
|
+
return (0, _request.default)(reqOptions, _this.clientConfig.requester).subscribe(subscriber);
|
|
127
131
|
});
|
|
128
132
|
},
|
|
129
133
|
request: function request(options) {
|
|
130
|
-
var observable = this._requestObservable(options).pipe(filter(function (event) {
|
|
134
|
+
var observable = this._requestObservable(options).pipe((0, _observable.filter)(function (event) {
|
|
131
135
|
return event.type === 'response';
|
|
132
|
-
}), map(function (event) {
|
|
136
|
+
}), (0, _observable.map)(function (event) {
|
|
133
137
|
return event.body;
|
|
134
138
|
}));
|
|
135
139
|
|
|
@@ -137,9 +141,11 @@ _extends(SanityClient.prototype, {
|
|
|
137
141
|
}
|
|
138
142
|
});
|
|
139
143
|
|
|
140
|
-
SanityClient.Patch =
|
|
141
|
-
SanityClient.Transaction =
|
|
142
|
-
SanityClient.ClientError =
|
|
143
|
-
SanityClient.ServerError =
|
|
144
|
-
SanityClient.requester =
|
|
145
|
-
|
|
144
|
+
SanityClient.Patch = _patch.default;
|
|
145
|
+
SanityClient.Transaction = _transaction.default;
|
|
146
|
+
SanityClient.ClientError = _request.default.ClientError;
|
|
147
|
+
SanityClient.ServerError = _request.default.ServerError;
|
|
148
|
+
SanityClient.requester = _request.default.defaultRequester;
|
|
149
|
+
var _default = SanityClient;
|
|
150
|
+
exports.default = _default;
|
|
151
|
+
module.exports = exports.default;
|
package/lib/users/usersClient.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
3
8
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
9
|
|
|
5
10
|
function UsersClient(client) {
|
|
@@ -14,4 +19,6 @@ _extends(UsersClient.prototype, {
|
|
|
14
19
|
}
|
|
15
20
|
});
|
|
16
21
|
|
|
17
|
-
|
|
22
|
+
var _default = UsersClient;
|
|
23
|
+
exports.default = _default;
|
|
24
|
+
module.exports = exports.default;
|
package/lib/util/defaults.js
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _default = function _default(obj, defaults) {
|
|
4
9
|
return Object.keys(defaults).concat(Object.keys(obj)).reduce(function (target, prop) {
|
|
5
10
|
target[prop] = typeof obj[prop] === 'undefined' ? defaults[prop] : obj[prop];
|
|
6
11
|
return target;
|
|
7
12
|
}, {});
|
|
8
|
-
};
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
exports.default = _default;
|
|
16
|
+
module.exports = exports.default;
|
package/lib/util/getSelection.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = getSelection;
|
|
7
|
+
|
|
8
|
+
function getSelection(sel) {
|
|
4
9
|
if (typeof sel === 'string' || Array.isArray(sel)) {
|
|
5
10
|
return {
|
|
6
11
|
id: sel
|
|
@@ -18,4 +23,6 @@ module.exports = function getSelection(sel) {
|
|
|
18
23
|
|
|
19
24
|
var selectionOpts = ['* Document ID (<docId>)', '* Array of document IDs', '* Object containing `query`'].join('\n');
|
|
20
25
|
throw new Error("Unknown selection - must be one of:\n\n".concat(selectionOpts));
|
|
21
|
-
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = exports.default;
|
package/lib/util/once.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _default = function _default(fn) {
|
|
4
9
|
var didCall = false;
|
|
5
10
|
var returnValue;
|
|
6
11
|
return function () {
|
|
@@ -12,4 +17,7 @@ module.exports = function (fn) {
|
|
|
12
17
|
didCall = true;
|
|
13
18
|
return returnValue;
|
|
14
19
|
};
|
|
15
|
-
};
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
exports.default = _default;
|
|
23
|
+
module.exports = exports.default;
|
package/lib/util/pick.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _default = function _default(obj, props) {
|
|
4
9
|
return props.reduce(function (selection, prop) {
|
|
5
10
|
if (typeof obj[prop] === 'undefined') {
|
|
6
11
|
return selection;
|
|
@@ -9,4 +14,7 @@ module.exports = function (obj, props) {
|
|
|
9
14
|
selection[prop] = obj[prop];
|
|
10
15
|
return selection;
|
|
11
16
|
}, {});
|
|
12
|
-
};
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
exports.default = _default;
|
|
20
|
+
module.exports = exports.default;
|
package/lib/validators.js
CHANGED
|
@@ -1,49 +1,66 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.validateObject = exports.validateInsert = exports.validateDocumentId = exports.validateAssetType = exports.requireDocumentId = exports.requestTag = exports.projectId = exports.hasDataset = exports.dataset = void 0;
|
|
7
|
+
|
|
3
8
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
9
|
|
|
5
10
|
var VALID_ASSET_TYPES = ['image', 'file'];
|
|
6
11
|
var VALID_INSERT_LOCATIONS = ['before', 'after', 'replace'];
|
|
7
12
|
|
|
8
|
-
|
|
13
|
+
var dataset = function dataset(name) {
|
|
9
14
|
if (!/^(~[a-z0-9]{1}[-\w]{0,63}|[a-z0-9]{1}[-\w]{0,63})$/.test(name)) {
|
|
10
15
|
throw new Error('Datasets can only contain lowercase characters, numbers, underscores and dashes, and start with tilde, and be maximum 64 characters');
|
|
11
16
|
}
|
|
12
17
|
};
|
|
13
18
|
|
|
14
|
-
exports.
|
|
19
|
+
exports.dataset = dataset;
|
|
20
|
+
|
|
21
|
+
var projectId = function projectId(id) {
|
|
15
22
|
if (!/^[-a-z0-9]+$/i.test(id)) {
|
|
16
23
|
throw new Error('`projectId` can only contain only a-z, 0-9 and dashes');
|
|
17
24
|
}
|
|
18
25
|
};
|
|
19
26
|
|
|
20
|
-
exports.
|
|
27
|
+
exports.projectId = projectId;
|
|
28
|
+
|
|
29
|
+
var validateAssetType = function validateAssetType(type) {
|
|
21
30
|
if (VALID_ASSET_TYPES.indexOf(type) === -1) {
|
|
22
31
|
throw new Error("Invalid asset type: ".concat(type, ". Must be one of ").concat(VALID_ASSET_TYPES.join(', ')));
|
|
23
32
|
}
|
|
24
33
|
};
|
|
25
34
|
|
|
26
|
-
exports.
|
|
35
|
+
exports.validateAssetType = validateAssetType;
|
|
36
|
+
|
|
37
|
+
var validateObject = function validateObject(op, val) {
|
|
27
38
|
if (val === null || _typeof(val) !== 'object' || Array.isArray(val)) {
|
|
28
39
|
throw new Error("".concat(op, "() takes an object of properties"));
|
|
29
40
|
}
|
|
30
41
|
};
|
|
31
42
|
|
|
32
|
-
exports.
|
|
43
|
+
exports.validateObject = validateObject;
|
|
44
|
+
|
|
45
|
+
var validateDocumentId = function validateDocumentId(op, id) {
|
|
46
|
+
if (typeof id !== 'string' || !/^[a-z0-9_.-]+$/i.test(id)) {
|
|
47
|
+
throw new Error("".concat(op, "(): \"").concat(id, "\" is not a valid document ID"));
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
exports.validateDocumentId = validateDocumentId;
|
|
52
|
+
|
|
53
|
+
var requireDocumentId = function requireDocumentId(op, doc) {
|
|
33
54
|
if (!doc._id) {
|
|
34
55
|
throw new Error("".concat(op, "() requires that the document contains an ID (\"_id\" property)"));
|
|
35
56
|
}
|
|
36
57
|
|
|
37
|
-
|
|
58
|
+
validateDocumentId(op, doc._id);
|
|
38
59
|
};
|
|
39
60
|
|
|
40
|
-
exports.
|
|
41
|
-
if (typeof id !== 'string' || !/^[a-z0-9_.-]+$/i.test(id)) {
|
|
42
|
-
throw new Error("".concat(op, "(): \"").concat(id, "\" is not a valid document ID"));
|
|
43
|
-
}
|
|
44
|
-
};
|
|
61
|
+
exports.requireDocumentId = requireDocumentId;
|
|
45
62
|
|
|
46
|
-
|
|
63
|
+
var validateInsert = function validateInsert(at, selector, items) {
|
|
47
64
|
var signature = 'insert(at, selector, items)';
|
|
48
65
|
|
|
49
66
|
if (VALID_INSERT_LOCATIONS.indexOf(at) === -1) {
|
|
@@ -62,7 +79,9 @@ exports.validateInsert = function (at, selector, items) {
|
|
|
62
79
|
}
|
|
63
80
|
};
|
|
64
81
|
|
|
65
|
-
exports.
|
|
82
|
+
exports.validateInsert = validateInsert;
|
|
83
|
+
|
|
84
|
+
var hasDataset = function hasDataset(config) {
|
|
66
85
|
if (!config.dataset) {
|
|
67
86
|
throw new Error('`dataset` must be provided to perform queries');
|
|
68
87
|
}
|
|
@@ -70,10 +89,14 @@ exports.hasDataset = function (config) {
|
|
|
70
89
|
return config.dataset || '';
|
|
71
90
|
};
|
|
72
91
|
|
|
73
|
-
exports.
|
|
92
|
+
exports.hasDataset = hasDataset;
|
|
93
|
+
|
|
94
|
+
var requestTag = function requestTag(tag) {
|
|
74
95
|
if (typeof tag !== 'string' || !/^[a-z0-9._-]{1,75}$/i.test(tag)) {
|
|
75
96
|
throw new Error("Tag can only contain alphanumeric characters, underscores, dashes and dots, and be between one and 75 characters long.");
|
|
76
97
|
}
|
|
77
98
|
|
|
78
99
|
return tag;
|
|
79
|
-
};
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
exports.requestTag = requestTag;
|
package/lib/warnings.js
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.printNoApiVersionSpecifiedWarning = exports.printCdnWarning = exports.printBrowserTokenWarning = void 0;
|
|
4
7
|
|
|
5
|
-
var
|
|
8
|
+
var _generateHelpUrl = _interopRequireDefault(require("./generateHelpUrl"));
|
|
9
|
+
|
|
10
|
+
var _once = _interopRequireDefault(require("./util/once"));
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
13
|
|
|
7
14
|
var createWarningPrinter = function createWarningPrinter(message) {
|
|
8
15
|
return (// eslint-disable-next-line no-console
|
|
9
|
-
|
|
16
|
+
(0, _once.default)(function () {
|
|
10
17
|
var _console;
|
|
11
18
|
|
|
12
19
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
@@ -18,6 +25,9 @@ var createWarningPrinter = function createWarningPrinter(message) {
|
|
|
18
25
|
);
|
|
19
26
|
};
|
|
20
27
|
|
|
21
|
-
|
|
22
|
-
exports.
|
|
23
|
-
|
|
28
|
+
var printCdnWarning = createWarningPrinter(['You are not using the Sanity CDN. That means your data is always fresh, but the CDN is faster and', "cheaper. Think about it! For more info, see ".concat((0, _generateHelpUrl.default)('js-client-cdn-configuration'), "."), 'To hide this warning, please set the `useCdn` option to either `true` or `false` when creating', 'the client.']);
|
|
29
|
+
exports.printCdnWarning = printCdnWarning;
|
|
30
|
+
var printBrowserTokenWarning = createWarningPrinter(['You have configured Sanity client to use a token in the browser. This may cause unintentional security issues.', "See ".concat((0, _generateHelpUrl.default)('js-client-browser-token'), " for more information and how to hide this warning.")]);
|
|
31
|
+
exports.printBrowserTokenWarning = printBrowserTokenWarning;
|
|
32
|
+
var printNoApiVersionSpecifiedWarning = createWarningPrinter(['Using the Sanity client without specifying an API version is deprecated.', "See ".concat((0, _generateHelpUrl.default)('js-client-api-version'))]);
|
|
33
|
+
exports.printNoApiVersionSpecifiedWarning = printNoApiVersionSpecifiedWarning;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/client",
|
|
3
|
-
"version": "3.3.3-esm.
|
|
3
|
+
"version": "3.3.3-esm.9",
|
|
4
4
|
"description": "Client for retrieving, creating and patching data from Sanity.io",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "lib/sanityClient.js",
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"browser": "./dist/sanityClient.browser.mjs",
|
|
15
15
|
"deno": "./dist/sanityClient.browser.mjs",
|
|
16
16
|
"default": "./lib/sanityClient.js"
|
|
17
|
-
}
|
|
17
|
+
},
|
|
18
|
+
"./package.json": "./package.json"
|
|
18
19
|
},
|
|
19
20
|
"files": [
|
|
20
21
|
"dist",
|
|
@@ -26,7 +27,7 @@
|
|
|
26
27
|
"browserify": "NODE_ENV=production BROWSERIFY_ENV=build DEBUG='' browserify -t envify -g uglifyify lib/sanityClient.js -o umd/sanityClient.js --standalone=SanityClient",
|
|
27
28
|
"compile": "babel -d lib src",
|
|
28
29
|
"build": "npm run compile && npm run browserify && npm run minify && npm run esbuild:browser",
|
|
29
|
-
"esbuild": "esbuild src/sanityClient.js --bundle --sourcemap --external:rxjs-v7 --external:@sanity/eventsource --external:get-it --external:make-error",
|
|
30
|
+
"esbuild": "esbuild src/sanityClient.js --bundle --sourcemap --external:rxjs-v7 --external:@sanity/eventsource --external:get-it --external:make-error --define:EdgeRuntime=undefined",
|
|
30
31
|
"esbuild:browser": "npm run esbuild -- --format=esm --outfile=dist/sanityClient.browser.mjs --platform=browser",
|
|
31
32
|
"lint": "eslint .",
|
|
32
33
|
"clean": "rimraf dist lib coverage .nyc_output umd/*.js",
|